Class: ABM.Set

Defined in: src/set.coffee
Inherits: ABM.Array

Direct Known Subclasses

ABM.BreedSet

Class Method Summary

Instance Method Summary

Inherited Method Summary

Methods inherited from ABM.Array

.from #toFixed #any #empty #clear #clone #first #last #select #reject #sample #contains #remove #removeItem #shuffle #min #max #sum #average #median #histogram #sort #uniq #flatten #concat #normalize #normalizeInt #ask #with #getProperty #setProperty #other

Class Method Details

. (void) from(array, setType)

from is a static wrapper function converting an array into an @model.Set

It gains access to all the methods below. Ex:

array = [1, 2, 3]
@model.Set.from(array)
randomNr = array.random()

Instance Method Details

# (void) from(array, setType = @undefined)

The static @model.Set.from as a method.

Used by methods creating new sets.

In the examples below, we'll use an array of primitive agent objects with three fields: id, x, y.

AS = for i in [1..5] # long form comprehension
  {id:i, x:u.randomInt(10), y:u.randomInt(10)}
@model.Set.from AS # Convert AS to Set in place
   [{id: 1, x: 0, y: 1}, {id: 2, x: 8, y: 0}, {id: 3, x: 6, y: 4},
    {id: 4, x: 1, y: 3}, {id: 5, x: 1, y: 1}]

# (void) setDefault(name, value)

Set the default value of an agent class, return agentset

# (void) exclude(breeds)

Return all agents that are not of the given breeds argument. Breeds is a string of space separated names:

@patches.exclude "roads houses"

# (void) draw(context)

For agentsets whose agents have a draw method. Clears the graphics context (transparent), then calls each agent's draw(context) method.

# (void) show()

Show/Hide all of an agentset or breed.

To show/hide an individual object, set its prototype: o.hidden = bool

# (void) hide()

# (void) inRadius(point, options)

Return all agents within d distance from given object.

# (void) inCone(point, options)

As above, but returns agents also limited to the angle cone around a heading from point.

    Quickly fuzzy find classes, mixins, methods, file:

    Control the navigation frame:

    You can focus and blur the search input: