Walking

From Maze

Revision as of 11:59, 17 November 2010 by Nickm (Talk | contribs) (Changed again to "Walking" since there is a "Generative Design" chapter already)
Jump to: navigation, search

Outline for Walking

Section 1: Creating a maze that fills a screen. The original 10-print generates a constantly scrolling sequence of characters. To create a static maze, the program must be modified to just produce enough characters to fill the screen. Introduce FOR NEXT. Discuss the intricacies of PRINT. PRINT automatically scrolls near the end of line, even when using the ; modifier, so it is not possible to perfectly fill the screen with PRINT. Introduce the concept of memory mapped I/O. What PRINT is really doing is placing screen codes in memory. Part of the work it’s doing is converting between PETSCII and screen codes. Screen codes are literally indices into characters stored in memory. Even when the c64 isn’t running a user program, it’s running processes to continuously refresh the screen, looking up characters in character memory, drawing them pixel and pixel on the screen, etc. A computer performs continuous work to maintain the constructed reality. Introduce POKE and PEEK as the BASIC commands for directly manipulating memory. Discuss the program using FOR NEXT and POKE that finally succeeds in generating a static screenfull of maze.

Section 2: Walking the maze. Now that we have a static screenfull of maze, we need to walk it. What does location mean in this maze? There is no floor, only walls. Introduce the Path movement rules in which the walls are treated like mirrors reflecting rays of light. Location requires three numbers, 2 for x,y location and one for direction. Movement involves updating the direction as a function of the wall at the current location plus the current direction, then updating x,y as a function of the new direction. Introduce IF THEN. Describe first walking program – it walks the maze, but the viewer can’t see it. It’s following rules invisibly. Movement is represented via a sequence of static snapshots – from walking the 10-print maze to the latest Pixar film, the illusion of movement is created via a sequence of computed snapshots. Introduce color on the c64. Revisit the work that the screen display processes must do to maintain an image on the screen. Now color can be used to mark the locations as we move through the maze. The walker is becoming unwieldy with repeated code blocks. Introduce GOSUB, more generally, the powerful idea of functional abstraction (the ability to identify a chunk of code for repeated use).

Section 3: Depicting the current location in the maze. The current location of the walker in the maze is still not well defined visually. Use a different graphics character to mark the current position of the walker. Again, because there are no floors in this maze (every screen location is taken by a wall), the characters depicting location must combine a wall with additional graphical representation. Discuss changes to the walker to show a location-indicating character at the current position, using a built-in character. Introduce the concept of defining custom characters. Introduce the DATA statement. Discuss version of walker that uses custom characters to show location and direction of the walker.

Section 4: Alternative walking rule. The Path walking rule walks cardinal directions, bouncing off of walls as if the walker is a reflected light beam (angle of incidence equals angle of reflection). 10-print mazes are constructed entirely of diagonal passageways. A more visually natural movement rule would move the walker directly down diagonal passages. In order to do this, we must change how we represent the walker’s state. Using the Path movement rules, the walker’s state consists of an x,y location (co-incident with a wall) and a cardinal direction (one of four directions). The new movement rule must define position using two x,y locations (the two walls the walker is standing between – alternatively, an x,y location and a number indicating which side of the wall the walker is standing on) and one of four diagonal directions (in a given passageway, only two of the four directions make sense). Discuss the changes to the walker with visual examples of the difference. This section overlaps with Warren’s section on walking (I believe his movement rule is a diagonal walker that takes account of the wall values at two x,y locations to make a decision). Coordinate with Warren on this section.

Section 5: What is a maze? Mazes vs. labyrinths. Defining maze properties (a path from a start to a finish, additionally adding a twists and turns (length) requirement, etc.). Introduce the concept of generate and test. The 10-print generator, which has no concept of maze properties, can be turned into a maze generator by adding a separate post-generate test (the essence of generate and test). Discuss the program. Discuss the general challenges of reasoning about global properties (such as “mazeness”) at generation time; generate and test isn’t just a hack, but a fundamental approach for hard problems (and generating “proper” mazes is a hard problem). Currently our mazes have no decision points. Add decision points to the maze. This requires that the generator randomly choose between / and \ as it does now, but occasionally choose “ “ (a blank space) as well. Warren has defined a similar section. Coordinate with Warren.

Section 6: Interactively walking a maze. Introduce an interactive maze walker that uses keyboard input to walk the maze. The maze in game culture. Describe several games that use the interactive maze walker.

Personal tools