Package HAL.GridsAndAgents
Class Agent2DBase<T extends AgentGrid2D>
- java.lang.Object
-
- HAL.GridsAndAgents.AgentBase<T>
-
- HAL.GridsAndAgents.AgentBaseSpatial<T>
-
- HAL.GridsAndAgents.Agent2DBase<T>
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
AgentPT2D
,AgentSQ2D
,AgentSQ2Dunstackable
public abstract class Agent2DBase<T extends AgentGrid2D> extends AgentBaseSpatial<T> implements java.io.Serializable
Agent2DBase functions are shared amongst all 2D agent types- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Agent2DBase()
-
Method Summary
Modifier and Type Method Description double
DispX(double x)
gets the X displacement from this agent to a given x positiondouble
DispY(double y)
gets the Y displacement from this agent to a given y positiondouble
Dist(double x, double y)
gets the distance from this agent to another positiondouble
DistSquared(double x, double y)
gets the distance squared from this agent to another position, more efficient than Distint
MapEmptyHood(int[] hood)
These functions are similar to the the MapHood function, but they will only include valid empty or occupied indices, and skip the others.int
MapHood(int[] hood)
This function takes a neighborhood (As generated by the neighborhood Util functions, or using GenHood2D/GenHood3D), translates the neighborhood coordinates to be centered around the agent, and computes the set of indices that the translated coordinates map to.int
MapHood(int[] hood, IndexCoords2DBool Eval)
This function takes a neighborhood and another mapping function as argument, the mapping function should return a boolean that specifies whether coordinates map to a valid location.int
MapI(Grid2D other)
returns the index of the center of the square in otherGrid that the coordinate maps to.int
MapOccupiedHood(int[] hood)
These functions are similar to the the MapHood function, but they will only include valid empty or occupied indices, and skip the others.double
MapXpt(Grid2D other)
returns the provided coordinate scaled to the dimensions of the otherGrid.int
MapXsq(Grid2D other)
returns the index of the center of the square in otherGrid that the coordinate maps to.double
MapYpt(Grid2D other)
returns the provided coordinate scaled to the dimensions of the otherGrid.int
MapYsq(Grid2D other)
returns the index of the center of the square in otherGrid that the coordinate maps to.abstract double
Xpt()
returns the X coordinate of the agent.abstract int
Xsq()
returns the X index of the square that the agent is currently on.abstract double
Ypt()
returns the Y coordinate of the agent.abstract int
Ysq()
returns the Y index of the square that the agent is currently on.-
Methods inherited from class HAL.GridsAndAgents.AgentBaseSpatial
Isq, MoveSQ
-
-
-
-
Method Detail
-
Xsq
public abstract int Xsq()
returns the X index of the square that the agent is currently on.
-
Ysq
public abstract int Ysq()
returns the Y index of the square that the agent is currently on.
-
Xpt
public abstract 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.
-
Ypt
public abstract double Ypt()
returns the Y 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.
-
MapXsq
public int MapXsq(Grid2D other)
returns the index of the center of the square in otherGrid that the coordinate maps to.
-
MapYsq
public int MapYsq(Grid2D other)
returns the index of the center of the square in otherGrid that the coordinate maps to.
-
MapI
public int MapI(Grid2D other)
returns the index of the center of the square in otherGrid that the coordinate maps to.
-
MapXpt
public double MapXpt(Grid2D other)
returns the provided coordinate scaled to the dimensions of the otherGrid.
-
MapYpt
public double MapYpt(Grid2D other)
returns the provided coordinate scaled to the dimensions of the otherGrid.
-
MapHood
public int MapHood(int[] hood)
This function takes a neighborhood (As generated by the neighborhood Util functions, or using GenHood2D/GenHood3D), translates the neighborhood coordinates to be centered around the agent, and computes the set of indices that the translated coordinates map to. The function returns the number of valid locations it set, which if wraparound is disabled may be less than the full set of coordinate pairs. this means that the passed in ret list will not be completely filled with valid entries. See the CellStep function in the Complete Model example for more information.
-
MapEmptyHood
public int MapEmptyHood(int[] hood)
These functions are similar to the the MapHood function, but they will only include valid empty or occupied indices, and skip the others.
-
MapOccupiedHood
public int MapOccupiedHood(int[] hood)
These functions are similar to the the MapHood function, but they will only include valid empty or occupied indices, and skip the others.
-
MapHood
public int MapHood(int[] hood, IndexCoords2DBool Eval)
This function takes a neighborhood and another mapping function as argument, the mapping function should return a boolean that specifies whether coordinates map to a valid location. the function will only include valid indices, and skip the others.
-
DispX
public double DispX(double x)
gets the X displacement from this agent to a given x position
-
DispY
public double DispY(double y)
gets the Y displacement from this agent to a given y position
-
Dist
public double Dist(double x, double y)
gets the distance from this agent to another position
-
DistSquared
public double DistSquared(double x, double y)
gets the distance squared from this agent to another position, more efficient than Dist
-
-