Libraries‎ > ‎Library‎ > ‎Environment‎ > ‎

Attribute of patches

BehaviourComposer: ignore everything before this.

Begin micro-behaviour:

Begin description:

Set the value of an attribute of all patches.

End description

Patch attribute

Begin NetLogo code:

substitute-text-area-for attribute-name some-attribute-of-patch
substitute-text-area-for patch-attribute-value 42
ask-every-patch [set attribute-name 
                     patch-attribute-value]

End NetLogo code

Variants

The first text area can be any NetLogo patch variable (pcolor plabel plabel-color pxcor pycor) or a name that ends with '-of-patch'. The second text area can be any expression or value. An example is the micro-behaviour that gives each patch a different random color.

How this works

This uses the Behaviour Composer NetLogo command ask-every-patch [...] which is a faster but equivalent to NetLogo's ask patches [...]. It uses NetLogo's set command.

Related micro-behaviours

History

Patch attribute was first implemented by Ken Kahn on 19 November 2011.

BehaviourComposer: ignore everything after this.

Comments