<s> """<STR_LIT>""" <EOL> import random <EOL> from axelrod import Actions , Player , flip_action , random_choice <EOL> C , D = Actions . C , Actions . D <EOL> class Champion ( Player ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> classifier = { <EOL> '<STR_LIT>' : float ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : set ( [ "<STR_LIT>" ] ) , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False <EOL> } <EOL> def strategy ( self , opponent ) : <EOL> current_round = len ( self . history ) <EOL> expected_length = self . match_attributes [ '<STR_LIT>' ] <EOL> if current_round == <NUM_LIT:0> : <EOL> return C <EOL> if current_round < expected_length / <NUM_LIT> : <EOL> return C <EOL> if current_round < expected_length * <NUM_LIT:5> / <NUM_LIT> : <EOL> return opponent . history [ - <NUM_LIT:1> ] <EOL> defection_prop = float ( opponent . defections ) / len ( opponent . history ) <EOL> if opponent . history [ - <NUM_LIT:1> ] == D : <EOL> r = random . random ( ) <EOL> if defection_prop > max ( <NUM_LIT> , r ) : <EOL> return D <EOL> return C <EOL> class Eatherley ( Player ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> classifier = { <EOL> '<STR_LIT>' : float ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : True , <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 len ( opponent . history ) : <EOL> return C <EOL> if opponent . history [ - <NUM_LIT:1> ] == C : <EOL> return C <EOL> defection_prop = float ( opponent . defections ) / len ( opponent . history ) <EOL> return random_choice ( <NUM_LIT:1> - defection_prop ) <EOL> class Tester ( 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 __init__ ( self ) : <EOL> Player . __init__ ( self ) <EOL> self . is_TFT = False <EOL> def strategy ( self , opponent ) : <EOL> if not opponent . history : <EOL> return D <EOL> if self . is_TFT : <EOL> return D if opponent . history [ - <NUM_LIT:1> : ] == [ D ] else C <EOL> else : <EOL> if opponent . history [ - <NUM_LIT:1> ] == D : <EOL> self . is_TFT = True <EOL> return C <EOL> if len ( self . history ) in [ <NUM_LIT:1> , <NUM_LIT:2> ] : <EOL> return C <EOL> return flip_action ( self . history [ - <NUM_LIT:1> ] ) <EOL> def reset ( self ) : <EOL> Player . reset ( self ) <EOL> self . is_TFT = False </s>
