Population
A composable view over a group of agents.
Following the convention adopted by Mesa 3.0, a Population is not a scheduler — it does not decide when its members act. It is a typed collection with the operations a modeler typically needs when expressing agent activation: shuffle, filter by type, filter by predicate, group. Iteration order is the caller's choice:
// random-order activation
population.shuffled(stream).forEach { it.step() }
// staged activation
population.ofType<Predator>().forEach { it.hunt() }
population.ofType<Prey>().forEach { it.flee() }
// two-phase simultaneous activation
population.forEach { it.preStep() }
population.forEach { it.commit() }A Population is a live view: changes to the underlying agent collection (for example, new agents created by an AgentModel.AgentGenerator) are reflected on the next iteration.
Constructors
Construct a population that always reflects the current contents of agentModel.agents, filtered to instances of A.
Construct a population backed by a snapshot of members. The population view reflects later mutations to members if it is a live collection.
Properties
Functions
Convenience: return an AgentModel.AgentMailbox-bound list of (agent, mailbox) pairs for use in broadcast scenarios. The mailbox returned is the agent's default mailbox.