Skip to content

Commit f6479f7

Browse files
committed
Change implementation of RandomTfT
This ensures it has the correct memory.
1 parent c612c1e commit f6479f7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

axelrod/strategies/titfortat.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,7 @@ def __init__(self, p: float=0.5) -> None:
826826
"""
827827
super().__init__()
828828
self.p = p
829+
self.act_random = False
829830
if p in [0, 1]:
830831
self.classifier['stochastic'] = False
831832

@@ -834,6 +835,10 @@ def strategy(self, opponent: Player) -> Action:
834835
"""This is the actual strategy"""
835836
if not self.history:
836837
return C
837-
if len(opponent.history) % 2 == 0:
838+
839+
if self.act_random:
840+
self.act_random = False
838841
return random_choice(self.p)
842+
843+
self.act_random = True
839844
return opponent.history[-1]

0 commit comments

Comments
 (0)