Implementing the Q_Learner class's __init__ method

Next, let us look into the Q_Learner class's member function definitions. The __init__(self, env) function takes the environment instance, env, as an input argument and initializes the dimensions/shape of the observation space and the action space, and also determines the parameters to discretize the observation space based on the NUM_DISCRETE_BINS we set. The __init__(self, env) function also initializes the Q function as a NumPy array, based on the shape of the discretized observation space and the action space dimensions. The implementation of __init__(self, env) is straightforward as we are only initializing the necessary values for the agent. Here is our implementation:

class Q_Learner(object): ...

Get Hands-On Intelligent Agents with OpenAI Gym now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.