AnyLogic
Expand
Font size
All Superinterfaces:
AgentExtension, ExtAgentInteractive, ExtAnimationParams, ExtWithSpaceType, java.io.Serializable

public interface ExtAgentDiscrete
extends ExtAgentInteractive, ExtAnimationParams, ExtWithSpaceType
An extension of 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

Field Summary

Fields inherited from interface com.anylogic.engine.AgentExtension

P_AGENT_INTERACTIVE_DELEGATE, P_AGENT_WITH_SPATIAL_METRICS_DELEGATE, P_AGENT_WITH_SPECIFIC_SPACE, P_AGENT_WITH_SPECIFIC_SPACE_DELEGATE, P_ENTITY_DELEGATE, P_ENV_WITH_SPECIFIC_SPACE, P_ROOT, P_SPACE, P_USER_EXT

Method Summary

All Methods Instance Methods Abstract Methods 
Agent getAgentAtCell​(int r, int c)
Returns the agent located in the cell with a given row and column, or null.
Agent getAgentNextToMe​(CellDirection dir)
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​(CellDirection dir)
Returns true if there is an adjacent cell in a given direction.
void jumpToCell​(int r, int c)
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​(CellDirection dir)
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​(int r, int c)
Puts the agent into a given cell.
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.
void swapWithAgent​(Agent anotherAgent)
Swaps the cell location of this agent with another agent.
void swapWithCell​(int r, int c)
Swaps this agent with an agent at the cell with the given row and column.
void swapWithNextCell​(CellDirection dir)
Swaps the agent with an agent at the adjacent cell in a given direction.
Modifier and Type Method Description

Methods inherited from interface com.anylogic.engine.AgentExtension

getAgent, next_xjal, onDestroy, onExtensionRemoved, priority, setNext_xjal, supportsInterface_xjal

Methods inherited from interface com.anylogic.engine.ExtAgentInteractive

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

Methods inherited from interface com.anylogic.engine.ExtAnimationParams

getAnimationPosition, getAnimationX, getAnimationY, getAnimationZ, getPresentationScaleOnOwnerSpace, getSpace, isAnimationVisible_xjal, setSpace

Method Detail

getR

int getR()
Returns the row of the agent's cell.
Returns:
the row of the agent's cell

getC

int getC()
Returns the column of the agent's cell.
Returns:
the column of the agent's cell

setCell

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 cell
c - the column of the cell

jumpToCell

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 cell
c - the column of the new cell

moveToNextCell

void moveToNextCell​(CellDirection dir)
Moves the agent to an adjacent cell in a given direction.
Parameters:
dir - the direction (NORTH, SOUTH, ..., NORTHEAST, ...)

isNextCellInsideSpace

boolean isNextCellInsideSpace​(CellDirection dir)
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)

swapWithCell

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 cell
c - the column of the new cell

swapWithNextCell

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, ...)

swapWithAgent

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

randomEmptyCell

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

jumpToRandomEmptyCell

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, otherwise false

getAgentAtCell

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 cell
c - the column of the cell
Returns:
the agent at (r,c) or null

getAgentNextToMe

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

getNeighbors

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

setRC_xjal

@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 Agent.setCell(int, int) instead.
Parameters:
r -
c -
How can we improve this article?