On this page

# Model

Class Model is the primary interface for modelers, integrating the Patches/Patch Turtles/Turtle and Links/Link AgentSets .. i.e.:

- model.Patches: an array Patches of Patch instances
- model.Turtles: an array Turtles of Turtle instances
- model.Links: an array Links of Link instances
- model.breed: a sub-array of any of the three above.
- All of which are subclasses of AgentSet.

Convention: Three abstract methods are provided by the modeler

- Startup(): (Optional) Called once to import images, data etc
- Setup(): Called to initialize the model state.
- Step(): Step the model. Will advance ticks.

## Constructor

### new Model(worldOptionsopt)

Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`worldOptions` | Object | World | <optional> | World.defaultOptions() | Can be Object of min/max X,Y,Z values or an instance of World or GeoWorld

Source
  - Model.js, line 31

## Methods

### reset(worldOptionsopt)

Resets model to initial state w/ new Patches, Turtles, Links. The worldOptions will default to initial values but can be changed by modeler. Setup() often called after reset() to re-initialize the model.

Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`worldOptions` | Object | World | <optional> | this.world | World object

Source
  - Model.js, line 73

### tick()

Increment the tick cound. Not needed if autoTick true, the default

Source
  - Model.js, line 80

### (async, abstract) startup()

An abstract method to perform one-time initialization.

Source
  - Model.js, line 89

### (abstract) setup()

An abstract method for initializing the model

Note: can be used with reset(). This will reinitialize the Patches, Turtles, Links for re-running the model

- reset()
- setup()

Source
  - Model.js, line 101

### (abstract) step()

An abstract method to run the model one step.

Source
  - Model.js, line 107

### patchBreeds(breedNames)

Create breeds (sub-arrays) of Patches. Used in the Exit model:

- this.patchBreeds('exits inside wall')

Parameters:

Name | Type | Description
--- | --- | ---
`breedNames` | string | A string of space separated breeds names

Source
  - Model.js, line 133

### turtleBreeds(breedNames)

Create breeds (sub-arrays) of Turtles. Used in Wallfollower model:

- this.turtleBreeds('lefty righty')

Parameters:

Name | Type | Description
--- | --- | ---
`breedNames` | string | A string of space separated breeds names

Source
  - Model.js, line 144

### linkBreeds(breedNames)

Create breeds (sub-arrays) of Links. Used in Roads model:

- this.linkBreeds('trips')

Parameters:

Name | Type | Description
--- | --- | ---
`breedNames` | string | A string of space separated breeds names

Source
  - Model.js, line 155

Type anything to view search result