当前位置: 首页>>代码示例>>Python>>正文


Python Node.setParent方法代码示例

本文整理汇总了Python中node.Node.setParent方法的典型用法代码示例。如果您正苦于以下问题:Python Node.setParent方法的具体用法?Python Node.setParent怎么用?Python Node.setParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在node.Node的用法示例。


在下文中一共展示了Node.setParent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setParent

# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import setParent [as 别名]
  def setParent(self, parent):
    if not parent:
      if self.gui:
        parent = self.gui.anchors["Center", "Center"]
      else:
        parent = render2d

    Node.setParent(self, parent)
开发者ID:kralf,项目名称:morsel,代码行数:10,代码来源:widget.py

示例2: setParent

# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import setParent [as 别名]
  def setParent(self, parent):
    if not parent and self.world:
      parent = self.world.scene

    Node.setParent(self, parent)
开发者ID:kralf,项目名称:morsel,代码行数:7,代码来源:light.py

示例3: Node

# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import setParent [as 别名]
	checklisttime = 0
	#Initial Node
	n = Node(current, None)
	queueofmoves.append(n)
	closedlist = set(n.getStateBoardStringForHash())
	#Search for a win at the beginning of the frontier
	while not queueofmoves[0].state.isAWin():
		print "Frontier: ", len(queueofmoves)
		print "Closed: ", len(closedlist)
		q = queueofmoves[0]
		queueofmoves.popleft()
		for a in q.state.whatCanMove():
			n = Node(q.state.doAction(a), a)
			#Check if the boards string rep is in the closed list
			if n.getStateBoardStringForHash() not in closedlist:
				n.setParent(q)
				q.addChild(n)
				queueofmoves.append(n)
				closedlist.add(n.getStateBoardStringForHash())
	elapsedtime = time.time() - elapsedtime
	#Prepare and output moves
	endmoves = [queueofmoves[0]]
	currentnode = queueofmoves[0]
	while currentnode.parent is not None:
		moves = moves + 1
		endmoves.append(currentnode.parent)
		currentnode = currentnode.parent
	print "The time it took for BFGS is", elapsedtime, "seconds."
	print "The AI won, in", moves, "moves!"
	raw_input("Press enter to see the moves taken!")
	endmoves.pop()
开发者ID:addiem7c5,项目名称:CS347-Rush-Hour-Project,代码行数:33,代码来源:puzzleproject2.py

示例4: HValueFromDistanceAndNumCars

# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import setParent [as 别名]
	print "We are going to do an A* Search on", boardname 
	current.printDisplay()
	elapsedtime = time.time()
	pqueue = []
	pqueue.append(Node(current, None, 0, HValueFromDistanceAndNumCars(current)))
	closedset = dict()
	#Search for a win at the beginning of the frontier
	while not pqueue[0].state.isAWin():
		currentnode = pqueue.pop(0)
		closedset[currentnode] = currentnode.depth
		for a in currentnode.state.whatCanMove():
			newstate = currentnode.state.doAction(a)
			newnode = Node(newstate, a, currentnode.depth + 1, \
				       HValueFromDistanceAndNumCars(newstate))
			if newnode not in closedset:
				newnode.setParent(currentnode)
				pqueue.append(newnode)
				closedset[newnode] = newnode.depth
			elif newnode in closedset and newnode.depth < closedset[newnode] :
				if newnode in pqueue:
					pqueue[pqueue.index(newnode)].depth = newnode.depth
					pqueue[pqueue.index(newnode)].setParent(currentnode)
				else:
					newnode.setParent(currentnode)
					pqueue.append(newnode)
					closedset[newnode] = newnode.depth
		pqueue.sort()
	elapsedtime = time.time() - elapsedtime
	#Prepare and output moves
	
开发者ID:addiem7c5,项目名称:CS347-Rush-Hour-Project,代码行数:31,代码来源:puzzleproject4.py

示例5: Node

# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import setParent [as 别名]
	#	print a
	#Search for a win at the beginning of the frontier
	while not stackofmoves[-1].state.isAWin():
		                    			
		s = stackofmoves[-1]
		
		stackofmoves.pop()
		#See if the current nodes depth is less than the iteration level
		#If it is, we can still expand
		if s.depth < iterationlevel:
			for a in s.state.whatCanMove():
				n = Node(s.state.doAction(a), a, s.depth + 1)
				#Check if the boards string rep is in the closed list
									
				if n.getStateBoardStringForHash() not in closedlist:
					n.setParent(s)
					s.addChild(n)
					stackofmoves.append(n)
					closedlist.add(n.getStateBoardStringForHash())
		
		if len(stackofmoves) == 0:
			s = []
			stackofmoves = []
			n = Node(current, None, 0)
			closedlist = set()
			closedlist.add(n.getStateBoardStringForHash())
			stackofmoves.append(n)
			iterationlevel += 1
	elapsedtime = time.time() - elapsedtime
	#Prepare and output moves
	endmoves = [stackofmoves[-1]]
开发者ID:addiem7c5,项目名称:CS347-Rush-Hour-Project,代码行数:33,代码来源:puzzleproject3.py

示例6: setParent

# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import setParent [as 别名]
 def setParent(self, parent):
   if not parent:
     parent = render
     
   Node.setParent(self, parent)
开发者ID:kralf,项目名称:morsel,代码行数:7,代码来源:scene.py


注:本文中的node.Node.setParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。