Marble Race: Pick the Winning Marble
Pick Cyan, Magenta, Gold or Lime, then press Start. The four marbles drop through a field of pegs, spinning paddles and bumpers, and the first one across the finish line wins. The board is long, so the camera follows the race down it, and a mini-map on the right edge shows where every marble is. If your marble is off screen, a YOU arrow points to it. If your marble comes 1st you get 100 points; 2nd gets 25. Every race has a new random course. Points are saved only in your own browser.
The physics behind it
Every marble is pulled down by gravity: each tick, a little downward speed is added, so a marble falling freely goes faster and faster.
When a marble touches a round peg, it bounces by reflection. The game finds the line from the centre of the peg to the centre of the marble, flips the part of the marble's velocity that points into the peg, and keeps the part sliding past it. But the bounce isn't perfect: only about half of that "into the peg" speed comes back out. That energy loss on every hit is why marbles settle into a steady tumble instead of bouncing higher and higher forever. A tiny sideways wobble is also added, so a marble can never balance perfectly on top of a peg.
The spinning paddles work a bit differently, because their surface is moving. A point near the tip of a paddle sweeps around fast; a point near the middle barely moves. When a marble hits the paddle, the game works out the bounce relative to the moving surface, so the paddle adds its own speed to the marble. Get caught by the rising side and you are flung up and away; land on the falling side and you are carried down.
The big round bumpers follow the same reflection rule as the small pegs, but they are much bouncier: they give back about 80% of the marble's speed into them, compared with about 55% for a peg. Hit one and the marble springs away instead of just tumbling off.
Marbles also collide with each other. When two touch, they are pushed apart so they don't overlap, and they share the push along the line between their centres: the faster one gives some of its speed to the slower one.
Why is the result so hard to predict? Because of chaos. A marble that hits a peg slightly left of centre goes one way; slightly right, and it goes the other. After a few dozen pegs, a difference you could never see at the start becomes a completely different path — just like a Galton board or a Plinko board, where every bounce follows simple rules but the final spot is impossible to call.
To keep the race readable, the game uses gentle gravity and a top speed limit. Each tick is also split into four smaller sub-steps, so a marble can't jump straight through a peg or a wall. And if a marble barely moves for a second and a half, it gets a small nudge, so every race finishes.
So does any colour have an edge? No. The four start slots are shuffled at the start of every race, so no colour always starts on the left or in the middle. The order the marbles are processed in is shuffled again every step, so no colour always gets to move first when two are fighting for the same gap. And every race builds a new random course — the pegs shift, a few gaps open up, the paddles move to new lanes and spin in new directions, and the bumpers land in new spots. Every colour follows exactly the same rules.
Finally, the simulation runs at a fixed 60 steps per second. A 120 Hz phone draws more pictures and a slow laptop draws fewer, but both move the marbles forward in the same-sized steps, so the race plays out the same way on any screen. Switch tabs and the race pauses.
What is simplified
- Marbles don't spin or roll — they slide and bounce like flat discs.
- There is no air resistance.
- Pegs, bumpers and paddles never wear, bend or get pushed out of place.
- The top speed limit is a game rule to keep the race readable, not real physics.
This is a game inspired by physics, not a scientific tool. See the disclaimer for more.