A graphical simulation of an ant colony demonstrating emergent behavior and path-finding algorithms.
- Interactive ant colony simulation with customizable parameters
- A* pathfinding algorithm for efficient navigation
- Ants with different behaviors based on energy levels
- Food gathering and transport mechanics
- Obstacle avoidance and stuck-detection systems
- Dynamic ant spawning when food packages are delivered
- Python 3.6+
- Tkinter (usually comes with Python)
Clone the repository:
git clone https://github.com/yourusername/ant-simulator.git
cd ant-simulatorRun the simulation:
python ants.py- First click: Place food source (red circle)
- Second click: Place nest (blue circle)
- Third click: Reset food and nest locations
Use the control panel on the right side to adjust:
- Number of ants
- Energy loss rate
- Ant speed range
- Number of obstacles
- Enable/disable ant spawning
- Toggle lifetime counting
The simulation models ant behavior with these key aspects:
- Pathfinding: Ants use A* algorithm to find efficient routes between locations
- Energy management: Ants lose energy over time and change colors (green→yellow→red)
- Food collection: Ants gather food from the source and return it to the nest
- Cooperation: Ants can help each other when stuck
This project is licensed under the MIT License - see the LICENSE file for details.
