Please verify you are human to use the visualiser.
The agent navigates a 5×5 grid with walls, hazards, and a goal. It receives +10 for reaching the goal, −5 for stepping on hazards, and −0.1 for each step to encourage efficiency.
The agent maintains a table of Q-values Q(s, a) for every state-action pair. After each step, it updates the Q-value using the Bellman equation to gradually converge on the optimal policy.
With probability ε, the agent takes a random action (exploration). Otherwise, it picks the action with the highest Q-value (exploitation). This balance is critical for discovering optimal paths.
As training proceeds, the arrows on the grid converge to show the optimal policy — the shortest safe path from start to goal, avoiding walls and hazards.
Q-learning is one of the foundational algorithms in reinforcement learning. It learns an action-value function Q(s, a) that estimates the expected cumulative discounted reward of taking action a in state s and then following the optimal policy. The update rule is:
Q(s, a) ← Q(s, a) + α · (r + γ · maxa′ Q(s′, a′) − Q(s, a))
where α is the learning rate, γ is the discount factor, r is the immediate reward, s′ is the next state, and the max is taken over all possible actions in s′. This off-policy update means Q-learning converges to the optimal Q-values regardless of the exploration strategy used, given sufficient exploration.
For a deeper dive into Q-learning with a complete Python implementation, see our tutorial on Q-Learning on FrozenLake from Scratch. To understand how Q-learning extends to deep neural networks, read about Deep Q-Networks with Experience Replay. The reward on this grid is handed to the agent; when a reward is specified rather than given, the policy optimises the proxy instead of the goal, and GRPO from scratch takes the opposite route to a value function, scoring a group of samples against their own mean rather than learning a critic. For the connection between Q-learning and dynamic programming, see Value Iteration and Q-Learning.
The same reward-and-update machinery now sits behind LLM post-training, where preference data replaces the grid and the reward model replaces the environment. Getting that loop into a product is our LLM implementation consulting work. Deciding whether it is worth attempting on a given problem comes first, under AI pilot design.
Editable transition matrices, stationary distribution computation, and convergence simulation with stacked area charts.
Try itStep-by-step convolution animation with heatmap grids. Watch a kernel slide across input, see element-wise multiplication, and adjust stride, padding, and dilation.
Try itGet notified when new tutorials and deep-dives are published. No spam, unsubscribe anytime.
Common questions about Q-learning, grid worlds, and reinforcement learning