コード例 #1
0
#game starts
while True:
    #select randomly the player.
    turn = whoGoesFirst()
    print(turn + ' will go first.')
    gameIsPlaying = True
    #loop until players are playing the game.
    while gameIsPlaying:
        if turn == 'player 1':
            # Player 1's turn.
            board.printBoard()
            #Player inputs his/her move.
            move = player1.getPlayerMove(board)
            #Make Player 1 move.
            player1.makeMove(move, board)
            #Check if Player 1 has won.
            if board.isWon(player1.symbol):
                #Print board.
                board.printBoard()
                print('Hooray! Player 1 has won the game!')
                gameIsPlaying = False
            else:  #Game is a tie.
                if board.fullBoard():
                    board.printBoard()
                    print('The game is a tie!')
                    break
                else:
                    turn = 'player 2'

        else: