Article Preview
Buy Now
| Print: | |
| PDF: |
Feature
Maze Generation
How to Get Lost in Your Work
Issue: 3.6 (July/August 2005)
Author: Joe Strout
Author Bio: Joe always loved mazes as a child, and spent many long hours generating them by hand, the dolt.
Article Description: No description available.
Article Length (in bytes): 9,897
Starting Page Number: 18
RBD Number: 3610
Resource File(s):
3610.sit Updated: Monday, July 25, 2005 at 11:26 AM
Related Link(s): None
Known Limitations: None
Excerpt of article text...
Mazes are one of those simple puzzles that have been enjoyed throughout history. For most of that history, designing a maze required a lot of careful work. Nowadays, we can let our computers do the grunt work for us. In this article, we'll see how to write REALbasic code that automatically generates a maze of any size and shape we like.
Let's start by considering some of the properties of a good maze. It should certainly be solvable; that is, there must be a path from the start location to the goal location. More generally, it should probably be possible to get from any point in the maze to any other. However, it shouldn't be too easy; there should be only one or a few ways to get from point A to point B.
For a maze composed of square cells, each cell has four walls (ignoring for now the edge cells around the outside of the maze). However, each wall is shared between two cells -- assuming we don't want to support one-way doors -- so really, there are two walls per cell. In the code for this article, I'll assume that a cell "owns" the walls above and to the left of that cell.
...End of Excerpt. Please purchase the magazine to read the full article.
Article copyrighted by REALbasic Developer magazine. All rights reserved.
|








