Post a New Question

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.
Operation1 Operation2 Operation3

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.

2 5 3

3 3 2
1 3 2
1 3 2

3 1 4

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.

Answer This Question

First Name:
School Subject:

Related Questions

More Related Questions

Post a New Question