navigator.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:mazerunner 作者: lucasdavid 项目源码 文件源码
def idle(self):
        """Updates the QLearning table, retrieves an action to be performed
        and checks for dead-ends."""
        state = NavigationState(self.perception_)
        action = self.learning_model.update(state).action_

        if (all(s.imminent_collision for s in self.sensors['proximity']) or
                self.sensors['orientation'][0].is_lying_on_the_ground):
            # There's nothing left to do. Flag this is a dead-end.
            self.behavior_ = self.BEHAVIORS.stuck
        else:
            move_to = self.INSTRUCTIONS_MAP[action]

            if action < ACTIONS.left:
                # It's walking straight or backwards. Reduce step size if it's
                # going against a close obstacle.
                dx = self.sensors['proximity'][action.index].distance
                move_to = np.clip(move_to, -dx, dx).tolist()

            self.motion.post.moveTo(move_to)
            self.behavior_ = self.BEHAVIORS.moving

        return self
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号