March 2019
Intermediate to advanced
184 pages
4h 57m
English
We will now repeat the same cliff walking problem, albeit using Q-learning in lieu of SARSA. Most of the code is the same as was used for SARSA, except for a few differences that will be summarized here. Since Q-learning uses a greedy action selection strategy, we will use a function for this as follows to compute the value of the maximum value of Q at a given location. Most of the code is the same as in the previous section, so we will only specify the changes to be made.
Now, let's code cliff walking with Q-learning.
The max_Q() function is defined as follows:
def max_Q(x,y,Q): a = np.argmax(Q[y,x,:]) return Q[y,x,a]
We will compute the Q value at the new state using the max_Q() function defined previously: ...
Read now
Unlock full access