The fly plays poker

Can a fixed fly circuit, read by a simple readout, learn when to bet, call and fold, and how close does it get to the best possible play?

Trained readout on fixed wiringFruit fly multisensory circuit (FlyWire)Train it yourself →Benchmark scores →
Loading 3D view…
Fly ·
livein your browser

What we measured

Real wiring, held out
0.01 chips per hand
Rewired, same degrees, held out
-0.02 chips per hand
Random wiring, held out
-0.02 chips per hand
Circuit silenced, held out
-0.02 chips per hand
Real wiring against the equilibrium player
0.000 chips per hand (0 is the best possible)
Measured with
scripts/gym-benchmark.ts: 12 generations of 16, same seed and budget for every circuit
Train it yourself
/train/gym-poker

What happens

Kuhn poker has three cards (jack, queen, king), one card for each player, an ante of one chip and one round of betting. It is small enough to be solved exactly, so every strategy has a known expected value.

The fly sees its card: the jack drives its LC4 neurons, the queen its LPLC2 neurons and the king its LPLC1 neurons. If the opponent has bet, the fly smells odour A (ORN DM1); if the opponent has checked, odour B (ORN DA2). This encoding is arbitrary; what matters is that it is fixed and that everything between senses and output is the real wiring.

A readout of 21 output neurons decides: positive means bet or call, negative means check or fold. Each episode asks the fly for its decision in all 12 situations (3 cards times 4 betting spots) and scores the exact expected chips per hand.

Training plays against two exploitable opponents, a bluffer and a calling station. The held out test is a third style the fly never met, a maniac who bets and calls almost everything. The benchmark also plays the equilibrium player, who cannot be beaten on average: 0 chips per hand is the best anyone can do against it, and betting only with the king already gets there.

What you see is the readout the benchmark trained on the real circuit, playing the held out setting. Switch the circuit to a rewired one to watch the same readout on wiring it was not trained for, or train your own in the training lab.

Inspired by: Kuhn (1950), A simplified two-person poker; Libratus and Pluribus for the poker AI that followed.

How the brain is wired to the world

The mapping is part of the experiment design. Everything between senses and motor output is the connectome.

Senses → neurons
  • Jack → LC4
  • Queen → LPLC2
  • King → LPLC1
  • Opponent bet → odour A (ORN DM1)
  • Opponent checked → odour B (ORN DA2)
Neurons → movement
  • Trained readout of 21 output neurons → bet or call (+), check or fold (−)

Dataset: Subcircuit of FlyWire v783: inputs HSE, HSN, HSS, LPLC1, LC4, LPLC2, LC16, ORN_DM1, ORN_DA2, sugar/water, bitter; outputs DNa01, DNa02, DNa03, DNb05, DNa11, DNp01, MDN, DNp09, DNg13, DNp03, CB0701; paths with at least 40 synapses per step. About this dataset

Run it locally

Every experiment can also use the local runner, which simulates the brain on your own computer. It is required for connectomes too large for a browser.

git clone https://github.com/berkeyc/connectome-lab.git
cd connectome-lab
pip install -r local/requirements.txt
python local/runner.py            # listens on ws://localhost:8765

Then choose “Local runner” in the player controls and press Restart. Your browser may ask for permission to connect to a local device.