In this section, we will define an environment for reinforcement learning. We could think of this as a typical maze where an agent needs to navigate the two-dimensional grid space to get to the end. However, in this case, we are going to use more of a physics-based maze. We will represent this using the mountain car problem. An agent is in a valley and needs to get to the top; however, it cannot simply go up the hill. It has to use momentum to get to the top. In order to do this, we need two functions. One function will start or reset the agent to a random point on the surface. The other function will describe where the agent is on the surface after a step.
We will use the following code to define the reset function to provide a place for the agent to start:
reset = function(self) { position = runif(1, -0.6, -0.4) velocity...