本文整理汇总了Python中PriorityQueue.PriorityQueue.update方法的典型用法代码示例。如果您正苦于以下问题:Python PriorityQueue.update方法的具体用法?Python PriorityQueue.update怎么用?Python PriorityQueue.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PriorityQueue.PriorityQueue
的用法示例。
在下文中一共展示了PriorityQueue.update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from PriorityQueue import PriorityQueue [as 别名]
# 或者: from PriorityQueue.PriorityQueue import update [as 别名]
def run(self, gridMap, defStartNode=None, defEndNode=None, distanceType=PFA.DIS_TYPE_MANHATTAN):
if not gridMap:
return (PFA.RSLT_GRIDMAP_ERR,)
startNode = defStartNode
if not startNode:
startNode = gridMap.getStartGridNode()
if not startNode:
return (PFA.RSLT_NO_START_NODE,)
endNode = defEndNode
if not endNode:
endNode = gridMap.getEndGridNode()
if not endNode:
return (PFA.RSLT_NO_END_NODE,)
self.initPathMap(gridMap, distanceType)
closeSet = PQ()
startPathNode = self.pMap[startNode.x][startNode.y]
closeSet.push(startPathNode)
endPathNode = self.pMap[endNode.x][endNode.y]
endPathNode.isInClose = True
ret = (PFA.RSLT_NONE,)
while not closeSet.isEmpty() and ret[0] == PFA.RSLT_NONE:
currNode = closeSet.pop()
currNode.isInClose = True
# print("%d,%d,%d" % (currNode.gridNode.x, currNode.gridNode.y,currNode.fv))
currGridNode = currNode.gridNode
for dv in PFA.DIR_VECTOR:
nx = currGridNode.x + dv[0]
ny = currGridNode.y + dv[1]
if not gridMap.isValidPos(nx, ny):
continue
if gridMap.isThroughTheWall(currGridNode.x, currGridNode.y, dv):
continue
gCost = self.getGCost(dv)
if gridMap.isEndGridNode(nx, ny):
endPathNode.updatePrev(currNode, gCost)
ret = (PFA.RSLT_OK, self.genValidPath(gridMap), self.genAllVisNodeSet(gridMap), None)
break
newNode = self.pMap[nx][ny]
if newNode:
if not newNode.isInClose:
newNode.isInClose = True
closeSet.push(newNode)
if currNode.gv + gCost < newNode.gv:
newNode.updatePrev(currNode, gCost)
closeSet.update(newNode)
# if newNode.isInClose:
# if currNode.gv + gCost < newNode.gv:
# newNode.isInClose = False
# newNode.updatePrev(currNode, gCost)
# openSet.push(newNode)
# newNode.isInOpen = True
# else:
# if currNode.gv + gCost < newNode.gv:
# newNode.updatePrev(currNode, gCost)
# if not newNode.isInOpen:
# openSet.push(newNode)
# newNode.isInOpen = True
# else:
# openSet.update(newNode)
return ret