Patches

Patches are the world other AgentSets live on. They define a coord system from the Model's World values: minX, maxX, minY, maxY, (minZ, maxZ) (z optional)

Patches form a grid of Patch objects which can store world data (elevation, fires, ant pheromones, buildings, roads, gis spatial data, water and so on)

Created by class Model. Used by modeler in their Model subclass

Constructor

new Patches(model, AgentClass, name)

Creates an instance of Patches.

Parameters:
NameTypeDescription
modelModel

An instance of class Model

AgentClassPatch

The Patch class managed by Patches

namestring

Name of the AgentSet

Methods

neighbors(patch) → {AgentList}

Return the 8 patch "Moore" neighbors of the given patch. Will be less than 8 on the edge of the patches

Parameters:
NameTypeDescription
patchPatch

a Patch instance

Returns:

An array of the neighboring patches

Type: 
AgentList

neighbors4(patch) → {AgentList}

Return the 4 patch "Van Neumann" neighbors of the given patch. Will be less than 4 on the edge of the patches

Parameters:
NameTypeDescription
patchPatch

a Patch instance

Returns:

An array of the neighboring patches

Type: 
AgentList

importDataSet(dataSet, property, useNearestopt)

Assign a DataSet's values into the patches as the given property name

Parameters:
NameTypeAttributesDefaultDescription
dataSetDataSet

An instance of DataSet

propertystring

A Patch property name

useNearestboolean<optional>
false

Resample to nearest dataset value?

exportDataSet(property, Typeopt) → {DataSet}

Extract a property from each Patch as a DataSet

Parameters:
NameTypeAttributesDefaultDescription
propertystring

The patch numeric property to extract

TypeType<optional>
Array

The DataSet array's type

Returns:

A DataSet of the patche's values

Type: 
DataSet

patchIndex(x, y) → {number}

Return index into Patches given valid x,y integers

Parameters:
NameTypeDescription
xnumber

Integer X value

ynumber

Integer Y value

Returns:

Integer index into Patches array

Type: 
number