Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132930 views
License: OTHER
1
class TitForTat():
2
''' TitForTat will replicate its opponent's last move. '''
3
def step(self, history, round):
4
if round == 0:
5
action = 1
6
else:
7
action = history[self.order^1][round - 1]
8
# ^ is the bitwise XOR operator, for easy switching from 0 to 1.
9
return action
10
11
12