C++/maze in c++
I'm sorry to bother you. I have a question from you. My question is about maze. One of my masters wanted us that we research about maze. But whatever I saerch it in the search engine, I coudn't please him, until I found this page in search engine. My master want us that we write a definition for maze and explain about algorithm for solve it and write data structure for save and solve it that works for any mazes. then we have to the program in c++. I hope U answer me. because I don't have any other opportunity to give my master.
Thanks a lot.
Hello masumeh, thank you for the question.
The most common algorithm to finding the exit of a maze is to move in the immediate direction you can move. If you hit a wall, it doesn't matter, because it will move back out since it can move there. You write a function that checks the space directly north, south, east and west and move that direction, then call the function recursively so it will continue going each way in the maze until it finds the exit. So your function would consist of 4 if checks, then a command to move your player, then calling the function again, with the terminating condition being that if(myPlayer.position == exit.position)
Or something to that extent.
If you have any other questions, please do not hesistate to ask.
I hope this information was helpful.