Package modelarium.entities
Class Agent
java.lang.Object
modelarium.entities.Entity<AgentSimulationContext,AgentContext,AgentAttributeSet,AttributeSetLog<AgentSimulationContext>>
modelarium.entities.Agent
public final class Agent
extends Entity<AgentSimulationContext,AgentContext,AgentAttributeSet,AttributeSetLog<AgentSimulationContext>>
Class for representing an agent in the model.
This class is an entity that owns AgentAttributeSet instances and uses an
AgentSimulationContext for its behaviour and interactions.
-
Constructor Summary
ConstructorsConstructorDescriptionAgent(String name, List<AgentAttributeSet> attributeSets) Constructs a new agent with the specified name and attribute sets. -
Method Summary
Modifier and TypeMethodDescriptionCreates and returns an immutable version of this agent.getAttributeSet(int attributeSetIndex) Retrieves an attribute set by index.getAttributeSet(String attributeSetName) Retrieves an attribute set by name.Retrieves an event attribute from one of this agent's attribute sets.getProperty(String attributeSetName, String propertyName) Retrieves a property attribute from one of this agent's attribute sets.getRoutine(String attributeSetName, String routineName) Retrieves a routine attribute from one of this agent's attribute sets.booleanisDead()Returns whether the agent is dead or not.voidkill()Sets the agent to the removed state (killed) so that it no longer functions or contributes to the simulation.voidrun()Runs each of this agent's attribute sets for the current tick unless it is dead.Methods inherited from class modelarium.entities.Entity
attributeCount, attributeSetCount, context, getLog, name
-
Constructor Details
-
Agent
Constructs a new agent with the specified name and attribute sets.- Parameters:
name- the name of the agent, used to identify it within the modelattributeSets- the attribute sets the agent will own
-
-
Method Details
-
getAttributeSet
Retrieves an attribute set by index.- Overrides:
getAttributeSetin classEntity<AgentSimulationContext,AgentContext, AgentAttributeSet, AttributeSetLog<AgentSimulationContext>> - Parameters:
attributeSetIndex- the index of the attribute set to retrieve- Returns:
- the attribute set at the specified index
-
getAttributeSet
Retrieves an attribute set by name.- Overrides:
getAttributeSetin classEntity<AgentSimulationContext,AgentContext, AgentAttributeSet, AttributeSetLog<AgentSimulationContext>> - Parameters:
attributeSetName- the name of the attribute set to retrieve- Returns:
- the attribute set with the specified name
-
getEvent
Retrieves an event attribute from one of this agent's attribute sets.- Parameters:
attributeSetName- the name of the attribute set containing the eventeventName- the name of the event to retrieve- Returns:
- the
AgentEventwith the specified name
-
getRoutine
Retrieves a routine attribute from one of this agent's attribute sets.- Parameters:
attributeSetName- the name of the attribute set containing the routineroutineName- the name of the routine to retrieve- Returns:
- the
AgentRoutinewith the specified name
-
getProperty
Retrieves a property attribute from one of this agent's attribute sets.- Parameters:
attributeSetName- the name of the attribute set containing the propertypropertyName- the name of the property to retrieve- Returns:
- the
AgentPropertywith the specified name
-
kill
public void kill()Sets the agent to the removed state (killed) so that it no longer functions or contributes to the simulation. -
isDead
public boolean isDead()Returns whether the agent is dead or not.- Returns:
- the boolean value of whether the agent is dead (true) or not (false)
-
run
public void run()Runs each of this agent's attribute sets for the current tick unless it is dead.- Overrides:
runin classEntity<AgentSimulationContext,AgentContext, AgentAttributeSet, AttributeSetLog<AgentSimulationContext>>
-
getAsImmutable
Creates and returns an immutable version of this agent.- Specified by:
getAsImmutablein classEntity<AgentSimulationContext,AgentContext, AgentAttributeSet, AttributeSetLog<AgentSimulationContext>> - Returns:
- the new
ReadOnlyAgentinstance
-