Write a program to represent you in the 7th Annual Prisoners

Write a program to represent you in the 7th Annual Prisoner’s Dilemma Tournament. Each player (each program) will compete in an iterated PD against each other player. Assuming all 115 students submit a program, then our tournament will have a total of 6555 contests. Each contest will consist of 200 games, and each game will use the payoff matrix shown here. Beware of ManBearPig and be aware of the following:

Your program filename must follow the usual format: lastname_firstname_p11.py and your function name must be lastname_firstname_p11

Your program must accept two input variables: history and score.The history argument will be a list of N two-character strings (e.g., [\'dh\', \'hh\', \'hh\', \'hd\', \'dd\']) containing the history of decisions that you (1st character) and your opponent (2nd character) have made up to that point in the N games that have been played. The score argument will be a two-element list (e.g., [20, 18]) containing the current scores in the ongoing contest for you (first element) and your opponent (second element).

Your program must return one and only one output: a single character that is either \'d\' (dove) or \'h\' (hawk), indicating your strategy for the current game.

It’s up to you whether you wish to use the history and/or score information in your strategic decision as to how you will play (i.e., which output to return for the current game).

On the first move of a contest your program will be called with argument history equal to None.

Since there are 200 games in each contest, the history list will contain 199 items when your program is called for the last time in a contest.

Except for the single character returned, your program must have no other output: no plots, no displays, no nuthin’!!

Solution

def lastname_firstname_p11(choices, scores): player_d = 0 player_h = 0 choice = \'d\' # default choice for ch in choices: if ch[0] == \'d\': player_d += 1 else: player_h += 1 if player_d > player_h: if scores[0] > scores[1]: return \'d\' else: return \'h\' else: if scores[0] > scores[1]: return \'h\' else: return \'d\'
Write a program to represent you in the 7th Annual Prisoner’s Dilemma Tournament. Each player (each program) will compete in an iterated PD against each other p

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site