O'Reilly logo

Hands-On Q-Learning with Python by Nazia Habib

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing Bellman equations

We're starting with a simplified Bellman equation for the first part of our code: 

Note that we are only including gamma in this equation at the moment. We'll include alpha and epsilon in later iterations. Let's assume we're choosing a value of 0.1 for gamma. 

This is what that equation looks like in Python:

Q[state,action] = reward + gamma * np.max(Q[next_state])

If you're a Python programmer, but not a mathematician, this version is probably much less intimidating than the math version, but it works exactly the same way. Let's go through each part of this equation. 

This is an assignment where we are setting ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required