Loading pythonsnake/candy.py +3 −15 Original line number Diff line number Diff line from random import choice from random import randint from pythonsnake.snake import Snake Loading Loading @@ -32,22 +32,10 @@ class Candy: self.Y = y def random_coord_X(self, grid_width: int, snake: Snake) -> int: coord_to_exclude = [] for snake_part in snake.coord: coord_to_exclude.append(snake_part["x"]) return choice( [i for i in range(0, grid_width) if i not in coord_to_exclude] ) return randint(0, grid_width-1) def random_coord_Y(self, grid_height: int, snake: Snake) -> int: coord_to_exclude = [] for snake_part in snake.coord: coord_to_exclude.append(snake_part["y"]) return choice( [i for i in range(0, grid_height) if i not in coord_to_exclude] ) return randint(0, grid_height-1) def new_coord( self, grid_width: int, grid_height: int, snake: Snake Loading Loading
pythonsnake/candy.py +3 −15 Original line number Diff line number Diff line from random import choice from random import randint from pythonsnake.snake import Snake Loading Loading @@ -32,22 +32,10 @@ class Candy: self.Y = y def random_coord_X(self, grid_width: int, snake: Snake) -> int: coord_to_exclude = [] for snake_part in snake.coord: coord_to_exclude.append(snake_part["x"]) return choice( [i for i in range(0, grid_width) if i not in coord_to_exclude] ) return randint(0, grid_width-1) def random_coord_Y(self, grid_height: int, snake: Snake) -> int: coord_to_exclude = [] for snake_part in snake.coord: coord_to_exclude.append(snake_part["y"]) return choice( [i for i in range(0, grid_height) if i not in coord_to_exclude] ) return randint(0, grid_height-1) def new_coord( self, grid_width: int, grid_height: int, snake: Snake Loading