~/imallett (Ian Mallett)

Project "Finger Game Oracle":

The finger game was introduced to me by my sister. It appears to be a simple grade-school game, related to Chopsticks. Happily, this variation is not a forced win for either side.

The rules are very simple. Each player has two hands, each with some number of fingers extended (begin with one on each). Players take turns. On your turn, you tap one of the opponent's hands with either one of yours. The opponent then adds the number of fingers on your hand to the number of fingers on his hand, modulo 5. When a hand gets 0 fingers, it is removed from future play (it can neither tap nor be tapped). The goal is to eliminate both hands of the opponent. You are not permitted to move fingers between hands.

I invented my own notation to make descriptions less clumsy. Here are some simple examples:

• [2.3]|(1.4)
Player 1 has 2 fingers on one hand and 3 on the other. Player 2 has 1 finger on one hand and 4 on the other. The braces indicate that it is player 1's turn. The periods indicate that the game outcome is unknown.
• (2$3)|[0 1] Player 1 has 2 fingers on one hand and 3 on the other. Player 2 has no fingers on one hand (and therefore this hand is eliminated from play) and 1 on the other. It is player 2's turn. The dollar/space symbols indicate that player 1 has a winning strategy. Notice that the order of the numbers in the braces doesn't matter. By (my) convention, the smaller number comes first, and all permuations are treated the same. An example game: 1. [1.1]|(1.1) 2. (1.1)|[1.2] 3. [1$3]|(1.2)
4. (1 3)|[2$2] 5. [0 1]|(2$2)
6. (0 1)|[2$3] 7. [0 3]|(2$3)
8. (0 3)|[1$2] 9. [0 0]|(1$2)
Neither player played optimally. The first two states (the same for any game) do not have a determined winner. However, player 2 makes an error, giving player 1 a winning strategy on state 3 (the correct move would have been to instead move to state [1.2]|(1.2)). However, player 1 immediately makes an error of his own, giving a winning stategy to player 2. The game ends when player 2 eliminates both hands of player 1.

This program implements an oracle for this game (that is, this game is now solved, and this is its (strong) solution). Essentially, it works by creating and filling a graph of the (relatively small) state space. A good number of possible states are actually unreachable as well. To use the oracle, start at the left and then follow the arrows. Usually they will go forward, but an occasional one will go backward (this is unavoidable; the state graph is not acyclic).

 Version 1.0.0

Source:
.zip file (2K)
Source Requirements:

 Python (Tested versions: 2.6.6, 2.7.3, 2.7.11, 3.2.5, 3.3.0, 3.3.5, 3.4.4, 3.5.1) PyGame

Screenshots: