In Class: Tuesday January 17
If you want to try out the robot code, you can copy my codefile
as a starting point, and then edit it to try out different commands, and
run the robot using different mazes as starting points:
# copy over my codefile starting point, don't forget the dot at the end of this command
% cp ~newhall/public/cs21/robot/codefile .
# edit codefile in emacs (or vim) to change the robot commands,
then save and exit emacs
% emacs codefile
# run the robot using the commands you listed in codefile
% run_robot codefile 0 maze0
You can also try different mazes as staring points (maze0 - maze5), and
try staring the robot facing a different direction (0, 1, 2, or 3):
% run_robot codefile 3 maze3 # start robot in maze3 facing WEST(3)
The set of robot commands you can add to a codefile include:
MoveForward(); # move the robot
TurnRight();
TurnLeft();
FacingWall() # tests evaluate to true or false
Outside()
Example codefile might look like:
if ( FacingWall() ) {
TurnLeft();
}
MoveForward();
while ( FacingWall() ) {
TurnLeft();
}
MoveForward();
TurnRight();