Building the environment
When building an AI, the first thing we always have to do is define the environment. Defining an environment always requires the following three elements:
- Defining the states
- Defining the actions
- Defining the rewards
These three elements have already been defined in the previous chapter on Q-learning, but let's quickly remind ourselves what they are.
The states
The state, at a specific time t, is the location where the robot is at that time t. However, remember, you have to encode the location names so that our AI can do the math.
At the risk of disappointing you, given all the crazy hype about AI, let's remain realistic and understand that Q-learning is nothing more than a bunch of math equations; just like any other AI model. Let's make the encoding integers start at 0, simply because indexes in Python start at 0:
Figure 5: Location to state mapping
The actions
The actions are the next possible...