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


Python Position.reverseDirection方法代码示例

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


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

示例1: _compute_path

# 需要导入模块: from position import Position [as 别名]
# 或者: from position.Position import reverseDirection [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
开发者ID:basman,项目名称:atc_bot,代码行数:52,代码来源:scheduler.py


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