예제 #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
    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
예제 #3
0
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


예제 #4
0
	print (board[1])

	print ("____________")

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


if __name__ == "__main__":
	b = AI_Board(3,3)

	b.verticalEdge = verticalEdge
	b.horizontalEdge = horizontalEdge
	b.boxes = boxes
	ai_util = AI_Util(b)
	Temp_children = ai_util.getBoardChildren("eloy")
	print ("Nivel 1: numero de hijos", len(Temp_children))

	children = Temp_children[0]

	print "Vertical edge", children[1]
	print "horizontal Edge", children[0]
	print "Secuencia", children[3]

	cajas = children[2]
예제 #5
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