rust-ants-colony-simulation
rust-ants-colony-simulation copied to clipboard
Feat: Add multiple food locations
I also have a very janky branch on my fork that clears the pheromones, kind of like a soft reset. It currently is using unsafe rust, however, so I don't think it would be good to merge.
Hey, thanks for creating the PR, I finally got some time to test it.
The only problem I found with the behaviour is that when there are multiple food sources, the ants eventually end up going to the source that is the closest, hence all other food sources are rendered useless.
Is there a way to make atleast some ants still follow other food sources mainly so that there's more activity on the screen?
I was looking into that, but I don't understand how to properly code in rust, so my solution ended up using unsafe rust.
My solution was to make the const food source tuple become a mutable tuple with an extra field for decay points. Every time an ant ate a bite of the food source, the counter would go down till it reached zero, where the food source would disappear. That way, the ants would path find to a different food source. It would also be possible to add food sources on the fly as well.
Yes the ants pathing to a different source once a food source is complete is a natural way to fix this problem. I feel like the best way to implement this is to create a new plugin for food, then have systems in place to detect ant collision and decrement its food count (and maybe also food size)
That would make a lot of sense. I tried doing it, but I couldn't figure out how to initiate a static mutable object on game start.
On Fri, Aug 11, 2023 at 11:21 AM Bones-ai @.***> wrote:
Yes the ants pathing to a different source once a food source is complete is a natural way to fix this problem. I feel like the best way to implement this is to create a new plugin for food, then have systems in place to detect ant collision and decrement its food count (and maybe also food size)
— Reply to this email directly, view it on GitHub https://github.com/bones-ai/rust-ants-colony-simulation/pull/2#issuecomment-1674964680, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWDVHG6IWNYXEUF7TH6PFXLXUZEYNANCNFSM6AAAAAA27WKCQA . You are receiving this because you authored the thread.Message ID: @.***>
It can be done using bevy resources. But I think in this case you wouldn't need anything static? Its just going to be a plugin that maintains a record of all food sources, then decrements the food quantity when an ant collides with it
I'll look into how to do that. I have absolutely no idea how to create a plugin but its my goal to learn rust so I will figure it out.