A ball rolls down the foggy hill from “Walk downhill”. Unlike the careful walker, it carries some of its motion from one step to the next. Write roll(state, slope, step_size, keep): the ball’s new state. state is [position, velocity], where the velocity is how far the ball moved on its last step (negative means to the left). Each step the slope pushes the ball downhill, and keep (0 to 1) is how much of its motion the ball keeps.
The hill from “Walk downhill”, fog lifted. A careful walker takes plain steps, step_size × slope, and stops dead where the ground goes flat. A ball keeps some of its motion from one step to the next. Watch both go down, then write the ball’s step.
roll(state, slope, step_size, keep)| state | [position, velocity], velocity = how far it moved last step | e.g. [3, 0] |
| slope | how steeply the ground rises to the right here | e.g. 6 |
| step_size | how hard the slope pushes the ball each step | e.g. 0.1 |
| keep | 0 to 1, how much of its motion the ball keeps | e.g. 0 |
| returns | the new [position, velocity] | |