In this section, we will define our agent for deep Q-learning. We have already seen how the preceding environment functions define how the agent moves. Here, we define the agent itself. In the previous chapter, we used Q-learning and were able to apply the Bellman equation to the new state that was the result of a given action. In this chapter, we will augment that portion of Q-learning with a neural network, which is what takes standard Q-learning and makes it deep Q-learning.Â
In order to add this neural network model to the process, we need to define a class. This is something that is often done in object-oriented programming; however, it is done less often in a programming language such as R. To accomplish this, we will use the R6 package for class creation. We will break up the creation of this R6 class into numerous parts...