Allegro.cc
Projects
Action252
Adventure22
Arcade216
Board Games30
Demos24
Emulators10
Other68
Puzzle139
Role Playing40
Sports25
Strategy58
Utilities46
Resource Directory
Code Gallery3
Compilers12
Help & Documents13
Libraries63
Media2
Tools8
IOTD: tile based maze
tile based maze
tile based maze, by Johan Halmén

I haven't re-invented the wheel for a long time, so inspired by a recent thread I decided to make a maze algo. Here's the result. The black parts are the paths in the maze. The maze world is simply a w*h array where each cell is either a square wall brick or empty. No thin walls. The Maze class has a member char **maze, which holds the maze data. 0 for a hole, 2 for a brick. (1 is used for marking during creation.) I have about 200 lines of code that I might upload somewhere on a.cc, if someone is interested in it
Doesn't seem to be enought variation. A little too easy to follow. - DanielH
Hey, at least it looks good; I think it's cool that your algo managed to produce a somewhat open "chamber" type room (right there, upper-middle)... But, do you mind labeling the start/finish? heehee - Gideon Weems
I said:
The black parts are the paths in the maze
...not the white parts, so there's no chamber. Actually there is a start but no finish. I'm Finnish, is that close enough? (Ok, bad joke.) The algo simply starts to draw the path at some point and with some direction. At each node, or tile, it performs some recursive stuff where it prepares to step forward, to the left and to the right. There's some randomness involved, too, of course. So this is not a maze with one entrance and one exit. - Johan Halmén
I didn't mean it looked bad, just that you he should try to adjust algorithms to get rid of those little one step deadends. - DanielH
I know, I should just forbid one step deadends. And the maze is easy to follow. I made the program colour the start and the farmost node. Knowing it was the farmost it was easy to find by eye. But as soon as I made a moving point, controlled with the keyboard, it got more difficult. Your eyes and thought are faster than your fingers and you see bigger structures and patterns without the moving point. - Johan Halmén
Now you need to develop a first-person-view engine to explore that maze with! Sort of inspires me to make my own, actually... - Michael A. Johnson
Well done... can you reverse the colors so white is the pathway though? It hurts my eyes and feels unatural. This would be a good start for a game similar to diablo where the dungeon randomizes for every level... wolfenstein style! - Adol
The algo goes like this (extremely simplified):
[pseudo_code]
Step(int x, int y, int direction)
{
   if (tile ahead, tile to the left and tile to the right == wall)
      make this tile path
   else
      return
   if (rand() % 100 < 75)
      Step( on tile ahead, direction);
   if (rand() % 100 < 95)
      Step( on tile to the left, direction-1);
   if (rand() % 100 < 95)
      Step( on tile to the right, direction+1);
}

The rand() lines make it interesting. With the probabilities you get longer or shorter straight lines of path. I guess I'll make it into some kind of maze explorer with a gui that lets you change those parameters. And the colours, too. - Johan Halmén
Look at [url=http://www.vollebregt00.freeler.nl/t/tankzone.html]TankZone[/url], a game I made really long ago. In random.c is the maze generation code. Turn it on in the configuration file. (random_map=1 I think)
-- Tobi - Tobi Vollebregt
This section is only available to registered Allegro.cc members.



The Gallery | Add your own image!
Poll
Is grammer and spelling important?
View Results