Package HAL.GridsAndAgents
Class AgentSQ2Dunstackable<T extends AgentGrid2D>
- java.lang.Object
-
- HAL.GridsAndAgents.AgentBase<T>
-
- HAL.GridsAndAgents.AgentBaseSpatial<T>
-
- HAL.GridsAndAgents.Agent2DBase<T>
-
- HAL.GridsAndAgents.AgentSQ2Dunstackable<T>
-
- Type Parameters:
T
- the extended Grid2unstackable class that the agents will live in Created by rafael on 11/18/16.
- All Implemented Interfaces:
java.io.Serializable
public class AgentSQ2Dunstackable<T extends AgentGrid2D> extends Agent2DBase<T> implements java.io.Serializable
extend the AgentSQ2Dunstackable class if you want agents that exist on a 2D discrete lattice without the possibility of stacking multiple agents on the same typeGrid square- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AgentSQ2Dunstackable()
-
Method Summary
Modifier and Type Method Description int
Age()
returns the age of the agent, in ticks.void
Dispose()
Deletes the agentvoid
GetAllOnSquare(java.util.ArrayList<AgentBaseSpatial> putHere)
int
Isq()
Gets the index of the square that the agent occupiesvoid
MoveSafeSQ(int newX, int newY)
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
MoveSQ(int i)
Moves the agent to the square with the specified indexvoid
MoveSQ(int x, int y)
Moves the agent to the square at the specified coordinatesvoid
SwapPosition(AgentSQ2Dunstackable<T> other)
swaps the positions of two agents.double
Xpt()
Gets the xDim coordinate agentint
Xsq()
Gets the xDim coordinate of the square that the agent occupiesdouble
Ypt()
Gets the yDim coordinate agentint
Ysq()
Gets the yDim coordinate of the square that the agent occupies-
Methods inherited from class HAL.GridsAndAgents.Agent2DBase
DispX, DispY, Dist, DistSquared, MapEmptyHood, MapHood, MapHood, MapI, MapOccupiedHood, MapXpt, MapXsq, MapYpt, MapYsq
-
Methods inherited from class HAL.GridsAndAgents.AgentBase
BirthTick, IsAlive, SetBirthTick
-
-
-
-
Method Detail
-
MoveSQ
public void MoveSQ(int i)
Moves the agent to the square with the specified index- Specified by:
MoveSQ
in classAgentBaseSpatial<T extends AgentGrid2D>
-
MoveSQ
public void MoveSQ(int x, int y)
Moves the agent to the square at the specified coordinates
-
MoveSafeSQ
public void MoveSafeSQ(int newX, int newY)
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.
-
Xsq
public int Xsq()
Gets the xDim coordinate of the square that the agent occupies- Specified by:
Xsq
in classAgent2DBase<T extends AgentGrid2D>
-
Ysq
public int Ysq()
Gets the yDim coordinate of the square that the agent occupies- Specified by:
Ysq
in classAgent2DBase<T extends AgentGrid2D>
-
Xpt
public double Xpt()
Gets the xDim coordinate agent- Specified by:
Xpt
in classAgent2DBase<T extends AgentGrid2D>
-
Ypt
public double Ypt()
Gets the yDim coordinate agent- Specified by:
Ypt
in classAgent2DBase<T extends AgentGrid2D>
-
Dispose
public void Dispose()
Deletes the agent- Specified by:
Dispose
in classAgentBase<T extends AgentGrid2D>
-
GetAllOnSquare
public void GetAllOnSquare(java.util.ArrayList<AgentBaseSpatial> putHere)
-
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 AgentGrid2D>
-
Isq
public int Isq()
Gets the index of the square that the agent occupies- Overrides:
Isq
in classAgentBaseSpatial<T extends AgentGrid2D>
-
SwapPosition
public void SwapPosition(AgentSQ2Dunstackable<T> other)
swaps the positions of two agents. useful for the AgentSQunstackable classes, which don't allow stacking of agents, making this maneuver otherwise impossible.
-
-