December 2018
Intermediate to advanced
764 pages
18h 18m
English
You may follow the code for this section in ch-13b.ipynb. Since our discretised space is of the dimensions [10,10,10,10], our Q-Table is of [10,10,10,10,2] dimensions:
# create a Q-Table of shape (10,10,10,10, 2) representing S X A -> Rq_table = np.zeros(shape = np.append(n_s,n_a))
We define a Q-Table policy that exploits or explores based on the exploration_rate:
def policy_q_table(state, env): # Exploration strategy - Select a random action if np.random.random() < explore_rate: action = env.action_space.sample() # Exploitation strategy - Select the action with the highest q else: action = np.argmax(q_table[tuple(state)]) return action
Define the episode() function that runs a single episode as follows:
Read now
Unlock full access