July 2018
Intermediate to advanced
254 pages
8h 12m
English
In this section, we will put together the whole code into a single Python script to initialize the environment, launch the agent's training process, get the trained policy, test the performance of the agent, and also record how it acts in the environment!
#!/usr/bin/env/ pythonimport gymimport numpy as npMAX_NUM_EPISODES = 50000STEPS_PER_EPISODE = 200 # This is specific to MountainCar. May change with envEPSILON_MIN = 0.005max_num_steps = MAX_NUM_EPISODES * STEPS_PER_EPISODEEPSILON_DECAY = 500 * EPSILON_MIN / max_num_stepsALPHA = 0.05 # Learning rateGAMMA = 0.98 # Discount factorNUM_DISCRETE_BINS = 30 # Number of bins to Discretize each observation dimclass ...
Read now
Unlock full access