Programing Project One

Write a program to simulate a "last man standing" battle between four robots on a 20x20 grid.

For this program it is not necessary to use records, classes or arrays.

Robots start at a random location on the grid, and have 8 health points.

Robots execute the following program:

    while (another robot is alive) {
       d = distance to closest robot
       if  (d == 1) {
          attack that robot
       } else {
          move closer to the closest robot
       }
    }

Robots either move or attack in name order (A,B,C,D).

To attack, a robot generates a random number between 1 and 10. If the number is greater than 5, the robot damages its opponent for 1 health point.

A robot dies when its health points reach 0.

The game ends when only one robot is left alive.

At the end of a turn, the board should be printed out in the following form.

A small portion of the board

    . . . . . .
    . A . . . .    A = 8
    . . . . D .    B = 3
    . . . . b .    C = 5
    . C . . . .    D = 8

Your game should place the robots on the board, then display one board at a time, pausing for user input, until only one robot remains. Robots with 0 health points should not be displayed.

Your code should be, as discussed in class, structured. It should include small subroutines which perform simple tasks. The code should be well documented with both comments, and self documenting code.

Since you may be asked to change the board size, make sure that this is easy to do.

When your code is complete, email the source code to dbennett@edinboro.edu.