def test_player_grouping(get_all_players): print( '\n---------------------------\nTest Schedule Player Grouping\n---------------------------' ) number_to_try = 41 players = get_all_players[0:number_to_try] # Getting the right params boards, lopsided, bye = utilities.get_number_of_boards_and_tweaks( number_to_try) test_schedule = schedule.Schedule(players, chessnouns.DEFAULT_NUMBER_OF_ROUNDS, lopsided, bye) test_schedule.sort_players() # These are internal methods beginners = test_schedule._get_beginner_players() intermediates = test_schedule._get_intermediate_players() advanceds = test_schedule._get_advanced_players() assert len(advanceds) == 16 assert len(intermediates) == 13 assert len(beginners) == 12
def test_slots(get_all_players): print( '\n---------------------------\nTesting Leaderboard Slots\n---------------------------' ) did_break = False number_to_try = 41 players = get_all_players[0:number_to_try] # Getting the right params boards, lopsided, bye = utilities.get_number_of_boards_and_tweaks( number_to_try) test_schedule = schedule.Schedule(players, chessnouns.DEFAULT_NUMBER_OF_ROUNDS, lopsided, bye) assert test_schedule is not None test_schedule.sort_players() test_schedule.initialize_draws_for_players() # We need to split players into two groups # to allow alternate playing rounds a, b = test_schedule.divide_players() test_schedule.schedule_players() test_schedule.assign_scheduled_games_to_draws() test_schedule._print_player_draws() # OK, let's now add this to the tournament may_tournament = tournament.Tournament(test_schedule, "Test May") may_tournament.create_random_results_all() board_slots = may_tournament.get_leaderboard() print("LEADERBOARD SLOTS") for ind_slot in board_slots: print(ind_slot) print("TOP TEN ONLY") top_ten_slots = may_tournament.get_leaderboard(10) assert 10 == len(top_ten_slots) for top_ten in top_ten_slots: print(top_ten)
def test_initialize_schedule(get_all_players): players = get_all_players[0:39] number_of_players = len(players) assert number_of_players == 39 (number_of_boards, lopsided, bye) = utilities.get_number_of_boards_and_tweaks(number_of_players) assert number_of_boards == 10 assert lopsided is True assert bye is True
def test_create_schedule(get_all_players): print( '\n---------------------------\nBig Test for Creating Schedule\n---------------------------' ) number_to_try = 33 players = get_all_players[0:number_to_try] # Getting the right params boards, lopsided, bye = utilities.get_number_of_boards_and_tweaks( number_to_try) logger.debug("Results were: {}, lopsided? {}, bye? {}".format( boards, lopsided, bye)) test_schedule = schedule.Schedule(players, chessnouns.DEFAULT_NUMBER_OF_ROUNDS, lopsided, bye) assert test_schedule is not None test_schedule.sort_players() test_schedule.initialize_draws_for_players() test_schedule.shuffle_players() # We need to split players into two groups # to allow alternate playing rounds a, b = test_schedule.divide_players() logger.debug("\nFirst Group has: {} players ".format(len(a))) logger.debug("\nSecond Group has: {} players ".format(len(b))) test_schedule.schedule_players() test_schedule.initialize_draws_for_players() test_schedule.assign_scheduled_games_to_draws() test_schedule._print_player_draws()
def test_get_number_of_boards_and_tweaks(): """ This method tests the strange function that, when you give it a number of players, it will tell you how many boards you need set up, whether or not there will be byes for players, and if the number of games in each round will be lopsided. # The tuple returned is: # Number of required boards, is it lopsided, and is there a bye """ # These variables will make the desired test results more obvious lopsided = True bye = True # 14 players # Round 1A: 6 players, 3 boards # Round 1B: 8 players, 4 boards assert (4, lopsided, not bye) == utilities.get_number_of_boards_and_tweaks(14) # 15 players # Round 1A: 6 players, 3 boards, one bye # Round 1B: 8 players, 4 boards assert (4, lopsided, bye) == utilities.get_number_of_boards_and_tweaks(15) # 16 players # # Round 1A: 8 players, 4 boards # Round 1B: 8 players, 4 boards assert (4, not lopsided, not bye) == utilities.get_number_of_boards_and_tweaks(16) # 17 players # Round 1A: 8 players, 4 boards # Round 1B: 8 players, 4 boards, one bye assert (4, not lopsided, bye) == utilities.get_number_of_boards_and_tweaks(17) # 18 players # Round 1A: 8 players, 4 boards # Round 1B: 10 players, 5 boards assert (5, lopsided, not bye) == utilities.get_number_of_boards_and_tweaks(18) # 27 players # Round 1A: 12 players, 6 boards, one bye # Round 1B: 14 players, 7 boards assert (7, lopsided, bye) == utilities.get_number_of_boards_and_tweaks(27) # 31 players # Round 1A: 14 players, 7 boards, one bye # Round 1B: 16 players, 8 boards assert (8, lopsided, bye) == utilities.get_number_of_boards_and_tweaks(31) # 36 players # Round 1A: 18 players, 9 boards # Round 1B: 18 players, 9 boards assert (9, not lopsided, not bye) == utilities.get_number_of_boards_and_tweaks(36) # 75 players # Round 1A: 36 players, 18 boards, one bye # Round 1B: 38 players, 19 boards assert (19, lopsided, bye) == utilities.get_number_of_boards_and_tweaks(75)
def xxxtest_tiebreakers(get_all_players): breaks = 0 schedules_with_two_in_playoffs = 0 schedules_with_three_in_playoffs = 0 schedules_with_four_in_playoffs = 0 schedules_with_more_in_playoffs = 0 number_of_tournaments = 10 for count in range(0, number_of_tournaments): did_break = False number_to_try = 41 players = get_all_players[0:number_to_try] # Getting the right params boards, lopsided, bye = utilities.get_number_of_boards_and_tweaks( number_to_try) logger.debug("Results were: {}, lopsided? {}, bye? {}".format( boards, lopsided, bye)) test_schedule = schedule.Schedule(players, chessnouns.DEFAULT_NUMBER_OF_ROUNDS, lopsided, bye) assert test_schedule is not None test_schedule.sort_players() test_schedule.initialize_draws_for_players() test_schedule.shuffle_players() # We need to split players into two groups # to allow alternate playing rounds a, b = test_schedule.divide_players() test_schedule.schedule_players() test_schedule.assign_scheduled_games_to_draws() test_schedule._print_player_draws() # OK, let's now add this to the tournament may_tournament = tournament.Tournament(test_schedule, "Test May") may_tournament.create_random_results_all() board_slots = may_tournament.get_leaderboard() for ind_slot in board_slots: print(ind_slot) print("\n\nNOW FOR THE SORT\n\n") sorted_slots = sorted(board_slots) for ind_slot in sorted_slots: print(ind_slot) print("Let's get the stats for the tournament") print("Number of games: {}".format( may_tournament.get_total_number_of_games())) wins, byes, losses, draws = may_tournament.return_result_numbers() print("Number of wins: {}".format(wins)) print("Number of byes: {}".format(byes)) print("Number of losses: {}".format(losses)) print("Number of draws: {}".format(draws)) did_break, candidates = may_tournament.calculate_playoff_candidates() print(candidates) if len(candidates) == 2: schedules_with_two_in_playoffs += 1 elif len(candidates) == 3: schedules_with_three_in_playoffs += 1 elif len(candidates) == 4: schedules_with_four_in_playoffs += 1 else: schedules_with_more_in_playoffs += 1 if did_break: breaks += 1 print("Final report for Playoff Generation in {} Tournaments:".format( number_of_tournaments)) print( "2 Finalists: {}/{}\n3 Finalists: {}/{}\n4 finalists: {}/{}\n5 or more : {}/{}" .format( schedules_with_two_in_playoffs, number_of_tournaments, schedules_with_three_in_playoffs, number_of_tournaments, schedules_with_four_in_playoffs, number_of_tournaments, schedules_with_more_in_playoffs, number_of_tournaments, )) print("Playoffs determined by tie breakers: {}".format(breaks))
def test_add_schedule(get_all_players): number_to_try = 39 players = get_all_players[0:number_to_try] # Getting the right params boards, lopsided, bye = utilities.get_number_of_boards_and_tweaks( number_to_try) logger.debug("Results were: {}, lopsided? {}, bye? {}".format( boards, lopsided, bye)) test_schedule = schedule.Schedule(players, chessnouns.DEFAULT_NUMBER_OF_ROUNDS, lopsided, bye) assert test_schedule is not None test_schedule.sort_players() test_schedule.initialize_draws_for_players() test_schedule.shuffle_players() # We need to split players into two groups # to allow alternate playing rounds a, b = test_schedule.divide_players() logger.debug("\nFirst Group has: {} players ".format(len(a))) logger.debug("\nSecond Group has: {} players ".format(len(b))) test_schedule.schedule_players() test_schedule.assign_scheduled_games_to_draws() test_schedule._print_player_draws() # OK, let's now add this to the tournament may_tournament = tournament.Tournament(test_schedule, "Test May") may_tournament.create_random_results_all() board_slots = may_tournament.get_leaderboard() for ind_slot in board_slots: print(ind_slot) print("Let's get the stats for the tournament") print("Number of games: {}".format( may_tournament.get_total_number_of_games())) wins, byes, losses, draws = may_tournament.return_result_numbers() print("Number of wins: {}".format(wins)) print("Number of byes: {}".format(byes)) print("Number of losses: {}".format(losses)) print("Number of draws: {}".format(draws)) tie_breakers_used, candidates = may_tournament.calculate_playoff_candidates( ) print("Playoff Players:") print(candidates)