Thread: CHeck my Maze Solver

  1. #1
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683

    CHeck my Maze Solver

    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

  2. #2
    Registered User moonwalker's Avatar
    Join Date
    Jul 2002
    Posts
    282
    It is pretty good although not fool proof. It found the best
    solution after all. Pretty well done.

  3. #3
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    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

  4. #4
    Registered User
    Join Date
    Feb 2003
    Posts
    265
    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?

  5. #5
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    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.

  6. #6
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    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.

  7. #7
    drdroidHERE
    Guest
    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!!!

  8. #8
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    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...

  9. #9
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    Posts
    533
    Very VERY well done. Reminds me of the code for Monkey Island. Hehe

    -LC
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BN_CLICKED, change button style
    By bennyandthejets in forum Windows Programming
    Replies: 13
    Last Post: 07-05-2010, 11:42 PM
  2. Solve a maze recursive
    By BENCHMARKMAN in forum C++ Programming
    Replies: 4
    Last Post: 09-19-2006, 11:33 PM
  3. noobie maze program
    By stormfront in forum C Programming
    Replies: 9
    Last Post: 11-30-2005, 10:23 AM
  4. Solving A Maze Using C Language!!!!
    By jonnybgood in forum C Programming
    Replies: 6
    Last Post: 11-08-2005, 12:15 PM
  5. Classic maze problem
    By dat in forum C Programming
    Replies: 3
    Last Post: 01-16-2003, 09:57 PM