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

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

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 115

#### # neighbors(patch) → {AgentArray}

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 79

Returns:

An array of the neighboring patches

Type
  AgentArray

#### # neighbors4(patch) → {AgentArray}

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 98

Returns:

An array of the neighboring patches

Type
  AgentArray

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

Returns:

Integer index into Patches array

Type
  number