Ant Simulation - Emerging Foraging Paths, Dual Pheromone, Autonomous Swarm
Overview
This package demonstrates a full, biologically inspired ant foraging simulation powered by Blender Geometry Nodes and a dual-stream Simulation Zone (tracking both dynamic ant agents, a 2D pheromone grid, and depleting food points simultaneously). Press Play from Frame 1 to watch unguided random walkers discover food, lay homeward pheromone trails, recruit nestmates, and form self-optimizing foraging highways.
Two Ways to Work With the Main Simulation:
-
Yellow-Frame Tree Editing (
Ant_Sim_Full_With_Food_depletion): Parameters sit inside highlighted Yellow frames right next to the math they drive, designed for learning and exploring the node graph. -
Modifier Tab Control (
Ant_Sim_Full_With_Food_depletion_Control): All 24 parameters are cleanly exposed on the Geometry Nodes modifier across 6 collapsible panels for rapid look-dev and iteration.
Simulation Logic (Step-by-Step)
- Autonomous Swarm Movement: Points spawn from the nest at timed intervals and wander with a 3-state random walk (left, right, or straight) over randomized frame durations.
- Obstacle & Boundary Avoidance: Look-ahead raycasting detects labyrinth walls and perimeter boundaries so ants rebound cleanly without getting stuck.
-
Blue "Search" Trail: Exploring ants deposit a
Bluepheromone value onto a separate procedural 2D grid with diffusion blur, deposit rates, and frame-by-frame evaporation. -
Finding Food: When an ant comes within pickup distance of a food object, its
has_foodboolean attribute switches toTrue, and it begins depositing aRed"return" pheromone trail. - Dual-Antennae Sensing & Steering: Each ant probes the grid ahead at front-left and front-right sensor positions, turning smoothly toward stronger concentrations of the target pheromone.
-
Delivery & The Turnaround: Upon finding food, the ant executes a 180° turnaround toward the nest. Reaching the nest center resets
has_foodtoFalseand turns the ant 180° back out. -
Trail Reinforcement & Emergence: Outbound ants pick up the
Redtrail left by successful foragers, while short-range food and nest scent halos guide final approach—naturally forming self-organizing foraging highways.
Geometry Nodes Architecture & Controls
- 1. Spawning & Nest Emitter (
1. Base Points (0 at start)/Spawn frame by frame a new ant):-
Spawn Interval (
Every Xth frame): Releases one new ant every N frames (default:3) using integer modulo timing so ants clear the nest entrance cleanly. -
Population Cap: Halts spawning once active points reach the cap (default:
200).
-
Spawn Interval (
- 2. Stepped Random Steering & Dampener (
2. Random Steering&Total Pheromone based Wander factor Dampener):-
Frame Range (
Random Dir Step Min / Max): Assigns each ant a stepped decision timer (default:[15, 60]frames) to alternate between turning left, turning right, or walking straight instead of jittering every frame. -
Wander Dampener: Measures total detected scent; once scent exceeds the threshold (default:
0.2), random wandering scales down toward a subtle minimum wiggle (default:0.1) so ants stay locked onto strong trails.
-
Frame Range (
- 3. Boundary Raycast Collision (
4. Boundary Raycast Collision & Heading Update):-
Collision Target (
THE COLLISION OBJECT): ReferencesLabyrinth (Boundary object)in Relative space. Computes bidirectional angle rebound from the surface hit normal whenever an obstacle is detected within range.
-
Collision Target (
- 4. Pheromone Grid & Diffusion (
The Feromon grid&8. Pheromone Grid - Sample Nearest Ant):-
Grid Geometry: Generates a circularly trimmed 2D grid (default Size:
95.05, Resolution:200×200, Outer Cutout:46.65, Center Nest Cutout:3.0). -
Dual Channels & Potency: Samples the nearest ant within the
Pheromone Brush Radius(default:1.0). Searching ants write toBlue(deposit:0.25, evaporation:0.985); food-carrying ants write toRed(deposit:0.25, evaporation:0.992), scaled by an ant'spotencyattribute (decaying at0.004/frame so newer trails stay strongest). Both channels pass through a blur diffusion step each frame.
-
Grid Geometry: Generates a circularly trimmed 2D grid (default Size:
- 5. Antennae Sensing & Short-Range Homing (
10. Antenna left-right probing, Nest and Food Short-Range Sense):-
Dual Antennae: Searching ants (
has_food == False) steer towardRedtrails; returning ants (has_food == True) steer towardBluetrails. -
Short-Range Scent Halos: Adds direct left/right attraction toward the Nest (default Radius:
7.5, Strength:2.0) and Food (default Radius:5.0, Strength:2.0) when close.
-
Dual Antennae: Searching ants (
- 6. Food Pickup, Recycling & Depletion (
9. Food and food contact turn,11. Recycle and turn ant,12. Food Depletion & Lifecycle):-
Food Collection (
Food_Added): Any food meshes placed in theFood_Addedcollection become active targets with parametricfood_hp(default:100.0). Each ant bite subtracts1.0HP within theFood Pickup Radius(default:2.9), flipshas_foodtoTrue, and turns the ant 180° (updatingrot_z). Depleted food points disappear once HP reaches 0. -
Nest Drop-Off: Entering the
Distance from Center to Turn(default:5.0) resetshas_foodtoFalse, restores fullpotency, and flips heading 180° back into the field.
-
Food Collection (
- 7. Movement & Instancing (
5. Move Forward&6. Instance Ant & Align Rotation):- Advances every ant along its
rot_zheading vector each frame and instancesTHE ANT OBJECT(Ant) outside the Simulation Zone with adjustableAnt Scale(default:0.25).
- Advances every ant along its
Discover more products like this
geometry nodes swarm boids Pheromone crowd simulation autonomous ant simulation emergent Pathfinding collision avoidance simulation foraging