Let's try to implement the SARSA algorithm explained previously in the mountain car problem. The initial part of the program shares similarities with the previous Q-learning program.
First, we will import the dependencies and examine the mountain car environment, using the following code:
#importing the dependenciesimport gymimport numpy as np#exploring Mountain Car environmentenv_name = 'MountainCar-v0'env = gym.make(env_name)print("Action Set size :",env.action_space)print("Observation set shape :",env.observation_space) print("Highest state feature value :",env.observation_space.high) print("Lowest state feature value:",env.observation_space.low) print(env.observation_space.shape) ...