Constructor
new Turtles(model, AgentClass, name, baseSetopt)
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
model | Model | The model I belong to | ||
AgentClass | Turtle | | The Turtle class | ||
name | string | The name of this new Turtles instance | ||
baseSet | null | | <optional> | null | Used to create a breed subclass |
- Source
Methods
createOne(initFcnopt) → {Turtle}
Create a single Turtle, adding it to this Turtles array. The init function is called to initialize the new Turtle. Returns the new Turtle.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
initFcn | function | <optional> | turtle => {} |
- Source
The newly created Turtle
- Type:
- Turtle
create(number, initFcnopt) → {Array}
Create num Turtles, adding them to this Turtles array. The init function is called to initialize each new Turtle. Returns an array of the new Turtles
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
number | number | Number of Turtles to create | ||
initFcn | function | <optional> | turtle => {} | A function to initialize new turtles. |
- Source
The newly created Turtles
- Type:
- Array
closestTurtle(x, y, radius) → {Turtle}
Return the closest turtle within radius distance of x,y. Return null if no turtles within radius. If I am a breed, return the closest fellow breed.
Name | Type | Description |
---|---|---|
x | number | X coordinate |
y | number | Y coordinate |
radius | number | Radius in patches units |
- Source
The closest Turtle
- Type:
- Turtle
inPatches(patches) → {AgentList}
Return an array of Turtles within the array of patchs. If I am a breed, return only the Turtles of my breed.
Name | Type | Description |
---|---|---|
patches | Array.<Patch> | Array of patches |
- Source
The turtles withn the Patches array.
- Type:
- AgentList
inPatchRect(turtle, dx, dyopt, meTooopt) → {AgentList}
Return an array of Turtles within the dx,dy patchRect centered on turtle. If I am a breed, return only the Turtles of my breed.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
turtle | Turtle | The Turtle at the patchRect center. | ||
dx | number | The integer x radius of the patchRect | ||
dy | number | <optional> | dx | The integer y radius of the patchRect |
meToo | boolean | <optional> | false | Whether or not to return me as well |
- Source
The turtles within the patchRect
- Type:
- AgentList
inPatchRectXY(x, y, dx, dyopt, meTooopt) → {AgentList}
Return an array of Turtles within the dx,dy patchRect centered on x,y. If I am a breed, return only the Turtles of my breed.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x | number | the patchRect center's integer x value | ||
y | number | the patchRect center's integer y value | ||
dx | number | The integer x radius of the patchRect | ||
dy | number | <optional> | dx | The integer y radius of the patchRect |
meToo | boolean | <optional> | false | Whether or not to return me as well |
- Source
The turtles within the patchRect
- Type:
- AgentList
inRadius(turtle, radius, meTooopt) → {AgentList}
Return all the Turtles within radius of me. If I am a breed, return only fellow breeds.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
turtle | Turtle | |||
radius | number | |||
meToo | boolean | <optional> | false | Whether or not to return me as well |
- Source
The turtles within radius of me
- Type:
- AgentList
inCone(turtle, radius, meTooopt) → {AgentList}
Return all the Turtles with a cone of me. The cone is coneAngle wide, centered on my heading. If I am a breed, return only fellow breeds.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
turtle | Turtle | |||
radius | number | |||
meToo | boolean | <optional> | false | Whether or not to return me as well |
- Source
The turtles within the cone.
- Type:
- AgentList
layoutCircle(radiusopt, centeropt)
Position the Turtles in this breed in an equally spaced circle of the given center and radius. The turtle headings will be away from the center.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
radius | number | <optional> | this.model.world.maxX * 0.9 | The circle's radius |
center | Array | <optional> | [0, 0] | An x,y array |
- Source