An action-value function, or Q-function, gives a state–action pair a score: the expected long-term reward from taking that action. Think of it as a scorecard for an agent deciding what to do next. In a Q-table, each row is a state, each column is an action, and each cell holds a Q-value. The agent can choose the highest-scoring action in its current row. section 10.10 section 10.6
Figure 10.11 An example Q-table and states that it represents
Compare the action scores for each illustrated state: the preferred move depends on where the agent is. section 10.6
The scores are learned, not known in advance. In Q-learning, the agent tries actions in an environment, receives rewards, and observes how its state changes. Early Q-values are guesses; repeated experience makes them more useful for choosing actions. The agent may also take a random action instead of following the table. section 10.6
A reward now, with a promising move later
Suppose the agent moves east, receives +1, and reaches a new state. Its predicted Q-values for the next state are 1.2 north, 0.5 south, 2.0 east, and 0.3 west. East has the highest predicted value. With a discount factor of 0.9, the training target for the move just taken is 1 + (0.9 × 2.0) = 2.8. The discount factor controls how much future rewards count alongside the immediate reward. section 10.11
For many possible states, deep Q-learning can use an artificial neural network instead of a table. The network predicts Q-values, then compares its prediction for the action taken with a target built from the reward and next-state predictions. The squared difference is its training loss. Whether stored in a table or predicted by a network, the practical question is the same: which action looks most rewarding from here? section 10.10 section 10.11
Figure 10.20 The difference between using a Q-table and an ANN for the Parking-Lot Problem
See how a Q-table and an artificial neural network represent learned action values differently in the parking-lot problem. section 10.10




