Recap: Previously we constructed a very simple class to emulate the type of environment which is provided by OpenAI. Then we simulated two windy walks and used the result of these walks to produce some plots.
Now we want to produce the same results again but via a different and more interesting route. This time we want a windy walk model that is implemented as an extension to OpenAI.
For this we create a custom python package, we name it gym_drifty_walk.
You can pull the source code of gym_drifty_walk from github .
To install gym_drifty_walk locally do a clone, cd into the gym_drifty_walk directory, then run python setup.py install.
How the package is created in the first place will be explained in the next post. Let’s look how we use it first.
# import packages
import numpy as np
import matplotlib.style as style
import matplotlib.pyplot as plt
style.use('ggplot')
Now import the custom environment …
import gym
import gym_drifty_walk # custom environment
env = gym.make('drifty_walk-v0')
Run the simulation and plot
# set random seed, for reproducibility
np.random.seed(166)
env.reset()
X=[]
for i in range(50):
state, reward, done, _ = env.step(0.1)
X.append(state)
plt.plot(X)