amethyst / evoli

An ecosystem-simulation game made with Amethyst
https://community.amethyst.rs/t/evoli-introduction/770
Other
217 stars 33 forks source link

Add perception system with basic spatial acceleration structure #68

Closed sunreef closed 5 years ago

sunreef commented 5 years ago

Creatures now detect nearby entities. The range of detection is decided by the Perception component of the creature.

To avoid the quadratic complexity of testing the distance between all entities, I also added a SpatialGrid resource that is updated every frame and splits the space into fixed size cells that contain entities. This way, we only need to check nearby cells when searching for the neighbors of an entity.

marotili commented 5 years ago

Can you talk a little bit about what your goals are? I can imagine this being useful for the behaviours, especially to replace the ClosestSystem.

Depending on what the use case is, we might want to change some details, but I'm fine with doing that in a later PR. But it would be great to have one issue or multiple issues describing the goal to keep track of it and related changes.

sunreef commented 5 years ago

I implemented this perception system with the Boids algorithm in mind. The creatures would try to get close to other creatures of the same species and avoid predators or other dangers. Since the full implementation of the boids algorithm would be really complex, I'd prefer to separate it in several PR with the perception being the first of the series.

Actually, this system already makes a few other components and systems redundant. We don't need the IntelligenceTag anymore, I believe.