11from axelrod .actions import Action , Actions
22from axelrod .player import Player
3+ from axelrod .random_ import random_choice
34
45from math import pi , sin
5- import random
66
77C , D = Actions .C , Actions .D
88
@@ -12,21 +12,21 @@ class SelfSteem(Player):
1212 This strategy is based on the feeling with the same name.
1313 It is modeled on the sine curve(f = sin( 2* pi * n / 10 )), which varies
1414 with the current iteration.
15-
15+
1616 If f > 0.95, 'ego' of the algorithm is inflated; always defects.
1717 If 0.95 > abs(f) > 0.3, rational behavior; follows TitForTat algortithm.
1818 If 0.3 > f > -0.3; random behavior.
1919 If f < -0.95, algorithm is at rock bottom; always cooperates.
20-
20+
2121 Names:
22-
22+
2323 - SelfSteem: [Andre2013]_
2424 """
2525
2626 name = 'SelfSteem'
2727 classifier = {
28- 'memory_depth' : 1 ,
29- 'stochastic' : False ,
28+ 'memory_depth' : float ( "inf" ) ,
29+ 'stochastic' : True ,
3030 'makes_use_of' : set (),
3131 'long_run_time' : False ,
3232 'inspects_source' : False ,
@@ -36,18 +36,15 @@ class SelfSteem(Player):
3636
3737 def strategy (self , opponent : Player ) -> Action :
3838 turns_number = len (self .history )
39- sine_value = sin ( 2 * pi * turns_number / 10 )
40-
39+ sine_value = sin (2 * pi * turns_number / 10 )
40+
4141 if sine_value > 0.95 :
4242 return D
43-
44- elif abs (sine_value ) < 0.95 and abs (sine_value ) > 0.3 :
43+
44+ if abs (sine_value ) < 0.95 and abs (sine_value ) > 0.3 :
4545 return opponent .history [- 1 ]
46-
47- elif sine_value < 0.3 and sine_value > - 0.3 :
46+
47+ if sine_value < 0.3 and sine_value > - 0.3 :
4848 return random_choice ()
49-
50- else :
51- return C
52-
53-
49+
50+ return C
0 commit comments