Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132930 views
License: OTHER
1
class TitForTwoTats():
2
''' TitForTat will replicate its opponent's last move. '''
3
def step(self, history, round):
4
if round == 0:
5
action = 1
6
elif round == 1:
7
action = 1
8
else:
9
#If last two rounds weren't both defections, doesn't defect.
10
action = int(history[self.order^1][round - 1] or history[self.order^1][round - 2])
11
return action
12
13