October 2019
Intermediate to advanced
366 pages
12h 4m
English
A basic RL cycle is shown in the following code block. This essentially makes the RL model play for 10 moves while rendering the game at each step:
import gym# create the environment env = gym.make("CartPole-v1")# reset the environment before startingenv.reset()# loop 10 timesfor i in range(10): # take a random action env.step(env.action_space.sample()) # render the game env.render()# close the environmentenv.close()
This leads to the following output:

Let's take a closer look at the code. It starts by creating a new environment named CartPole-v1, a classic game used in control theory ...
Read now
Unlock full access