Exemplo n.º 1
0
            beforeAITokenSize = len(gameBoard.getAITokens(p2))

            print("AI is calculating it's move")
            miniMaxTree = MiniMaxTree()
            AI_moves = []  #array of AI intial moves
            AI_nodes = []  #array of AI move nodes
            player_moves = []  # list of lists of player moves
            player_nodes = []  # list of lists of player nodes
            temp = []

            rootnode = MiniMaxNode(
                gameBoard.board)  # create node of the current gameboard
            miniMaxTree.setRoot(rootnode)  # set as the root node

            AI_moves.extend(gameBoard.allPutOptions(
                p2))  # calculate all put options for AI
            if movesActionsRemaining > 0 and len(p2.playerTokenLocations) != 0:
                AI_moves.extend(gameBoard.possibleMoves(
                    p2))  # calculate all move options for AI

            for each in AI_moves:  # make each AI move a node
                AI_nodes.append(MiniMaxNode(
                    each.board))  # setting heuristic to 0 for all of them,

            for each in AI_moves:  # calculate player moves for each AI move
                moves = []
                if p1.tokensRemaining > 0:
                    moves = each.allPutOptions(p1)

                if movesActionsRemaining > 0 and len(
                        p1.playerTokenLocations) != 0: