Exemplo n.º 1
0
                    playersTurn = False
                    continue

                elif board.checkFinished():
                    #if the game has finished, get scores and display the winner
                    board.findWinner()
                    sleep(8)
                    gameFinished = True

    else:

        # COMPUTER'S TURN #

        #(row, column) = getIndex(board.square_size)
        #(row, column) = board.randomMove('white')
        (row, column) = board.bestMove('white')
        piecesToFlip = board.isValidMove(row, column, 'white')

        #place piece and flip the surrounded pieces
        board.place(row, column, 'white')
        for (row, column) in piecesToFlip:
            board.place(row, column, 'white')

        board.display()
        pg.display.flip()

        if board.findAvailable('black'):
            #if the other player has available moves, then it becomes their
            #turn, otherwise it is still this players turn
            playersTurn = True
            continue
Exemplo n.º 2
0
while not gameFinished:

    for event in pg.event.get():
        if event.type == pg.QUIT:
            run = False
            pg.quit()
            sys.exit()


    if playersTurn:

        # PLAYER'S TURN #

        #check if a valid square is clicked
        (row, column) = board.bestMove('black')
        piecesToFlip = board.isValidMove(row, column, 'black')

        #place piece and flip the surrounded pieces
        board.place(row, column, 'black')
        for (row, column) in piecesToFlip:
            board.place(row, column, 'black')

        board.display()
        pg.display.flip()

        if board.findAvailable('white'):
            #if the other player has available moves, then it becomes their
            #turn, otherwise it is still this players turn
            playersTurn = False
            continue