#### Overview of this book

Deep Reinforcement Learning Hands-On is a comprehensive guide to the very latest DL tools and their limitations. You will evaluate methods including Cross-entropy and policy gradients, before applying them to real-world environments. Take on both the Atari set of virtual games and family favorites such as Connect4. The book provides an introduction to the basics of RL, giving you the know-how to code intelligent learning agents to take on a formidable array of practical tasks. Discover how to implement Q-learning on 'grid world' environments, teach your agent to buy and trade stocks, and find out how natural language models are driving the boom in chatbots.
Deep Reinforcement Learning Hands-On
Contributors
Preface
Other Books You May Enjoy
Free Chapter
What is Reinforcement Learning?
OpenAI Gym
Deep Learning with PyTorch
The Cross-Entropy Method
Tabular Learning and the Bellman Equation
Deep Q-Networks
DQN Extensions
The Actor-Critic Method
Chatbots Training with RL
Continuous Action Space
Trust Regions – TRPO, PPO, and ACKTR
Black-Box Optimization in RL
Beyond Model-Free – Imagination
AlphaGo Zero
Index

## The Bellman equation of optimality

To explain the Bellman equation, it's better to go a bit abstract. Don't be afraid, I'll provide the concrete examples later to support your intuition! Let's start with a deterministic case, when all our actions have a 100% guaranteed outcome. Imagine that our agent observes state and has N available actions. Every action leads to another state, , with a respective reward, . Also assume that we know the values, , of all states connected to the state . What will be the best course of action that the agent can take in such a state?

Figure 3: An abstract environment with N states reachable from the initial state

If we choose the concrete action , and calculate the value given to this action, then the value will be . So, to choose the best possible action, the agent needs to calculate the resulting values for every action and choose the maximum possible outcome. In other words: . If we're using discount factor , we need to multiply the value of the next state...