Let the Games Begin

Katie Steckles

Image credits: J Laso from Pixabay

We are currently in the midst of the Olympic and Paralympic games – two epic events of world-class sport and competition, taking place in Paris and pitting the world’s sporting heroes against each other (with plenty of wonderful statistics and physics along the way). But if you prefer your games to be more sedate, I can recommend a game which I have played for many years – and that will go on for a lot longer than seventeen days if you want it to!

Non-Olympic Games

When I was a child, I often played card games with my grandad – he taught me many games he knew, including one which I enjoyed a lot, called “Beggar-my-neighbour” (otherwise known by a variety of interesting names, including “Strip Jack Naked” and “Beat Your Neighbour Out Of Doors”). The game is fairly old – having been played since around the 1840s, it is even featured as a children’s game in Charles Dickens’s novel Great Expectations. The game involves splitting a deck of cards between all the players, then taking it in turns to play on to a central pile.

Certain cards in the game – picture cards and aces – have a “penalty” associated with them. A jack demands a penalty of one card, while a queen is two, a king is three and an ace is four. If one of the players puts down one of these cards, the following player must then play that many cards in response; if they do so, and all the cards they play are just numbered cards rather than being penalty cards, the player who demanded the penalty wins that trick, and picks up the whole pile played so far.

But if during that penalty countdown, the player plays another penalty card, this passes the penalty on to the next player – the existing count is abandoned and a new one started for the new penalty card. In the two-player version of the game in particular, this can lead to some high-octane back-and-forth rallies, in which players keep deflecting the penalty back on to each other until finally someone runs out of luck. The more times you pick up cards, the larger your hand will be – and the winner is the person who eventually ends up holding all 52 cards of the deck.

When I played this game as a child, I enjoyed the ebb and flow of play; after calm stretches of number cards, the sudden excitement of a penalty challenge and its resolution was a little rush. I was very deeply convinced that not only was this my favourite game, but that also I was definitely very good at it.

Of course, looking back on this as an adult, I can say for sure that I definitely was not, in any meaningful way, very good at this game. Since the actions taken by each player are entirely determined by the ordering of the cards in the deck once the game starts, it is actually fully known from the start exactly how the game will go, and who will win. It is, in essence, a zero-player game (much like the ones I wrote about previously) – unless you count the person who initially shuffles the cards, who is the only one who has any influence over the outcome of the game.

Determined to win

Now that I can understand this game more logically and analyse it mathematically, I am aware there is a layer to it that my childhood self may not have appreciated. Studying deterministic systems is common practice in mathematics, and trying to determine or predict which initial states will lead to which results can be an interesting puzzle.

Since each card turned over determines exactly what happens next (the other player puts down one or more cards, or someone picks up) the ordering can be fed into an algorithm to play through the resulting game. For example, given an initial deal of the deck, it should be possible to know not only which player will win, but exactly how long it will take them to win – how many cards will be played before someone runs out of cards? 

This in itself presents an interesting set of further questions; for example, what is the average length of a game given a random deal? And how long is it possible for a game to be? For years, mathematicians tinkering with the game have wondered about this last question, and challenged each other to find initial deck orderings which result in longer and longer games. Given the immense number of possible deals to study (calculated using combinatorics, which I’ve written about here previously) the chances of finding one with a particular property are small, unless you have a clever approach.

Richard Mann, a mathematician at the University of Leeds, was one of a team who held the record for the longest possible game from around July 2007 to May 2012 – lasting for 1007 tricks and involving the playing of 7157 cards. The deck orderings are specified in terms of only the picture cards, since the value of the non-penalty cards does not affect the game at all. Their game was given by the ordering:

Player 1: K-KK----K-A-----JAA--Q--J-
Player 2: ---Q---Q-J-----J------AQ--

Once this record was broken, and people continued to find new longer games, Mann set up a website logging all known Beggar-my-neighbour records to serve as a repository for the search. But some people wanted to know more: would it be possible to find an infinite game?

The question of whether this is possible – to have a game which will at some point reach a loop and continue with two players playing the same cards in the same order for the rest of time – was one that stumped the mathematicians working on this: an open question.

Of course, finding the answer would not result in awards or accolades, or unlock whole new areas of research. The mathematician John Conway described the problem as an “anti-Hilbert problem”; by contrast with the Hilbert problems (major open questions mathematicians were challenged to seek answers to), this was one which “emphatically should not drive mathematical research.” Michael Kleber, who himself held the record for the longest game at one point, said of his achievement, “This is almost entirely uninteresting.” Others have wisely stated, “This question has definitely not plagued scientists for millennia.”

Game Over?

Nonetheless – the lure of an unsolved puzzle is always going to draw some people to work on it. And until recently, it remained unsolved – longer and longer games were found, including one with a monster 1164 tricks, involving playing 8344 cards (taking over two hours to play, at one card per second). But this still would not satisfy those looking for a game which loops.

And then, finally, earlier this year, it happened. In February 2024, BMN enthusiast Brayden Casella shared a deal which led to an infinite game:

Player 1: ---K---Q-KQAJ-----AAJ--J--
Player 2: ----------Q----KQ-J-----KA

The first 34 cards played are not part of the loop, but after 474 turns and 66 tricks (and after 33,034 cards have been played), the game goes back to the state it was in after the 34th card was played, and we are trapped in an infinite loop. The loop reached in this game can be reached from any one of 30 distinct starting hands, but once you are in it, there is no escape.

The finding has been published as a paper on the ArXiV, and if you want to see the loop for yourself, chess and puzzle enthusiasts John and Sue Beasley have published this PDF listing the tricks as they are played. You can also test it for yourself – Richard Mann’s website links to BeggarMyPython, a script by Matt Mayer (the source of my final quote above) which can be used to run and test games.

And if you would like to just watch the action slowly unfold, there is a Mastodon bot which is posting the newly discovered infinite game as a play-by-play, one turn every three hours – as I write, an exciting scuffle has just taken place in which one player picks up nine cards. It is tense, not knowing who will win (although the answer is: Nobody will win, as the game will go on forever).

So, if you would like to play a game that has a tiny chance of continuing for the whole of the rest of time – so far, only a handful of deals with this property have been discovered, but who knows how many more are out there – why not try a game of Beggar-my-neighbour? You might even find you are as good at it as I am!

The post Let the Games Begin originally appeared on the HLFF SciLogs blog.