Search
Detailed specification for tournament players follow.
All the code needed for the player to function has to be in file name player.py. This file (and only this file) has to be uploaded through the upload system.
First we have to realize that the players do not communicate directly, but through intermediary, which will call the players and archive their results. Players are to be implemented in the MyPlayer class which has to have these methods:
Player class, has to have a description in form of doc-string. Maximal length is 80 character. It should explain how the player plays. i.e.
class MyPlayer: '''The player plays what she wants to, mostly C''' def __init__ # ... and so on, a standard code continues
Two dimensional field of tuples. First row and column, index 0, correspond to COOPERATE, second row and second column to DEFECT.
Thus, the profit for player A, if he plays COOPERATE and player B plays DEFECT, is
payoff_matrix[0][1][0]
payoff_matrix[COOPERATE][DEFECT][0]
It is supposed to just play.
At the end, all the players will play in a round robin tournament. The objective is to maximize your total profit. There are going to be two tournaments, basic one, for which the payoff matrix will be known, so you can specially set up your player. In the advanced tournament, the payoff matrix will be given to the player at the start of the game, thus it has to decide its strategy according to the payoff matrix. Player can change its strategy, if it chooses to.
Matrix for the first tournament
or in Python:
payoff_matrix = [ [(4,4),(1,6)] , [(6,1),(2,2)] ]
If you already have implemented player, you can download and look through tournament code. This ZIP archive contains two files game.py, which implements the game and test_game.py, which can take two players and let them play against each other. Read both codes and try to run them with your player. (test_game.py places two copies of your player against each other.) You can of course experiment and change both files.