Recently I stayed at the farmhouse of a tight-knit family in eastern Montana, invited out to help and get acquainted at the wheat harvest. One afternoon, when the wheat was too green to cut after two nights of rain, the uncle who ran the farm sat me down at its big family dinner-table. Clearing away the newspapers, color-coded maps and scrawled lists of yield per field, he proposed a game. Here are three blue, five white and seven red poker chips. Oops—we’ll use a spice-jar lid for the seventh red one. You can take as many as you like of any one color; then I’ll do the same. We alternate until the chips are gone, and your object is to force me to take the last chip. We call it three-five-seven.
We started to play. I chose colors, quickly lost, and lost again a bit more slowly. “Is the trick that you have to go first?” I asked, but that wasn’t it. He let me start the next three times, to no avail. The rules were simple, the logic elusive. A couple of times, I saw the beginning of a sly smile on his face as I made what I had thought was a clever move. Without fail, a turn later the path to victory I had counted on evaporated, leaving me with no way to win even if three or four tokens were still on the table. As I learned the game, those checkmate moments became clear earlier. I began to see that there were patterns that were safe, and patterns that would always get me. I could win—if only I could pitch one of the second set of patterns at my opponent before he saw what I was up to.
My chances on that front were slim. I wasn’t the first person that favorite farmer uncle had snookered into playing and losing. Mischievously, he unrolled a long spool of stories that distracted me as I peered at the table, looking for a for-certain safe move. He had learned this game in math class as a child. On the long school bus ride home from town, he and his brother had worked out with a paper and pencil the best way to win. He’d held onto the game for entertainment in bars, a non-drinker playing for quarters against his tipsy coworkers after a day in California’s pistachio orchards. He brought it back to the farm as a grown man, perching his five-year-old nephew on his knee and coaching him invisibly to win against a visitor—a story the nephew in question grinned to be reminded of. After a good half hour of playing, I was able to scrape a win while they revisited fond family memories.
Later the farmer’s two nephews, brothers who nowadays mostly see each other there on the farm, sat across from each other to play the same game for the best of three. The boys—men now—spent summers here growing up, and now both work in software. Each played very deliberately, and they folded up games a turn or two before I could tell how the endgame would look. “Wait, who won that one?” I would ask. It was like watching two clever friends play chess, only easier on the attention span. “There are just a few positions that are safe, if your opponent doesn’t make a mistake,” explained the farmer’s second nephew, the one I had just met. He’d memorized more of those positions than his brother, so he had an edge.
Back at home in the city, I suggested a round of three-five-seven over beers at a game night with the farmer’s nephew. Our friend, a student of law, had gotten bored with losing at reflex games. The farmer’s nephew dug in his change jar for three pennies, five dimes, seven quarters. He dug out his store of patterns, too, and beat our law student friend handily. (The farmer’s nephew has his own private laundry room, so unlike at my apartment, quarters were plentiful).
The friend turned out to be a game theory aficionado, who was sure he recognized the game from somewhere—with phone in hand, he placed it as the ancient game of Nim. Sure enough, as the farmer’s other nephew had told me, there’s a table of positions you can use to win, available right there on the internet. There’s an algorithm, too, one that was published in 1901 and that Wikipedia informs me is a foundational piece of game theory. I, for one, wouldn’t want to run those computations on the fly. They involve converting the number of pieces in each heap into binary, then adding them without carrying the one (the farmer’s nephew calls this XOR logic) to calculate a nim-sum that informs your play.
Unfortunately having all this wealth of human knowledge at hand didn’t help our friend as much as he’d hoped. With the slight muddlement of someone who’s sure he would get this with just one less beer in him, he lost five times in a row to the farmer’s nephew. Walking back through the moves in a round he had just lost, he explained his thinking, trying to piece together where his algorithm had failed him. “So the nim-sum here is two,” he said, gesturing at five quarters, four dimes and three pennies. “That should be 0100 in binary, right?” The farmer’s nephew guffawed. He claimed that he was just winning empirically, citing just three patterns he’d memorized.
Meanwhile, with the whole universe on my phone and a pretzel stick in the other hand, I learned that some of the first computer games, the early and little-remebered Nimatron and the later, aptly named Nimrod, were developed to play this very game. It delights a nerdy corner of my heart—the same corner that devoured Cryptonomicon and was delighted to find out about cybernetics—to think that I sat absorbed in a game that someone had worked out a perfect logic-playing computer for back in the 1940s.
Our friend left that evening with a promise that, next time he was back, he’d beat the farmer’s nephew. I have yet to see it happen, but I don’t doubt his stubbornness, or his ability (when sober) to memorize a whole lot of patterns or a tricky algorithm. But I like the game better when you don’t quite know the rules yet. I like the slow build, the pattern-recognition engine of human cognition being brought to bear on a problem it hasn’t encountered before. Sure, there’s an app for that—you can practice on your commute! But the mystified grin on the face of someone playing the first time, for kicks, is worth the hassle of scrounging up fifteen game pieces in the right colors. I commend it to you. Make sure you have salty snacks close at hand.