Mazes

From Maze

(Difference between revisions)
Jump to: navigation, search
Line 232:Line 232:
----
----
 +
'''Mazes in psychology'''
 +
 +
The maze also has cultural resonance because of its role in behavioral research. Mazes have been used as laboratory environments for rats and mice, and as means of testing these rodents. The depiction of mazes in certain cultural productions reflects this aspect of the maze. For instance, images of rats in a maze are prominent in Alex Proyas' 1998 film ''Dark City''. Dr. Schreber, a captive human who works with his alien captors, is shown looking down on a rat in a large, intricate maze; the rat and the maze connect figuratively to the people in the film and the titular city, which is constructed for the purpose of an experiment. In Daniel Keyes' novel ''Flowers for Algernon'' (1966; first published as a short story in 1959), a white mouse with augmented intelligence demonstrates his abilities by traversing a maze. Algernon parallels the novel's protagonist, Charlie, in many ways: The success of the intelligence-enhancing procedure performed on him leads to its being done to Charlie. This sort of maze has been important to mention in less mainstream literary practices, too. The co-founder of the influential French group Oulipo, Raymond Queneau, famously described the members of this group, who set writing constraints for themselves, as "rats who build the labyrinth from which they plan to escape."
 +
 +
Editorial cartoons and cartoons in ''The New Yorker'' [e.g., New Yorker cartoon: July 3, 2006] depict mazes of all sorts, but make particularly frequent and interesting use of the psychologist's maze. Cartoons sometimes employ rats as characters and sometimes substitute people for amusing effect. The rat's maze is also a staple in advertising. A 2006 TV commercial for the Game Boy Micro, for instance, shows a rat traversing a maze and finding one as its reward. Besides these abundant fictional depictions of research mazes, pet owners and students have also put dozens of videos of rats and mice running mazes up on YouTube. Even though this experimental use of mazes is specialized and recent - not much more than a century old - it clearly became and remains a part of the popular consciousness.
 +
 +
Intriguingly, the first maze constructed for rats by researchers, which was built in the late 1890s, was not for testing the creatures. Willard Small of Clark University built a maze environment for rats to eat and exercise in when they ''weren't'' taking part in experiments. Small wanted the environment to simulate the burrows that rats inhabited in nature. But rather than look at the specifics of how these burrows are laid out, he modeled the first laboratory rat maze "after the Hampton Court Palace maze, a trapezoidal hedge maze that dates in its present form to 1690 but was probably built in the early sixteenth century by the first owner of the palace, Cardinal Thomas Wolsey" (Lemov 2005, p. 25). The maze was first given to rats so that they could relax - for restorative purposes quite consonant with the purposes for which the Hampton Court Palace maze was built. It made for an unusual continuity in the history of the maze, with the researchers treating the rats like aristocrats.
 +
 +
This thread would be broken when John B. Watson took up the maze and used it, initially in his dissertation research, to determine whether rats could make their way through it under different conditions. Watson, who became the youngest person to earn a Ph.D. from the University of Chicago in 1903, continued his work by systematically blinding rats and maiming them in other ways to deprive them of different senses after they had learned their way through a maze. His work attracted public attention, and he was denounced in a ''New York Times'' editorial as a torturer. Watson, however, was sure of his behavioral science agenda and that the same principles that applied to rats applied to people. By 1916 he had moved on to experiments with infants. While he didn't mutilate them, in a 1920 experiment that became famous he did condition one, "Little Albert," to fear a furry white rat and furry white things in general.
 +
 +
The use of mazes in experiments with rats increased greatly during the 1920s. We now associate ''behaviorism,'' the perspective that all animal and human actions are behaviors, mainly with another American scientist, B. F. Skinner. Skinner's operant conditioning chamber, also known as the Skinner box, is another famous environment for laboratory animals that was built decades after Watson's mazes. While Skinner's name is better known today, Watson's maze remains emblematic - and similar environments remain in use today.
 +
 +
In 1959, one of the earliest computer programs written for fun - an example of "recreational computing" - depicted an experimenter's maze. The program, which is possibly the first computer program to draw a maze of any sort, was written for the TX-0 at MIT by Douglas T. Ross and John E. Ward. The TX-0 was an experimental computer built at MIT's Lincoln Laboratories along the way to the construction of the TX-1. The earlier computer was a transistorized version of Project Whirlwind and, when loaned to the Research Laboratory for Electronics in 1958, provided one of the first opportunities for people to program when not working on an official project. It also allowed programmers to work on the machine interactively, much as Commodore 64 programmers later would, rather than submitting batch jobs in the form of decks of punched cards. In the program that became known as "Mouse in the Maze," a mouse would move through a maze, eating cheese. The mouse could also consume martinis, which would cause it to become disoriented. Here, the environment implemented was not the hedge maze of diversion and fun, but a research maze which was then made playful by the implementation of an amusing reward for the mouse and appropriate behavior.
 +
 +
The rather thin default light-blue diagonal lines produced by 10 PRINT are likely to appear, against the default dark blue background, to be much more like white laboratory maze partitions than like hedges. In that case, the structure that is being represented may be more easily imagined as the maze of behavioral experiments and than the diversionary hedge maze. The regular arrangement of the "walls" in a grid is also more akin to the arrangement of the stereotypical laboratory maze. The output of the program may suggest a puzzle-book maze even more strongly, but if it leads the viewer to think of a ''structure'' of some sort, the rat-sized researcher's maze may be the one most likely to come to mind. It wouldn't be outrageous, given that a famous early computer maze - possibly the first - was explicitly based on such a structure.
 +
 +
If some of those who look at this Commodore 64 maze do think of the experimenter's maze, they are sure to make some different further associations. Instead of suggesting that the computer is creating structures or drawings for pure amusement, the idea of the laboratory maze offers something more serious and scientific. It also brings in the idea of the experimenter - at least indifferent to the struggles of the creatures lost in the maze and perhaps cruelly impairing those creatures - and the subject of the experiment, trapped in a bewildering structure created by powers and for purposes beyond comprehension. When 10 PRINT runs, it relentlessly provides a maze, but it does not seem to be trapping us in this maze in any straightforward way. Instead, given the top-down view and the lack of a user-controlled maze walker, the computer may be offering to collaborate with the user in experimenting on virtual rats. This would be a different suggestion than the cinematic, literary, and cartoon representation of behavioral science mazes that encourage people to identify with the rat or mouse. Whoever the rat may be, and whoever the scientist may be, any computer program that evokes the researcher's maze at least hints that the computer is a scientific instrument and that the recent history of science has some darker corners.
 +
 +
----
'''Mazes in Computers'''
'''Mazes in Computers'''
==Introduction==
==Introduction==
Line 391:Line 410:
 +
----
 +
[[Category:Mazes]]
 +
Variations on a Maze: 10 Print as CHR calls
 +
 +
This section examines a set of simple variations in the ''10 Print'' one-liner, each drawing on different graphic characters from the PETSCII table. Although each change is small, every variation has a significant impact on the perceived maze-like qualities of the visual output. The output of ''10 Print'' has a unique visual appeal, which we can understand in terms of design and composition (diagonal vs orthogonal), and in terms of how it plays against the contextual expectations of the historical period when it emerged (graphical software -- particularly video games of the era).
 +
 +
When we attempt to change even the smallest element of ''10 Print'', we make an interesting discovery -- ''10 Print'' is a kind of optimal solution that is uniquely elegant in its design space (a c64 BASIC one-line maze generator). Any similar attempt is both less concise (requires more code) and less expressive (resembles a maze less). In fact, the concision of the code and the expressiveness of the image are tightly related, and arise out of a unique set of constraints and interactions:
 +
 +
* the keyboard layout of the PET / C64
 +
* the sequence of adjacent characters in the PETSCII table
 +
* graphic design and topology
 +
* a design goal to make the one-liner short and simple
 +
 +
Because the original program is a concise randomized offset to a region of the PETCSII character table, our variations are limited to other such lookups. The code is limited by the characters available in PETSCII, and the concision or elegance of the code is affected by the adjacency of characters, which must otherwise be randomized in a more complex way than an offset.
 +
 +
== Keyboard and Character Map, Hardware and Software ==
 +
 +
[[Image:PET_Keyboard.png|thumb|400px|The PET 2001 chicklet keyboard, with the visually complementary arrangement of graphic characters on the keys.]]
 +
 +
As we will see when exploring visual alternatives below, the PETSCII CHR table contains few related graphical characters the are next to each other and can be easily addressed by offsets -- in fact, many related images (sets of corners, mirror images) appear to have been randomly scattered through the space. This lack of adjacency complicates our ability to generate graphics using a simple offset -- in fact, to use anything but an offset of one, we have to cast the random number generator's float result to an int before multiplying.
 +
 +
[[Image:C64_PETSCII_chart.png|thumb|300px|Chart of unshifted PETSCII characters displaying on a Commodore 64]]
 +
 +
Why is the order of graphical characters in the PETSCII table so haphazard? The answer is that arrangement was dictated, not by logically grouping index numbers (a program-up strategy), but by arranging them visually on the PET keyboard design (a hardware-down strategy). Because the PET 2001 keyboard was a chicklet variant of the QWERTY arrangement, yet lacking the row offsets that QWERTY designer Christopher Sholes originally created for mechanical typewriter levers, its grid of keys presented a clear canvas for logical groupings of related symbols. Thus we can see four corners of a square grouped on OPL:, four arcs of a circle on UIJK, and four suits of a card deck on ASZX.
 +
 +
This visual logical grouping, however, occurs in the space of the QWERTY keyboard arrangement, which originally attempted to minimize mechanical jams in typewriters by maximizing the distance between common letter pairs. As a side-effect of this principle, few adjacent letters pairs in the alphabetic sequence are actually visual neighbors on the QWERTY keyboard. Other related graphical characters, while adjacent on the physical keyboard, are effectively scrambled by the QWERTY layout before being placed in the alphabetized PETSCII index. This preserves their logical relationship to the keys (any graphical character can be transformed into its letter, or vice-versa, by a fixed offset). However it obfuscates their relationship to each other. The only alphabetically adjacent keys found in QWERTY rows are:
 +
 +
* FG (102/103)
 +
* JK (106/107)
 +
* NM (110/109) (reversed)
 +
* OP (111/112)
 +
 +
Not coincidentally, our ''10 Print'' one-liner uses the NM pair -- because it is visible on the interface, because it is elegant and concise in the code, and because the output is surprising, given the context of maze-like computer graphics at the time. On the PET, all of the other pairs also bear related graphical characters, and we will try each of them below -- but only NM will produce something more structural than textural.
 +
 +
== Context of Expectations: Computer Graphics and Games ==
 +
 +
The representation of mazes in computer graphics was already a staple during the period that finds the ''10 Print'' BASIC one-liner appearing in C64 manuals and journals -- in fact, the use of computers to represent mazes conceptually was common even before the advent of home computer graphics.
 +
 +
(Sidebar? Summary IF and the tradition of box diagram maps, the importance of mazes in Adventure / Zork / Acheton, and the contextual relationship to home computing and dominance of early PC video game industry. The maze was already a part of the culture of computer games before the computer game became visual.)
 +
 +
[[Image:Game-Gotcha-arcade-(1973).jpg|thumb|160px|''Gotcha'' (1973 arcade) a game of tag between two players in a maze-like field of partitions]]
 +
 +
[[Image:Game-Amazing_Maze-arcade-(1976).png|thumb|160px|''The Amazing Maze Game'' (1976 arcade) -- a classic maze]]
 +
 +
[[Image:Game-Maze_Craze-Atari2600-(1978).png|thumb|160px|''Maze Craze'' (1978 Atari VCS) -- a large set of games -- complete, race-to-complete, tag, etc. -- all played within classic mazes.]]
 +
 +
In graphical computer games, one common feature of the many different 2D [http://en.wikipedia.org/wiki/List_of_maze_video_games maze video games] from the period is orientation: all are rectilinear and aligned to the Cartesian axes, rather than being diagonal. This similarity, it turns out, constitutes the category -- in fact, it is even more important than the degree to which given games are maze-like, or what impact their maze-ness has on gameplay. Different games have different maze aesthetics. The arcade game ''Gotcha'' (1973) stages a game of tag between two players in a maze-like field of disconnected partitions which served as an obstacle course. Conversly, the arcade game ''The Amazing Maze Game'' (1976) implements a race (two-player or against a computer) to solve a classic continuous closed maze. A similar implementation on the home Atari VCS, ''Maze Craze'' (1978) provides a playable random maze generator as the field for a very a large number of games, including races and tag, and includes modes with invisible walls where the maze must be interactively felt out and remembered.
 +
 +
[[Image:Game-Pac-Man-Atari2600-(1982).gif|thumb|160px|''Pac-Man'' (1982 Atari VCS)]]
 +
 +
''Pac-Man'' (1980) is perhaps the most famous classic maze-like arcade game, although, like ''Gotcha'', it is less a maze than a free-form obstacle course, using the free-floating wall partitions to complicate the game of tag rather than obfuscating any path to escape. When ''Pac-Man'' was reimplemented for the Atari VCS in 1982, vertical field was redesigned in horizontal format and for lower resolution display, however the essential topology of the game (partitions, looped corners, and warp gates connecting one side to the other) remained the same.
 +
 +
Another feature shared by all these games (both arcade and for home video game consoles) is their treatment of the screen display as a single complete visual unit, like the board of a board game. An interesting contrast to this aesthetic is a close-up design that puts the player in the Maze, the Atari VCS game ''Adventure'' (1979) implements a maze as a series of many close-up screens. ''Adventure'' was extremely loosely based on the interactive fiction work of the same name, and featured a hero with a sword collecting treasures despite the efforts of four dragons. Unlike ''Pac-Man'', in which the player can guide Pac-Man out a warp gate on one side of the screen and see him enter on the other side, Adventure contains numerous topologically impossible warps that are always hidden from view, and can only be deduced. Instead of an overview map of the total maze, each screen is a claustrophobic close-up of simple paths, often emphasizing discontinuous fragments of other paths that can't easily be reached. This kind of claustrophobic, discontinuous maze-space was later further explored in ''Haunted House'' (1981), particularly in the use of darkness and the addition of keys in some modes to restrict and sequence room access.
 +
 +
=== Isometric Games ===
 +
 +
[[Image:Game-Ant_Attack-ZX_Spectrum-(1983).gif|thumb|160px|''Ant Attack'' (1983 ZX Spectrum)]]
 +
 +
Whether close up or distant, continuous mazes or partitioned obstacle courses, what all these period maze-games have in common is that, unlike the diagonal orientation of ''10 Print'', all are constructed of horizontal/vertical walls that are orthogonal to the edges of the screen and the scan line of the display.
 +
 +
Diagonal orientation did have a place in the design of early maze-like games, but not in simple 2D fields -- instead, it emerged through [http://en.wikipedia.org/wiki/Video_games_with_isometric_graphics isometric video games] that introduced diagonal motion at the same time it challenged the picture plane through the pseudo-3D effect of isometric perspective. In the arcade, two isometric games emerged in 1982: ''Q*bert'', an completion/avoidance platform on an isometric pyramid, and ''Zaxxon'', an obstacle-racer emphasizing pseudo-3D elements. Neither of these game designs is particularly maze-like.
 +
 +
Later games did incorporate maze-like obstacle elements into isometric gameplay. Part of this limitation was due to available resolution at the time, particularly on home systems. Graphics with isometric effects took up a lot of space, which limited the ability to design large complex level structures like mazes on a unified field. Thus, when ''Ant Attack'' (1983) and ''Marble Madness'' (1984) introduced isometric obstacle course elements on a large field, both did so using scrolling.** By contrast, ''Knight Lore'' (1984) follows the design pattern of ''Adventure'' for the VCS, showing a close-up view of one room at a time in a maze-like castle.
 +
 +
<blockquote>** ''Ant Attack'' also alters the camera view when navigating behind objects.</blockquote>
 +
 +
Even here, however, we see how extremely different aesthetic of early isometric maze games was when compared to the ''10 Print'' output. While both have a dynamic diagonal orientation, the move from 2D design to volumetric pseudo-3D space leaves them, visually, worlds apart.
 +
 +
== Patterns ==
 +
 +
=== Diagonals ===
 +
 +
[[Image:10print-diagonal.png|160px|thumb|10 PRINT CHR$(109+RND(1)*2); : GOTO 10]]
 +
 +
By contrast, the maze output of 10 PRINT is oriented diagonally, giving it a distinctive visual look.
 +
 +
Several things about this visual orientation are surprising. First, when we visually trace the maze the long runs or paths that lead through the maze do not follow the lines along which the algorithm constructs the maze (which remains left-right, top-bottom). Second, this feature of being diagnol is not an elaboration in the code, but instead an elegant simplification that is part of the essence of the succinct one-liner.
 +
 +
<blockquote>10 PRINT CHR$(109+RND(1)*2); : GOTO 10</blockquote>
 +
 +
=== Orthogonal Weave ===
 +
 +
[[Image:10print-orthogonal-weave.png|160px|thumb|10 PRINT CHR$(102+RND(1)*2); : GOTO 10]]
 +
 +
There are no other two characters in the [http://en.wikipedia.org/wiki/PETSCII PETSCII] data set that, when substituted for our "\" and "/", will result in the construction of a traditional orthogonal maze. Vertical and horizontal bars, for example, result in a disconnected weave, while solid and empty squares result in rough static.
 +
 +
<blockquote>10 PRINT CHR$(102+RND(1)*2); : GOTO 10</blockquote>
 +
 +
(add note on 3d wicker visual interpretation)
 +
 +
=== Corners ===
 +
 +
[[Image:10print-elbows.png|160px|thumb|10 PRINT CHR$(108+(INT(RND(1)+.5)*3)); : GOTO 10]]
 +
 +
Randomly selecting corner pieces such as "L", on the other hand, simply turn the image into a honeycomb.
 +
 +
As it turns out, 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.
 +
 +
(Add note on including 1,2,3,4,5 etc. spaces in order to try to create a spaced offset -- note similarity to Gotcha etc.)
 +
 +
10 PRINT " "CHR$(108+(INT(RND(1)+.5)*3)); : GOTO 10
 +
 +
=== Four Walls ===
 +
 +
[[Image:10print-orthogonal-rough.png|160px|thumb|10 PRINT CHR$(181+(INT(RND(1)+.5)*3)+(INT(RND(1)+.5))); : GOTO 10]]
 +
 +
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.
 +
 +
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 (like the code) lacks simplicity and elegance. potential redundancy between the top / bottom and left / right elements creates apparent variation in the thickness of the walls -- an interesting but potentially distracting implication of messiness and texture.
 +
 +
=== Two Walls ===
 +
 +
[[Image:10print-orthogonal.png|160px|thumb|10 PRINT CHR$(181+(INT(RND(1)+.5)*3)); : GOTO 10]]
 +
 +
<blockquote>(...discuss how 181/184 is the best approximation of the classic orthogonal game aesthetic, but it is still less elegant than 109/110 -- we have to carefully force the random result to an INT before introducing an offset multiplier, which adds length to the line, conceptual complexity to the demo, AND as a result we get a less visually interesting output -- that is, it is both less formally dynamic as a design and less contextually unexpected)</blockquote>
 +
 +
<blockquote>10 PRINT CHR$(181+(INT(RND(1)+.5)*3)); : GOTO 10</blockquote>
 +
 +
== See Also ==
 +
 +
* [[10_Print_in_a_visual_context]]
 +
* [[Visual_Essay]]
 +
* [[Cultural_History_of_Mazes]]
 +
 +
== Notes ==
 +
Cross-reference the discussion of QWERTY / PETSCII with a small table of textures that indexes the variations, giving each a letter pair, index pair, a name, and a picture:
 +
 +
* FG (102/103) Weave
 +
* JK (106/107) Waves ?
 +
* NM (110/109) (reversed) Maze
 +
* OP (111/112) Corners2 ?
 +
 +
How should the table be sorted? Probably by alphabetical / index, although it doesn't make sense to go through it in that order.... Table might also have two pictures -- one of the textured render, the other of the symbolic render (-32 shifted, so NM etc.) There is a hotkey in C64 BASIC to do this...?
 +
 +
 +
*[http://www.commodore.ca/manuals/c64_programmers_reference/c64-programmers_reference_guide-02-basic_language_vocabulary.pdf c64 Programmers reference guide]
 +
* Potential illustration for IF sidebar
 +
** [http://ifarchive.giga.or.at/if-archive/mapping-tools/maps/varic.jpg Map of Varicella]?
 +
** [http://www.youtube.com/watch?v=YeV0pLRyM7o MC Frontalot ''It is Pitch Dark'' @2:38]
 +
*Porting / Reimplementation as Translation vs. Adaptation
 +
** [http://jeremydouglass.com/cv/benchmark.pdf Benchmark fiction]?
 +
 +
 +
=== Additional Images ===
 +
 +
[[Image:Game-Pac-Man-arcade-(1980).png|left|thumb|160px|''Pac-Man'' (1980 arcade) -- a maze-like field of partitions must be run while being chased by ghosts]]
 +
 +
[[Image:Atari2600-Adventure-v2-(vgmaps).png|left|thumb|200px|Map of ''Adventure'' for Atari 2600 (VGmaps)]]
 +
 +
[[Image:10print-77,78-NM-letters.png|left|thumb|160px|10 PRINT CHR$(77+RND(1)*2); : GOTO 10]]
 +
 +
 +
== Bibliography ==
== Bibliography ==

Revision as of 00:12, 30 September 2010

View this revision of Mazes.

Personal tools