one-file-projects/1000games.py

20 lines
393 B
Python
Raw Normal View History

2014-11-04 13:02:25 +01:00
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))