Contents
Page-10
Prev
Next
Page+10
Index
Robot Mouse Program
- The maze is a 2-D array. * represents a wall.
0 represents an open space. c represents cheese.
- The mouse starts in an open position.
- The mouse has 4 possible moves at each point: w, n,
e or s.
- We have to keep track of where the mouse has been, or it might
wander infinitely in circles. The list prev is a stack of
previous states. If the mouse re-visits a position on prev,
we want to fail.
- We need to return an answer:
- nil for failure
- a list of moves that will lead from the current position to the
goal; for the goal itself, we return ().
As we unwind the recursion, we will push the operator that led to the
goal onto the answer list at each step.