Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

ChessFly: a fruit-fly brain map that plays chess

This notebook is a beginner introduction to one idea: a neural network can be built on a map of a real brain, then trained to do a task the animal never did.

You will play chess against ChessFly, a published model that uses the wiring of a female fruit fly’s brain. The game runs in your browser. This notebook does not contain the model. It opens a copy hosted on the internet.

By the end of this notebook, you will be able to:

  1. Say what a computer has to be given before it can choose a chess move.

  2. Tell training apart from inference.

  3. Follow one chess position through the ChessFly pipeline, from the board to a chosen move.

  4. Record what the hosted app actually does, and say what that game does not prove about a living fly.

You do not need a neuroscience background. You only need to know that chess is a game of two players, White and Black, taking turns moving pieces on an 8 by 8 board.

0. Warmup

In the cell directly below, answer this question: What would a computer need to learn before it could play chess?

Write whatever comes to mind. A list is fine.

Add your response here:

1. From brain wiring to an AI model

A connectome is a map of nerve cells and the connections among them. FlyWire published that map for one adult female fruit fly: 138,639 neurons and 15,091,983 connections.

A model architecture is the layout of a computer model: which parts read the input, which parts pass signals along, and which parts produce the output. ChessFly’s architecture follows the fly connectome. The connections stay where the map put them.

Trained weights are numbers learned from examples. In ChessFly, those numbers set how strongly each connection is used and how the chess board is translated into the network. The map says a connection exists. The weights say how strong it is.

Inference is using a finished model to answer a new question. The weights stay as they are. Playing a game is inference.

Here is the path of one chess position:

chess position
    → input encoder
    → connectome-based network
    → output decoder
    → move scores
    → search chooses a move

The input encoder turns the board into signals on the fly’s visual neurons. The connectome-based network passes those signals along the mapped connections for a few steps. The output decoder turns the resulting activity into a score for each legal move. Search then looks ahead at more than one possible future and picks the move the app will play.

From FlyWire: which neurons connect, and whether each connection is treated as excitatory or inhibitory.

Added by the developers: the encoder, the learned strengths, the decoder, the chess examples used in training, and the search that chooses the move you see.

ChessFly uses the female FlyWire brain. The assigned Google article is about a different map: one male fly’s brain and nerve cord. Do not treat those as the same animal or the same dataset.

Look at the diagram above. Which stage comes from the fly map, and which stages did people add?

Add your response here:

2. Load and use the real model

The next cell does one job. It opens the hosted ChessFly page inside this notebook. The chess calculations happen in your browser, not in the Python kernel.

You need an internet connection. The first time, the page downloads about 148 MB: the connectome and the trained weights. A progress box titled Loading the fly brain shows how many megabytes have arrived. When loading finishes, the Brain tab names the neuron count and the connection count, and names the backend: WebGPU or JS fallback.

WebGPU lets this app use your computer’s graphics processor for model calculations inside the browser. If the tab says JS or JS fallback, those same calculations ran in ordinary browser code instead. Write down which label you see. That label describes your computer. It is not a score for the chess move.

This notebook is not offline and not self-contained. If the box stays blank, open the same hosted app in a new tab: https://mlabonne-chessfly.static.hf.space/

You play White, the pieces closer to the label You. The model plays Black, the pieces closer to Drosophila. Playing uses the weights that were already trained. It does not change them, and it does not train the model.

How to make a move

Wait until the loading box closes.

  1. Click one of your white pieces.

  2. Click a highlighted square. That is a legal move. If the piece does not move, try a different highlighted square.

  3. Watch Drosophila. While the model is choosing, it shows thinking….

  4. The model’s reply is the black piece that moves when thinking stops.

  5. Open the Moves tab. It says You are white. Your move is on the left. The model’s reply is on the right. Copy those labels even if the chess words are unfamiliar. You do not need to decide whether a move was good.

The Brain tab is where the measurements are. Before a game it shows the neuron and connection counts, and the backend: WebGPU or JS. After a reply it shows how many positions were evaluated and a time in seconds. During thinking, the brain view can also say search, N positions in one pass. Record the backend. A time from one opening and a time from a different opening are not a fair speed comparison.

A bar beside the board is an evaluation display. You can notice it. You do not have to say who is winning.

New game, under the Brain / Moves / About tabs, clears the board so you can start again.

3. Guided experiments

Experiment A. Predict, then play

Pick one white piece and one square you might move it to. Before you click, write the reply you expect. A plain description is enough, such as “a black pawn moves forward.”

Then make the move. On the Moves tab, copy the model’s actual reply. On the Brain tab, write down WebGPU or JS.

Add your response here:

Experiment B. Does the reply repeat?

Press New game and play the same first move again. Copy the reply.

Press New game once more and play a different first move. Copy that reply.

Did the same opening get the same reply both times? A different reply would not, by itself, show that the model learned during gameplay. The trained numbers stay fixed. A new board is a new question, and the search can look through many positions before it chooses.

Add your response here:

Experiment C. Read the search measurement

After a reply, open the Brain tab. Find the line that reports how many positions were evaluated and how many seconds it took. Also note whether it says WebGPU or JS.

In your own words, what is that number counting? It is a measurement of that search, not a grade for the move. Two different openings are not a fair speed comparison.

Add your response here:

4. Record what you saw

The app is in a separate page inside the notebook. Python cannot see that page or click the board. The table below is only a place to type what you already read.

Edit the three rows. Game 1 and game 2 are the same opening, played from a new game each time. Game 3 is the different opening.

Use the Moves tab for the move labels. Use the Brain tab for the position count, the seconds, and WebGPU or JS. If you did not see a word, leave that text field as "". Keep a missing number as None. Enter a time you did see as a number, such as 4.0.

Then run the cell.

Manually recorded observations. Python did not read the board.
Loading...
Enter the actual reply for games 1 and 2, then run this cell again.
Keep missing times as None. Enter observed times as numbers, such as 4.0.

Look at games 1 and 2. Did the same opening get the same reply both times? If game 3 differed, what does that show about learning during the game?

Add your response here:

5. Training versus inference

Developers kept the wiring fixed and trained adjustable numbers using millions of chess examples. The examples were Stockfish-generated move and position evaluations for about 4.4 million Lichess positions. That training is already done. The model card is here: mlabonne/chessfly.

Optional note. The adjustable numbers are an encoder from the board onto visual neurons, a positive strength on each connection, a gain and a threshold for each neuron at each step, and a decoder. A gain rescales a neuron’s input. A threshold shifts when that neuron becomes active. The decoder reads central-brain neurons and descending neurons, which are cells with outputs toward the body, and turns their activity into move scores. You can play the game without memorizing this list.

The move on the board is not the decoder’s score alone. The hosted app runs a search on top of those scores. A whole level of that search is one batched pass through the brain. When you see positions evaluated, you are seeing that search, not a second round of training.

Which stage did you perform in this notebook: training or inference? What in the app tells you that?

Add your response here:

6. Reflection

Keep this short. You already have the game and the diagram to draw on. The About tab in the app also labels what is fixed and what was learned.

What did the developers add beyond the fly’s wiring to make chess possible?

Add your response here:

Does a chess game show that this model reproduces a living fly’s thinking or learning? What further evidence would that claim need?

Add your response here:

Sources

ChessFly model card, including the training description used above: mlabonne/chessfly. Hosted demo: the ChessFly Space. Direct board, if the box in this notebook stays blank: mlabonne-chessfly.static.hf.space.

The wiring is the FlyWire reconstruction of an adult female fruit fly brain. FlyWire’s public release is available under CC BY-NC 4.0. Papers named with the ChessFly connectome files: Shiu et al., Nature 2024 and Schlegel et al., Nature 2024.

The assigned Google article describes a different dataset, a male fly brain and nerve cord: Januszewski and Jain, Google Research Blog, 3 September 2026.

Chess labels used to train the published weights: Lichess/chess-position-evaluations, CC0.

The leg that moves the black pieces is a photograph by GorissM, CC BY-SA 2.0, via Wikimedia Commons.

References
  1. Shiu, P. K., Sterne, G. R., Spiller, N., Franconville, R., Sandoval, A., Zhou, J., Simha, N., Kang, C. H., Yu, S., Kim, J. S., Dorkenwald, S., Matsliah, A., Schlegel, P., Yu, S., McKellar, C. E., Sterling, A., Costa, M., Eichler, K., Bates, A. S., … Scott, K. (2024). A Drosophila computational brain model reveals sensorimotor processing. Nature, 634(8032), 210–219. 10.1038/s41586-024-07763-9
  2. Schlegel, P., Yin, Y., Bates, A. S., Dorkenwald, S., Eichler, K., Brooks, P., Han, D. S., Gkantia, M., dos Santos, M., Munnelly, E. J., Badalamente, G., Serratosa Capdevila, L., Sane, V. A., Fragniere, A. M. C., Kiassat, L., Pleijzier, M. W., Stürner, T., Tamimi, I. F. M., Dunne, C. R., … Jefferis, G. S. X. E. (2024). Whole-brain annotation and multi-connectome cell typing of Drosophila. Nature, 634(8032), 139–152. 10.1038/s41586-024-07686-5