Homework 4:

Short Description: Testing a Program

This assignment is worth 15 points.

Goals

When you finish this homework, you should

Formal Description

I have implemented a simple simulation of the Peace War Game. I would like to collect statistics on the results of this implementation.

This game is played between two players. It attempts to provide a simple simulation of deciding strategies for cooperation and aggression. The result of the game is an amount of money for each player. For example, after a game player 1 might have 16 cash units and player 2 might have 13. For full details see the wikipedia link.

Initially I would like you to create software that can compute the average outcome for this game for different player strategies. For each different strategy, your program should run n competitions with every player strategy (including themselves). This will result in n values for player 1 and n values for player 2 for each combination. Dividing the sum of the results by n will provide the average outcome for each strategy pair.

There are currently four five strategies configured for this game, so your program should produce two five by five tables. The rows are the index for player 1 and the columns are the index for player 2. The entry in each row should be the average outcome, rounded to two decimal places, for that strategy match up. The first table should represent the results for the first player while the second should represent the results for the second player.

The following is an example of the expected output:



Results for Player 1:
P1/P2   0      1      2      3      4
  0   xx.xx  xx.xx  xx.xx  xx.xx  xx.xx  
  1   xx.xx  xx.xx  xx.xx  xx.xx  xx.xx  
  2   xx.xx  xx.xx  xx.xx  xx.xx  xx.xx  
  3   xx.xx  xx.xx  xx.xx  xx.xx  xx.xx  
  4   xx.xx  xx.xx  xx.xx  xx.xx  xx.xx  

Results for Player 2:
P1/P2   0      1      2      3      4
  0   xx.xx  xx.xx  xx.xx  xx.xx  xx.xx  
  1   xx.xx  xx.xx  xx.xx  xx.xx  xx.xx  
  2   xx.xx  xx.xx  xx.xx  xx.xx  xx.xx  
  3   xx.xx  xx.xx  xx.xx  xx.xx  xx.xx  
  4   xx.xx  xx.xx  xx.xx  xx.xx  xx.xx  
Please note, I will be checking this by hand, so you may have minor variation in output.

You may modify the simulation only in the following manner

For this program I would consider modifying the simulation to write to a file, then reading the results of this file to compute averages in the main program. If you adopt this strategy, you should use the unlink system command to remove the file after you have finished with it.

Your program should employ the following command line arguments

Simulation Files

Submission

Please email a tar file containing source code for both the simulation and your test driver, along with a Makefile to the dbennett@edinboro.edu by the due date.