Equilibrium: I Built the Numbers Game from Alice in Borderland
In episode six of Alice in Borderland, a group of strangers are led into a room and told to pick a number between 0 and 100. The target is 80% of the average of every number picked. Closest without going over wins. Everyone else loses a point. Lose ten points and a basin of acid over your head tips over.
No cards, no weapons, no physical challenge. Just a room full of people trying to out-think each other, and a slowly filling basin of acid to keep things honest.
I couldn't stop thinking about that game after watching it. Not because of the acid. Because of the math underneath it, which turns out to be a real thing economists have studied for almost a century.
So I built it. It's called Equilibrium, and you can play it here.
The Game Nobody Can Actually Solve
Here's the trick with "guess 80% of the average": there's a correct answer, but you can only find it by assuming everyone else is also trying to find it.
Say everyone picks randomly. The average lands around 50, so 80% of that is 40. A smart player picks 40. But if everyone is smart and picks 40, the average is now 40, and 80% of that is 32. So a smarter player picks 32. But if everyone reasons that far, the target drops again. And again.
Keep folding that logic in on itself forever and the only number that survives contact with infinitely rational opponents is 0. That's the Nash equilibrium: the point where nobody can do better by changing their guess alone.
Except nobody actually plays that way, because nobody in the room is infinitely rational, and everyone knows everyone else isn't either. This exact puzzle has a name in economics: the Keynesian Beauty Contest, first described by John Maynard Keynes in 1936 as a metaphor for the stock market. He compared it to a newspaper contest where you don't pick the face you find prettiest, you pick the face you think everyone else will vote prettiest. Real-world experiments running the "guess 2/3 of the average" version of this game tend to land somewhere in the low twenties, not zero, because most people stop reasoning after two or three levels of "I think that they think that I think."
That gap, between the theoretically correct answer and what actual humans do under pressure, is the entire game. It's not a math problem. It's a mind-reading problem wearing a math problem's clothes.
The show frames this as the King of Diamonds trial, one of the Diamond suit games that lean on logic and probability rather than physical skill. The escalating rules (duplicate guesses get disqualified, exact matches punish everyone else harder) exist specifically to punish players who try to camp on the theoretically "correct" answer once the group gets small.
Building the Room
I didn't want a single-player calculator that just tells you the Nash equilibrium and calls it a day. I wanted the actual experience: sitting across from opponents who are also trying to read you, in real time, with something on the line.
Equilibrium runs two modes. In single-player, you're up against four AI personas, each named and themed after the show's card-suit logic: The Gambler (clubs, easy), The Analyst (diamonds, normal), The Strategist (hearts, hard), and The Mastermind (spades, expert). Each one only remembers its own history of past rounds, the same way a real opponent would, it never gets to peek at what anyone else is guessing mid-round. Under the hood they track a rolling exponential average of past targets and lean on it more aggressively as the difficulty climbs, so The Mastermind plays noticeably more like someone who's actually been counting.
In multiplayer, you can host a room, hand out a join code, and mix up to ten real players with up to four AI opponents in the same game. There's a live scoreboard, elimination tracking as players cross the penalty threshold, and a global leaderboard tracking wins, streaks, and total games played across everyone who's played.
The whole thing is built on Next.js 15 and React 19, styled with Tailwind and shadcn/ui, with Framer Motion doing the heavy lifting on animation. One touch I'm fond of: while the AI opponents are "thinking," the UI streams their reasoning as staggered, monospace, cyan-glowing terminal text, which does a lot to sell the tension of watching four cold, calculating opponents decide your fate in real time.
The Part That Actually Broke My Brain
Building the game logic was the fun part. Building multiplayer that survives Vercel was the hard part.
Serverless functions don't stay warm. They spin up, do their job, and get recycled, sometimes between one request and the next. That's fine for a stateless API route. It's a disaster for a live multiplayer game, where you need to remember exactly who guessed what, in a room that might have people submitting guesses within milliseconds of each other, across function instances that have no memory of each other.
The naive approach, keeping game state in memory on the server, just doesn't work here. Instead, every game's state lives as a JSON blob in Postgres. Every guess submission reads it, updates it, and writes it back. Which introduces its own problem: what happens when two players in the same room submit their guess at the exact same moment, and both requests try to read-modify-write the same row?
Without protection, you get a classic race condition, one guess silently overwrites the other, and someone's number just vanishes from the round. The fix is SELECT ... FOR UPDATE, a row-level lock that forces the second request to wait until the first one finishes its read-modify-write cycle before it's allowed to touch the same row. It's not a clever trick, it's just correct, and correct was exactly what I needed for a game where all the scoring has to be provably fair. All scoring logic runs server-side for the same reason: if the client could compute its own results, this becomes a game about editing JavaScript in devtools instead of a game about reading people.
One Thing I'm Not Going to Fully Explain
There's a hidden mode in Equilibrium called assist mode. I'm not going to tell you exactly how it triggers, because figuring that out is more interesting than being told. What I'll say is this: it's deterministic, it's tied to the target from the previous round, and when it activates, it quietly nudges the AI opponents' guesses for one round so that a specific number becomes the target, all while their "thinking" text on screen keeps streaming like nothing unusual happened.
Consider that your one clue.
Play It
If you want to see whether you can out-think four opponents who are all trying to out-think each other trying to out-think you, Equilibrium is live here. The code is on GitHub if you want to see how the room-locking and the AI reasoning actually work under the hood.
Bring friends if you want the multiplayer version. Just don't expect them to stay friends once the acid basin starts filling.
If this was worth sharing, send it to someone on 𝕏 or LinkedIn. Got a question or a thought? Drop me a message , I read everything. If this was worth your time, .