entrance --> |
0 1 0 0 0 0 0 0 1 0 1 0 1 1 0 1 0 0 1 0 1 0 1 1 0 <-- exit |
5
0 1 0 0 0
0 0 0 1 0
1 0 1 1 0
1 0 0 1 0
1 0 1 1 0
If the file is not in the right format, this constructor prints out an error message, and constructs a random maze of default size 11 x 11.
2 1 2 2 2
2 2 2 1 2
1 0 1 1 2
1 0 0 1 2
1 0 1 1 2
n = 7 |
n = 6 |
n = 6 |
0 1 0 1 0 1 0 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 0 1 0 1 0 1 0 |
0 1 0 1 0 1 1 1 1 1 1 1 0 1 0 1 0 1 1 1 1 1 1 1 0 1 0 1 0 1 1 1 1 1 0 0 |
0 1 0 1 0 1 1 1 1 1 1 1 0 1 0 1 0 1 1 1 1 1 1 1 0 1 0 1 0 0 1 1 1 1 1 0 |
// i and j are the row and column number of a cell[Grading] The total points for this project is 100, with 40 extra credit if you choose to use Algorithm B for random maze generation.
private boolean solve( int i, int j )
{
// check error conditions
// if reached exit, marked the cell, return true
// block the current cell so it won't be visited repeatedly
// check the left, right, up and down cells.
if( solve(i+1,j) || solve(i,j+1) || solve(i-1,j) || solve(i,j-1) )
{
// mark current cell as path
return true;
}
// no path found
return false;
}