In this exercise we implement two functions at the same time.
This reason is that the nextWorld
function can be used
both when the snake is extended and when the snake has moved.
nextWorld
converts a world to a new world but checks
whether the head of the snake:
1) is still within the board
2) is not colliding with itself.
Otherwise the status needs to be changed to dead and set the snake back to the initialPosition
The step
function
1) move the snake at each call
2) extend the snake after one second