Play Tic-Tac-Toe Using a Fruit Fly's Neural Network Simulation
Job to be done: Simulate a fruit fly's neural network to play Tic-Tac-Toe
🇳🇬 Ways to use this in Nigeria
Ideas to get you started, adapt to your situation.
- Student
For your final year project (FYP) at UNILAG, simulate a fruit fly's neural network to demonstrate how biological systems can be modeled for AI decision-making in a game like Tic-Tac-Toe.
What this is, in plain English
This workflow uses a detailed map of a fruit fly’s nervous system, called a connectome, to simulate playing the game Tic-Tac-Toe. Think of the connectome as a complete blueprint of all the brain cells (neurons) in a fruit fly and how they are connected to each other. The author took a small part of this blueprint and used it to create a program that can play Tic-Tac-Toe.
This is an advanced concept because it bridges neuroscience data with game theory. It’s not a simple copy-paste recipe because the exact steps involve running Python code that interacts with a large biological database and performs complex simulations. The specific code and how it’s set up are detailed in a GitHub repository, which can change as the project evolves.
What you can use it for
- Explore biological data: Understand how real-world biological data, like neural connections, can be used to model simple behaviors or games.
- Learn about AI in research: See an example of how AI and computational methods are applied to complex scientific problems, like understanding brain function.
- Experiment with game AI: Investigate how different decision-making processes, like a biological circuit versus a programmed algorithm (minimax), perform in a game.
- Visualize neural pathways: Potentially adapt the code to visualize how signals might flow through specific parts of a neural network.
Tools you need
- Python (free): A popular programming language used for many AI and data science tasks.
- neuprint-python (free): A Python library to access and work with neuPrint, a database of neural connectomes.
- networkx (free): A Python library for creating, manipulating, and studying the structure, dynamics, and functions of complex networks.
- pandas (free): A Python library that provides easy-to-use data structures and data analysis tools.
How it actually works
- Get a neuPrint token: You will need to sign up for a free neuPrint token to access the fruit fly connectome data.
- Set up your environment: Install Python and the required libraries (neuprint-python, networkx, pandas). The project’s README file on GitHub provides specific instructions for this setup.
- Run the simulation pipeline: Execute the provided Python scripts. This will build the neural circuit model from the connectome data.
- Play the game: Once the circuit is built, you can play Tic-Tac-Toe from your terminal. The program will use the simulated fly brain to make moves, often with a safety net from a minimax algorithm.
- Explore variations: The author suggests trying
unbeatable=Falseto see the raw circuit play without the minimax backup, which can lead to it making mistakes.
The exact commands and code are available in the linked GitHub repository, and the README file is the primary source for setup and execution details.
Words you’ll see, explained
- Connectome: A complete map of all the nerve cells (neurons) and their connections in an organism’s nervous system.
- Neuron: A nerve cell; the basic building block of the nervous system.
- Synapse: The junction between two nerve cells, consisting of a minute gap across which impulses pass by diffusion of a neurotransmitter.
- Neurotransmitter: A chemical substance that transmits nerve impulses across a synapse.
- Minimax: A decision-making algorithm used in artificial intelligence for turn-based games, aiming to find the optimal move.
- Signal flow: The movement of information or electrical/chemical signals through a network of neurons.
Original source
This workflow is based on a blog post by asyncinnovator, shared on DEV Community. It details how they connected a fruit fly’s neural network data to a Tic-Tac-Toe game, using Python and neuroscience databases to simulate brain activity for gameplay.
Notes & variations
- Do you even need this?: This is a highly specialized project for exploring the intersection of neuroscience and AI. For simply playing Tic-Tac-Toe, a basic programming approach or even a simple AI algorithm would be far easier.
- Free tier limits: All the core tools mentioned (Python, neuprint-python, networkx, pandas) are free and open-source. The main requirement is obtaining a free neuPrint token.
- Common pitfall: The mapping of fly neurons to Tic-Tac-Toe squares is an arbitrary choice made by the author. The raw fly circuit, without the minimax safety net, is not very good at playing the game and can easily lose. Understanding this distinction between the real biological data and the author’s game implementation is key.