P
R
O
G
R
A
M
M
I
N
G
 
C
O
M
P
E
T
I
T
I
O
N
 

Mars Rover

Task #10
Novice/Advanced
10 Points

Task Description
Your team is assigned to write simple navigation code for a Mars PRM (Planetary Rover Module). The PRM must be able to execute these simple commands: MOVE, RIGHT, LEFT, and STOP. These commands are transmitted to the PRM from the ADV (Atmospheric Descent Vehicle) which carried the PRM to the Martian surface. The PRM must supply feedback status to the ADV after each command (see Table 1).
     The martian surface is represented by a two dimensional grid of ASCII text characters summarized in Table 2.


COMMAND     STATUS
LEFT or RIGHT   COMPLETE
MOVE   SUCCESS or FAILURE
STOP   STOPPED
Table 1. Command Set and
Return Status Codes
          
           CHAR       KEY
 
.
  flat ground
 
*
  obstacle
 
A
  start position
 
o
  ore
 
#
  crystal
Table 2. Grid Chars

      Note: A move command may fail (at least partially) if the PRM detects an obstacle in its path. When such a failure occurs, the PRM must indicate the relative position of the obstacle during the feedback transmission to the ADV.

Program Input
The input file consists of three sections: a header, a map, and a command sequence. The header is a single line of text with two fields: (1) an integer map size Z (where Z < 20) and (2) a starting orientation string. The orientation string may be either NORTH, SOUTH, EAST or WEST, with NORTH being at the top of the screen (or file). This orientation string tells your program which direction the PRM is facing at the start of the exploration.
      The map is a character array of Z lines with Z characters per line separated by spaces. The valid input map characters and their meanings are shown in Table 2 above. The command sequence follows the format in the Task Description. The MOVE command is followed by an integer declaring the number of units which the PRM must move forward.

8 NORTH
. . . . . . . .
. . . . . . . .
. . . . . . * .
. . . . . . . .
. * . . . . # .
. . o . . . . .
. . . . . . . .
. A . . * . . .
MOVE 3
RIGHT
MOVE 2
LEFT
MOVE 4
STOP

Program Output
The output file must consist of two sections: a command feedback log and a result map. The command feedback log must have a line of text for each command from the input file. The first part of the line echoes the command, and the second part reports the ADV feedback string. If ore or crystal is discovered on the path then the program must print a status message indicating the type of discovery and the position (see the example below). You may assume that the move commands will not put the PRM outside the map boundaries.
     The result map must be printed according to these rules: (1) It must show the path taken by the PRM with plus characters. (2) It must show the start position with an A and the final stopped position of the PRM with a capital P. (3) It must show obstacles that interfered with movement with a * character. (4) It must show ore and crystal discoveries with the appropriate # or o character. (5) All other positions must be written with a ? character.
     Your program must write the command feedback log and result map with the same syntax and format as the sample below.

MOVE 3: FAILURE DUE TO OBSTACLE AT POSITION 3.
RIGHT: COMPLETE.
MOVE 2: SUCCESS.
ORE DISCOVERED AT POSITION 1.
LEFT: COMPLETE.
MOVE 4: SUCCESS.
STOP: STOPPED.
? ? ? ? ? ? ? ?
? ? ? P ? ? ? ?
? ? ? . ? ? ? ?
? ? ? . ? ? ? ?
? * ? . ? ? ? ?
? . o . ? ? ? ?
? . ? ? ? ? ? ?
? A ? ? ? ? ? ?