[try Beta version]
Not logged in

 
recursion maze backtracking program?

Sep 2, 2012 at 7:06pm
Need help getting started.

I need to use backtracking to find and print the path through the maze and find the gold nugget (*).

The maze is represented by a two-d array (11by11). The border is surrounded by X's and the path is represented by 'O'. We start at [1,1]

I really need help on the recursion function.
Last edited on Sep 2, 2012 at 7:44pm
Sep 2, 2012 at 7:08pm
I think this should go to the beginners section.
And read this : http://www.cplusplus.com/forum/beginner/1/
Sep 3, 2012 at 1:04am
Read the following post regarding using recursion to solve mazes:
http://www.cplusplus.com/forum/general/76307/
Sep 4, 2012 at 3:51am
This is what I have so far. I tried the recursive function in words:
1
2
3
4
5
6
7
8
9
10
11
12
//code in words

//bool Solve (board){
//if(no more choices)  //basecase
//return (board is good)
//For (all avalible choices)
//try choice a;
//if (solve(a)) return true;
//else
//undo choice a;
//return false;
//} 


I just don't know how I would do this in code or if it will even work. I am still writing the main function to open the txt file containing the maze.

also here is a pic of the assignment: http://i49.tinypic.com/357ndyb.jpg
Last edited on Sep 4, 2012 at 3:52am
Topic archived. No new replies allowed.