@@ -15,6 +15,13 @@ class AbstractAdaptor(Player):
1515 round of play. Using this state the player Cooperates with a probability
1616 derived from the state.
1717
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+
1825 Names:
1926
2027 - Adaptor: [Hauert2002]_
@@ -32,18 +39,18 @@ class AbstractAdaptor(Player):
3239 "manipulates_state" : False ,
3340 }
3441
35- def __init__ (self , d : Dict [Tuple [Action , Action ], float ],
42+ def __init__ (self , delta : Dict [Tuple [Action , Action ], float ],
3643 perr : float = 0.01 ) -> None :
3744 super ().__init__ ()
3845 self .perr = perr
39- self .d = d
46+ self .delta = delta
4047 self .s = 0.
4148
4249 def strategy (self , opponent : Player ) -> Action :
4350 if self .history :
4451 # Update internal state from the last play
4552 last_round = (self .history [- 1 ], opponent .history [- 1 ])
46- self .s += self .d [last_round ]
53+ self .s += self .delta [last_round ]
4754
4855 # Compute probability of Cooperation
4956 p = self .perr + (1.0 - 2 * self .perr ) * (
@@ -66,12 +73,13 @@ class AdaptorBrief(AbstractAdaptor):
6673 name = "AdaptorBrief"
6774
6875 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 )
7583
7684
7785class AdaptorLong (AbstractAdaptor ):
@@ -87,9 +95,10 @@ class AdaptorLong(AbstractAdaptor):
8795 name = "AdaptorLong"
8896
8997 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