Class: ABM.Patch

Defined in: src/


Patch instances represent a rectangle on a grid. They hold variables that are in the patches the agents live on. The set of all patches (@model.patches) is the world on which the agents live and the model runs.

Variables Summary

id =

Unique ID, set by BreedSet create() factory method.

breed =

The BreedSet this agent belongs to.

position =

Position on the patch grid, hash with patch coordinates {x: some float, y: float}.

color =

The color of the agent patch.

hidden =

Whether or not to draw this agent.

label =

Text for a label.

labelColor =

The color of the label.

labelOffset =
  x: 0,
  y: 0

The x, y offset of the label.

agents =

Agents on this patch.

Instance Method Summary

Constructor Details

# (void) constructor(position)

New Patch: Just set position {x: some integer, y: some integer}.

Instance Method Details

# (void) toString()

Returns a string representation of the patch.

# (void) empty()

Returns true if the patch is empty.

# (void) isOnEdge()

Returns true if this patch is on the edge of the grid.

# (void) sprout(number = 1, breed = @model, init = function() {})

Factory: Create num new agents on this patch. The optional init proc is called on the new agent after inserting in its agentSet.

# (void) distance(point, options)

Return distance in patch coordinates from me to given agent/patch using patch topology (isTorus).

Pass {euclidian: true} for always euclidian distance, and {dimension: true} for max distance along one dimension.

# (void) neighbors(options)

Get neighbors for patch.

# (void) neighborAgents(options)

Get agents on neigboring patches.

# (void) diamondNeighbors(range, meToo)

Not to be used directly, will not cache.

# (void) draw(context)

Draw the patch and its text label if there is one.

    Quickly fuzzy find classes, mixins, methods, file:

    Control the navigation frame:

    You can focus and blur the search input: