Commands Affecting Patchest (Printable)
ca, clearall [Observer]
Kills all turtles, sets all patches to black, and resets all patch variables.
cg, cleargraphics [Observer]
Sets all patches to black
count-patches-with ilist
[Observer, Turtle]
Returns the number of patches whose ilist
is true.
Sample usage:
show count-patches-with [(distance 0 0) < 5]
This gives the number of patches inside a circle of radius 5 centered at the
origin.
count-pc color
[Observer, Turtle]
Returns the number of patches that are the color color
.
cp, clearpatches [Observer]
Sets all patches to black and resets all patch variables.
diffuse variable percentage
[Observer]
Makes each patch give 1/8 of percentage
of variable
to each neighboring patch.
Note:percentage should be expressed as a number between 0 and 1.
diffuse4 variable percentage
[Observer]
Makes each patch give 1/4 of percentage
of variable
to each neighboring patch to the N, S, E and W.
Note:percentage should be expressed as a number between 0 and 1.
max-of-patches-with pred-ilist ilist
Reports the highest value of ilist
when run over the turtles
that statisfy pred-ilist
. If there are no patches in which pred-ilist
is true, reports minnum
, the smallest number possible without going
into negative infinity. Note: This command can also be executed by patches,
for example within an ask-patches
statement.
min-of-patches-with pred-ilist ilist
Reports the lowest value of ilist
when run over the turtles that
statisfy pred-ilist
. If there are no patches in which pred-ilist
is true, reports maxnum
, the largest number possible without going
into positive infinity. Note: This command can also be executed by patches,
for example within an ask-patches
statement.
nsum variable1 variable2
[Observer]
For each patch, takes the sum of variable1
from all neighboring
patches and places it in variable2
nsum4 variable1 variable2
[Observer]
For each patch, takes the sum of variable1
from the non-diagonal
(N,E,S,W) neighboring patches and places it in variable2
pc, patchcolor [Turtle]
Reports the color of the patch the turtle is on.
Please see the color reference for more info on colors.
pc-ahead [Turtle]
Reports the color of the patch one space ahead in the direction that the turtle
is facing.
Please see the color reference for more info on colors.
pc-at xcor ycor
[Observer, Turtle]
Reports the color of the patch xcor
units in the x direction
and ycor
units in the y direction away from the caller.
Please see the color reference for more info on colors.
pc-towards angle distance
[Observer, Turtle]
Reports the color of the patch distance
away at a relative heading
of angle
.
Please see the color reference for more info on colors.
pstamp color
[Observer]
Allows patches to set the color of the turtle that is on it to color.
pstamp-at xcor ycor color
[Observer]
Allows patches to set the color of the turtle xcor
patches in
the x-direction and ycor
patches in the y-direction away to color.
pstamp-towards radius angle color
[Observer]
Allows patches to set the color of the turtle radius
units away
at an angle of angle
to color.
scale-pc color variable limit1 limit2
[Observer]
Patches set their color to a shade of color
based on their value
of variable
. limit1
and limit2
determine
the amount of gradation.
Example:
scale-color green density 0 20
Patches turn one of twenty shades of green. Patches with lower density turn
darker green.
scale-color blue energy 20 0
Patches turn one of twenty shades of green. Patches with lower density turn
lighter green.
NOTE: This is a patch command. It must be called from within an ask-patches
or ask-patch-at
statement
setpc, setpatchcolor color
[Observer, Turtle]
This command has two different uses. It can be run as a turtle command, in
which case it will set the color of the patches which are underneath turtles
to color
. It can also be run as a patch command, inside either
an ask-patches
or ask-patch-at
statement. In these
cases, the patches being asked will set their color to color
.
stamp color
[Observer, Turtle]
Sets color of patch under turtle to color
stamp-at xcor ycor color
[Observer, Turtle]
Sets the color of the patch xcor
units in the x direction and
ycor
units in the y direction away from the caller to color
.
stamp-towards angle distance color
[Turtle]
Sets the color of the patch distance
away, if the heading were
angle
, to color
.
sum-of-patches ilist
[Observer, Turtle]
Reports the total of evaluating ilist
in every patch and adding
it up.
Example usage: show sum-of-patches [food]
This gives the total amount of food in the world.
sum-of-patches-with pred-ilist ilist
[Observer, Turtle]
Reports the total value of ilist
when run over the turtles that
statisfy pred-ilist
. If there are no patches in which pred-ilist
is true, reports 0. Note: This command can also be executed by patches, for
example within an ask-patches
statement.
Example: sum-of-patches-with (pc = green or pc = blue) [density]
returns the sum of the densities of all patches which are blue or green.