def __init__(self, num_samples=5, epb_values=[7], num_rtt_values=[21], output_path='simulation'): ''' Constructor ''' # Set arguments self.epb_values = epb_values self.num_rtt_values = num_rtt_values self.output_path = output_path # Ensure the directory exists try: os.makedirs(self.output_path) except OSError: pass # Iterate over epb and num_rtt values for epb_value in self.epb_values: for num_rtt_value in self.num_rtt_values: for n in xrange(num_samples): # Output path results_path = "results/sample_{0}_epb_{1}_num_rtt_{2}"\ .format(n, epb_value, num_rtt_value) print(results_path) # Create a tournament tournament = Tournament(engagements_per_bout=epb_value, numRRTs=num_rtt_value, play_self=True, results_path=results_path) tournament.run_tournament()
class TournamentTest(unittest.TestCase): ''' Test out a tournament. ''' def setUp(self): # Setup the tournament self.tournament = Tournament('./entrants/') def tearDown(self): pass def testPairCoverage(self): ''' Test that our pair selection is working properly. ''' # Initialize coverage sampling players_seen = set() # Pass self.tournament.run_tournament() # Iterate over engagement history for match in self.tournament.get_engagement_history(): players_seen.add(match['player_a']) players_seen.add(match['player_b']) # Make sure we got the full count. self.assertEqual(len(self.tournament.player_pool), len(players_seen)) def testTournament(self): ''' Test that our engagement logic is working properly. ''' # Pass self.tournament.run_tournament() # All test players should have score equal to num_engagements. ''' We can't trust any numbers now. TODO: Design and implement new tests. ''' '''
def setUp(self): # Setup the tournament self.tournament = Tournament('./entrants/')