Class AgentGrid0D<T extends Agent0D>

  • 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 agents
      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
      void CleanShuffle​(Rand rn)
      calls CleanAgents, then ShuffleAgents
      int GetPop()
      returns the number of agents that are alive in the typeGrid
      int GetTick()  
      void IncTick()  
      java.util.Iterator<T> iterator()  
      T NewAgent()
      returns an uninitialized agent at the specified coordinates
      T RandomAgent​(Rand rn)
      gets a random agent from the grid, be careful not to use this during iteration over the grid
      void Reset()
      calls dispose on all agents in the typeGrid
      void ResetTick()  
      void ShuffleAgents​(Rand rn)
      shuffles the agent list to randomize iteration do not call this while in the middle of iteration
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • 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
      • iterator

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<T extends Agent0D>