SARSA algorithm for mountain car problem in OpenAI gym

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) ...

Get Reinforcement Learning with TensorFlow 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.