self.position = position
self.task = Task('wait')
- def task_wait(self):
- pass
-
- def task_move(self, direction):
+ def _move_pos(self, direction, pos_yx):
if direction == 'UP':
- self.position[0] -= 1
+ pos_yx[0] -= 1
elif direction == 'DOWN':
- self.position[0] += 1
+ pos_yx[0] += 1
elif direction == 'RIGHT':
- self.position[1] += 1
+ pos_yx[1] += 1
elif direction == 'LEFT':
- self.position[1] -= 1
+ pos_yx[1] -= 1
+
+ def task_wait(self):
+ pass
+
+ def task_move(self, direction):
+ self._move_pos(direction, self.position)
def decide_task(self):
if self.position[1] > 1:
else:
direction = kwargs['direction']
test_pos = self.position[:]
- if direction == 'UP':
- test_pos[0] -= 1
- elif direction == 'DOWN':
- test_pos[0] += 1
- elif direction == 'RIGHT':
- test_pos[1] += 1
- elif direction == 'LEFT':
- test_pos[1] -= 1
+ self._move_pos(direction, test_pos)
if test_pos[0] < 0 or test_pos[1] < 0 or \
test_pos[0] >= self.world.map_size[0] or \
test_pos[1] >= self.world.map_size[1]: