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
def action(self): if self.delay(): return self.delay_action if self.state == 0: return ac.turn_left(ac.empty(), arg=90) elif self.state == 1: return ac.turn_left(ac.empty(), arg=180) elif self.state == 2: return ac.turn_left(ac.empty(), arg=90) else: self.position += 1 if self.direction else -1 return ac.step_aside(ac.empty(), right=self.direction)
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