Skip to content

Instantly share code, notes, and snippets.

@mukeshsolanki
Created May 27, 2022 05:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mukeshsolanki/a36287efdfed5223ce1e5bd8fd3bc20b to your computer and use it in GitHub Desktop.
Save mukeshsolanki/a36287efdfed5223ce1e5bd8fd3bc20b to your computer and use it in GitHub Desktop.
it.copy(
food = if (newPosition == it.food) Pair(
Random().nextInt(BOARD_SIZE),
Random().nextInt(BOARD_SIZE)
) else it.food,
snake = listOf(newPosition) + it.snake.take(snakeLength - 1),
currentDirection = currentDirection.value,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment