- All Superinterfaces:
AgentExtension
,ExtAgentInteractive
,ExtAnimationParams
,ExtWithSpaceType
,Serializable
public interface ExtAgentDiscrete extends ExtAgentInteractive, ExtAnimationParams, ExtWithSpaceType
An extension of
- time (continuous or discrete)
- 2D discrete space
- connections between agents, networks (e.g. social) and their visualization
- communication - message passing and broadcasting
Agent
designed to support agent based modeling in
discrete 2D space, in particular:- time (continuous or discrete)
- 2D discrete space
- connections between agents, networks (e.g. social) and their visualization
- communication - message passing and broadcasting
- Author:
- AnyLogic North America, LLC https://anylogic.com
Modifier and Type | Method | Description |
---|---|---|
Agent | getAgentAtCell |
Returns the agent located in the cell with a given row and column, or null.
|
Agent | getAgentNextToMe |
Returns the agent next to this agent in a given direction, if any.
|
int | getC() |
Returns the column of the agent's cell.
|
Agent[] | getNeighbors() |
Returns the array of neighbor agents, subject to the current
neighborhood type (Euclidean - {N,S,E,W}, Moore - also {..,NW,NW,SE,SW})
|
int | getR() |
Returns the row of the agent's cell.
|
boolean | isNextCellInsideSpace |
Returns
true if there is an adjacent cell in a given direction. |
void | jumpToCell |
Moves the agent into a cell with the given row and column.
|
boolean | jumpToRandomEmptyCell() |
Finds a random empty cell and places the agent there.
|
void | moveToNextCell |
Moves the agent to an adjacent cell in a given direction.
|
CellPosition | randomEmptyCell() |
Finds a pseudo-randomly located empty cell and returns its row and column in
the array with two elements.
|
void | setCell |
Puts the agent into a given cell.
|
void | setRC_xjal |
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. |
void | swapWithAgent |
Swaps the cell location of this agent with another agent.
|
void | swapWithCell |
Swaps this agent with an agent at the cell with the given row and column.
|
void | swapWithNextCell |
Swaps the agent with an agent at the adjacent cell in a given direction.
|
addConnection_xjal, agentInfo, connectTo, copyToAndDestroyOnSpaceTypeChange_xjal, deliver, deliver, disconnectFrom, disconnectFromAll, getConnectedAgent, getConnections, getConnectionsNumber, getEnvironment, getRandomConnectedAgent, getSpaceType, isConnectedTo, receive, removeConnection_xjal, restoreConnections_xjal, send, send, setEnvironment_xjal
int getR()
Returns the row of the agent's cell.
- Returns:
- the row of the agent's cell
int getC()
Returns the column of the agent's cell.
- Returns:
- the column of the agent's cell
void setCell(int r, int c)
Puts the agent into a given cell. Should only be used to initialize
the agent location. Agent is put into the given cell of discrete 2D environment
(it is assumed the cell is empty, and the agent has not yet been assigned a cell).
- Parameters:
r
- the row of the cellc
- the column of the cell
void jumpToCell(int r, int c)
Moves the agent into a cell with the given row and column.
Raises error if that cell is nonempty.
- Parameters:
r
- the row of the new cellc
- the column of the new cell
void moveToNextCell(CellDirection dir)
Moves the agent to an adjacent cell in a given direction.
- Parameters:
dir
- the direction (NORTH, SOUTH, ..., NORTHEAST, ...)
boolean isNextCellInsideSpace(CellDirection dir)
Returns
Returns
true
if there is an adjacent cell in a given direction.
Note that the cell may be occupied by some agent.Returns
false
if going in a given direction will push agent outside
the discrete space grid (e.g. moveToNextCell(CellDirection)
will throw error in such case)- Parameters:
dir
- the direction (NORTH, SOUTH, ..., NORTHEAST, ...)- Returns:
- whether the adjacent cell in the given direction exists (
true
) in the discrete space grid, or not (false
)
void swapWithCell(int r, int c)
Swaps this agent with an agent at the cell with the given row and column.
That cell may be empty - is this case simply moves the agent there.
- Parameters:
r
- the row of the new cellc
- the column of the new cell
void swapWithNextCell(CellDirection dir)
Swaps the agent with an agent at the adjacent cell in a given direction.
- Parameters:
dir
- the direction (NORTH, SOUTH, ..., NORTHEAST, ...)
void swapWithAgent(Agent anotherAgent)
Swaps the cell location of this agent with another agent.
- Parameters:
anotherAgent
- agent to swap cell location with. Should be located on the same environment
CellPosition randomEmptyCell()
Finds a pseudo-randomly located empty cell and returns its row and column in
the array with two elements.
- Returns:
- the cell position (row and column) of the empty cell, or
null
boolean jumpToRandomEmptyCell()
Finds a random empty cell and places the agent there. If there is no empty cell,
does nothing.
- Returns:
true
if empty cell was found and agent was moved there, otherwisefalse
Agent getAgentAtCell(int r, int c)
Returns the agent located in the cell with a given row and column, or null.
- Parameters:
r
- the row of the cellc
- the column of the cell- Returns:
- the agent at (r,c) or null
Agent getAgentNextToMe(CellDirection dir)
Returns the agent next to this agent in a given direction, if any.
- Parameters:
dir
- the direction (NORTH, SOUTH, ..., NORTHEAST, ...)- Returns:
- the agent next to this agent in a given direction, or null
Agent[] getNeighbors()
Returns the array of neighbor agents, subject to the current
neighborhood type (Euclidean - {N,S,E,W}, Moore - also {..,NW,NW,SE,SW})
- Returns:
- the array of neighbor agents, or null if there are none
@AnyLogicInternalAPI void setRC_xjal(int r, int c)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. Please use
it may be removed/renamed in future. Please use
Agent.setCell(int, int)
instead.- Parameters:
r
-c
-