📚 The CoCalc Library - books, templates and other resources
1class 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