A Python implementation of neuroevolution using NEAT (NeuroEvolution of Augmenting Topologies) to train agents for foraging behavior. The agents learn to navigate their environment, locate rewards, and return to their home base (similar to a bee leaving the hive and returning with pollen).
We try to mechanistically interpret the evolved networks to discern how this kind of navigation evolves.
These are early research experiments inspired by Dr. Gaby Maimon's Drosophila neural circuitry for navigation. I can't share all my commercial or research code since I'm often not the sole contributor but I strongly believe in openly sharing as much code as possible for research rather than falling into the common trap of defensiveness or gatekeeping seen among researchers.
The rest of this readme is AI-generated.
- Advanced agent navigation with vision cone system
- Spatial memory grid for environment tracking
- Energy management system
- Path integration for movement optimization
- Comprehensive visualization tools for network topology and agent behavior
- Automated checkpoint system for training progress
pip install neat-python numpy matplotlib graphvizmain.py- Core training loop and NEAT implementationagent.py- Agent class with navigation and sensor systemsconstants.py- Global configuration constantsutilities.py- Helper functions for visualization and data managementactivation_test.py- Interactive visualization of trained agents
python main.pyTraining progress is automatically saved in timestamped directories under runs/. Each run includes:
- Network topology visualizations
- Fitness statistics
- Agent simulation videos
- Saved genomes
python activation_test.pyModify the genome path in activation_test.py to load different trained agents:
genome_path = "runs/run_TIMESTAMP/genomes/champion_genome_genXXX.pkl"Agents are trained to:
- Explore efficiently using vision and spatial memory
- Locate and collect rewards
- Navigate back to home base without vision
- Optimize paths for energy efficiency
Energy costs are associated with:
- Movement (scaled with speed)
- Rotation (higher when carrying reward)
- Base operation
Key parameters in constants.py:
- Environment dimensions:
WIDTH,HEIGHT - Vision parameters:
VISION_RANGE,VISION_CONE_ANGLE - Movement parameters:
ROTATION_SPEED,MOVE_SPEED - Memory system:
GRID_SIZE,MEMORY_DECAY
NEAT-specific parameters are in config-neat.
