File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -1486,18 +1486,23 @@ class Leyvraz(Player):
1486
1486
'manipulates_state' : False
1487
1487
}
1488
1488
1489
+ def __init__ (self ) -> None :
1490
+ super ().__init__ ()
1491
+ self .prob_coop = {
1492
+ (C , C , C ): 1.0 ,
1493
+ (C , C , D ): 0.5 ,
1494
+ (C , D , C ): 0.0 ,
1495
+ (C , D , D ): 0.25 ,
1496
+ (D , C , C ): 1.0 ,
1497
+ (D , C , D ): 1.0 ,
1498
+ (D , D , C ): 1.0 ,
1499
+ (D , D , D ): 0.5
1500
+ }
1501
+
1489
1502
def strategy (self , opponent : Player ) -> Action :
1490
1503
recent_history = [C , C , C ] # Default to C.
1491
1504
for go_back in range (1 , 4 ):
1492
1505
if len (opponent .history ) >= go_back :
1493
1506
recent_history [- go_back ] = opponent .history [- go_back ]
1494
1507
1495
- if recent_history [- 1 ] == D and recent_history [- 2 ] == D :
1496
- return random_choice (0.25 )
1497
- if recent_history [- 3 ] == D :
1498
- return C
1499
- if recent_history [- 2 ] == D :
1500
- return D
1501
- if recent_history [- 1 ] == D :
1502
- return random_choice (0.5 )
1503
- return C # recent_history == [C, C, C]
1508
+ return random_choice (self .prob_coop [tuple (recent_history )])
You can’t perform that action at this time.
0 commit comments