Package HAL.GridsAndAgents
Class AgentPT1D<T extends AgentGrid1D>
- java.lang.Object
-
- HAL.GridsAndAgents.AgentBase<T>
-
- HAL.GridsAndAgents.AgentBaseSpatial<T>
-
- HAL.GridsAndAgents.Agent1DBase<T>
-
- HAL.GridsAndAgents.AgentPT1D<T>
-
- Type Parameters:
T
- the extended AgentGrid2D class that the agents will live in Created by rafael on 11/18/16.
- All Implemented Interfaces:
java.io.Serializable
public class AgentPT1D<T extends AgentGrid1D> extends Agent1DBase<T> implements java.io.Serializable
extend the AgentPT2D class if you want agents that exist on a 2D continuous lattice with the possibility of stacking multiple agents on the same typeGrid square- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AgentPT1D()
-
Method Summary
Modifier and Type Method Description int
Age()
returns the age of the agent, in ticks.void
Dispose()
removes the agent from the gridvoid
MovePT(double newX)
Moves the agent to the specified coordinatesvoid
MoveSafePT(double newX)
Similar to the move functions, only it will automatically either apply wraparound, or prevent moving along a partiular axis if movement would cause the agent to go out of bounds.void
MoveSafePT(double newX, Point1DBool IsValidMove)
void
MoveSafeSQ(int newX)
Similar to the move functions, only it will automatically either apply wraparound, or prevent moving along a partiular axis if movement would cause the agent to go out of bounds.void
MoveSafeSQ(int newX, Coords1DBool IsValidMove)
void
MoveSQ(int newX)
Moves the agent to the center of the square at the specified coordinates<T extends AgentPT1D>
doubleXdisp(T other)
gets the displacement from this agent to anotherdouble
Xpt()
returns the X coordinate of the agent.int
Xsq()
returns the X index of the square that the agent is currently on.-
Methods inherited from class HAL.GridsAndAgents.Agent1DBase
DispX, Dist, DistSquared, MapEmptyHood, MapHood, MapHood, MapI, MapOccupiedHood, MapXpt, MapXsq
-
Methods inherited from class HAL.GridsAndAgents.AgentBaseSpatial
Isq
-
Methods inherited from class HAL.GridsAndAgents.AgentBase
BirthTick, IsAlive, SetBirthTick
-
-
-
-
Method Detail
-
MoveSQ
public void MoveSQ(int newX)
Moves the agent to the center of the square at the specified coordinates- Specified by:
MoveSQ
in classAgentBaseSpatial<T extends AgentGrid1D>
-
MovePT
public void MovePT(double newX)
Moves the agent to the specified coordinates
-
MoveSafeSQ
public void MoveSafeSQ(int newX)
Similar to the move functions, only it will automatically either apply wraparound, or prevent moving along a partiular axis if movement would cause the agent to go out of bounds.
-
MoveSafeSQ
public void MoveSafeSQ(int newX, Coords1DBool IsValidMove)
-
MoveSafePT
public void MoveSafePT(double newX)
Similar to the move functions, only it will automatically either apply wraparound, or prevent moving along a partiular axis if movement would cause the agent to go out of bounds.
-
MoveSafePT
public void MoveSafePT(double newX, Point1DBool IsValidMove)
-
Xpt
public double Xpt()
returns the X coordinate of the agent. If the Agent is on-lattice, these functions will return the coordinates of the middle of the square that the agent is on.- Specified by:
Xpt
in classAgent1DBase<T extends AgentGrid1D>
-
Xsq
public int Xsq()
returns the X index of the square that the agent is currently on.- Specified by:
Xsq
in classAgent1DBase<T extends AgentGrid1D>
-
Age
public int Age()
returns the age of the agent, in ticks. Be sure to use IncTick on the AgentGrid appropriately for this function to work.- Specified by:
Age
in classAgentBase<T extends AgentGrid1D>
-
Xdisp
public <T extends AgentPT1D> double Xdisp(T other)
gets the displacement from this agent to another
-
Dispose
public void Dispose()
removes the agent from the grid- Specified by:
Dispose
in classAgentBase<T extends AgentGrid1D>
-
-