Skip to main content

Video Games that Secretly Teach Mathematics

This essay is different from what I'm used to writing. By a lot. I feel as though I'm at my best when doing cultural commentary, or web development, but I've never really written about pure mathematics.

I love mathematics, and there is such beauty to be found in the field. Some of the best examples of this are Grant Sanderson's animated explanations. Mathematics is not a catalogue of facts to memorize, but a way of seeing.

We have failed generation after generation of children with the pedagogy of mathematics. School teaches maths as a sequence of procedures to execute correctly, a set of hoops to jump through on the way to a grade. The ritual of the "mad minute," the multiplication speed drill, have been the cause of the lifelong math anxiety many have.

I myself came to mathematics late, and sideways. I personally don't have education on mathematics beyond freshman classes in university, so I apologize beforehand. Mea culpa. Technical and dense posts like this, which I deeply admire, are written by people who have PhDs in these fields, and typically go above my head. This post is more oriented towards laypeople like myself.

We have a staggeringly large population that reflexively says I'm just not a math person. This essay is, in a small way, a protest against that. And a love letter to the mathematics hiding inside video games.

PART ONE: Video Games, Mathematics, and Parallel Universes

Video games are, surprisingly, a good vehicle for encountering mathematics and computer science. For example, Tony Zhu has an excellent video about how Factorio teaches you software engineering. The factory-building simulation, beloved by engineers and the sleep-deprived alike, demonstrates algorithmic thinking.

But that's not what I'm talking about.

Ten years ago, a video was uploaded about getting a star in Super Mario 64 with only 0.5 A presses. It has over 5 million views. The video goes through scuttlebug transportation, scuttlebug raising, hyper speed walking (HSWing), and most jarring of all, parallel universes (PUs). You really have to watch the video to appreciate it, my commentary could never do it full justice. My description is a pale sketch, but let me try anyways:

Super Mario 64 tracks Mario's position using fixed-point arithmetic. The game represents coordinates as integers, values that overflow and wrap around when they exceed certain thresholds. When Mario accumulates enough speed, a multiple of 65,536 in the game's internal units, the position arithmetic overflows, and Mario appears to teleport to a distant region of the coordinate grid. These regions are called parallel universes (PUs). Discrete, repeating copies of the game's spatial layout, offset from each other at regular integer intervals.

The sheer amount of time, effort, and skill that went into performing modular arithmetic inside a 1996 Nintendo 64 game just to obtain a star with the least amount of A presses possible captivated millions, including myself.

It's one of many videos from Scott Buchanan, known online as pannenkoek2012, who has provided hours of specialized, technical explanations. The viral response of the above video in particular turned out to be too much for Pannen—the amount of memes, surface-level engagement, and response from people who did not understand the video at all and could only make jokes. Though most of it was light-hearted, it was demoralizing. It took several years before Pannen would make another commentated technical explanation video. I'm very happy he has, and I think I speak for a lot of people when I say I have only awe and admiration for him and the many people who provide contributions to the efforts behind the scenes.

But Pannen is not the only video game technical specialist (I don't think I have a better term for this)—a scholarship for systems never meant to be studied. I am going to happily share and gush over my favourites:

  • Hunter R. has dozens of videos analyzing the Animal Crossing series in technical detail. Including going over lost content, arbitrary code execution, and how to intentionally crash the game. His deep dive on how villagers read letters shows how much heart developers put into the game.
  • Marticore has fantastic deep-dives on The Sims 2, specifically going over how the game processes genetics (family trees are literally models of heredity), sim creation, and many of the other bugs and quirks of the game.
  • TheZZAZZGlitch has been making videos on the mechanics of early-gen Pokémon games for fifteen years. Most people are aware of the infamous MissingNo, but there is so much you can do with glitched items, it's mind-boggling. They also host a fun April Fools' event yearly.
  • Stryder7x has played more Paper Mario than probably anybody else, with titles like "Baking a Cake for 4.5 Years is Perfectly Acceptable" and "Hitting this Block for 416 Years Crashes Paper Mario". They sadly became inactive years ago after controversy, but their channel still has over 150 videos on the game.

What connects all of these creators, I think, is a sun-bright curiosity towards the things they love.

All of these creators encounter a system—a game, a piece of software, a set of rules—and feel compelled to understand rather than just complete. It's devotional, and the analysis becomes exegesis. Cartographers mapping the edges of made worlds. And they find mathematics at those edges the world's makers were often not even aware of.

PART TWO: Balatro and Big Numbers

I want to switch gears here and talk about one of the only games that I have hundreds of hours in. Balatro. The game is described, correctly but insufficiently, as "a poker-themed roguelike deck-building game developed by anonymous solo developer LocalThunk."

The premise of the game is incredibly simple: you play cards, they score points (by chips and multiplication), you add Jokers which will increase score if certain conditions are met.

Numbers go up. The further you get, the bigger the numbers you have to score get. That's all there is to it. This video is wonderful in describing how the game works.

Unsurprisingly, a game about numbers is actually a game about maths. Now, I could go into the weeds on how you manage to score so absurdly high, but that's a topic for another time. You build and optimize and stack effects, chaining and chasing numbers escalating from hundreds to thousands to millions to alphabetical letters.

If this is about scoring the largest number, naturally there's the question of "is there a limit?" In this game, yes.

In the base game, the maximum score Balatro can register is approximately 1.803×103081.803 \times 10^{308}. This is the largest number a standard 64-bit floating-point value can store, the IEEE 754 double-precision maximum:

1.7976931348623157×103081.7976931348623157 \times 10^{308}

In context, there are an estimated 108010^{80} atoms in the observable universe. Balatro's maximum score exceeds that number raised to roughly the fourth power. Already, it is big in the way that makes the word big stop meaning anything.

But this is just the beginning. What I want to talk about is big numbers (and finally have an excuse for using the LaTeX plugin on my blog).

A Ladder of Incomprehension

Mathematics has a history of building new tools to be able to handle what previous tools couldn't.

When numbers grew too large to write out digit by digit, we have scientific notation. 1030810^{308} is legible where 1 followed by 308 zeros is not, though both are equally unimaginable to actually hold in your head.

When exponents grew unwieldy, we invented power towers. This is called tetration, the fourth hyperoperation, after addition, multiplication, and exponentiation:

na=aaan copies{}^n a = \underbrace{a^{a^{\cdot^{\cdot^{\cdot^a}}}}}_{n \text{ copies}}

So, 410{}^4 10 means a tower of four tens:

410=10101010{}^4 10 = 10^{10^{10^{10}}}

This is an absurd number. 101010^{10} is ten billion. 10101010^{10^{10}} is 10 raised to the power of ten billion. 1010101010^{10^{10^{10}}} is 10 raised to the power of that. You cannot picture this. You cannot usefully approximate it. Balatro's maximum score, 1030810^{308}, is smaller than 410{}^4 10 the way a grain of sand is smaller than the solar system. We have already, in four easy steps, left the addressable universe behind.

But, of course, mathematicians needed to go further. So Donald Knuth invented up-arrow notation.

Knuth's Up-Arrow Notation

A single up-arrow is exponentiation:

1010=1010=10,000,000,00010 \uparrow 10 = 10^{10} = 10{,}000{,}000{,}000

Two arrows is tetration, the power tower:

1010=10101010 tens10 \uparrow\uparrow 10 = \underbrace{10^{10^{\cdot^{\cdot^{\cdot^{10}}}}}}_{10 \text{ tens}}

Three arrows is pentation. Where double-arrow builds a tower, triple-arrow builds a tower of towers:

103=10(1010)10 \uparrow\uparrow\uparrow 3 = 10 \uparrow\uparrow (10 \uparrow\uparrow 10)

That inner piece, 101010 \uparrow\uparrow 10, is already the power tower of ten tens we just looked at. 10310 \uparrow\uparrow\uparrow 3 uses that as the height of a new power tower. And 101010 \uparrow\uparrow\uparrow 10 does this ten times over, each step wrapping the previous computation into a single input.

You stop asking how big the number is, you begin asking how the number is built. Each additional arrow is not merely a new rung on the ladder, it collapses the entire previous ladder into a single step of the next one.

Conway Chained Arrow Notation

Even Knuth's arrows eventually hit their limits as notation. Writing expressions like 3g6333 \underbrace{\uparrow\uparrow\cdots\uparrow}_{g_{63}} 3 gets unwieldy fast. John Horton Conway developed chained arrow notation as an extension:

abca \to b \to c

Here, aba \to b is just aba^b. But abca \to b \to c generates numbers that vastly exceed what any fixed number of Knuth arrows can express:

10101010 \to 10 \to 10

We are far beyond reasonable descriptors. Each link in the chain wraps the previous computation into a single operation of the next level. Conway chains, in a compact handful of symbols, gestures at numbers that would fill more pages with arrow notation than there are atoms in the universe to print them on.

Graham's Number

One of the most famous big numbers is Graham's number, emerging from a real mathematical proof, a result in Ramsey theory which is a branch of combinatorics concerned with inevitable structure in large systems. (That string of words makes sense, right?) Ronald Graham needed an upper bound for a problem about high-dimensional hypercubes. The upper bound he found was a specific, well-defined, finite number. That number now bears his name.

It is built like this. Define:

g1=34 arrows3g_1 = 3 \underbrace{\uparrow\uparrow\uparrow\uparrow}_{4 \text{ arrows}} 3

That first step is already so large that it contains more digits than the number of atoms in the observable universe. Now define:

g2=3g1 arrows3g_2 = 3 \underbrace{\uparrow \cdots \uparrow}_{g_1 \text{ arrows}} 3

You take g1g_1—an already incomprehensible value—and use it as the number of arrows between the two 3s. Then:

g3=3g2 arrows3g_3 = 3 \underbrace{\uparrow \cdots \uparrow}_{g_2 \text{ arrows}} 3

Each step uses the previous number as the arrow count. Repeat sixty-four times:

G=g64G = g_{64}

Graham's number is g64g_{64}

We know the last digit of Graham's number, it's 7. We can compute that, but we cannot compute the first digit, nor the amount of digits in the number.

We cannot say anything legible about its magnitude. The number is a process, not a quantity. A procedure for generating a specific, finite thing that no human mind could ever hold.

TREE(3)

Graham's number, vast beyond expression, is essentially nothing compared to TREE(3). This "number" (I feel as though we're using that word very loosely at this point) comes from a problem in combinatorics and graph theory, Kruskal's Tree Theorem. The methodology behind this number concerns sequences of labelled trees obeying certain rules, blatantly beyond the scope of this blog post and my brain.

TREE(1) = 1 and TREE(2) = 3. The function barely does anything at first, but then:

TREE(3)\text{TREE}(3)

This has been proven to be finite—a specific number. But the magnitude so completely dwarfs Graham's number that saying "Graham's number is smaller" is the same as saying "a single hydrogen atom is smaller than the observable universe."

The growth rate of TREE(n) is related to functions that, by the standards of the mathematical universe, grow so fast that they are essentially incomprehensible even in terms of tower notation. Graham's number, for all its enormity, is expressible using a finite tower of arrow operations starting from 3. TREE(3) is not expressible this way. We currently have no way to express this number in any notation that fits in our universe.

And I am so full of wonder and awe encountering something that cannot be understood. The number is proven real and finite and specific, but it is not fit for the consumption of the human mind.

The Cryptid Mod

Returning back to Balatro, there's something called the Cryptid mod (and the ecosystem of mods built around it), which is a content modification intentionally designed to disregard game balance. While the original game is challenging and reasonable in its scaling, Cryptid has multipliers stacked on multipliers, effects compounding effects, and the game becomes a machine generating numbers it cannot fully represent.

The base game caps at 1.80×10308\approx 1.80 \times 10^{308}, equal to 21024(1253)2^{1024}(1 - 2^{-53}), the largest value representable in IEEE 754 double-precision floating point. Cryptid, running atop the Talisman score-extension mod, removes those guardrails. Scores grow indefinitely, bound only by the run ending, the computer crashing, or numerical precision collapsing into undefined behaviour.

When Balatro's normal floating-point numbers run out, Talisman switches notation. Regular scientific notation 1e6=1061\text{e}6 = 10^6 gives way to stacked exponents: once the exponent itself grows too large to write plainly, you prepend another ee. Each ee is one more application of x10xx \mapsto 10^x:

e6=106\text{e}6 = 10^6

ee6=10106=101,000,000\text{ee}6 = 10^{10^6} = 10^{1{,}000{,}000}

eee6=1010106\text{eee}6 = 10^{10^{10^6}}

You'll notice what's happening here. Each additional ee prepended is another layer of exponentiation, evaluated right to left. The same associativity as a power tower, for as we've gone over already, the operation underlying tetration is iterated exponentiation. The same operation we explored with Knuth arrows, now implemented in a card game mod!

Standard tetration na{}^n a builds a uniform tower. nn copies of the same base aa. In Knuth arrow notation, for example, 310=103=101010{}^3 10 = 10 \uparrow\uparrow 3 = 10^{10^{10}}. The ee-notation works differently: the base is always 1010, but the seed is whatever follows the string of e's So eee6\text{eee}6 is a height-3 power tower in base 1010 with the innermost value being 66 rather than 1010 itself:

eee6=1010106compare: 310=101010\text{eee}6 = 10^{10^{10^6}} \qquad \text{compare: } {}^3 10 = 10^{10^{10}}

Since 6<10<1066 < 10 < 10^6, we have 310<eee6<410{}^3 10 < \text{eee}6 < {}^4 10. The ee-notation sits between the third and fourth levels of the base-1010 tetration ladder, and can't be expressed as na{}^n a for any single clean base. What it is, exactly, is one more application of x10xx \mapsto 10^x applied to ee6\text{ee}6. The structure is tetration; the seed is just not 1010.

Cryptid runs have produced values like eee ⁣(1.353×1021)\text{eee}\!\left(1.353 \times 10^{21}\right). Expressed formally:

eee ⁣(1.353×1021)=1010101.353×1021\text{eee}\!\left(1.353 \times 10^{21}\right) = 10^{10^{10^{1.353 \times 10^{21}}}}

Another ee can always be prepended. The only real ceilings here are the run ending, a hardware crash, or the display logic itself giving up. As long as the build keeps scaling, the notation keeps growing.

A roguelike poker card game has, through the accretion of mods and optimization and community obsession, become a practical implementation of mathematics. Of big numbers and tetration.

Super Mario 64 didn't know it had parallel universes. Balatro wasn't designed for tetration. The mathematics was always there, latent in the rules, waiting for someone to push hard enough to find it.

Why This Matters

Here's the journey that we just took:

When this breaks down... ...we need this
Too many digits to write Scientific notation
Exponents too large to express Power towers (tetration)
Towers too tall to write Knuth's up-arrows (\uparrow)
Arrows too unwieldy Conway chains (\to)
Everything too weak New systems, endlessly

Each notation system is used because the previous one broke. The numbers themselves didn't change-TREE(3) was always there. Our tools for pointing at them had to be created. Mathematics is a history of notation catching up to the infinite.

I've learned that the question of how big can a number get? is the wrong question. Graham's number and TREE(3) are answers to the question "how big can the structure of a number get?" And the answer always is: bigger than we can ask.

I hope this blog post will change at least one person's mind about math—that I did a good enough job of showing an example of how interesting and fascinating this field of study truly is. That the video games we play are not just containers of computer science but, in some rare beautiful cases, opportunities for us to tinker and escape the container ourselves.

Comments

To comment, please sign in with your website:

How it works: Your website needs to support IndieAuth. GitHub profiles work out of the box. You can also use IndieAuth.com to authenticate via GitLab, Codeberg, email, or PGP. Setup instructions.

No comments yet. Be the first to share your thoughts!


Webmentions

No webmentions yet. Be the first to send one!


Related Posts

↑ TOP