+ def check_task(self, task, *args, **kwargs):
+ if task == 'move':
+ if len(args) > 0:
+ direction = args[0]
+ 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
+ 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]:
+ raise GameError('would move outside map bounds')
+ pos_i = test_pos[0] * self.world.map_size[1] + test_pos[1]
+ map_tile = self.world.map_[pos_i]
+ if map_tile != '.':
+ raise GameError('would move into illegal terrain')
+