How mathematicians use Minecraft to calculate pi


The blockbuster game Minecraft depicts a world created by cubes: everything is made of discrete building blocks. It may therefore seem particularly unsuitable for calculating pi (π), the mathematical constant that equals the ratio of a circle’s circumference to its diameter. To determine the infinitely many, never-repeating decimal places of this irrational number, one must use the shape of a perfect circle that has no corners or edges.

Yet mathematicians Molly Lynch of Hollins University and Michael Weselcouch of Roanoke College have found a way to determine the mathematical constant’s value of 3.14159… as accurately as possible within the Minecraft world.

If you—like me—are only vaguely familiar with Minecraft, here’s a brief explanation: in this “sandbox” game, you can move relatively freely through the blocky world and build various structures, such as buildings or circuits, from cube-shaped elements. To do this, you have to gather resources and process those raw resources into new materials and items.


On supporting science journalism

If you’re enjoying this article, consider supporting our award-winning journalism by subscribing. By purchasing a subscription you are helping to ensure the future of impactful stories about the discoveries and ideas shaping our world today.


The many freedoms offered by Minecraft’s gameplay allow players to be creative. Past players have demonstrated that Minecraft is Turing complete, meaning that any computer program can be implemented within the game. Users have even managed to program a playable version of Minecraft within the game itself!

Knowing this, it’s no longer too surprising that the mathematical constant pi can also be calculated in Minecraft. If any computer program can be implemented in the game, then so can one that outputs the value of pi. Translating an algorithm into the game world is usually extremely complex, however. It requires translating all the instructions a computer follows on an electrical level—clear the register and insert a new value, process values from registers x and y using a logical AND operation, and so on—into a Minecraft action. A simple algorithm can quickly escalate into thousands of different in-game instructions.

Lynch and Weselcouch wanted to avoid that. Their goal was to make mathematics appealing to young people, and they thought Minecraft was a perfect vehicle with which to do so. In a 2024 paper they presented several methods for calculating well-known mathematical constants such as pi in the popular video game—all done without too much effort.

Throwing Darts at a Board

The two researchers first needed a method for calculating pi that could be easily implemented in Minecraft. They opted for the well-studied darts technique.

Imagine you play darts about as well as I do—which is to say, very badly. In this thought experiment, you’re throwing darts at a circular board mounted to a square area of wall. You’ll definitely hit somewhere within the square area of wall but not necessarily the circular dartboard. Because you’re not particularly skilled at throwing darts, it’s pure chance whether the dart lands on the circular board or on the wall outside of it; in other words, it’s equally likely to hit anywhere within the total area of the square. If you throw enough darts, you can approximate the value of pi.

Why is this the case? Let’s assume the square has a side length of two meters and covers an area of four square meters. That would make the diameter of the circle two meters as well, giving the circle a radius of one meter and thus an area of π square meters. Therefore, if the darts are randomly distributed within the square, there is a probability of π4 that they will land within the circle. By counting the darts within the circle and dividing by the total number of darts thrown, the result should be close to π4. Multiply that result by four, and you have an approximation of pi.

Lynch and Weselcouch implemented precisely this clever technique for approximating pi in Minecraft in 2024. They first approximated a circular structure within the game using red blocks with a “radius” of 11 blocks. They then surrounded the red blocks with blue blocks, resulting in a red approximate circle enclosed within a blue square.

Next they generated random events in the game that functioned similarly to the darts hitting the target in the darts example. To do this, the pair used a Minecraft creature known as a slime. Unlike other creatures in the game, “slimes continue moving when no players are nearby and they change direction at random,” Lynch and Weselcouch explain in their paper. They paired the slimes with a second type of creature, called zoglins, which kill slimes.

With these two creatures, Lynch and Weselcouch were able to generate random events that could be tracked in-game without direct observation. By covering the red circle with funnel-shaped blocks called hoppers, which automatically collect objects that fall directly on top of them, the researchers created a way to get a signal for each slime’s death: every time a slime was killed, it dropped items that were collected by a hopper. By dividing the number of slimes killed within the circle (or the number of items collected by hoppers within the circle) by the total number of creatures killed (or the number of items collected by all hoppers on the square), one can obtain an approximation of π4.

The two researchers tested their method in the game. During their test run, a total of 619 slimes were killed, 508 of which were killed inside the circle. These data allowed them to obtain the following approximate value for pi:

π ≈ 4 × (508 / 619) = 3.283

By the authors own admission, this isn’t a particularly good approximation of pi. They provide two ways to improve their method: enlarging the area of the square, and thus the area of the circle, and increasing the number of slimes killed within that total area. Enlarging the circle improves accuracy by better approximating a true circle. And the darts technique—which is formally called the Monte Carlo method—becomes more accurate when more random events are generated. In the Minecraft case, that means sending even more slimes and zoglins into battle.

This method of calculating pi will never be truly efficient, as Lynch and Weselcouch themselves admit. But efficiency is not their goal: it’s to inspire people, particularly young people, with mathematics. A Minecraft battle between slimes and zoglins is probably far better suited to that than a highly optimized algorithm.

This article originally appeared in Spektrum der Wissenschaft and was reproduced with permission. It was translated from the original German version with the assistance of artificial intelligence and reviewed by our editors.


Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top