Code for the computational model in Active Inferants: An Active Inference Framework for Ant Colony Behavior by Daniel Ari Friedman, Alec Tschantz, Maxwell J. D. Ramstead, Karl Friston, and Axel Constant.
The simulation models ant-colony foraging in a 40 × 40 T-maze. Individual simulated ants use a Markov decision process (MDP) to infer local pheromone observations, move through the environment, and deposit trail pheromone while returning from food. The repository contains the implementation used for the paper's in-silico experiments.
- Running the simulations — installation, commands, outputs, and runtime notes.
- Model overview — environment, observations, MDP components, and parameters.
- Contributing — scope, tests, and development guidance.
- Review TODO — documentation review findings and status.
The project requires Python 3.10 or later. From the repository root:
python3 -m venv .venv
.venv/bin/python -m pip install -e .
.venv/bin/python figure_1.pyWith uv, the same setup is uv sync --extra dev followed by uv run figure_1.py.
The figure scripts create an imgs/ directory containing PNG snapshots, GIFs, NumPy arrays, text summaries, and (for figure_1.py) path plots. Generated output is ignored by Git. The default experiments are intentionally larger runs; see Running the simulations for the smaller API smoke test and experiment details.
The test suite lives in tests/ and runs under pytest with a 90% coverage floor:
.venv/bin/python -m pip install -e ".[dev]"
.venv/bin/python -m pytest # full suite, ~99% coverage (90% floor)
.venv/bin/ruff check . # lintContinuous integration runs the same checks on every push and pull request (see .github/workflows/ci.yml).
For the published article:
Friedman DA, Tschantz A, Ramstead MJD, Friston K, Constant A (2021). Active Inferants: An Active Inference Framework for Ant Colony Behavior. Frontiers in Behavioral Neuroscience, 15, 647732. https://doi.org/10.3389/fnbeh.2021.647732
Machine-readable citation metadata is provided in CITATION.cff. The repository's source code is released under the MIT License. See LICENSE. The article is open access under the license specified by its publisher; consult the publication for the article's reuse terms.