Flood Fill Algorithim
The Flood Fill Algorithm is used to discover walls and find the center. Each cell in the maze is given a value which indicates its distance from the center. The robot assumes that there are no walls in the interior of the maze until it discovers them. When the robot enters a new cell, it must record any newly discovered walls, update the distance values, and determine the next cell to move to. Using this method, the robot can determine the shortest path to the center of the maze.
In the first block, there are no walls or north and east. In the seond block, the walls are detected. In the third block, it updates the distance value. In the fourth block, it maps the maze with distance values.