# Model

#### # new Model(worldOptionsopt, autoTickopt)

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. See AgentSet's ct
- 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 if autoTick = true in constructor.

See tutorial 01-HelloModel

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
`autoTick` | boolean | <optional> | true | Automatically advancee tick count each step if true

Source:
  - Model.js, line 28

### Methods

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

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

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

#### # (abstract) setup()

A 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 100

#### # (async, abstract) startup()

A method to perform one-time initialization

Source:
  - Model.js, line 88

#### # (abstract) step()

Run the model one step.

Source:
  - Model.js, line 106

#### # tick()

Increment the tick cound. Generally not needed if autoTick true

Source:
  - Model.js, line 77

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