16 ms·
Show HN: Ants Sandbox - an ants simulator
I was inspired to make a web based ants simulator after watching this video https://www.youtube.com/watch?v=81GQNPJip2Y https://www.youtube.com/watch?v=81GQNPJip2Y
Any feedback appreciated.
Best viewed on Chromium based browsers. Firefox is slow for some reason and Safari is not tested as I don't have a Mac.
- deleted 4y ago[deleted]
- smcleod 4y agoGives me nostalgia for playing Sim Ant when I was young. https://en.wikipedia.org/wiki/SimAnt https://en.wikipedia.org/wiki/SimAnt
- wintermutestwin 4y agoSim Ant and Sim Earth are both begging for remakes!
- folli 4y agoI don't understand why there's no true SimCity remake (not this Mobile game crap). It's a surefire commercial success.
- dawnerd 4y agoEven the spiritual successor Cities Skylines is getting old at this point. There's a few other city-building games that almost nail it but the devs always add in something that makes it too micro-managey like production chains.
- eproxus 4y agoPersonally I like the production chains in Cities Skylines. I feel they add purpose to the design of the road network and handling of traffic problems. I just wish the AI was a ton better (there are a few mods that help though).
- noduerme 4y agoYup, I loved both those games. SimEarth in particular would be fantastic for a remake... lots of stuff you can learn about climate change from that game. Maxis did such excellent work building the systems that you could probably work from the original sim logic and build something massive in Unity mostly focusing on the graphics.
- JoeDaDude 4y agoIn that vein, I remember SimLife, which had a whole textbook dedicated to it, showing how to model real world things like predator/prey cycles. https://www.amazon.com/SimLife-Official-Strategy-Guide-Secrets/dp/1559581905 https://www.amazon.com/SimLife-Official-Strategy-Guide-Secre...
- wdfx 4y agoThe simulation works fine on Firefox on Android. But touching the map causes it to fly out of view and I can never get it back. Might benefit from a Centre View button for navigation.
- adenozine 4y agoHow does the draw function work? I can't seem to draw food or rocks when I try. Latest MS Edge on Windows 10.
- tulustul 4y agoYou should be able to draw with right mouse button. Is this how you try it? Does it work on other browsers?
- adenozine 4y agoAh! In fact, it does. Thanks!
- seszett 4y agoI don't have a right mouse button. On OSX, I use ctrl+click as an equivalent (normally) to the right mouse button. But it might be because of my convoluted setup (using the touchpad on Linux on a Macbook to control OSX on another Mac using barrier) so I'm not sure if it's actually relevant, don't sweat it.
- dylan604 4y agoYeah, right-click drawing is not the most intuitive. I found it purely by accident.
- drivers99 4y agoWhen I touch the screen on iPad, everything goes black. Edit: it’s usable if I only use the gui element to zoom out one step and don’t scroll or zoom. I was thinking: what if workers also fight? I think they generally do in real life.
- tulustul 4y agoUnfortunately, I don't posses any Apple device so I cannot fix it. You're right, workers do fight in the real life. It's one of many simplifications in the simulation. Real world is much more complex
- noman-land 4y agoLooks like the same thing happens on an Android phone as well.
- MonsieurMoony 4y agoJust curious, can't device emulation on Chrome and other browsers help reproduce the issue?
- nullwarp 4y agoNegatory, there's literally no way other than owning an apple device. I have a stack of bugs in a FLOSS app I can't fix for safari because I don't have a mac anymore. I guess I could try to boot a hackintosh but it's not worth the effort to me.
- ivmoreau 4y agoYou might want to take a look at Epiphany[1]. It's just Safari (Webkit, actually), but without the need for Apple devices. [1]: https://gitlab.gnome.org/GNOME/epiphany https://gitlab.gnome.org/GNOME/epiphany
- hughrlomas 4y agoThis is great to see. Years ago I created a basic simulation using the same principles of pheromone gradients, one for the nest and one for food. https://youtu.be/VsHc91IhzdI https://youtu.be/VsHc91IhzdI It a fascinating example of emergent behavior from simple rules. I've been wanting to find time to revisit the concept and produce an updated version, your simulation seems to include everything I wanted to do and more.
- geuis 4y agoSorry but this completely fails on iOS. Can't touch the controls, zoom in or out, etc.
- mthoms 4y agoWorks for me.
- NelsonMinar 4y agoVery nice! There's a long history of this kind of simulation, going back to Alan Turing (or before). I used to work doing this kind of thing in the 90s, as part of the Artificial Life community. There's a lot of papers from back then if you're looking for other ideas for agent based simulations or complex systems. For that matter the ALife community itself still exists.
- JKCalhoun 4y agoI remember A. K. Dewdney introducing "Wa-Tor" in Scientific American in the 80's. I was fascinated by those explorations. (And SimAnt is of course the more obvious parallel to this particular simulation.) https://en.wikipedia.org/wiki/Wa-Tor https://en.wikipedia.org/wiki/Wa-Tor https://en.wikipedia.org/wiki/SimAnt https://en.wikipedia.org/wiki/SimAnt
- louky 4y agoYeah, there was a discussion of emergence in Gödel, Escher, Bach[0] published 1979. "Aunt Hillary" was the super-organism created from the actions of the indivdual ants, IIRC. [0] https://en.wikipedia.org/wiki/G%C3%B6del%2C_Escher%2C_Bach https://en.wikipedia.org/wiki/G%C3%B6del%2C_Escher%2C_Bach
- bcjordan 4y agoReally love this, it can create such amazing visuals (before the ants erase them with the "no food left" signal!) Fun to read through the TS/Vue/PixiJS source as well, thanks for open sourcing it. Nicely built! Could imagine this being a fun base upon which to build a game like Liquid War https://www.gnu.org/software/liquidwar6/ https://www.gnu.org/software/liquidwar6/
- mywacaday 4y agoI think it crashed my phone, froze between tutorial steps and when I looked back my phone, a galaxy note 10+ had restarted.
- throwaway413 4y agoMy dog is currently running a similar study from the balcony to her dog food bowl. Every day I move the bowl, every night they find it, and every morning I spend battling soldier ants. The tour was really enjoyable to watch through, thanks for sharing this!
- mthoms 4y agoHave a little fun with it. Chalk can disrupt the ant’s route finding. At least for a little while. https://homeguides.sfgate.com/kind-chalk-used-keep-ants-away-81714.html https://homeguides.sfgate.com/kind-chalk-used-keep-ants-away...
- xixixao 4y agoThe tours are awesome! The last one (with soldiers) stops working after the first Next tap (iOS, Safari).
- fho 4y agoOne thing that is missing from this simulation is that (at least some) ant species walk straight back to their nest once they found some food. They do this (as far as we know) by accumulating each step they take into what is called the "home vector", effectively integrating the whole path they took. That way they always know which way is "back to the nest". There is a vast amount of papers on the topic. Some (personal) highlights: If you put the ants on stilts they will follow the same home vector, but because each step on stilts is effectively longer they will overshoot the target: https://www.researchgate.net/figure/Fig4-Odometry-by-stride-integration-Stride-integration-in-desert-ant-odometry_fig4_51081971 https://www.researchgate.net/figure/Fig4-Odometry-by-stride-... If the ant is placed close to the nest after gathering food, it will still follow its home vector ... away from the nest: https://royalsocietypublishing.org/doi/abs/10.1098/rspb.2004.2749 https://royalsocietypublishing.org/doi/abs/10.1098/rspb.2004... Crazy little buggers these ants.
- Retr0id 4y agoHah, that reminds me of a robotics competition I took part in at school. Robots were placed in an arena, and the objective was to gather QR-marked boxes, and bring them back "home". There were also QR codes placed at known locations around the arena, and the intention was that you could use them for navigation. However, the camera systems were pretty flakey (especially under unpredictable lighting conditions), so we wanted to avoid using them as much as possible. So, we put rotary encoders on our wheels, and integrated the readings to calculate a "home vector" for the return journey, just like you described. At the time, I wasn't aware that this was an ant-inspired technique - but it was very effective, and we won the competition. Thanks, ants!
- x0hm 4y agothants
- eclipticplane 4y agoBless you ants. Blants. [0] [0] https://www.youtube.com/watch?v=gaI6kBVyu00 https://www.youtube.com/watch?v=gaI6kBVyu00 - Look Around You
- detritus 4y agoMay I ask - in the early stages, when a wandering ant encounters its first food pheromone trail, is there a logic that dictates which direction it chooses to then follow? It has two options - towards the source of the food, or away from. The latter resulting in a wasted journey home before a hoped-for bounce back. - ed - it seems to me that they always go towards the food, is all. - ed - ed : Great work, btw! SimAnt was a big favourite as a kid, so this is right up my street! :)
- garyfirestorm 4y agoWhat happens when there is a circular path. Do all ants follow it until they die?
- detritus 4y agoYes. The system breaks down locally. https://en.wikipedia.org/wiki/Ant_mill https://en.wikipedia.org/wiki/Ant_mill - ed - d'oh, sorry - I have no idea how this works in the simulation, but I guess This. :)
- foobiekr 4y agoI was trying to create a circular mill with rock placement without luck. https://www.youtube.com/watch?v=LEKwQxO4EZU https://www.youtube.com/watch?v=LEKwQxO4EZU
- Cameri 4y agoDoesn't work well on Firefox Android. Zooming in causes the map to fly away who knows where.
- x86x87 4y ago
- adnanc 4y agoBrings back memories of my final year dissertation at University nearly 20 years ago, "An emergent model of an Ant colony" (in VRML and Javascript). Incredibly fascinating and great to see this.
- TruthWillHurt 4y agocool, but this needs WebGL or something as I'm getting 8 fps
- tulustul 4y agoIt does use WebGL. I can run 15k ants in 60FPS on my machine. What browser and spec do you have?
- TruthWillHurt 4y agoYea I think something was borked with my Linux Nvidia driver. Works at 60fps in Windows.
- sa1 4y agoIndividual ants might be smarter than you give them credit for: they've been known to pass the mirror test. https://www.scinapse.io/papers/2180773430 https://www.scinapse.io/papers/2180773430
- EamonnMR 4y agoMy only feedback is that this is amazing. I would gladly pay for a fleshed out version of this. SimAnt was an old favorite of mine.
- testmasterflex 4y agoSuper cool!
- Anunayj 4y agoI don't know why, but it seems to malfunction on Microsoft Edge for some reason, where the ant looks like a circular brown blob.
- Jenn_With_Two_N 4y agoI got super into messing with the parameters of the ants, and after watching a randomized map (along with tampering with it mid-game to see what would happen) I decided I wanted to see what would happen if I pit them against each other. I set up a map between different extremes that gave them all of the same resources and obstacles, and would over time force them to interact to increasing degrees. I want to preface this by saying I didn't make some of the decisions I made for any particular reason. This whole thing was purely for fun and not intended to be perfect. Things like the placement of the colonies and what the map ended up looking like in the end just felt right. Some of the decisions were deliberate, like the quality of the food is based on where it is on the map, and the likelihood of encountering another colony to get it.
- Jenn_With_Two_N 4y agoThe experiment: I copied an old warcraft arcade map initially meant for tower defense, made some adjustments to add additional resources and interaction points, as well as some walls to not have an all-out war immediately, and some extra long tunnels with big payoffs so the less aggressive ants. The map was originally made for 8 players, but to create each extreme maximum-medium-minimum combo I only needed 6 colonies, plus the med-med-med colony, so I ended up with 7 colonies. I just duplicated the all-mediums colony for the sake of balance on the 8-colony map. I wrote out each combo, and used a randomizer to assign each to a number, then placed them on the map in counter-clockwise order starting in the upper-left, as seen in image 2 of the imgur album. The list of colonies and their randomly assigned max-med-min combos are at the bottom of the post. This is twice the number of colonies as the default, so I just halved the starting ants to 50 just so we can get a slower and more interesting start. I felt like this would keep the colonies from being obliterated before we get to see them all have a chance. I kept the maximum at 500, however, because I thought the ending would be more interesting. As I said before, I manually drew the food in with varying values based on where it is on the map, the likelihood of encountering another colony to get it, distance travelled to get it, or how small the payoff was in size. You can check image 3 for the map with the food values listed. Imgur album: https://imgur.com/a/hU1noNy https://imgur.com/a/hU1noNy TL;DR: Winner: Colony 4 Total ants: 4685 Starved ants: 0 Killed: 4185 Kills: 1976 Stored food: 187,308 Total food obtained: 512,782 Start time: 07/10/22 8:59pm End time: 07/11/22 12:34am Total runtime: 3 hours, 35 minutes Run speed: 25x In the end, it came back to the old tactic of starvation as a very good method to kill armies. ------------------------------------- Colonies: Colony #1 Aggressiveness: 1 Mean ant Energy: 1 Freedom: 0.05 Colony #2 Aggressiveness: 0.1 Mean ant Energy: 5 Freedom: 0.1 Colony #3 Aggressiveness: 0.5 Mean ant Energy: 5 Freedom: 0.05 Colony #4 Aggressiveness: 0.5 Mean ant Energy: 10 Freedom: 0.003 Colony #5 Aggressiveness: 0.5 Mean ant Energy: 1 Freedom: 0.1 Colony #6 Aggressiveness: 0.5 Mean ant Energy: 5 Freedom: 0.05 Colony #7 Aggressiveness: 1 Mean ant Energy: 5 Freedom: 0.003 Colony #8 Aggressiveness: 0.1 Mean ant Energy: 10 Freedom: 0.05
- marclou 4y ago[dead]
- ehzy 4y agoWould you mind describing the mechanism responsible for the ants optimizing the path? I would assume that once a path is established it become self-reinforcing as more ants follow it and drop their pheromones. Is it that the ants that randomly begin taking the shortest path complete trips more quickly, thereby increasing the pheromone concentration along the shorter path? Still, it seems difficult to overcome the sheer amount of pheromones being laid across the longer but more popular path...
- bobharris 4y agoThis is awesome. Way to go. It'd be cool to get the same kinda effect with Ml Agents and Unity. I should work on that.