Saturday
April 19, 2014

Homework Help: computer programming

Posted by Logan on Tuesday, September 28, 2010 at 12:03am.

Robot Game
Consider a robot moving in an environment consisting of 5x5 cells. The robot can either be rotated or moved forward for a certain distance. The environment in which the robot moves is bounded by walls - so if you try to move the robot out of the area it will stop at the grid besides the wall.
Let the lower left grid be 1/1 and the upper right grid be 5/5. The coordinates are given in X/Y form, the X direction is upwards and Y from left to right.
The robot starts in the middle of the field (3/3) with its orientation in positive X direction.
Possible actions for the robot are defined by the numbers 1-5:
1 --> turn clockwise 90 degrees
2 --> turn clockwise 180 degrees
3 --> move 3 grids forward
4 --> move 4 grids forward
5 --> move 5 grids forward

If an illegal command is given (a number different than [1-5]) the command should be ignored.

Write a program that will read 3 commands and print the robots position and orientation after moving according to each command.
Input:
Operation1 Operation2 Operation3

Output:
Position_X_first_round Position_Y_first_round Orientation_first_round
Position_X_second_round Position_Y_second_round Orientation_second_round
Position_X_third_round Position_Y_third_round Orientation_third_round

For the output let the orientation be defined as 0 for being oriented in positive X direction, 1 for positive Y direction, 2 negative X direction and 3 negative Y direction.

Example1
Input:
2 5 3

Output:
3 3 2
1 3 2
1 3 2

Example2
Input:
3 1 4

Output:
5 3 0
5 3 1
5 5 1

Everyone can help me withis coding...I tried but i won't come out whith the good code...Please help me with this..

Answer this Question

First Name:
School Subject:
Answer:

Related Questions

English - 1. Who is Aibo? 2. He is a robot dog. 3. It is a robot dog. 4. What is...
science - How do you use motors and gears in a robot so the robot can walk in a ...
English - Around the corner came a huge robot. Is the subject robot Is the verb ...
science - 1. Do you know what is the origin of the word "HiRobo"? It is a robot...
physics - The mass of a robot is 5470 kg. This robot weighs 3740 N more on ...
Physics - The mass of a robot is 5489.0kg. This robot weighs 3646.0N more on ...
language please check my work - In 2000 an experimental robot performed ...
English - Can you please check these sentences for me? Thank you very much. 1) ...
Physics - How far will a humanoid robot travel in 3.0 s, accelerating at 1.0cm/s...
math - Robots are being used with increasing frequency on production lines to ...

Search
Members