Ant Simulation - Emerging Foraging Paths, Dual Pheromone, Autonomous Swarm

codesignprojects in Simulations & Effects


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)

  1. 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.
  2. Obstacle & Boundary Avoidance: Look-ahead raycasting detects labyrinth walls and perimeter boundaries so ants rebound cleanly without getting stuck.
  3. Blue "Search" Trail: Exploring ants deposit a Blue pheromone value onto a separate procedural 2D grid with diffusion blur, deposit rates, and frame-by-frame evaporation.
  4. Finding Food: When an ant comes within pickup distance of a food object, its has_food boolean attribute switches to True, and it begins depositing a Red "return" pheromone trail.
  5. 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.
  6. Delivery & The Turnaround: Upon finding food, the ant executes a 180° turnaround toward the nest. Reaching the nest center resets has_food to False and turns the ant 180° back out.
  7. Trail Reinforcement & Emergence: Outbound ants pick up the Red trail 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).
  • 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.
  • 3. Boundary Raycast Collision (4. Boundary Raycast Collision & Heading Update):
    • Collision Target (THE COLLISION OBJECT): References Labyrinth (Boundary object) in Relative space. Computes bidirectional angle rebound from the surface hit normal whenever an obstacle is detected within range.
  • 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 to Blue (deposit: 0.25, evaporation: 0.985); food-carrying ants write to Red (deposit: 0.25, evaporation: 0.992), scaled by an ant's potency attribute (decaying at 0.004/frame so newer trails stay strongest). Both channels pass through a blur diffusion step each frame.
  • 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 toward Red trails; returning ants (has_food == True) steer toward Blue trails.
    • 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.
  • 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 the Food_Added collection become active targets with parametric food_hp (default: 100.0). Each ant bite subtracts 1.0 HP within the Food Pickup Radius (default: 2.9), flips has_food to True, and turns the ant 180° (updating rot_z). Depleted food points disappear once HP reaches 0.
    • Nest Drop-Off: Entering the Distance from Center to Turn (default: 5.0) resets has_food to False, restores full potency, and flips heading 180° back into the field.
  • 7. Movement & Instancing (5. Move Forward & 6. Instance Ant & Align Rotation):
    • Advances every ant along its rot_z heading vector each frame and instances THE ANT OBJECT (Ant) outside the Simulation Zone with adjustable Ant Scale (default: 0.25).
$3.90

Have questions about this product?
Login to message

Details
Published about 2 hours ago
Blender Version 4.1 - 5.3
Render Engine Used Cycles, Eevee
License Creative Commons