On this page

# 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:

Name | Type | Description
--- | --- | ---
`model` | Model | An instance of class Model
`AgentClass` | Patch | The Patch class managed by Patches
`name` | string | Name of the AgentSet

Source
  - Patches.js, line 17

## Methods

### exportDataSet(property, Typeopt) → {DataSet}

Extract a property from each Patch as a DataSet

Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`property` | string |  |  | The patch numeric property to extract
`Type` | Type | <optional> | Array | The DataSet array's type

Source
  - Patches.js, line 139

Returns:

A DataSet of the patche's values

Type:
  DataSet

### importDataSet(dataSet, property, useNearestopt)

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

Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`dataSet` | DataSet |  |  | An instance of DataSet
`property` | string |  |  | A Patch property name
`useNearest` | boolean | <optional> | false | Resample to nearest dataset value?

Source
  - Patches.js, line 119

### 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:

Name | Type | Description
--- | --- | ---
`patch` | Patch | a Patch instance

Source
  - Patches.js, line 81

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:

Name | Type | Description
--- | --- | ---
`patch` | Patch | a Patch instance

Source
  - Patches.js, line 101

Returns:

An array of the neighboring patches

Type:
  AgentList

### patchIndex(x, y) → {number}

Return index into Patches given valid x,y integers

Parameters:

Name | Type | Description
--- | --- | ---
`x` | number | Integer X value
`y` | number | Integer Y value

Source
  - Patches.js, line 159

Returns:

Integer index into Patches array

Type:
  number

Type anything to view search result