Implement a maze navigation algorithm that effectively explores mazes of arbitrary size and configuration, while also updating the GUI.
void dfs(){
if (forward_unexplored){
move_forward();
push_coordinate_stack();
}
else if (right_unexplored){
turn_right();
move_forward();
push_coordinate_stack();
}
else if (left_unexplored){
turn_left();
move_forward();
push_coordinate_stack();
}
else if (only_see_walls){
turn_around();
move_forward();
retrace_steps();
}
else{
move_visited_grid();
pop_coordinates_stack();
retrace_steps();
}
}
void retrace_steps(){
pos = pop_coordinate_stack();
move_to_coordinate(pos);
if (see_unexplored)
dfs();
else
retrace_steps();
}
This video demonstrates our robot completing all required behaviors:
This video shows our robot exploring a 4x6 maze in a different configuration, still using DFS: