computer programming

posted by .

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..

  • computer programming -

    Post your code and we can help.
    State the language and the make and version of the compiler, if you use any.

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. science

    1. Do you know what is the origin of the word "HiRobo"?
  2. science

    How do you use motors and gears in a robot so the robot can walk in a circular motion?
  3. physics

    The mass of a robot is 5470 kg. This robot weighs 3740 N more on planet A than it does on planet B. Both planets have the same radius of 1.33 107 m. What is the difference MA - MB in the masses of these planets?
  4. English

    1. Who is Aibo? 2. He is a robot dog. 3. It is a robot dog. 4. What is Aibo?
  5. Physics

    The mass of a robot is 5489.0kg. This robot weighs 3646.0N more on planet A than it does on planet B. Both planets have the same radius of 1.33 x 107 m. What is the difference MA - MB in the masses of these planets?
  6. English

    Around the corner came a huge robot. Is the subject robot Is the verb came?
  7. physics

    The mass of a robot is 6930 kg. This robot weighs 2520 N more on planet A than it does on planet B. Both planets have the same radius of 3.01 × 106 m. What is the difference MA - MB in the masses of these planets?
  8. Algebra

    The function f(x,y) accepts an ordered pair as input and gives another ordered pair as output. It is defined according to the following rules: If x>4, f(x,y)=(x-4,y). If x<=4 but y>4, f(x,y)=(x,y-4). Otherwise, f(x,y)=(x+5,y+6). …
  9. Algebra

    The function f(x,y) accepts an ordered pair as input and gives another ordered pair as output. It is defined according to the following rules: If x>4, f(x,y)=(x-4,y). If x<=4 but y>4, f(x,y)=(x,y-4). Otherwise, f(x,y)=(x+5,y+6). …
  10. Math

    Aaron designed a robot for a contest. His robot can move 3/4 meter in 1/2 second. What is the robot's unit rate of speed?

More Similar Questions