Question: Write the algorithm to program the Mechanical Man to carry out the following objectives: 1) Begin sitting in a chair at an unknown integer number
Write the algorithm to program the Mechanical Man to carry out the following objectives:
1) Begin sitting in a chair at an unknown integer number of steps from the wall with his arms lowered.
2) He will stand up and walk forward until he touches the wall with his fingertips.
3) After touching the wall, he will return to his chair.
4) Because the chair is too low for him to sense, he can get to it only by going back exactly the number of steps as he came forward.
The Mechanical man possesses the following properties:
* He is restricted to carrying out a limited set of instructions.
* He does nothing unless given a specific instruction.
* He must carry out any instructions he is given one at a time.
* He understands only the following instructions:
Physical Movement:
- Stand up
- Sit down
- Take one step
- Raise arms
- Lower arms
- Turn right 90 degrees
Arithmetic:
- Add one
- Subtract one
- Record total
Logic: The mechanical man can decide what instruction he will carry out next on the basis of answers to the following questions:
Arithmetic Results:
- Is the result positive? or negative? or zero?
- Is the result equal to a predetermined amount?
Physical status:
- Are the raised arms touching anything?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
