PDA

View Full Version : CHeck my Maze Solver



vasanth
07-31-2003, 04:23 AM
I saw some one posting an interesting problem... Solving Mazes... Though I had an idea never programmed it... So gave it a try... I have created a DOS based program with a graphical interface where the user can build his own maze (map) and ask the computer to solve it... Please try it and give me your feedback... The code is much unstructured and not understandable as I did it in a hurry... Please excuse... ( I have included the executable.. Please extract all files before running the exe..)

I have used recursive function to solve it... it only finds a path and not necessaraly the shortest...

Note: - Use left clicks to build road (path) and right click to build blocks (Blockage) and use the Button S to solve the maze... The computer will try to find a path between the @ (Mouse) symbol and the top corner which says C (Cheese)

Thanks in advance for trying
Vasanth

moonwalker
07-31-2003, 05:15 AM
It is pretty good although not fool proof. It found the best
solution after all. Pretty well done.

vasanth
07-31-2003, 05:21 AM
Well i have considered how people build maps and optmised it for that.. because many people usually tend to build it in up and right direction based on the position i have given.. If you change this it will take a longer route then....


Well is there any better way other than recursions....


Thanx
Bye

DeepBlackMagic
07-31-2003, 06:50 AM
I tried it, i made a curvy looping maze and it backtracked and even teleported once. lol. overall a good job. the single best way of maze pathfinding is to create a map of the level. example:

COOO
XOXO
XOXO
MOOO

Cheese Mouse Open XWall.
What you do is create an array starting at the cheese, moving out until all spaces are mapped.
[0 1 2 3]
[9 2 9 4]
[9 3 9 5]
[5 4 5 6]
Generally walls would be set some insanely high number like 65000 but this time i just used 9 for such a small maze.

The rule is simple. start at the mouse. check left right up and down and move to the square thats the lowest number. So your always moving closer. Move 5 4 3 2 1. start right up up up left. What do u think?

PJYelton
07-31-2003, 10:17 AM
Good job! Reminds me of a maze program I wrote awhile back using Win32. It creates a random perfect maze and then goes about solving it. I'll attach it to the end here with the source. Word of warning though, I made this before I completely understood windows programming and never got around to fixing it, meaning you can't resize the window and you can't close the window when its thinking.

Press enter to start the maze creation and enter again when the maze is done and you want to start to solve it.

sean
07-31-2003, 10:18 AM
Not bad. There was a guy on here a few weeks ago asking about AI methods of doing stuff like that. He'd love to hear this.

drdroidHERE
07-31-2003, 11:32 AM
if you check that thread, you'll see he responded to that... with the exact same program... i think you knew that though and were being sarcastic in which case I am just j/k otherwise....... HAH HAH HAH HAH HAH!!!

vasanth
07-31-2003, 12:23 PM
Originally posted by PJYelton
Good job! Reminds me of a maze program I wrote awhile back using Win32. It creates a random perfect maze and then goes about solving it. I'll attach it to the end here with the source. Word of warning though, I made this before I completely understood windows programming and never got around to fixing it, meaning you can't resize the window and you can't close the window when its thinking.

Press enter to start the maze creation and enter again when the maze is done and you want to start to solve it.


Looks and works better than my DOS based maze program.. Keep it up...

Lynux-Penguin
07-31-2003, 10:37 PM
Very VERY well done. Reminds me of the code for Monkey Island. Hehe

-LC