while True: numMoves += 1 agt = getAgentForMove(numMoves, whiteAgent, blackAgent) moveTuple = agt.getNextMove(board) if moveTuple == checkmate: printWinMessage(numMoves) if getColorForMove(numMoves) == white: # the loser blackWins += 1 else: whiteWins += 1 break elif moveTuple == stalemate or checkForStalemate(): printStalemateMessage(numMoves) stalemates += 1 break board.movePiece(moveTuple[0], moveTuple[1]) print "Game statistics:" print "Games: %d" % simulationNum print "White wins: %d" % whiteWins print "Black wins: %d" % blackWins print "Stalemates: %d" % stalemates else: # use graphics root = Tk() boardGraphics = BoardGraphics(root) board = Board() boardGraphics.drawBoard(board.getGrid()) root.after(1000, getAndDrawNextMove) root.mainloop()