Remarks: Processing Mazes

From Maze

(Difference between revisions)
Jump to: navigation, search
Line 7:Line 7:
The first Processing version of 10 PRINT was written to take advantage of the increased resolution of contemporary screens. It does this by making the thickness and ends of the lines into variables that can be changed while the program runs. The lines of the maze can range from 0.5 to 10 pixels wide and the lines can terminate with a rounded or square end. Like 10 PRINT, it maintains the grid of lines at 40 x 25 units, but unlike 10 PRINT it doesn't add each grid unit in sequence from left to right and top to bottom. In the new high-resolution version, the entire maze is refreshed in unison. Without thinking carefully about it, we used the default Processing colors to create white lines and a black background. In hindsight, this imbued the program with a distinct mood from the original lower-contrast blues of the C64. The result is shown in figures ?? to ??.
The first Processing version of 10 PRINT was written to take advantage of the increased resolution of contemporary screens. It does this by making the thickness and ends of the lines into variables that can be changed while the program runs. The lines of the maze can range from 0.5 to 10 pixels wide and the lines can terminate with a rounded or square end. Like 10 PRINT, it maintains the grid of lines at 40 x 25 units, but unlike 10 PRINT it doesn't add each grid unit in sequence from left to right and top to bottom. In the new high-resolution version, the entire maze is refreshed in unison. Without thinking carefully about it, we used the default Processing colors to create white lines and a black background. In hindsight, this imbued the program with a distinct mood from the original lower-contrast blues of the C64. The result is shown in figures ?? to ??.
−
While we were making these variations, we took the opportunity to make some additional quick changes to explore the visual aspects of the 10 PRINT maze. [MORE, about weighting the random values, using different symbols to show how it's based on the diagonals. ]
+
[THIS PARAGRAPH IS IN PROGRESS]
 +
While we were making these variations, we took the opportunity to make some additional quick changes to explore the visual aspects of the 10 PRINT maze. First, the 50-50 chance to draw a left or right line was altered so it could be changed while the program ran to increase the chance of one or the other. The result is shown in Figures ?? to ??. Next, we tried drawing symbols other than the diagonal lines to expose the structure of the program in a different way. In our opinion, the essence of the 10 PRINT maze algorithm is to make a coin-toss, a 50-50 random decision, to draw a left or right diagonal line within a grid from left to right, top to bottom. [MORE, about weighting the random values, using different symbols to show how it's based on the diagonals. ]
−
It's important to note that these new changes could have been explored directly on the C64, but it was convenient to do to in Processing because Casey was writing this code and he was more fluent with that syntax than with BASIC. Every programmer is more familiar with some language than others. As with natural languages, it's easier to work through ideas in ones native tongue. dThe 10 PRINT variations to explore weighting the random value to have a higher percentage of one diagonal lines is created by changing the value after the decimal in 205.5:
+
It's important to note that these new changes could have been explored directly on the C64, but it was convenient to do to in Processing because Casey was writing this code and he was more fluent with that syntax than with BASIC. Every programmer is more familiar with some language than others. As with natural languages, it's easier to work through ideas in ones native tongue. The 10 PRINT variations to explore weighting the random value to have a higher percentage of one diagonal lines is created by changing the value after the decimal in 205.5:
10 PRINT CHR$(205.2+RND(1)); : GOTO 10
10 PRINT CHR$(205.2+RND(1)); : GOTO 10
Line 17:Line 18:
10 PRINT CHR$(32+(INT(RND(1)+.5)*81)); : GOTO 10
10 PRINT CHR$(32+(INT(RND(1)+.5)*81)); : GOTO 10
−
After writing this first variable program in Processing to focus entirely on the image of the maze, it became clear that watching the maze build one unit at a time on the C64 is a major component of the program. This behavior doesn't naturally work with Processing because the entire screen updates as a whole, rather than character by character. Processing uses a technique called double-buffering. This means the graphics are drawn to an off-screen image buffer stored in RAM. When the image is finished, it's pushed to the computer's screen. For programs that feature animation or interaction, the result is a new image being written and drawn to the screen about sixty times a second. Unlike in BASIC, the lines of Processing program aren't assigned numbers; each line is run in order from top to bottom and according to some higher level rules. This becomes more clear when we look at this program written in Processing by Ben Fry to approximate the behavior of our 10 PRINT program on the C64:
+
After writing this first variable program in Processing to focus entirely on the image of the maze, it became clear that watching the maze build one unit at a time on the C64 is a major component of the program. This behavior doesn't naturally work with Processing because the entire screen updates as a whole, rather than character by character. Processing uses a technique called double-buffering. This means the graphics are drawn to an off-screen image buffer stored in RAM. When the image is finished, it's pushed to the computer's screen. For programs that feature animation or interaction, the result is a new image being written and drawn to the screen about sixty times a second. Unlike in BASIC, the lines of Processing program aren't assigned numbers; each line is run in order from top to bottom and according to some higher level rules. This becomes more clear when we look at this program written in Processing by Ben Fry, the co-founder of Processing, to approximate the behavior of our 10 PRINT program on the C64:
int w = 16;
int w = 16;

Revision as of 21:32, 9 July 2011

View this revision of Remarks: Processing Mazes.

Personal tools