Skip to content

Commit 64a1d0b

Browse files
committed
Update variable names for Adaptor
1 parent 54da931 commit 64a1d0b

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

axelrod/strategies/adaptor.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ class AbstractAdaptor(Player):
1515
round of play. Using this state the player Cooperates with a probability
1616
derived from the state.
1717
18+
The strategy relies on one internal state and two parameters:
19+
s, float: the internal state, initially 0
20+
perr, float: an error threshold for misinterpreted moves
21+
delta, a dictionary of floats: additive update values for s depending
22+
on the last round's outcome
23+
1824
Names:
1925
2026
- Adaptor: [Hauert2002]_
@@ -32,18 +38,18 @@ class AbstractAdaptor(Player):
3238
"manipulates_state": False,
3339
}
3440

35-
def __init__(self, d: Dict[Tuple[Action, Action], float],
41+
def __init__(self, delta: Dict[Tuple[Action, Action], float],
3642
perr: float = 0.01) -> None:
3743
super().__init__()
3844
self.perr = perr
39-
self.d = d
45+
self.delta = delta
4046
self.s = 0.
4147

4248
def strategy(self, opponent: Player) -> Action:
4349
if self.history:
4450
# Update internal state from the last play
4551
last_round = (self.history[-1], opponent.history[-1])
46-
self.s += self.d[last_round]
52+
self.s += self.delta[last_round]
4753

4854
# Compute probability of Cooperation
4955
p = self.perr + (1.0 - 2 * self.perr) * (
@@ -66,12 +72,13 @@ class AdaptorBrief(AbstractAdaptor):
6672
name = "AdaptorBrief"
6773

6874
def __init__(self) -> None:
69-
d = {(C, C): 0., # R
70-
(C, D): -1.001505, # S
71-
(D, C): 0.992107, # T
72-
(D, D): -0.638734 # P
73-
}
74-
super().__init__(d=d)
75+
delta = {
76+
(C, C): 0., # R
77+
(C, D): -1.001505, # S
78+
(D, C): 0.992107, # T
79+
(D, D): -0.638734 # P
80+
}
81+
super().__init__(delta=delta)
7582

7683

7784
class AdaptorLong(AbstractAdaptor):
@@ -87,9 +94,10 @@ class AdaptorLong(AbstractAdaptor):
8794
name = "AdaptorLong"
8895

8996
def __init__(self) -> None:
90-
d = {(C, C): 0., # R
91-
(C, D): 1.888159, # S
92-
(D, C): 1.858883, # T
93-
(D, D): -0.995703 # P
94-
}
95-
super().__init__(d=d)
97+
delta = {
98+
(C, C): 0., # R
99+
(C, D): 1.888159, # S
100+
(D, C): 1.858883, # T
101+
(D, D): -0.995703 # P
102+
}
103+
super().__init__(delta=delta)

0 commit comments

Comments
 (0)