本文整理汇总了Python中State.State.from_previousState方法的典型用法代码示例。如果您正苦于以下问题:Python State.from_previousState方法的具体用法?Python State.from_previousState怎么用?Python State.from_previousState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类State.State
的用法示例。
在下文中一共展示了State.from_previousState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: neighbors
# 需要导入模块: from State import State [as 别名]
# 或者: from State.State import from_previousState [as 别名]
def neighbors(self,closedTable,spacecraft,sim):
neighborList = []
for i in range(2**spacecraft.numThr):
# Compute the state (position, velocity, theta vector, and angular velocity) of the neighbor
state = State.from_previousState(
self.state, spacecraft.accelMatrix[i], spacecraft.alphaMatrix[i], sim.dt)
# Compute the key for the neighbor
key = state.keyFromSim(sim)
cost = self.cost + sim.dt
h = sim.heuristic(state,spacecraft)
totalCost = cost + h
# outfile.write(str(state.p) + '\n')
# outfile.write(str(state.v) + '\n')
# outfile.write(str(h) + '\n\n')
# test for membership in the closed table
if key in closedTable:
if not closedTable[key].valid:
continue
if totalCost < closedTable[key].totalCost: #the heuristic is not perfectly consistent
closedTable.pop(key) #it's possible to have two nodes with the same key
#with different totalCosts
continue
parent = self
controls = [(i//(2**j))%2 for j in range(spacecraft.numThr)] # Array of bits of i
neighborList.append(Node(key,parent,cost,totalCost,state,True,controls))
return neighborList