<s> from axelrod import Actions , Player , init_args , flip_action <EOL> C , D = Actions . C , Actions . D <EOL> class TitForTat ( Player ) : <EOL> """<STR_LIT>""" <EOL> name = '<STR_LIT>' <EOL> classifier = { <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : set ( ) , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False <EOL> } <EOL> def strategy ( self , opponent ) : <EOL> """<STR_LIT>""" <EOL> if len ( self . history ) == <NUM_LIT:0> : <EOL> return C <EOL> if opponent . history [ - <NUM_LIT:1> ] == D : <EOL> return D <EOL> return C <EOL> class TitFor2Tats ( Player ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> classifier = { <EOL> '<STR_LIT>' : <NUM_LIT:2> , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : set ( ) , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False <EOL> } <EOL> @ staticmethod <EOL> def strategy ( opponent ) : <EOL> return D if opponent . history [ - <NUM_LIT:2> : ] == [ D , D ] else C <EOL> class TwoTitsForTat ( Player ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> classifier = { <EOL> '<STR_LIT>' : <NUM_LIT:2> , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : set ( ) , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False <EOL> } <EOL> @ staticmethod <EOL> def strategy ( opponent ) : <EOL> return D if D in opponent . history [ - <NUM_LIT:2> : ] else C <EOL> class Bully ( Player ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> classifier = { <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : set ( ) , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False <EOL> } <EOL> @ staticmethod <EOL> def strategy ( opponent ) : <EOL> return C if opponent . history [ - <NUM_LIT:1> : ] == [ D ] else D <EOL> class SneakyTitForTat ( Player ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> classifier = { <EOL> '<STR_LIT>' : float ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : set ( ) , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False <EOL> } <EOL> def strategy ( self , opponent ) : <EOL> if len ( self . history ) < <NUM_LIT:2> : <EOL> return "<STR_LIT:C>" <EOL> if D not in opponent . history : <EOL> return D <EOL> if opponent . history [ - <NUM_LIT:1> ] == D and self . history [ - <NUM_LIT:2> ] == D : <EOL> return "<STR_LIT:C>" <EOL> return opponent . history [ - <NUM_LIT:1> ] <EOL> class SuspiciousTitForTat ( Player ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> classifier = { <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : set ( ) , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False <EOL> } <EOL> @ staticmethod <EOL> def strategy ( opponent ) : <EOL> return C if opponent . history [ - <NUM_LIT:1> : ] == [ C ] else D <EOL> class AntiTitForTat ( Player ) : <EOL> """<STR_LIT>""" <EOL> name = '<STR_LIT>' <EOL> classifier = { <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : set ( ) , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False <EOL> } <EOL> @ staticmethod <EOL> def strategy ( opponent ) : <EOL> return D if opponent . history [ - <NUM_LIT:1> : ] == [ C ] else C <EOL> class HardTitForTat ( Player ) : <EOL> """<STR_LIT>""" <EOL> name = '<STR_LIT>' <EOL> classifier = { <EOL> '<STR_LIT>' : <NUM_LIT:3> , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : set ( ) , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False <EOL> } <EOL> @ staticmethod <EOL> def strategy ( opponent ) : <EOL> if not opponent . history : <EOL> return C <EOL> if D in opponent . history [ - <NUM_LIT:3> : ] : <EOL> return D <EOL> return C <EOL> class HardTitFor2Tats ( Player ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> classifier = { <EOL> '<STR_LIT>' : <NUM_LIT:3> , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : set ( ) , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False <EOL> } <EOL> @ staticmethod <EOL> def strategy ( opponent ) : <EOL> if not opponent . history : <EOL> return C <EOL> history_string = "<STR_LIT>" . join ( opponent . history [ - <NUM_LIT:3> : ] ) <EOL> if '<STR_LIT>' in history_string : <EOL> return D <EOL> return C <EOL> class OmegaTFT ( Player ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> classifier = { <EOL> '<STR_LIT>' : float ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : set ( ) , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False <EOL> } <EOL> @ init_args <EOL> def __init__ ( self , deadlock_threshold = <NUM_LIT:3> , randomness_threshold = <NUM_LIT:8> ) : <EOL> Player . __init__ ( self ) <EOL> self . deadlock_threshold = deadlock_threshold <EOL> self . randomness_threshold = randomness_threshold <EOL> self . randomness_counter = <NUM_LIT:0> <EOL> self . deadlock_counter = <NUM_LIT:0> <EOL> def strategy ( self , opponent ) : <EOL> if len ( self . history ) == <NUM_LIT:0> : <EOL> return C <EOL> if len ( self . history ) == <NUM_LIT:1> : <EOL> return D if opponent . history [ - <NUM_LIT:1> : ] == [ D ] else C <EOL> if ( self . deadlock_counter >= self . deadlock_threshold ) : <EOL> self . move = C <EOL> if self . deadlock_counter == self . deadlock_threshold : <EOL> self . deadlock_counter = self . deadlock_threshold + <NUM_LIT:1> <EOL> else : <EOL> self . deadlock_counter = <NUM_LIT:0> <EOL> else : <EOL> if opponent . history [ - <NUM_LIT:2> : ] == [ C , C ] : <EOL> self . randomness_counter -= <NUM_LIT:1> <EOL> if opponent . history [ - <NUM_LIT:2> ] != opponent . history [ - <NUM_LIT:1> ] : <EOL> self . randomness_counter += <NUM_LIT:1> <EOL> if self . history [ - <NUM_LIT:1> ] == opponent . history [ - <NUM_LIT:1> ] : <EOL> self . randomness_counter += <NUM_LIT:1> <EOL> if self . randomness_counter >= <NUM_LIT:8> : <EOL> self . move = D <EOL> else : <EOL> self . move = D if opponent . history [ - <NUM_LIT:1> : ] == [ D ] else C <EOL> if opponent . history [ - <NUM_LIT:2> ] != opponent . history [ - <NUM_LIT:1> ] : <EOL> self . deadlock_counter += <NUM_LIT:1> <EOL> else : <EOL> self . deadlock_counter = <NUM_LIT:0> <EOL> return self . move <EOL> def reset ( self ) : <EOL> Player . reset ( self ) <EOL> self . randomness_counter = <NUM_LIT:0> <EOL> self . deadlock_counter = <NUM_LIT:0> </s>
