Exemplo n.º 1
0
                    minimaxnode = MiniMaxNode(move.board)
                    # print(minimaxnode.heuristic())  # calculating heuristic for leaf nodes
                    temp.append(MiniMaxNode(move.board))  # make playernode
                    #  call heuristic function on the playermoves when created (can make it in the node class itself)
                player_nodes.append(temp)
                moves = []  # clear player move array
                temp = []
            i = 0
            #  iterate through
            for each in AI_nodes:
                each.setChildren(player_nodes[i])
                i = i + 1
            rootnode.setChildren(AI_nodes)
            miniMaxTree.computeMiniMax()

            gameBoard.board = miniMaxTree.getAIComputedMove()
            print(miniMaxTree.getRootValue())

            afterAITokenSize = len(gameBoard.getAITokens(p2))

            # Checking if the AI has chosen to play a token or move a token
            if beforeAITokenSize < afterAITokenSize:
                p2.tokensRemaining = p2.tokensRemaining - 1

            elif beforeAITokenSize == afterAITokenSize:
                movesActionsRemaining = movesActionsRemaining - 1

        # Print the Board
        gameBoard.printBoard()
        player.printPlayerStatus()
        player.printPlayerTokens()