a maze-ing algorithim

September 5, 2008 at 4:48 pm (code)

well, i have been working on a simple maze game on the side and i am having some issue with generating a maze that is complex, but yet still has a path.  currently, i am using a north/south/west/east method for each piece.  this is where i assign a 1 or 0 to each direction that indicates how each piece works.  for example, if you have a top-left corner piece, that would be 0, 1, 0, 1 in my array.  this piece would then match up with any piece that has a 1 for the north or west directions.  very simple way to determine pathing, but my problem lies in creating an intelligent route.  currently i am employing a north/west approach to build the path.  i check the row that has been already built (north) and the piece directly to the left of the piece i am working on (west).  this ensures that a path will be created that connects.  the complexity of the puzzle seems to naturally occur through this semi-random selection.  my main problem is that sometimes the algorithim randomly cuts the path off and will not allow anyone to continue through the maze.  i am still puzzled (pun anyone?) by this, but hope to have a simple browser version working soon.  as i always say, we shall see…


Permalink Leave a Comment