Remarks: Variations in BASIC

From Maze

(Difference between revisions)
Jump to: navigation, search
(Full revision)
(Further revision)
Line 7:Line 7:
= Weave =
= Weave =
−
[[Image:weave.png|||10 PRINT CHR$(198.5+RND(1)); : GOTO 10]]
+
[[Image:weave.png]]
 +
 +
<code>10 PRINT CHR$(198.5+RND(1)); : GOTO 10</code>
There are no other two characters in the PETSCII data set that, when substituted for the diagonal "\" and "/", will result in the construction of a traditional orthogonal maze, one that is aligned to the vertical and horizontal axes of the screen screen. Using vertical and horizontal bars, for example, results in a disconnected weave, while solid and empty squares result in rough static.
There are no other two characters in the PETSCII data set that, when substituted for the diagonal "\" and "/", will result in the construction of a traditional orthogonal maze, one that is aligned to the vertical and horizontal axes of the screen screen. Using vertical and horizontal bars, for example, results in a disconnected weave, while solid and empty squares result in rough static.
−
<blockquote>10 PRINT CHR$(198.5+RND(1)); : GOTO 10</blockquote>
+
Though the result certainly does not suggest a maze as strongly, this version of the program is not without visual interest. The output imparts a three-dimensional impression, as if someone had woven bands of material over and under one another.
−
 
−
Though the result is certainly not a maze, this version of the program is not without visual interest. The output imparts a three-dimensional impression, as if someone had woven bands of material over and under one another.
 
= Corners =
= Corners =
−
[[Image:corners.png|||10 PRINT CHR$(204+(INT(RND(1)+.5)*3)); : GOTO 10]]
+
[[Image:corners.png]]
 +
 +
<code>10 PRINT CHR$(204+(INT(RND(1)+.5)*3)); : GOTO 10</code>
Randomly selecting either a bottom-left or top-left corner piece, by contrast, turns the image into a honeycomb. Diagonal mazes are symbolically efficient on a Cartesian grid due to the fact that four characters meet at the corners, whereas only two meet along an edge. Thus, intersections of up to four lines (the building blocks of a rectilinear maze) can be created at corners if we use diagonal lines.
Randomly selecting either a bottom-left or top-left corner piece, by contrast, turns the image into a honeycomb. Diagonal mazes are symbolically efficient on a Cartesian grid due to the fact that four characters meet at the corners, whereas only two meet along an edge. Thus, intersections of up to four lines (the building blocks of a rectilinear maze) can be created at corners if we use diagonal lines.
Line 23:Line 25:
= Corners and Diagonals =
= Corners and Diagonals =
−
[[Image:corners_and_diagonals.png|||10 PRINT CHR$(204+(RND(1)+.5)*3); : GOTO 10]]
+
[[Image:corners_and_diagonals.png]]
 +
 +
<code>10 PRINT CHR$(204+(RND(1)+.5)*3); : GOTO 10</code>
A simplification of the program above involves dropping the "INT" function, so that the program chooses at random not only between characters 204 and 207, the two corners; it can also choose the two characters in between. These characters happen to be 205 and 206, the ╲ and ╱ characters which are invoked by 10 PRINT. The result does not have the clear structure of the 10 PRINT maze, but is compelling in its confusion of elements.
A simplification of the program above involves dropping the "INT" function, so that the program chooses at random not only between characters 204 and 207, the two corners; it can also choose the two characters in between. These characters happen to be 205 and 206, the ╲ and ╱ characters which are invoked by 10 PRINT. The result does not have the clear structure of the 10 PRINT maze, but is compelling in its confusion of elements.
Line 29:Line 33:
= Four Walls =
= Four Walls =
−
[[Image:10print-orthogonal-rough.png|||10 PRINT CHR$(181+(INT(RND(1)+.5)*3)+(INT(RND(1)+.5))); : GOTO 10]]
+
[[Image:four_walls.png]]
−
One of the most intuitive methods of constructing a maze-grid is to take an approach like graph paper, using four characters to signify either a top-wall, bottom-wall, left-wall or right-wall for each cell on the grid. Such characters exist in PETSCII in both "thick" and "thin" variants. Such a process is unfortunately less elegant, as these characters are never placed continuously in the PETSCII character set, and so cannot be addressed with a simple offset.
+
<code>10 PRINT CHR$(181+(INT(RND(1)+.5)*3)+(INT(RND(1)+.5))); : GOTO 10</code>
 +
 +
One of the most intuitive methods of constructing a maze-grid is to take an approach similar to filling in one edge of each square on a sheet of graph paper. The four characters here correspond to a top-wall, bottom-wall, left-wall or right-wall. Such characters exist in PETSCII in both "thick" and "thin" variants; the ones used here are the thick ones. Such a process is unfortunately less elegant, as these characters are not (in either variety) placed adjacent to one another in the PETSCII character set, and so cannot be addressed with a simple offset.
One can, of course, construct an orthogonal maze instead in a variety of other ways. One way is to address a set of four or more horizontal character elements a l. There are two styles of these characters (thick and thin) available in the Commodore 64 ASCII character set. However, these four character types never appear continuously in the table, so the elegant method of using a simple RND offset must be made a bit more verbose -- for example, selecting between 181, 182, 184 and 185 using two random offsets.
One can, of course, construct an orthogonal maze instead in a variety of other ways. One way is to address a set of four or more horizontal character elements a l. There are two styles of these characters (thick and thin) available in the Commodore 64 ASCII character set. However, these four character types never appear continuously in the table, so the elegant method of using a simple RND offset must be made a bit more verbose -- for example, selecting between 181, 182, 184 and 185 using two random offsets.
−
 
−
<blockquote>10 PRINT CHR$(181+(INT(RND(1)+.5)*3)+(INT(RND(1)+.5))); : GOTO 10</blockquote>
 
The image that emerges is indeed mazelike, but this image, like the underlying code, lacks simplicity and elegance. Since top and bottom and left and right lines can be printed up against each other, a variation in the thickness of the walls appears -- an interesting but potentially distracting implication of messiness and texture.
The image that emerges is indeed mazelike, but this image, like the underlying code, lacks simplicity and elegance. Since top and bottom and left and right lines can be printed up against each other, a variation in the thickness of the walls appears -- an interesting but potentially distracting implication of messiness and texture.
Line 41:Line 45:
==== Two Walls ====
==== Two Walls ====
−
[[Image:10print-orthogonal.png|||10 PRINT CHR$(181+(INT(RND(1)+.5)*3)); : GOTO 10]]
+
[[Image:10print-orthogonal.png]]
−
The selection of characters 181 and 184, a thick left line and thick top line, is the best approximation of the classic orthogonal maze aesthetic seen in computer and videogames. It is still less elegant than using 205 and 206 as PETSCII values. The characters are not adjacent, so some trick, such as this one involving the use of INT, must be used to select one of the two at random. The result is less visually interesting output. It is a maze, but is both less formally dynamic (being aligned to the screen) and less contextually unexpected (being typical of computer mazes).
+
<code>10 PRINT CHR$(181+(INT(RND(1)+.5)*3)); : GOTO 10</code>
−
<blockquote>10 PRINT CHR$(181+(INT(RND(1)+.5)*3)); : GOTO 10</blockquote>
+
The selection of characters 181 and 184, a thick left line and thick top line, provides the best approximation of the classic orthogonal maze that is seen in computer and videogames. Producing it is still less elegant than selecting between 205 and 206 as PETSCII values. The characters used are not adjacent, so some trick, such as this one involving the use of INT, must be used to select one of the two at random. The result is less visually interesting output. It is a maze, but is both less formally dynamic (being aligned to the screen) and less contextually unexpected (being typical of familiar computer and videogame mazes).

Revision as of 20:40, 1 August 2011

View this revision of Remarks: Variations in BASIC.

Personal tools