I am exploring the ECS pattern and my pet project is a simulation of an economy where the primary mode of interaction between economic agents is a transaction. Some of these agents are market makers (they passively advertise offers to trade - sometimes called making a market). Some agents are market takers (they browse offers and decide which they want to trade with).
So an offer is a component of a market maker. This is clear to me. I have a system that governs the process of market makers setting offers.
Now I need a system that governs the process of market takers browsing the offers and "notifying" the market maker of their intention to trade. I call this notification a proposed_trade
. At every tick of the main loop, multiple market takers may want to trade with the same market maker based on the same offer. The market maker will then accept the proposed_trade
s for as long as it has the resources to satisfy them, then reject them thereafter.
So how do I model this with an ECS? Some options:
- Each
proposed_trade
belongs to a distinct entity and references both the maker and the taker. There may be many relating to the same maker. - Each maker has, as a component, a list of
proposed_trade
s (like a buffer) and the takers just add to the list when they want to trade.
Are either of these considered more idiomatic or is the choice a matter of taste?