本文整理汇总了Python中position.Position.time方法的典型用法代码示例。如果您正苦于以下问题:Python Position.time方法的具体用法?Python Position.time怎么用?Python Position.time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类position.Position
的用法示例。
在下文中一共展示了Position.time方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _compute_path
# 需要导入模块: from position import Position [as 别名]
# 或者: from position.Position import time [as 别名]
def _compute_path(self, airplane, timelimit):
#print "looking for a path from " + str(start) + " to " + str(dest) + ", starting at " + str(p)
begin_computation = time.time()
start = Position(airplane)
start.time = self._arena.clock
plan = [ start ]
# aim for approach position, one step in front of airport
if isinstance(airplane.dest, Airport):
tmp = Position(airplane.dest)
tmp.dir = tmp.reverseDirection()
approach = tmp.step(0, 1)
approach.dir = airplane.dest.dir # turn around
else:
approach = Position(airplane.dest)
approach.dir_tolerance = 90 # allow max. 90 degree derivation from target direction
# enter recursion
if not self._step_recursive(airplane, plan, start, approach, timelimit):
if time.time() > timelimit:
print "Path of " + str(airplane) + " from " + str(start) + " to " + str(airplane.dest) + ": COMPUTATION TIMEOUT (comp.time=" + \
str(int((time.time()-begin_computation) * 1000000)/1000.0) + "ms)"
else:
print "Airplane " + str(airplane) + " will delay its take-off due to ongoing traffic"
return False
# append destination itself
d = Position(airplane.dest)
d.time = plan[-1].time + 1
plan.append( d )
self._compute_commands(plan, airplane)
print "Path of " + str(airplane) + " from " + str(start) + " to " + str(airplane.dest) + " (" + str(len(plan)) + " steps, comp.time=" + \
str(int((time.time()-begin_computation) * 100000)/100.0) + "ms): ",
print string.join(map(str, plan), '; ')
# add schedule to database
for s in plan:
if s.time < self._arena.clock:
raise Exception("can't schedule for past time " + str(s.time) + ". current time: " + str(self._arena.clock))
if not s.time in self._schedules:
self._schedules[s.time] = {}
self._schedules[s.time][airplane] = s
return True