Observe
The agent reads its surroundings: where it is, what is nearby, and what could help or hurt.
LAB 02 / REINFORCEMENT LEARNING LIVE IN YOUR BROWSER
Try a move. Get a reward. Learn what to try next.
Help a little pixel runner collect coins, jump over trouble, and reach the flag. The network starts with random weights and learns from the game’s rewards. No account or installation needed.
The ring marks the chosen move. A gold ring means a random exploratory move. Output scores estimate future rewards; they are not probabilities. Hover or tap a neuron to inspect its value.
Fresh learning can take many attempts. A practiced brain was trained with this same learning algorithm. Loading it gives you a useful comparison; it is not a scripted player.
Light line: each attempt. Dark line: the recent average. Rewards can improve, dip, or stay flat. We measure results rather than promising that every attempt will win.
It reads the measurements below, not the game’s screenshot. Those are the input neurons. Position, speed, ground contact, and nearby blocks, gaps, enemies, and coins help it make choices.
WHAT MAKES THIS REINFORCEMENT LEARNING?
The agent reads its surroundings: where it is, what is nearby, and what could help or hurt.
The network scores each possible move. Sometimes the agent explores with a random move instead.
Coins give +1, reaching the flag gives +5, and getting hurt costs 3. Moving right gives a small reward; moving left takes it away. Each move also has a tiny cost.
It saves what happened and learns from past moves. Better reward estimates can lead to better choices.
This is a small deep Q-network: input measurements → 24 hidden neurons → 16 hidden neurons → one reward estimate per move. Hidden neurons use tanh; their signed activations are the values shown live.
Training samples past moves from a memory buffer. The target is the reward received, plus a discounted estimate of later rewards when the attempt continues. A second, slowly updated network helps stabilize those targets. This implementation uses Double DQN action selection, Huber loss, and Adam weight updates.
At higher speeds, several moves happen between screen frames. The game and network display the latest decision. Connection brightness reflects the signal through that connection. Hidden neurons have no hand-assigned meaning such as “fear” or “jump.”
This is an original miniature platformer inspired by Mario, with its own art and physics. It is a small course for exploring reinforcement learning. Learning and rendering happen on your device. Downloaded brains contain weights and settings, not an account or a game recording.
Further reading: PyTorch’s deep Q-learning tutorial.