Graph all the things

analyzing all the things you forgot to wonder about


interests: game theory, interactive visualizations

This is the game chopsticks, played according to one of my friend's rules, where each possible state is a vertex and each legal move is an edge (try clicking a node!):

I programmed the game and derived the data to make this visualization, including the layout. Each state is a_1, a_2 vs. b_1, b_2 where a_1, a_2 are the number of fingers on the current player's hands, and b_1, b_2 are the number of fingers on the opponent player's hands. The rules my friend goes by are as follows:

  • Each player starts with 1 finger on each of their 2 hands.
  • On each turn, you choose one of your hands to tap one of your opponent's hands. This will change the number of fingers on your hand. If yours has a and theirs has b, yours now has a + b mod 5. That is, add the two together, but 5 spills over to become 0, 6 spills over to become 1, and so forth. (Actually, my friend uses 10 instead of 5, but that game had too many states to make a pretty graph out of.) (I find this rule the most confusing, since I had always played the game where you cause your opponent "damage" rather than gaining "points" for yourself.)
  • You cannot tap or be tapped by a hand with 0 fingers.
  • You lose if you have no legal moves; this happens when your opponent has 0 on both hands.


We know that the game's end states are the ones in which you have no legal moves; these are marked in red on the graph. A state is defined as "losing" if all legal moves leave the opponent in a "winning" state, and defined as "winning" if there exists a legal move that leaves the opponent in a "losing" state. Everything that isn't "winning" or "losing" is considered a "draw". In a "draw", an optimal player will only make moves that leave their opponent in another "draw" state. In this way, optimal play involves cycling around the "draw" states forever.

There isn't much of a general rule in this variant's strategy, which is why the graph looks so beautiful. What I find most interesting is the fact that the second player can give the opponent a win on the first move (state 1,2 vs 1,3), and otherwise that opponent can give him the exact same win on the following move.