-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.py
54 lines (45 loc) · 1.46 KB
/
client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import copy
from game import Game
from board import Board
from human_agent import HumanAgent
from pile import Pile
from player import Player
from random_agent import RandomAgent
from state import State
def main():
board = Board.from_config_file('board.cfg')
pile = Pile.from_config_file('pile.cfg')
players = [
Player('Bot_1', RandomAgent()),
Player('Bot_2', RandomAgent())
]
state = State(board, players, pile, True, True)
game = Game(state)
game.execute_setup()
game.play_game()
def test():
board = Board.from_config_file('board.cfg')
pile = Pile.from_config_file('pile.cfg')
players = [
Player('Bot_1', RandomAgent()),
Player('Bot_2', RandomAgent())
]
game_count = 10000
starter_winner_count = 0
total_move_count = 0
for i in range(game_count):
new_board = copy.deepcopy(board)
new_pile = copy.deepcopy(pile)
new_players = copy.deepcopy(players)
state = State(new_board, new_players, new_pile, False, False)
game = Game(state)
game.execute_setup()
game.play_game()
print(f'At game #{i:04}')
total_move_count += game.move_count
if game.starter == game.winner:
starter_winner_count += 1
print(f'Percentage of games won by starter: {starter_winner_count/game_count*100}%')
print(f'Average number of total moves in a game: {total_move_count/game_count}')
if __name__ == '__main__':
test()