From 6eb83cf293dde9e0e4027df4d6197905518b086f Mon Sep 17 00:00:00 2001 From: Casper Guo Date: Mon, 29 Jul 2024 15:52:41 +0800 Subject: [PATCH] Player 1 and player 2 alternate moving first --- tournament.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tournament.py b/tournament.py index 9faeae9..ffdcdfc 100644 --- a/tournament.py +++ b/tournament.py @@ -120,10 +120,14 @@ def main( else combinations_with_replacement(player_classes, 2) ) for player1, player2 in iterator: - for _ in range(num_games): - game = Game(player1(), player2(), board_seed) + for i in range(num_games): + white_player, black_player = player1, player2 + if i >= num_games // 2: + white_player, black_player = player2, player1 + + game = Game(white_player(), black_player(), board_seed) if game.play(): - # player1 wins + # white wins num_wins[str(game.player1)][str(game.player2)] += 1 else: if player1 != player2: