
My Ant Simulation Seems to Wander Off [10k ants now with obstacles!]
Published at : September 19, 2021
Based on my previous work with ants:
1) 5k ants: https://youtu.be/uNIkS0-o2eM
2) 20k ants sped up by a factor of 20: https://youtu.be/CWMD6Lrmq0A
3) 20k ants short video: https://youtu.be/AnXfNzduTpY
4) 10k ants burrowing through the ground: https://youtu.be/CCpqTQRTHWo
5) 100k ants with new visuals: https://youtu.be/6tE2pZVTh1U
Code can be downloaded here: https://github.com/LennartGimm/Processing3.4_Ants.git
The files "AntsPImageLoadMaps.pde" and "Map7.png" are necessary to recreate this video. Other files are used in older videos.
In this version, we introduce obstacles into the mix! The ants try to turn away from them, and if they can't, they stop their movement and pick a new direction until they find one they can walk to. This effectively utilises the same system already in place to detect pheromones and made for a simple change. Obstacles are shown in grey.
You can now also easily add your own maps to the simulation. Simply create an image with the same dimensions you want the simulation to be, make the background grey, add food in green, caves in black, and obstacles in red.
The ant-paths seeming to drift to the bottom right of the screen in a bug. This bug has been in the software from the start, and I can't figure out, why. The values for x and y seem to increase on their own, or more than intended each step. It's especially pronounced here as this simulation is 8 timesteps per frame (compared to 1 step per frame in previous videos) and then played at 120 fps first, later 4x that. This leads to most of the video being 3840 time steps per second, whereas previous simulations worked with 60 steps per second. I'm still working on the ideal speed at which to show these simulations, but with the new obstacles added in, it seems the ants need much more time to clear out food.
At the usual 60fps, this video would've been 1039s, or 17min 19s long.
[Edit: Turns out thecounter I tried to add (+0.02 for both x and y at every step) made this worse. Set this to -0.05 in lines 274 & 275 to somewhat fix the problem by artificially moving the ants to the top left. This doesn't fix the root cause, it just fixes the symptom for the most part.]
The price for speeding this simulation up by that much was that I had to go back down to simulating 10k ants, but honestly: I can't see that big a difference once they all combine into set paths.
Music:
Bug Catching - Emily A. Sprague
1) 5k ants: https://youtu.be/uNIkS0-o2eM
2) 20k ants sped up by a factor of 20: https://youtu.be/CWMD6Lrmq0A
3) 20k ants short video: https://youtu.be/AnXfNzduTpY
4) 10k ants burrowing through the ground: https://youtu.be/CCpqTQRTHWo
5) 100k ants with new visuals: https://youtu.be/6tE2pZVTh1U
Code can be downloaded here: https://github.com/LennartGimm/Processing3.4_Ants.git
The files "AntsPImageLoadMaps.pde" and "Map7.png" are necessary to recreate this video. Other files are used in older videos.
In this version, we introduce obstacles into the mix! The ants try to turn away from them, and if they can't, they stop their movement and pick a new direction until they find one they can walk to. This effectively utilises the same system already in place to detect pheromones and made for a simple change. Obstacles are shown in grey.
You can now also easily add your own maps to the simulation. Simply create an image with the same dimensions you want the simulation to be, make the background grey, add food in green, caves in black, and obstacles in red.
The ant-paths seeming to drift to the bottom right of the screen in a bug. This bug has been in the software from the start, and I can't figure out, why. The values for x and y seem to increase on their own, or more than intended each step. It's especially pronounced here as this simulation is 8 timesteps per frame (compared to 1 step per frame in previous videos) and then played at 120 fps first, later 4x that. This leads to most of the video being 3840 time steps per second, whereas previous simulations worked with 60 steps per second. I'm still working on the ideal speed at which to show these simulations, but with the new obstacles added in, it seems the ants need much more time to clear out food.
At the usual 60fps, this video would've been 1039s, or 17min 19s long.
[Edit: Turns out thecounter I tried to add (+0.02 for both x and y at every step) made this worse. Set this to -0.05 in lines 274 & 275 to somewhat fix the problem by artificially moving the ants to the top left. This doesn't fix the root cause, it just fixes the symptom for the most part.]
The price for speeding this simulation up by that much was that I had to go back down to simulating 10k ants, but honestly: I can't see that big a difference once they all combine into set paths.
Music:
Bug Catching - Emily A. Sprague
![My Ant Simulation Seems to Wander Off [10k ants now with obstacles!]](https://i.ytimg.com/vi/MQkngcL5rzw/hqdefault.jpg)
ProcessingSimulationAnts