# Turtles

Turtles are objects living on the Patches world. Their coordinates are floats, unlike Patches with integer coordinates.

## Constructor

#### # new Turtles()

Source:
  - Turtles.js, line 13

### Extends

- AgentSet

### Methods

#### # addAgent(o) → {Object}

Add an Agent to this AgentSet. Only used by factory methods. Adds the `id` property to Agent. Increment AgentSet `ID`.

Parameters:

Name | Type | Description
--- | --- | ---
`o` | Object | An Agent to be added to this AgentSet

Inherited From:
  - AgentSet#addAgent
Source:
  - AgentSet.js, line 157

Returns:

The input Agent, bound to this AgentSet.

Type
  Object

#### # ask(fcn)

Call fcn(agent, index, array) for each item in AgentArray. Index & array optional. Overrides AgentArray's ask with additional guards for modifications in AgentSet's array.

Parameters:

Name | Type | Description
--- | --- | ---
`fcn` | function | fcn(agent, index?, array?)

Inherited From:
  - AgentSet#ask
Source:
  - AgentSet.js, line 267

#### # askSet(fcn)

A much stronger version of ask(fcn) with stronger mutability guards.

Parameters:

Name | Type | Description
--- | --- | ---
`fcn` | function | fcn(agent, index?, array?)

Inherited From:
  - AgentSet#askSet
Source:
  - AgentSet.js, line 281

#### # clear()

Remove all Agents from this AgentSet using agent.die() for each agent.

Inherited From:
  - AgentSet#clear
Source:
  - AgentSet.js, line 173

#### # getDefault(name) → {any}

Return a default, shared value

Parameters:

Name | Type | Description
--- | --- | ---
`name` | String | The name of the default

Inherited From:
  - AgentSet#getDefault
Source:
  - AgentSet.js, line 211

Returns:

The default value

Type
  any

#### # inPatches(patches) → {AgentArray}

Return an array of this breed within the array of patchs

Parameters:

Name | Type | Description
--- | --- | ---
`patches` | Array.<Patch> | Array of patches

Source:
  - Turtles.js, line 51

Returns:

Type
  AgentArray

#### # isBaseSet() → {boolean}

Inherited From:
  - AgentSet#isBaseSet
Source:
  - AgentSet.js, line 129

Returns:

true if I am a Patches, Turtles or Links AgentSet

Type
  boolean

#### # isBreedSet() → {boolean}

Inherited From:
  - AgentSet#isBreedSet
Source:
  - AgentSet.js, line 123

Returns:

true if I am a baseSet subarray

Type
  boolean

#### # newBreed(name) → {AgentSet}

Create a subarray of this AgentSet. Example: create a people breed of Turtles:

`people = turtles.newBreed('people')`

Parameters:

Name | Type | Description
--- | --- | ---
`name` | String | The name of the new breed AgentSet

Inherited From:
  - AgentSet#newBreed
Source:
  - AgentSet.js, line 116

Returns:

A subarray of me

Type
  AgentSet

#### # protoMixin(agentProto, AgentClass)

Add common variables to an Agent being added to this AgentSet.

Each Agent has it's AgentSet and the Model instance. It also has an id, set by the AgentSet's global ID.

The Agent also has three methods added: setBreed, getBreed, isBreed.

Parameters:

Name | Type | Description
--- | --- | ---
`agentProto` | Object | A new instance of the Agent being added
`AgentClass` | Patch | Turtle | Link | It's Class

Inherited From:
  - AgentSet#protoMixin
Source:
  - AgentSet.js, line 77

#### # removeAgent(o) → {AgentSet}

Remove an Agent from this AgentSet

Parameters:

Name | Type | Description
--- | --- | ---
`o` | Object | The Agent to be removed

Inherited From:
  - AgentSet#removeAgent
Source:
  - AgentSet.js, line 183

Returns:

This AgentSet with the Agent removed

Type
  AgentSet

#### # setBreed(a) → {Agent}

Move an agent from its AgentSet/breed to be in this AgentSet/breed

Parameters:

Name | Type | Description
--- | --- | ---
`a` | Agent | An agent, a member of another AgentSet

Inherited From:
  - AgentSet#setBreed
Source:
  - AgentSet.js, line 236

Returns:

The updated agent

Type
  Agent

#### # setDefault(name, value) → {AgentSet}

Set a default value shared by all Agents in this AgentSet

Parameters:

Name | Type | Description
--- | --- | ---
`name` | String | The name of the shared value
`value` | any |

Inherited From:
  - AgentSet#setDefault
Source:
  - AgentSet.js, line 201

Returns:

This AgentSet

Type
  AgentSet

#### # withBreed(breed) → {AgentArray}

Return breeds in a subset of an AgentSet

Ex: patches.inRect(5).withBreed(houses)

Parameters:

Name | Type | Description
--- | --- | ---
`breed` | AgentSet | A breed AgentSet

Inherited From:
  - AgentSet#withBreed
Source:
  - AgentSet.js, line 141

Returns:

Type
  AgentArray