Maze Generation
Home Up QBASIC+Assembly Floating Point Maze Generation Modules Parsing EMS Game Writing

 

1.  Structure
2.  Features
3.  Genesis
4.  First Step
5.  An End?
6.  New Lease
7.  Finishing
8.  Data Design
9.  Some Limits
10. Path List
11. Algorithm
12. Last Thoughts

One programming project I wanted to write, back in 1973, was a program written in BASIC to generate mazes and print them out on an ASC-33 teletype. The idea certainly wasn't original. I got the idea from running someone else's existing maze program. I just didn't have the source code and I wondered how it worked. I also didn't have the kinds of fancy graphics capabilities of today's computers, so the output had to be in ASCII, but I enjoyed figuring out how to generate mazes, writing the program, and working through the mazes it generated.

It's getting close to 30 years since then (okay, so now it's more than 30 years) and it's time I wrote something down about it.  It's one of those programs that can be a satisfying experience for all programmers, novice or experienced. It's not so complex that a novice would get swamped out and it has enough interesting features that keep it from being entirely trivial for a more experienced programmer. And others can enjoy the results, too.

Getting Started

I've written up some short pages designed to be read, sequentially.  They are connected to this page.  In addition, I've also provided some finished programs for you to try out and look at.  All source code is provided.   Hopefully, you will find both the pages and the programs enjoyable.  Good luck!

If you click on "up" above to get to the parent page, you can find links for getting QBASIC, if you don't already have it, and some Quick BASIC compilers. (By the way, the terse descriptions below will carry somewhat more meaning if you read the web pages I've written on making mazes.) Here are the files:

ALLMAZES.ZIP
All of the following mazes are available here, included in a 30k ZIP file.
Text-mode mazes, no bit flags, limited
This text-output version is fairly simple and follows the logic outlined in the tutorial. It is a straight-forward rendition.
Text-mode mazes, bit flgs, limited
This text-output version provides the same features as the first, except that it uses bit flags instead of wasting an entire INTEGER to represent walls and room visitation status.   The tutorial addresses this detail, as well.
Text-mode mazes, bit flgs, big mazes
This text-output version uses the denser packing of bit flags to extend the maximum size for a maze.  The path list is eliminated, due to it's excessive use of memory, by using a bit field and a fast search algorithm.  (This path list algorithm isn't addressed directly in the tutorial.)
HP LaserJet mazes, bit flgs, big mazes
This HP-output version uses the same idea above and provides the ability to place several mazes on a single page.
HP LaserJet mazes, bit flgs, big, fast
This HP-output version reorganizes the output routine to take advantage of fast vector drawing on the HP LaserJet.  This program should print much more quickly onto the printer than the previous one.
Screen Maze, bit flgs, big, fast
This screen-output version modifies the HP vectorized version of the maze program and uses that same method to draw to the screen in mode 12.
Screen Maze + path finding
This screen-output version adds an animated path-finding algorithm, once the maze is drawn. The path-finding algorithm searches the maze drawn on the screen by examining pixel values.

All source code is provided with these programs. I believe they will all run in the free version of QBASIC and they should all run in the various compiler versions, as well.

Some of above programs also illustrate how to access the mouse driver, from QBASIC.

 

Feel free to email me.

Last updated: Wednesday, January 04, 2006 01:13