Reputation: 309
I am planning to write some simulations using the Specs crate for Rust.
The goal would be to have a few agents and to model their activity. So far working through the specs book example I have not seen a idiomatic way to assess the interaction of all entities against each other and I am unclear how once the interaction is decided, this information can be passed down to another system.
Interaction in this sense is if, for example, two people or agents bump into each other physically or are standing 'on top' of each other, similar to what a collision system in a game would do I'd imagine.
Another example would be if I was to simulate an economy. Each entity would like to trade with another entity and in that case it would need to understand what resources all the other entities have on sale and at what price. Once that has been assessed it might make a decision to buy or not. In this example, I would also like the InventoryCheck
system to do the assessment of which trades might happen and the PurchasingSystem
to then handle it, but it's unclear how I would pass that knowledge from the former to the later system in the specs
API.
How would one go about using join
or any other available tools in specs
to write idiomatic entity to entity interactions or checks as well as pass down the results of these checks to other systems. I understand that comparing all entities to each other is a O(N^2)
algorithm and I can't imagine it would be any faster than that.
Upvotes: 0
Views: 250