def tick(self, e):
        if (e in key_directions and
            abs(key_directions[e][0]) + abs(self.direction[0]) < 2 and
            abs(key_directions[e][1]) + abs(self.direction[1]) < 2):
            self.direction = key_directions[e]
        self.advance_snake()
        if self.snake_parts[0] == self.apple:
            self.new_apple()
        elif ((not (0 <= self.snake_parts[0][0] < self.height and
                    0 <= self.snake_parts[0][1] < self.width)) or
                self.snake_parts[0] in self.snake_parts[1:]):
            return True
        else:
            self.snake_parts.pop()
dataset/ETHPy150Open thomasballinger/curtsies/examples/snake.py/Snake.tick/original