Package HAL.GridsAndAgents
Class AgentGrid0D<T extends Agent0D>
- java.lang.Object
-
- HAL.GridsAndAgents.AgentGrid0D<T>
-
- Type Parameters:
T
- the type of agent that the grid will hold
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<T>
public class AgentGrid0D<T extends Agent0D> extends java.lang.Object implements java.lang.Iterable<T>, java.io.Serializable
AgentGrid0Ds can only hold Agent0Ds- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AgentGrid0D(java.lang.Class<T> agentClass)
-
Method Summary
Modifier and Type Method Description java.util.ArrayList<T>
AllAgents()
returns an umodifiable copy of the complete agentlist, including dead and just born agentsvoid
CleanAgents()
cleans the list of agents, removing dead ones, may improve the efficiency of the agent iteration if many agents have died do not call this while in the middle of iterationvoid
CleanShuffle(Rand rn)
calls CleanAgents, then ShuffleAgentsint
GetPop()
returns the number of agents that are alive in the typeGridint
GetTick()
void
IncTick()
java.util.Iterator<T>
iterator()
T
NewAgent()
returns an uninitialized agent at the specified coordinatesT
RandomAgent(Rand rn)
gets a random agent from the grid, be careful not to use this during iteration over the gridvoid
Reset()
calls dispose on all agents in the typeGridvoid
ResetTick()
void
ShuffleAgents(Rand rn)
shuffles the agent list to randomize iteration do not call this while in the middle of iteration
-
-
-
Constructor Detail
-
AgentGrid0D
public AgentGrid0D(java.lang.Class<T> agentClass)
- Parameters:
agentClass
- pass T.class, used to instantiate agent instances within the typeGrid as needed
-
-
Method Detail
-
NewAgent
public T NewAgent()
returns an uninitialized agent at the specified coordinates
-
ShuffleAgents
public void ShuffleAgents(Rand rn)
shuffles the agent list to randomize iteration do not call this while in the middle of iteration- Parameters:
rn
- the Random number generator to be used
-
CleanAgents
public void CleanAgents()
cleans the list of agents, removing dead ones, may improve the efficiency of the agent iteration if many agents have died do not call this while in the middle of iteration
-
CleanShuffle
public void CleanShuffle(Rand rn)
calls CleanAgents, then ShuffleAgents
-
AllAgents
public java.util.ArrayList<T> AllAgents()
returns an umodifiable copy of the complete agentlist, including dead and just born agents
-
Reset
public void Reset()
calls dispose on all agents in the typeGrid
-
RandomAgent
public T RandomAgent(Rand rn)
gets a random agent from the grid, be careful not to use this during iteration over the grid
-
GetTick
public int GetTick()
-
IncTick
public void IncTick()
-
ResetTick
public void ResetTick()
-
GetPop
public int GetPop()
returns the number of agents that are alive in the typeGrid
-
-