def test_init_with_opponents(self): player = axl.TitForTat() opponents = [s() for s in axl.demo_strategies] fingerprint = axl.TransitiveFingerprint(strategy=player, opponents=opponents) self.assertEqual(fingerprint.strategy, player) self.assertEqual(fingerprint.opponents, opponents)
def test_init(self): player = axl.TitForTat() fingerprint = axl.TransitiveFingerprint(strategy=player) self.assertEqual(fingerprint.strategy, player) self.assertEqual( fingerprint.opponents, [axl.Random(p) for p in np.linspace(0, 1, 50)] )
def test_init_with_not_default_number(self): player = axl.TitForTat() number_of_opponents = 10 fingerprint = axl.TransitiveFingerprint( strategy=player, number_of_opponents=number_of_opponents) self.assertEqual(fingerprint.strategy, player) self.assertEqual(fingerprint.opponents, [axl.Random(p) for p in np.linspace(0, 1, 10)])
checkpoint = neat.Checkpointer.restore_checkpoint(CHECKPOINT_FILE_PATH) # Create players from the checkpoint neat_players = create_players_from_checkpoint(checkpoint, config) axel_players = [ axl.Cooperator(), ] #OLD players = neat_players + axel_players # tournament = axl.Tournament(players, turns = TOURNAMENT_TURNS) # results = tournament.play() for i, player in enumerate(neat_players): tf = axl.TransitiveFingerprint(player, opponents=axel_players) data = tf.fingerprint(turns=10, repetitions=10) ... # Write data to disk for analysis p = tf.plot(display_names=True) p.savefig(f"plot_{i}.png") # Saves a plot for each player of interest p.show() ############ ANALYSIS PLOTS # # cooperation_df_nc1 = pd.DataFrame(results.cooperation, # index=results.players, # columns=results.players) # plt.subplots(figsize=(20,15)) # sns.heatmap(cooperation_df_nc1, annot=True).set( # xlabel="Cooperations received", # ylabel="Cooperations emitted",