Marble Race Generator
Generate a seeded marble race with four to ten marbles, each its own colour, and a finish order that the seed fixes. Runs on a canvas in your browser.
How this simulation works
The race is a seeded model rather than a random draw: each marble gets a base speed from the seed, then advances by that speed multiplied by a seeded jitter on every step, and stops at the finish line. The finish order is recorded once and never revised. Because the only source of variation is the seed, the same seed and the same number of steps produce the same order every time; only the pacing of the animation uses the clock. Each marble is drawn in its own colour so the lanes stay readable as the field spreads out.
How to use it
Pick how many marbles race, set a seed, then press Start. Pause holds the race, Step advances it one tick, and Reset returns every marble to the start line with the same seed.
Why it runs in your browser
The simulation runs on this page with JavaScript and the canvas API. Nothing is uploaded, no account is needed, and the page works offline after it loads.
Choose a seed and a field of four to ten marbles, then watch or step a seeded race across parallel lanes toward a finish line on the right.
The seed fixes where the marbles start and how far each one advances on every step, so the same seed and step count always produce the same finishing order. Only the speed of watching the race depends on the clock.
The drawing happens on a canvas in the tab, with no server call. When the operating system asks for reduced motion the page starts paused and waits for Play, rather than animating without being asked.
The controls
The seed field accepts a whole number from 0 to 9999 and starts at 8080. The runner slider moves the field from four to ten and starts at eight; changing it starts a fresh race from the same seed.
Play runs the race continuously, Step advances one frame, and Reset returns to the seeded starting positions. The status line says whether the race is ready, running or finished.
- Seed 0 to 9999, default 8080
- Four to ten runners, default eight
- Play, Step and Reset controls with a live status line
Why the result is repeatable
Every random decision is drawn from the seed, so the page never calls an unseeded random source. Two visitors who enter the same seed and the same runner count see the same order arrive at the line.
The race ends when the last marble crosses, not after a fixed time. Stepping and playing therefore reach the same final order; only how many frames you watch changes.
How to use the race controls
Set the Seed from 0 to 9999, starting at 8080, and the Runners slider from four to ten, starting at eight, in the Controls panel; changing the count starts a fresh race from the same seed. Press Play to run the field on a timer, Step for one generation at a time, or Reset for the first frame, and read the status line for ready, running or finished.
The seed fixes where the marbles start and how far each advances every step, so the same seed with the same field always finishes in the same order; the race ends when the last marble crosses. The page starts paused when the system asks for reduced motion.
What to Expect
Best for
- Seeing how a seeded simulation produces a repeatable outcome
- A classroom demonstration of randomness from a seed
- A short animation for a page with a marble-race theme
Not ideal for
- Predicting anything real, since the race models no physical process
- Betting or any decision with money attached
- A long animation, because the race ends when every marble finishes
What this tool keeps
- The same finishing order for the same seed and runner count
- The runner count you set, across Play, Step and Reset
- A paused start when reduced motion is requested
What may need cleanup
- A seed that produces a dull race, which you fix by changing the seed
- A runner count change, which restarts rather than continues
- The canvas size, which is fixed by the page
Common errors
- Expecting a different order from the same seed
- Reading the race as a physical simulation
- Wondering why the page is paused when reduced motion is on
Example use cases
- Demonstrating seeded randomness
- A playful hero animation
- Teaching what a deterministic simulation means
Sample input
Leave the seed at 8080, set eight runners and press Play.
Sample output
Eight marbles crossing in a fixed order determined by the seed, with the status line reporting the race finished.
Who this is for
- Teachers explaining seeded randomness
- Developers testing a deterministic animation
- Anyone who wants a small marble race to watch
Frequently asked questions
Is the marble race random on every run?
No. A seed and a field of four to ten marbles fix the finishing order, and the same seed repeats it.
Can it predict anything real?
No. The race models no physical process and has no bearing on a real event.
Why did changing the runner count restart the race?
The field size restarts the race rather than continuing it; change the seed instead if you only want a different result.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.