Pi with Teabags (Monte Carlo)

Monte Carlo methods estimate an answer by running a large number of random trials and looking at the aggregate outcome, rather than solving the problem directly — useful whenever an exact calculation is too complex, or there's no clean formula for what you're after in the first place. The more trials you run, the closer the estimate typically gets to the true value. Someone's pulling a box of tea bags off a shelf in a tea shop's stockroom, and the box slips, scattering tea bags across the floor. The tile underneath happens to have a circle inscribed inside its square border. Since where each bag lands is effectively random, counting how many land inside the circle versus outside it turns out to be a genuine way to estimate the number pi — a circle with radius 0.5 fits exactly inside a 1x1 square and covers pi/4 of its area, so four times the fraction landing inside is an estimate of pi itself.

Drop tea bags onto the tile using the buttons below — one at a time, or in batches of 10, 100, or 1,000 to see convergence faster. Each dot is a bag, coloured by whether it landed inside the circle or outside. Watch the pi estimate card and the chart on the right: with only a few bags the estimate can be wildly off, but it settles in close to the true value of pi as more bags pile up. Sweep up and start over to try again from zero.

What this teaches: Throw random tea bags onto a tiled floor and use the count to estimate pi. It teaches Monte Carlo simulation, random sampling, and how an estimate gets closer to the true value as the number of trials grows.