Remarks: Maze Walker

From Maze

(Difference between revisions)
Jump to: navigation, search
(→Stabilizing the Maze)
Line 70:Line 70:
Before moving onto this step, however, let us reflect on the additional complexity that has been introduced in our efforts to stabilize the maze. Our original one line program has grown to five lines, though the original kernel of the program, which randomly prints a forward or backward slanting character, still appears on line 10. The additional complexity comes from the need to produce a finite number of forward and back slashes, and from the formatting requirements of placing the maze on a blank screen. To produce a finite number of symbols, the FOR and NEXT statements, with their corresponding count variable X, are introduced. To place the maze on a clear screen, the CLR control character is printed and an infinite loop that prevents the return to the BASIC prompt is introduced. This is a common experience in programming, that the input and output behavior of the program, the formatting and interface, the "surface" of the program, requires more programming complexity than the simulation or calculation that defines the kernel or "depth" of the program.
Before moving onto this step, however, let us reflect on the additional complexity that has been introduced in our efforts to stabilize the maze. Our original one line program has grown to five lines, though the original kernel of the program, which randomly prints a forward or backward slanting character, still appears on line 10. The additional complexity comes from the need to produce a finite number of forward and back slashes, and from the formatting requirements of placing the maze on a blank screen. To produce a finite number of symbols, the FOR and NEXT statements, with their corresponding count variable X, are introduced. To place the maze on a clear screen, the CLR control character is printed and an infinite loop that prevents the return to the BASIC prompt is introduced. This is a common experience in programming, that the input and output behavior of the program, the formatting and interface, the "surface" of the program, requires more programming complexity than the simulation or calculation that defines the kernel or "depth" of the program.
 +
 +
To fill the whole screen with a stable maze, the program should loop for 1000 characters instead of 400. However, instead of filling the whole screen, the screen scrolls up by two lines when the last character is printed. This is verified by printing 999 characters, which almost perfectly fills the screen, leaving one blank space in the lower right-hand corner [image?]. This is the same ragged scrolling behavior observed at the bottom of the screen in the original, infinitely scrolling version of 10 PRINT. The seemingly innocent PRINT command, which promises to simply place text on the screen, is doing something more. As discussed in [C64 chapter], PRINT is actually enforcing the concept of 80 character logical lines, on top of the C64's 40 character wide screen. So, starting with a blank screen, when the 1000th character is printed, this happens to be the 80th character of the last logical line on the display, causing the screen to scroll by two physical (40 character) lines to make room for the next 80 character logical line. Two layers of code underwrite the operation of PRINTing to the screen: code in the BASIC interpreter, which handles the various language-specific features associated with PRINT, such as formatting operations like the semi-colon, and code specific to the C64 hardware platform, invoked by the BASIC interpreter, providing facilities such as the ability to output a character to the screen. So to generate our screen full of stable maze, a mechanism other than the virtual teletype enforced by PRINT and its two layers of language platform and hardware platform code, must be used.

Revision as of 19:43, 29 July 2011

View this revision of Remarks: Maze Walker.

Personal tools