How mathematicians use Minecraft to calculate pi

how-mathematicians-use-minecraft-to-calculate-pi

How mathematicians use Minecraft to calculate pi

The hit game Minecraft depicts a world created by cubes: everything is made up of discrete building blocks. It may therefore seem particularly unsuitable for calculating pi (π), the mathematical constant which is equal to the ratio between the circumference of a circle and its diameter. To determine the infinity of never repeating decimal places of this irrational number, we must use the shape of a perfect circle without corners or edges.

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

If, like me, you’re only vaguely familiar with Minecraft, here’s a brief explanation: In this “sandbox” game, you can move relatively freely around the blocky world and construct various structures, such as buildings or circuits, from cube-shaped elements. To do this, you must gather resources and transform these raw resources into new materials and items.


On supporting science journalism

If you enjoy this article, please consider supporting our award-winning journalism by subscribe. 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 gameplay allow players to get creative. Former players have demonstrated that Minecraft Is Turing finished?which means that any computer program can be implemented in the game. Users have even managed to program a playable version of Minecraft in the game itself!

Knowing this, it is no longer surprising that the mathematical constant pi can also be calculated in Minecraft. If a computer program can be implemented into the game, so can the one that generates the value of pi. However, translating an algorithm into the gaming world is usually extremely complex. This requires translating all the instructions that a computer follows at the electrical level: clearing the register and inserting a new value, processing register values. x And Yes using a logical AND operation, and so on, in a Minecraft action. A simple algorithm can quickly turn into thousands of different in-game instructions.

Lynch and Weselcouch wanted to avoid this. Their goal was to make math attractive to young people, and they thought Minecraft was the perfect vehicle to achieve this. In a 2024 paper, they presented several methods for calculating well-known mathematical constants such as pi in the popular video game, all without much effort.

Throwing darts on 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 dart technique.

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

Why is this the case? Suppose the square has a side of two meters and covers an area of ​​four square meters. This would also give the circle a diameter of two meters, which would give the circle a radius of one meter and therefore an area of ​​π meters squared. Therefore, if the darts are randomly distributed in the square, there is a probability that p4 that they will land in the circle. By counting the darts in the circle and dividing by the total number of darts thrown, the result should be close to p4. Multiply this result by four and you get an approximation of pi.

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

Then they generated random events in the game that worked the same way as the darts hitting the target in the darts example. To do this, the couple used a Minecraft creature known as a drool. Unlike other creatures in the game, “slimes continue to move when no players are nearby and they change direction randomly,” Lynch and Weselcouch explain in their article. They associated slimes with a second type of creature, called zoglinswhich 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 hopperswhich automatically collect items that fall directly onto it, the researchers created a way to get a signal for each slime’s death: each time a slime was killed, it would drop collected items from a hopper. By dividing the number of slimes killed in the circle (or the number of items collected by the hoppers inside the circle) by the total number of creatures killed (or the number of items collected by all hoppers in the square), we can obtain an approximation of p4.

The two researchers tested their method in-game. During their test, a total of 619 slimes were killed, 508 of which were 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 is not a very good approximation of pi. They propose two ways to improve their method: enlarge the surface area of ​​the square, and therefore that of the circle, and increase the number of slimes killed in this total surface area. Enlarging the circle improves accuracy by getting closer to a real circle. And the dart technique, officially called the Monte Carlo method, becomes more precise when more random events are generated. In Minecraft’s 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 is about inspiring people, especially young people, with mathematics. A Minecraft battle between slimes and zoglins is probably much better suited to this than a highly optimized algorithm.

This article was originally published in spectrum of science and has been reproduced with permission. It was translated from the original German version with the help of artificial intelligence and reviewed by our editors.

It’s time to defend science

If you enjoyed this article, I would like to ask for your support. Scientific American has been defending science and industry for 180 years, and we are currently experiencing perhaps the most critical moment in these two centuries of history.

I was a Scientific American subscriber since the age of 12, and it helped shape the way I see the world. SciAm always educates and delights me, and inspires a sense of respect for our vast and magnificent universe. I hope this is the case for you too.

If you subscribe to Scientific Americanyou help ensure our coverage centers on meaningful research and discoveries; that we have the resources to account for decisions that threaten laboratories across the United States; and that we support budding and working scientists at a time when the value of science itself too often goes unrecognized.

In exchange, you receive essential information, captivating podcastsbrilliant infographics, newsletters not to be missedunmissable videos, stimulating gamesand the best writings and reports from the scientific world. You can even give someone a subscription.

There has never been a more important time for us to stand up and show why science matters. I hope you will support us in this mission.

Exit mobile version