Skip to main content
. 2020 Mar 10;16(3):e1007635. doi: 10.1371/journal.pcbi.1007635

Table 3. HAL functions used in the example.

Each function is a method of a particular object, meaning that when the function is called it may use properties that pertain to the object that it is called from.

Function Object Action
NewAgentSQ(INDEX) AgentGrid2D Returns a new agent, placed at the center of the square at the provided position INDEX.
ShuffleAgents(RNG) AgentGrid2D Usually called after every timestep to shuffle the order of agent iteration.
GetTick() AgentGrid2D Returns the current grid timestep.
ItoX(INDEX), ItoY(INDEX) AgentGrid2D Converts from a grid position INDEX into the x and y components that point to the same grid position.
MapHood(NEIGHBORHOOD,X,Y) AgentGrid2D Finds all position indices in the provided neighborhood, centered around X,Y that don’t fall out of bounds of the AgentGrid2D. Writes these indices into the NEIGHBORHOOD argument, and returns the number that were found.
MapEmptyHood(NEIGHBORHOOD) AgentSQ2D Finds all position indices in the provided neighborhood, centered around the agent, that do not have an agent occupying them. Writes these indices into the NEIGHBORHOOD argument, and returns the number that were found.
G AgentSQ2D Gets the grid that the agent occupies.
Isq() AgentSQ2D Gets the position index of the grid square that the agent occupies.
Dispose() AgentSQ2D Removes the agent from the grid and from iteration.
Get(INDEX) PDEGrid2D Returns the concentration of the PDE field at the given index.
Mul(INDEX, VALUE) PDEGrid2D Multiplies the concentration at the given INDEX by VALUE and adds the result to the current concentration when Update() is called
DiffusionADI(RATE) PDEGrid2D Applies diffusion using the ADI method with the rate constant provided. A reflective boundary is assumed. The result is applied when Update() is called.
DiffusionADI(RATE, BOUNDARY_COND) PDEGrid2D Applies diffusion using the ADI method with the RATE constant provided. The BOUNDARY_COND value diffuses from the grid borders. The result is applied when Update() is called.
Update() PDEGrid2D Applies all state changes simultaneously to the PDEGrid
SetPix(INDEX, COLOR) GridWindow Sets the color of a pixel.
TickPause(MILLISECONDS) GridWindow Pauses the program between calls to TickPause. The function automatically subtracts the time between calls from MILLISECONDS to ensure a consistent timestep rate for visualization.
ToPNG(FILENAME) GridWindow Writes out the current state of the UIWindow to a PNG image file.
Close() GridWindow Closes the GridWindow.
ProbScale(PROB, DURATION) Util Scales the probability that an event will occur in 1 unit of time to the probability that the event will occur at least once in the DURATION.
RGB(RED, GREEN, BLUE) Util Returns an integer with the requested color in RGB format. This value can be used for visualization.
HeatMapRGB(VALUE) Util Maps the VALUE argument (assumed to be between 0 and 1) to a color in the heat colormap.
CircleHood(INCLUDE_ORIGIN, RADIUS) Util Returns a set of coordinate pairs that define the neighborhood of all squares whose centers are within the RADIUS distance of the center (0, 0) origin square. The INCLUDE_ORIGIN argument specifies whether to include the origin in this set of coordinates.
MooreHood(INCLUDE_ORIGIN) Util Returns a set of coordinate pairs that define a Moore neighborhood around the (0, 0) origin square. The INCLUDE_ORIGIN Boolean specifies whether we intend to include the origin in this set of coordinates.
Write(STRING) FileIO Writes the STRING to the output file.
Close() FileIO Closes the output file.
Double() Rand Generates a random double value in the range [0 − 1)