CSC 2210, SPA 4: Raiderbot

Description

A small robot explores a two-dimensional word with pits, gold, and other objects. The robot cannot escape the world or climb pits. Being a good raider, it does pick up any gold it encounters. You are to write a simulator for the raider. This assignment will give you experience with two-dimensional arrays, classes, and pointers.

The raider's world is a grid 20 columns wide, 10 rows high. The following shows a sample world followed by initial coordinates for the robot and a series of instructions.

        +--------------------+
        |     #              |
        |  **          -     |
        | #         #        |
        |                    |
        | O                  |
        |    *#      +   #   |
        |                    |
        |  ####              |
        |              ##    |
        |                    |
        +--------------------+
        1 1
        ees
The dashes and vertical bars mark the edges of the world. Pound signs (occasionally known as hashtags) mark pits, asterisks mark gold, and other characters mark objects that have no consequence to the raider. (The raider will pass over them without picking them up. Note this means that you show the raider's R on the cell while the raider is in it.) If the raider attempts to pass through a wall, by robot magic the raider is transported to the same location on the other side of the world. So if the raider is in the lower right corner and goes south, it will move to the upper right corner. The two numbers give the starting location as (x, y) values, where 0 0 is the upper left corner of the world and 19 9 is the lower right corner. Note there are 10 rows and 20 columns within the walls of the world.

The remaining text (which may be on more than one line) captures the list of commands:

Commands are written as "words" - a sequence of characters surrounded by whitespace. The robot and world state is printed before and after each sequence. Running the above example results in
        Initial state: Robot at 1, 1 (0 gold)
        +--------------------+
        |     #              |
        | R**          -     |
        | #         #        |
        |                    |
        | O                  |
        |    *#      +   #   |
        |                    |
        |  ####              |
        |              ##    |
        |                    |
        +--------------------+
        ========================================
        Executing ees
        Robot at 3, 2 (2 gold)
        +--------------------+
        |     #              |
        |              -     |
        | # R       #        |
        |                    |
        | O                  |
        |    *#      +   #   |
        |                    |
        |  ####              |
        |              ##    |
        |                    |
        +--------------------+
        ========================================
        Robot has completed its task.
Note the robot picked the gold in row 1. Print an error message (and stop executing instructions) when the robot runs into a pit. The above world followed by the input
        4 5
        seesw
would mean it would print
        Executing seesw

        Error: robot with current status of Robot at 6, 7 (1 gold) broke while executing seesw
        +--------------------+
        |     #              |
        |  **          -     |
        | #         #        |
        |                    |
        | O                  |
        |     #      +   #   |
        |                    |
        |  ####R             |
        |              ##    |
        |                    |
        +--------------------+
between the two lines of equal signs. (If you want to see more detail, this is test 2 in the tests given at the bottom of this writeup.) In this case, note the robot is shown at its last legal position.

Details and Getting Started

Constraints

Hints

Submitting

Test Data