Nim
The game Zei never loses.
Pick one pile. Take at least one circle. Take the last one to win. Learn Zei’s trick from Snowmoon, then duel for .
Take the last circle
Two players take turns at one board: four boxes of circles. A game takes about a minute.
- Pick one boxOn your turn, choose any box that still has circles in it.
- Take circles from itTap one circle or several, but only in that one box, then press Take. Now it is the other player’s turn.
- Take the last one to winWhoever takes the very last circle on the board wins.
A children’s game in the middle of a war
The game comes straight out of Snowmoon, the novel Vitalik Buterin published under the GPL v3. The book never gives it a name: on the tabletop screen, “there were four piles of circles.” We use its mathematical name, Nim. In chapter 25, Zei, a Minpentai player from Dzego, uses it to teach Gladias of Veridia’s Order of Steering how this war can be won.
- The book
Snowmoon
A 32-chapter novel about Veridia, a rich and peaceful democracy, and Dzego, a country rebuilding itself in secret, as the Arctic Empire moves against them both.
- Chapters 15–20
The Arctics move first
The Arctic Empire annexes Redshire, then invades Northglade. Its agents have already worked their way into Veridia’s institutions.
- Chapter 25 · Pafogai Du, 3724 Frostime 1
Four piles of circles
Gladias has come to Dzego for help. Zei sits him at a tabletop screen with piles of 3, 4, 10 and 13 circles and lets him move first. Gladias loses. Then Zei explains why: write the piles in binary and XOR them. If the result is zero, whoever moves now loses.
- The question
First player or second player?
Zei turns the game into a question about the war: “Is the fight for Veridia a first-player-favoring or a second-player-favoring game?”
Gladias
Careful and curious. He has never seen the trick and loses the first game, as you probably will.
Zei
Grew up playing this before Minpentai existed. Never misses the move that sets the XOR sum back to zero.
“…as long as you get to choose if you’re going first or second, you will always win.”
Zei, chapter 25That line is the whole design of the duel: the choice is what you bid for.
Learn it the way Gladias did
Chapter 25 is free and needs no wallet. Duels are staked in and settled by the NimDuel contract on Ethereum.
You bid for the choice, not for luck
Anyone can learn the XOR trick, and a bot never makes a mistake. With perfect play, whoever chooses the seat always wins. So the duel puts that choice up for auction.
- StakeBoth players put in the same stake. The pot is twice that.
- BoardFour random piles of 1 to 15 circles appear.
- Sealed bidsEach player bids in secret, up to the stake, for the right to choose.
- ChooseThe higher bid takes the choice and picks first or second.
- Play & settleLast circle wins. The chooser pays the bid only if the chooser wins.
| Stake 10,000 each · you bid 6,000, they bid 4,000 | You receive | They receive | Your net |
|---|---|---|---|
| You hold the choice and win | 14,000 | 6,000 | +4,000 |
| You hold the choice and lose | 0 | 20,000 | −10,000 |
Who converts the choice
Every settled duel writes the result on-chain: wins, losses and net . The board is rebuilt from those records, so nobody can edit it. Seasons last 28 days; the all-time board never resets.
| # | Player | Won | Lost | Win rate | Net |
|---|
Every step is a transaction
One contract holds the stakes, checks the sealed bids, records each move, pays out the pot and keeps the leaderboard. Nobody has to trust a server.
createDuel(stake)You open a duel and lock your stake in the contract.joinDuel()Your opponent matches it. The board is drawn from the block’s randomness.commitBid(hash)Each player sends keccak256(bid, salt), so nobody can see the bid.revealBid(bid, salt)Both bids open. The contract checks them and names the chooser.chooseSeat(first | second)The chooser picks who moves first.move(box, count)One transaction per move, with a time limit per turn.settle()The contract pays out the pot by the rule above.