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 \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 \times 10^{308}$$

In context, there are an estimated $10^{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. Beyond our comprehension. Tetration, Knuth's up-arrows, Conway chains, Graham's number, TREE(3) (and I finally have an excuse to use 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. $10^{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:

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

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

$${}^4 10 = 10^{10^{10^{10}}}$$

This is an absurd number. $10^{10}$ is ten billion. $10^{10^{10}}$ is 10 raised to the power of ten billion. $10^{10^{10^{10}}}$ is 10 raised to the power of that. You cannot picture this. You cannot usefully approximate it. Balatro's maximum score, $10^{308}$, is smaller than ${}^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:

$$10 \uparrow 10 = 10^{10} = 10{,}000{,}000{,}000$$

Two arrows is tetration, the power tower:

$$10 \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:

$$10 \uparrow\uparrow\uparrow 3 = 10 \uparrow\uparrow (10 \uparrow\uparrow 10)$$

That inner piece, $10 \uparrow\uparrow 10$, is already the power tower of ten tens we just looked at. $10 \uparrow\uparrow\uparrow 3$ uses that as the height of a new power tower. And $10 \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 $3 \underbrace{\uparrow\uparrow\cdots\uparrow}{g{63}} 3$ gets unwieldy fast. John Horton Conway developed chained arrow notation as an extension:

$$a \to b \to c$$

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

$$10 \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:

$$g_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:

$$g_2 = 3 \underbrace{\uparrow \cdots \uparrow}_{g_1 \text{ arrows}} 3$$

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

$$g_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 = g_{64}$$

Graham's number is $g_{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:

$$\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 $\approx 1.80 \times 10^{308}$, equal to $2^{1024}(1 - 2^{-53})$, the largest value representable in IEEE 754 double-precision floating point. Cryptid, running atop the Talisman score-extension mod, raises those guardrails dramatically. In its OmegaNum mode, Talisman replaces the game's native floating-point arithmetic with a purpose-built big-number library, pushing the score ceiling from $\approx 10^{308}$ to approximately $10 \uparrow\uparrow 1000$—a power tower of tens 1000 stories high. (Left on its default BigNum setting, the cap is a comparatively modest $\text{ee}308$; OmegaNum is where things get strange.)

$$10 \uparrow\uparrow 1000 ;=; {}^{1000}10$$

$${}^{1000}10 ;=; \underbrace{10^{10^{\cdot^{\cdot^{\cdot^{10}}}}}}_{1000 \text{ copies}}$$

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

$$\text{e}6 = 10^6$$ $$\text{ee}6 = 10^{10^6} = 10^{1{,}000{,}000}$$ $$\text{eee}6 = 10^{10^{10^6}}$$

You'll notice what's happening here. Each additional $e$ 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 ${}^n a$ builds a uniform tower. $n$ copies of the same base $a$. In Knuth arrow notation, for example, ${}^3 10 = 10 \uparrow\uparrow 3 = 10^{10^{10}}$. The $e$-notation works differently: the base is always $10$, but the seed is whatever follows the string of e's So $\text{eee}6$ is a height-3 power tower in base $10$ with the innermost value being $6$ rather than $10$ itself:

$$\text{eee}6 = 10^{10^{10^6}} \qquad \text{compare: } {}^3 10 = 10^{10^{10}}$$

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

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

$$\text{eee}!\left(1.353 \times 10^{21}\right) = 10^{10^{10^{1.353 \times 10^{21}}}}$$

Another $e$ can always be prepended—up to the ceiling. At $10 \uparrow\uparrow 1000$, the hard limit of the OmegaNum library underpinning Talisman, there is nowhere left to go. In practice, performance issues from the sheer volume of calculations tend to end a run long before that ceiling is ever reached. But as long as the build keeps scaling and the machine keeps running, the notation keeps growing.

To place that ceiling against the numbers we covered earlier: $10 \uparrow\uparrow 1000$ lives in the tetration band—double arrows only, no pentation, no triple arrows. Even $3 \uparrow\uparrow\uparrow 3$, a tower of over seven trillion threes, already dwarfs it. $g_1$, the very first step of Graham's construction, is incomprehensibly larger still. The ceiling of the most ambitious Balatro build in existence doesn't clear the first rung of the ladder we built to describe it.

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. What I do know is that these are numbers that would absolutely require many parallel universes to write out in full.

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.

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.

UPDATE: If you want to learn more about the Cryptid mod from an actual Balatro modder, check out this post by candyether.space!