The Robot and the Wall Introduction to Pseudocode Your Name Goes Here

advertisement
The Robot and the Wall
Introduction to Pseudocode
Your Name Goes Here
The Problem
A robot is sitting on a chair, facing a wall a
short distance away. The robot can sense
the wall with its fingertips but cannot see
the wall or the chair. Your assignment is to
instruct the robot to walk to the wall and
return to its initial position. You are to
express the required logic in pseudocode.
Robot Commands
STAND
SIT
TURN (90 degrees)
STEP
ARMS UP
ARMS DOWN
ADD (Increment a counter)
SUBTRACT (Decrement a counter)
INITIALIZE (Zero a counter)
The First Attempt
Arms Up
Zero Counter
DO WHILE fingers do not sense wall
Step
Add
ENDDO
Arms Down
DO WHILE counter not equal to zero
Step
Subtract
ENDDO
Sit
The Solution
Download