There are many ways to solve a maze, here we are going to consider the maze as a 2 dimensional array of values.
in our maze we can consider it as a 10x10 matrix.. (see the no. of dots vertically and horizontally).. let us consider 10 as the height of the maze and the other 10 as the width of the maze. now for each position we will assign a value. By doing that we will come to know the starting point the ending point,the ways that are blocked by walls,and the route taken.
so, it can be explained in simple steps:
step 1: enter the starting position.(in our case it is 0x0)
step 2: enter the end position..(in our case it is 10X10)
step 3: the row will increment , if the current position is not on a wall, the function will check other possible values for further movement,if such a value is not already visited it will follow that path, else if it is visited it will backtrack,visited positions are stored
step 4: if the current position is on the wall,then also it will do backtracking,
step 5: all above steps are repeated till it reaches the end position.
int dog_maze = new dog_maze[w][h];//we enter the maze in matrix
int x1,y1 //starting position
int x2,y2// end position
boolean already_visited=boolean[w][h];// as i said already there will be a visited set
boolean solution=boolean[w][h]// after reaching end position path is saved.
void help_dog()//function for solving the puzzle
dog_maze = createmaze()
for(row 0 to length)
for(column 0 to length)
public boolean tracking(int a, int b)
now this function gets repeated till the end node is visited...
please help with the code that would solve this Choose Ultrakarel as your starting point. World #1 RESET II » RUN Wo...