Maze generation

Gregory N. Bond gnb at bby.oz.au
Fri Dec 14 10:07:45 AEST 1990


>>>>> On 13 Dec 90 01:19:40 GMT, martins at syacus.acus.oz (Martin Schwenke) said:

Martin> I am interested in software or algorithms for generating mazes with
Martin> unique solutions. I am also, but less, interested in maze solving
Martin> algorithms, and programs.

OK, build it by induction.

1) Select a start square.  This is a uniquely connected maze.

Induct: 
2) Given a uniquely connected maze of n squares, we can make a
   uniquely connected maze of n+1 squares by adding a new square
   adjacent to the existing maze and connecting it by removing wall
   only.

3) Choose arbitary start and end squares.  Guaranteed only 1 way
   through between any two squares.

However, this generates "choppy" mazes, with very few long runs.  Much
better looking mazes can be generated by slightly changing the
algorithm so that at point 2) instead of adding just one square, you
add a "corridor" that is straight say 80% of the time, and turns
randomly 20% of the time, and join that on to the existing maze at
only one point.  The length of the coridor can be limited (say, the
length of the short size fo the maze) or run untill it gets boxed in
by existing maze elements.

I experemented a lot with maze generation many years ago on a 64k Z80
system.  With fairly compact encoding (4 cells/byte) and a 60K TPA, I
was producing mazes approx 150 x 2000.  If I could read 8inch 1.2MB
CP/M disks, I'd send you the programs, but they don't fit in the Sun
tapedrive slot...

As for solving.....

With any uniquely connected maze it is possible to solve it by the
"right hand rule" - stick your right hand on the wall and keep
walking, always turning right at every opportunity.  The sunview maze
screenblanker does that.  (I once hacked it to leave a grey trail
where it had visited - most interesting graphical view of the
algorithm at work).

Greg.
--
Gregory Bond, Burdett Buckeridge & Young Ltd, Melbourne, Australia
Internet: gnb at melba.bby.oz.au    non-MX: gnb%melba.bby.oz at uunet.uu.net
Uucp: {uunet,pyramid,ubc-cs,ukc,mcvax,prlb2,nttlab...}!munnari!melba.bby.oz!gnb



More information about the Alt.sources.d mailing list