Example #1
0
    def action(self):
        self.similar_frames = self.similar_frames + 1 if not collector.image_changed else 0

        time_for_action = self.similar_frames >= WAIT_NO_CHANGE
        if not time_for_action:
            return ac.empty()

        if self.side_step_repeat > 0:
            self.side_step_repeat -= 1
            return self.side_step_action
        self.similar_frames = 0
        action = ac.empty()

        phase = PHASES[int(self.step / LENGTH)%len(PHASES)]
        substep = self.step % LENGTH
        # print(phase, substep, substep % 2)
        use_x_axis = substep % 2 == 0
        # make steps along extremes longer
        if self.step / LENGTH % 2 == 1:
            use_x_axis = not use_x_axis
        print('ph:%d ss:%d/%d F:%s  \t%d \t%s' % (self.step / LENGTH,
                                                  substep + 1,
                                                  LENGTH,
                                                  str(use_x_axis),
                                                  collector._counter,
                                                  str(phase)))
        if use_x_axis:
            action = ac.step(action, forward=phase[0])
        else:
            self.side_step_action = ac.step_aside(action, right=phase[1])
            self.side_step_repeat = SIDE_REPEAT - 1
            action = self.side_step_action
        collector.register_action(action)
        self.step += 1
        return action
Example #2
0
    def subturn(self, direction):
        '''Turn by 1 degree and make a step every STEP turns'''
        self.substep = self.substep + 1 if self.substep < STEP else 0
        action = ac.turn_left(ac.empty(), arg=direction)

        # skip a bit once a circle
        if self.turn != 0 and self.turn % 360 == 0 and self.substep == 0:
            action = ac.empty()
            print('SKIPPED A BIT')

        if self.substep == 0:
            action = ac.step(action, forward=True)
        return action
Example #3
0
 def move_to_action(self, action, delta):
     if delta[1] != 0:
         action = ac.step(action, forward=delta[1] > 0)
     if delta[0] != 0:
         action = ac.step_aside(action, right=delta[0] > 0)
     return action