October 2018
Intermediate to advanced
472 pages
10h 57m
English
Let's load the CartPole-v1 game from the gym module. It's very simple. All you have to do is feed the gym.make() function the name of the game. In our case, the game is CartPole-v1. Gym then loads the game into your workspace:
env = gym.make('CartPole-v1')
It is important that you set seed for reproducibility:
# Set seed for reproducibilityseed_val = 456np.random.seed(seed_val)env.seed(seed_val)random.seed(seed_val)
Let's explore how many variables we have in the CartPole game:
states = env.observation_space.shape[0]print('Number of states/variables in the cartpole environment', states)
The following is the output:
We can ...
Read now
Unlock full access