예제 #1
0
    def miniMax(self, node, depth, typeLevel):
        self.graph.add_node(node)

        ai_board = AI_Board(node.horizontalEdge, node.verticalEdge, node.boxes)

        if (depth == 0):
            node.heuristicValue = ai_board.heuristic(self.orderTurn, typeLevel)

        else:

            owner = None
            if (typeLevel == "max"):
                owner = 1
            else:
                owner = 2

            children = ai_board.getBoardChildren(owner)
            if (len(children) == 0):
                node.heuristicValue = ai_board.heuristic(
                    self.orderTurn, typeLevel)
            else:
                print "########################## ", len(children)
                for i in children:
                    self.graph.add_edge(node, i)
                    auxTypeLevel = self.changeType(typeLevel)
                    self.miniMax(i, depth - 1, auxTypeLevel)
                if (typeLevel == "min"):
                    node.heuristicValue = getMin(children).heuristicValue
                else:
                    node.heuristicValue = getMax(children).heuristicValue
예제 #2
0
         [Box(2, 0, 4), Box(2, 1, 4), Box(2, 2, 4)]]

sequenceEdge = []


def printBoard(board):
    print("Hoizontal:")
    print(board[0])
    print("Vertical:")
    print(board[1])

    print("____________")


def printBoard2(board):

    print("El padre")
    print("Hoizontal:")
    print(board.horizontalEdge)
    print("Vertical:")
    print(board.verticalEdge)
    print("____________")


if __name__ == "__main__":

    board = AI_Board(horizontalEdge, verticalEdge, boxes)

    heuristic = board.heuristic(1)
    print heuristic