February 2020
Intermediate to advanced
432 pages
10h 50m
English
The first script that we ran, cart-pole_env.py, was intended to show a sequence of 1,000 random steps. The new script will provide feedback for every action that is taken by giving rewards for good actions:
$ cd ~/catkin_ws/src/Chapter12_OpenAI_Gym/cart-pole$ conda activate(gym) $ python CartPole-v0.py
The iterative block in the script includes the following lines:
env.render()action = agent.act(state)next_state, reward, done, _ = env.step(action)score += rewardnext_state = np.reshape(next_state, (1, 4))agent.remember(state, action, reward, next_state, done)state = next_state
Following the order of the lines, this is what is done in each step:
Read now
Unlock full access