Jarvitä
New member
For the uninitiated: http://en.wikipedia.org/wiki/Prisoner's_dillemma#The_iterated_prisoners.27_dilemma
I wrote a python script that pits two IPD strategies against each other. Each is aware of its, and its opponent's current score and action history, and must decide whether to defect or cooperate based on that.
The game framework looks like this:
And the strategy function looks like this:
If people would like to play, announce your participation here and send your strategies via PM (if you don't know Python well enough, you can discuss your strategy in private and receive help in implementing it as a Python function). A tournament date will then be determined, and the results posted. If you wish, your strategy can be revealed afterwards.
The tournament will be structured as follows: Each valid submitted agent will play against all others, and the final ranking will be obtained by summing an agent's score over all matches it took part in.
Confirmed players
Urwumpe - agent submitted
Arrowstar - agent submitted
I wrote a python script that pits two IPD strategies against each other. Each is aware of its, and its opponent's current score and action history, and must decide whether to defect or cooperate based on that.
The game framework looks like this:
Code:
# Scoring:
# Both agents cooperate: 10 points each
# P1 cooperates, P2 defects: 1 point to P1, 15 points to P2
# Above, reversed: Above, reversed
# Both agents defect: 5 points each
#
# Each playing function receives as its arguments the current score and
# Action history of both players.
#
# The number of iterations is random so as to render constant defection
# non-dominant. The final score is normalised by the number of turns.
import player1
import player2
import random
turns = random.randint(5,1000)
p1score, p1hist, p2score, p2hist = 0, [2], 0, [2]
scorehist1 = [0]
scorehist2 = [0]
for i in range(0,turns-1):
p1hist.append(2)
p2hist.append(2)
scorehist1.append(0)
scorehist2.append(0)
def ipd():
global p1score, p1hist, p2score, p2hist
for i in range(0,turns):
p1act = player1.play(i, p1hist, p2hist, p1score, p2score)
p2act = player2.play(i, p2hist, p1hist, p2score, p1score)
if(not(p1act) and not(p2act)):
p1score += 10
p2score += 10
elif(not(p1act) and (p2act)):
p1score += 1
p2score += 15
elif((p1act) and not(p2act)):
p1score += 15
p2score += 1
elif((p1act) and (p2act)):
p1score += 5
p2score += 5
p1hist[i] = p1act
p2hist[i] = p2act
scorehist1[i] = p1score
scorehist2[i] = p2score
ipd()
print "Number of iterations: " + str(turns)
print "Player 1:"
print ""
print "Score: " + str(p1score/float(turns))
print ""
print "Player 2: "
print ""
print "Score: " + str(p2score/float(turns))
And the strategy function looks like this:
Code:
def play(i, myhist, oppshist, myscore, oppsscore):
# Fill out your playing strategy here
return 0
If people would like to play, announce your participation here and send your strategies via PM (if you don't know Python well enough, you can discuss your strategy in private and receive help in implementing it as a Python function). A tournament date will then be determined, and the results posted. If you wish, your strategy can be revealed afterwards.
The tournament will be structured as follows: Each valid submitted agent will play against all others, and the final ranking will be obtained by summing an agent's score over all matches it took part in.
Confirmed players
Urwumpe - agent submitted
Arrowstar - agent submitted
Last edited: