@@ -15,6 +15,13 @@ class AbstractAdaptor(Player):
15
15
round of play. Using this state the player Cooperates with a probability
16
16
derived from the state.
17
17
18
+ s, float:
19
+ the internal state, initially 0
20
+ perr, float:
21
+ an error threshold for misinterpreted moves
22
+ delta, a dictionary of floats:
23
+ additive update values for s depending on the last round's outcome
24
+
18
25
Names:
19
26
20
27
- Adaptor: [Hauert2002]_
@@ -32,18 +39,18 @@ class AbstractAdaptor(Player):
32
39
"manipulates_state" : False ,
33
40
}
34
41
35
- def __init__ (self , d : Dict [Tuple [Action , Action ], float ],
42
+ def __init__ (self , delta : Dict [Tuple [Action , Action ], float ],
36
43
perr : float = 0.01 ) -> None :
37
44
super ().__init__ ()
38
45
self .perr = perr
39
- self .d = d
46
+ self .delta = delta
40
47
self .s = 0.
41
48
42
49
def strategy (self , opponent : Player ) -> Action :
43
50
if self .history :
44
51
# Update internal state from the last play
45
52
last_round = (self .history [- 1 ], opponent .history [- 1 ])
46
- self .s += self .d [last_round ]
53
+ self .s += self .delta [last_round ]
47
54
48
55
# Compute probability of Cooperation
49
56
p = self .perr + (1.0 - 2 * self .perr ) * (
@@ -66,12 +73,13 @@ class AdaptorBrief(AbstractAdaptor):
66
73
name = "AdaptorBrief"
67
74
68
75
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 )
76
+ delta = {
77
+ (C , C ): 0. , # R
78
+ (C , D ): - 1.001505 , # S
79
+ (D , C ): 0.992107 , # T
80
+ (D , D ): - 0.638734 # P
81
+ }
82
+ super ().__init__ (delta = delta )
75
83
76
84
77
85
class AdaptorLong (AbstractAdaptor ):
@@ -87,9 +95,10 @@ class AdaptorLong(AbstractAdaptor):
87
95
name = "AdaptorLong"
88
96
89
97
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 )
98
+ delta = {
99
+ (C , C ): 0. , # R
100
+ (C , D ): 1.888159 , # S
101
+ (D , C ): 1.858883 , # T
102
+ (D , D ): - 0.995703 # P
103
+ }
104
+ super ().__init__ (delta = delta )
0 commit comments