本文整理匯總了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