one-file-projects/1000games.py

19 lines
393 B
Python

from tictactoe import *
wins = {}
game = Game([AI("X"),AI("O")])
for i in range(1000):
winner = game.run(out=False)
game.reset()
if winner in wins:
wins[winner] += 1
else:
wins[winner] = 1
for winner,count in wins.items():
if winner == Board.draw:
print("%d draws." % count)
else:
print("%s has won %d times." % (str(winner),count))