Week 4: Antlions
March 28, 2026
Hi everyone, and welcome back to the 4th week of my blogs!
Pheromone changes:
I started off the week with more changes to how ants worked with pheromones. I already revised the model last time, but as the video showed, the results were still mostly scattered. Ants were unable to find their way home despite sometimes knowing their general direction. This made it hard to navigate around large obstacles.
This included with me playing around with various solution attempts, including…
1. Making it so to-home pheromones evaporated faster the farther it is from home (and vice versa for to-food pheromones), so the gradient would easier for ants to navigate.
2. Creating not 1, but 3 detection zones around ants in an attempt to guide the way they navigated around.
3. Further changing and optimizing ant movement systems so they deviated from their tracks less frequently.
Most of these were pretty tedious to implement (usually from the string of bugs that came along as I try to implement these features). Unfortunately, despite being tedious, none of these yielded significantly better results compared to last week’s pheromones.
Right when I was about to give up and move on to predators, I stumbled upon a solution while rewatching the second series of the ant simulation by YouTuber Pezzza’s Works. He assigns each pheromone a value indicating its distance from home or food. Ants then travel toward the most optimal pheromone based on that value.
I implemented this property onto my simulation by adding a value to every pheromone indicating the time it was placed since visiting either food or home. This time, ants created thin, smooth lines and were able to navigate around obstacles.
This system is also great because the timed-property of pheromones meant that trails could often optimize themselves when ants detect a better path. In the example below (done with a higher “wander” probability), despite the first ant being lost, new ants quickly picked up on the pheromones and were able to optimize the trails.
Overall, this was great! Despite taking 3 weeks, I think I’m now finally close to a model of pheromone that I think accurately capture how ants move. Now, it’s time to introduce predators…
Antlions:
Antlions are insects who burrow cone-shaped pits in the sand. Once ants fall into these pits, they are unable to climb out, and the antlion waits at the bottom to devour their meal using their mandibles. Fun fact, this was the real life inspiration for the Sarlacc pit from Star Wars: Return of the Jedi.
I started out by coding a basic model for the antlion and its pit (and even made a death animation for the ants):
Next, in order to let the ants have a basic defense mechanism, I decided to give them…more pheromones.
Once ants fall into these pits, they release an expanding gas of pheromones that stand for “avoid danger”. Ants that are near this pheromone will try to pathfind away, breaking their original pheromone paths.
Note above how the expanding pheromones cause the ants to break formation and create new trails around these antlions.
Future goals:
If you’ll notice the video above, you can see how sometimes the ants seem to be spinning around. This seemed to be caused by some new bugs in the code I haven’t found yet, since it wasn’t present before I added the antlions. I’ll try to fix that next week.
I’ve also already started on creating a second predator for the ants to fend off: the wolf spider.

Currently, the wolf-spider simply runs towards ants and devours them. Unfortunately, I seem to have accidentally messed up the collider system, causing them to no longer detect ants (or walls, for that matter). Hopefully by next week, I’ll also finish building a model for the wolf-spider and ways ants can defend themselves.
I hope to see you all next week!
Reader Interactions
Comments
Leave a Reply
You must be logged in to post a comment.

Looks like you made a lot of great progress this week; congrats!
I’m wondering: do real ants fall in antlions as often as the ones in your simulation do? I’m curious to know if real ants can see them and deliberately avoid them while the ones in your simulation can’t exactly “see” ahead. Would this be something to account for?