hi all,
i have to write a maze program using stack and tree structure but i don't know how to start coding this?
can anyone tell me how to start?
thank you very much!!
hi all,
i have to write a maze program using stack and tree structure but i don't know how to start coding this?
can anyone tell me how to start?
thank you very much!!
Start with this:
int main()
{
...
return 0;
}
Just joking... Sorry, I don't know anything about stacks
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
What's the stack got to do with it??? If you want to write a program that gets you out of a maze, then you'll need a tree structure. For that I gave an example further down (it was about 1-3 trees). Once you've programmed your Tree/Node classes you use your tree to explore each path in the maze. If you do a width first search you'll find the shortest way out!!! This is done qute easely. You represent the maze by an integer matrix. You say 1 is a wall and 2 is where you've already been. You have four options (ie each node will have maximum 4 direct kids) up,down,left and right. A branch ends when either it its a wall (1) or it hits your path (2). You're out when the current position in a Node is equal to the exit.
All AI books treat this example. Come back if you need more help.