Пример #1
0
def match(player1, player2, n_games, size):
    for _ in range(n_games):
        game = HexGame(size, player1, player2)
        game.play([''])
        if game.win[1] == 1:
            player1.rating, player2.rating = rate_1vs1(player1.rating,
                                                       player2.rating,
                                                       drawn=False)
        elif game.win[1] == 2:
            player2.rating, player1.rating = rate_1vs1(player2.rating,
                                                       player1.rating,
                                                       drawn=False)
    return player1.rating, player2.rating
Пример #2
0
from hexgame import HexGame
from hexplayer import HexPlayerHuman, HexPlayerRandom

if __name__ == '__main__':
    # test functionality
    game = HexGame(2, HexPlayerRandom(3), None)
    game.step(['tree'])

    # play a game
    game = HexGame(5, HexPlayerRandom(4), HexPlayerHuman())
    game.play()