The science
Temporal-difference learning. An agent walks through 8 states towards a reward that is paid when it leaves the last state; each trial begins with a cue light that appears at unpredictable times (so the "waiting" state keeps value 0). After each step it computes the prediction error δ = r + γV(s') - V(s) and nudges the value estimate V(s) ← V(s) + αδ (TD(0), Sutton and Barto). With reward probability p and size R the true values are V(s) = p R γ7-s, the dashed lines in the figure.
What the error signal does. Before learning, δ is large at the reward. As V is learned the surprise moves backward in time: δ at the reward falls to zero and δ at the cue rises to γV(first). If a reward you expected is omitted, δ becomes negative; if it is doubled, δ is positive. This matches the famous recordings of dopamine neurons (Schultz, Dayan and Montague, 1997), which is why it is a common computational model of reward-related "feeling". Here the face simply shows the smoothed δ, a toy analogy for valence.
Check. A separate sample-average TD run (step size 1/n, 6000 episodes) is compared with the closed-form values; the tolerance is 5% of R. With p < 1 the animated agent's values jitter around the true values by an amount that grows with α.
Honest simplifications. Tabular states, one reward type, fixed discrete timing; real brains use richer time representations and many neuromodulators. Nothing here is conscious or feels anything: "emotion" is only the mapping from prediction error to a drawn face. This is an educational model, not a diagnostic or clinical tool.