Command List

This is a list of all StarLogo commands.

Turtle, Observer, Patch

number1 +, -, *, /, ^ number2

Parameters:
number1 Number
number2 Number

Description:
Basic math functions. Be sure to put a space between the numbers and the symbol.

Examples:
5 + 3 returns 8

variable1 * variable2 returns the product of the numbers stored in variable1 and variable2

xcor ^ 2 returns the square of the turtle's x coordinate.


Turtle, Observer, Patch

number1 >, <, =, !=, <=, >=, not= number2

Parameters:
number1 Number
number2 Number

Description:
Equivalency operators. A space is needed between the numbers and the symbol.

Examples:
5 = 5 returns true

5 != 3 returns true

number1 <= number2 returns true if the number stored in number1 was less than or equal to the number stored in number2, otherwise it would return false

Notes:
!= and not= both return true if number1 and number2 are not equal to each other


Turtle, Observer, Patch

abs number

Parameters:
number Number the number whose absolute value is to be determined

Description:
Reports the absolute value of number.

Turtle, Observer, Patch

acos number

Parameters:
number Number

Description:
Trigonometric function. Returns the arccosine of number. All angles returned are in degrees.

Related Commands:
asin atan cos sin tan
Turtle

alive?

Description:
A tautology that always returns true. While this command may not seem useful, its counterpart alive?-of is.

Related Commands:
alive?-of
Turtle, Observer, Patch

alive?-of who number

Parameters:
who number Integer The who id of a turtle

Description:
Returns a boolean. If the turtle with the given who number is alive, it returns true. If the turtle with the given who number is not alive it returns false.

This command is useful when looping over a set of turtle who-numbers. Since each turtle may die between the time you get the who numbers and the time you ask it about itself, you should check alive?-of before using it. A better way to loop over a set of turtles is to use grab because grabbed turtles that try to die will not be allowed to completely die until they are let go.

Examples:
alive?-of 2 returns true when the turtle with who number 2 is alive.

Related Commands:
alive?
Turtle, Observer, Patch

condition1 and condition2

Parameters:
condition1 Boolean
condition2 Boolean

Description:
Reports true if condition1 and condition2 report true.

Related Commands:
not or xor
Turtle, Observer, Patch

asin number

Parameters:
number Number

Description:
Trigonometric function. Returns the arcsine of number. All angles returned are in degrees.

Related Commands:
acos sin tan
Observer

ask-breed [list of commands]

Parameters:
[list of commands] List of turtle commands A list of turtle commands to run

Description:
Asks all turtles of breed frogs to run [list of commands]. The observer will wait for all of the turtles to finish before continuing.

Examples:
ask-frogs [fd 1 rt 90] will make all turtles of breed frogs move forward one step and then turn 90 degrees to the right.

Related Commands:
ask-breed-with ask-list-of-turtles ask-patch-at ask-patches ask-turtle ask-turtles ask-turtles-with
Observer

ask-breed-with [condition] [list-of-commands]

Parameters:
[condition] List of commands list of commands that evaluates to either true or false
[list-of-commands] List of turtle commands list of commands to run

Description:
This observer command asks all of the turtles of the breed specified that satisfy [condition] to run the [list-of-commands]. The observer will wait for the turtles to finish before moving on.

Examples:
ask-frogs-with [color = green] [fd 1] has all of the turtles of color green and breed frogs move forward 1

Related Commands:
ask-breed
Turtle, Observer, Patch

ask-list-of-turtles [list of turtle who numbers] [list of commands]

Parameters:
[list of turtle who numbers] List A list of turtle who numbers to ask
[list of commands] List of turtle commands A list of commands to ask these turtles to run

Description:
Turtles whose who numbers (ID numbers) are in [list of turtle who numbers] run [list of commands]. The caller of this command waits for it to finish before continuing. If some invalid whonumbers make up [list of turtle who numbers], they are ignored.

Asking a list of turtles to do something is a moderately expensive operation since StarLogo creates a thread for each turtle. Try to group commands that you would have put into separate ask-list-of-turtles into the same one to minimize thread creation overhead.

Examples:
ask-list-of-turtles [4 6 10 14] [fd 1] makes 4 turtles (those with who numbers 4, 6, 10, and 14) move forward one step.

Related Commands:
ask-breed ask-patch-at ask-patches ask-turtle ask-turtles ask-turtles-with
Turtle, Observer, Patch

ask-patch-at [list of commands]

Parameters:
[list of commands] List of patch commands A list of commands for the patch to run

Description:
This command asks the patch which is xcor units in the x direction and ycor units in the y direction away from the caller to run the [list of commands]. The caller of this command will wait for the patch to finish before moving on. The observer is considered to be located at (0, 0).

Examples:
ask-patch-at 5 6 [setpc red] makes the patch 5 units to the right and 6 units up from the caller turn red.

ask-patch-at -3 -8 [setpc blue] makes the patch 3 units to the left and 8 units down from the caller turn blue.

Related Commands:
ask-breed ask-list-of-turtles ask-patches ask-patches-with ask-turtle ask-turtles ask-turtles-with
Observer

ask-patches [list of commands]

Parameters:
[list of commands] List of patch commands A list of commands for the patches to run

Description:
This observer command asks all of the patches to run the [list of commands]. The observer will wait for the patches to finish before moving on.

Asking the patches to do something is a moderately expensive operation since StarLogo creates a thread for each patch. Try to group commands that you would have put into separate ask-patches into the same one to minimize thread creation overhead.

Examples:
ask-patches [setpc red] colors all of the patches red.

Related Commands:
ask-breed ask-list-of-turtles ask-patch-at ask-turtle ask-turtles ask-turtles-with setbg
Observer

ask-patches-with [condition] [list-of-commands]

Parameters:
[condition] List of patch commands list of commands that evaluates to either true or false
[list-of-commands] Number list of commands to run

Description:
This observer command asks all of the patches that satisfy [condition] to run the [list-of-commands]. The observer will wait for the patches to finish before moving on.

Examples:
ask-patches-with [pc = red] [setpc blue] colors all of the red patches blue

Related Commands:
ask-patch-at
Turtle, Observer, Patch

ask-turtle who number [list of commands]

Parameters:
who number Integer The who number of a turtle
[list of commands] List of turtle commands A list of commands for the turtle to run

Description:
This command asks the turtle with who number number to run the [list of commands]. The caller will wait for the turtle to finish before moving on.

Examples:
ask-turtle 5 [fd 1] makes the turtle with who number 5 move forward 1 step.

Related Commands:
ask-breed ask-list-of-turtles ask-patch-at ask-patches ask-turtles ask-turtles-with
Observer

ask-turtles [list of commands]

Parameters:
[list of commands] List of turtle commands A list of commands for the turtles to run

Description:
Asks all turtles to run the [list of commands]. The observer will wait for all of the turtles to finish before continuing.

Asking all of the turtles to do something is a moderately expensive operation since StarLogo creates a thread for each turtle. Try to group commands that you would have put into separate ask-turtles into the same one to minimize thread creation overhead.

Examples:
ask-turtles [fd 1] will make all of the turtles move forward 1 step.

Related Commands:
ask-breed ask-list-of-turtles ask-patch-at ask-patches ask-turtle ask-turtles-with
Observer

ask-turtles-with [condition] [list of commands]

Parameters:
[condition] List of turtle commands An expression that returns a true or false value
[list of commands] List of turtle commands A list of commands for the turtles to run

Description:
This observer command asks turtles satisfying [condition] to run the [list of commands].
Asking many turtles to do something is a moderately expensive operation since StarLogo creates a thread for each turtle. Try to group commands that you would have put into separate ask-turtles-with into the same one to minimize thread creation overhead.

Examples:
ask-turtles-with [color = red] [fd 1] tells all red turtles to move forward one step.

Related Commands:
ask-breed ask-list-of-turtles ask-patch-at ask-patches ask-turtle ask-turtles
Turtle, Observer, Patch

atan numerator denominator

Parameters:
numerator Number
denominator Number

Description:
Trigonometric function. Returns the arctangent of the specified number numerator/denominator. All angles returned are in degrees.

Related Commands:
acos sin tan
Turtle, Observer, Patch

average-of-breed [list of commands]

Parameters:
[list of commands] List of turtle commands A list of commands for the frogs to run which returns a number

Description:
Returns the numerical average of the [list of commands] when evaluated across all the turtles of breed frogs.

Examples:
average-of-frogs [speed] returns the average speed of all the turtles of breed frogs.

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it, itself, is not included as part of the calculation.

Related Commands:
average-of-breed-with average-of-patches average-of-turtles max-of-breed median-of-breed min-of-breed mode-of-breed sum-of-breed variance-of-breed
Turtle, Observer, Patch

average-of-breed-with [condition] [list of commands]

Parameters:
[condition] List of turtle commands An expression that returns a true or false value
[list of commands] List of turtle commands A list of commands for the turtles to run which returns a number

Description:
Returns the numerical average of the [list of commands] when evaluated across all the turtles of breed frogs that satisfy the condition (must return a boolean of true or false) specified by the [condition].

Examples:
average-of-frogs-with [color = red] [speed] returns the average speed of all the red turtles of breed frogs.

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it, itself, is not included as part of the calculation.

Related Commands:
average-of-breed average-of-patches-with average-of-turtles-with max-of-breed-with median-of-breed-with min-of-breed-with mode-of-breed-with sum-of-breed-with variance-of-breed-with
Turtle, Observer, Patch

average-of-list [list of values]

Parameters:
[list of values] List List of values to average

Description:
Returns the numerical average of values in the given list.

Examples:
average-of-list [1 2 3 4 5] returns 3

Notes:
If [list of values] contains no numbers, an error occurs. If some of the [list of values] are not numbers, those values are ignored.

Related Commands:
max-of-list median-of-list min-of-list mode-of-list sdev-of-list sum-of-list variance-of-list
Turtle, Observer, Patch

average-of-patches [list of commands]

Parameters:
[list of commands] List of patch commands A list of commands for the patches to run which returns a number

Description:
Returns the numerical average of the [list of commands] when evaluated across all the patches.

Examples:
average-of-patches [pc] returns the average of the patch color of all of the patches.

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

Related Commands:
average-of-breed median-of-patches min-of-patches mode-of-patches sum-of-patches variance-of-patches
Turtle, Observer, Patch

average-of-patches-with [condition] [list of commands]

Parameters:
[condition] List of patch commands An expression that returns a true or false value
[list of commands] List of patch commands A list of commands for the patches to run which returns a number

Description:
Returns the numerical average of the [list of commands] when evaluated across all the patches that satisfy the condition (must return a boolean of true or false) specified by the [condition].

Examples:
average-of-patches-with [color = red] [food] returns the average food of all the red patches

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

Related Commands:
average-of-breed-with median-of-patches-with min-of-patches-with mode-of-patches-with sum-of-patches-with variance-of-patches-with
Turtle, Observer, Patch

average-of-turtles [list of commands]

Parameters:
[list of commands] List of turtle commands A list of commands for the turtles to run which returns a number

Description:
Returns the numerical average of the [list of commands] when evaluated across all the turtles.

Examples:
average-of-turtles [speed] returns the average speed of all the turtles.

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it, itself, is not included as part of the calculation.

Related Commands:
average-of-breed median-of-turtles min-of-turtles mode-of-turtles sum-of-turtles variance-of-turtles
Turtle, Observer, Patch

average-of-turtles-with [condition] [list of commands]

Parameters:
[condition] List of turtle commands An expression that returns a true or false value
[list of commands] List of turtle commands A list of commands for the turtles to run which returns a number

Description:
Returns the numerical average of the [list of commands] when evaluated across all the turtles that satisfy the conditions (must return a boolean of true or false) specified by the [condition].

Examples:
average-of-turtles-with [color = red] [energy] returns the average energy of all the red turtles.

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it, itself, is not included as part of the calculation.

Related Commands:
average-of-breed-with median-of-turtles-with min-of-turtles-with mode-of-turtles-with sum-of-turtles-with variance-of-turtles-with
Turtle

back (bk) steps

Parameters:
steps Number Number of turtle steps to move

Description:
Turtles move $steps$ backward.

Examples:
bk 4 makes the turtles move 4 steps backward.

Related Commands:
forward left right
Turtle, Observer, Patch

integer1 bitand integer2

Parameters:
integer1 Integer First argument
integer2 Integer Second argument

Description:
Reports the value of bitwise-and on the inputs.

Examples:
2 bitand 3 returns 2. This statement is executed in binary form as 0010 and 0011, which returns 0010.

Related Commands:
bitnot bitor bitxor
Turtle, Observer, Patch

bitnot value

Parameters:
value Integer The argument to be negated

Description:
Reports the bitwise-negation of its input.

Examples:
bitnot 4 returns -5. The negation of 00000100 is 11111011.

Related Commands:
bitand
Turtle, Observer, Patch

integer1 bitor integer2

Parameters:
integer1 Integer First argument
integer2 Integer Second argument

Description:
Reports the bitwise-or of the inputs.

Examples:
1 bitor 2 returns 3. This statement is executed in binary form as 0001 or 0010 which returns 0011.

Related Commands:
bitand
Turtle, Observer, Patch

integer1 bitxor integer2

Parameters:
integer1 Integer First argument
integer2 Integer Second argument

Description:
Reports the value of the bitwise-exclusive-or of the inputs.

Examples:
2 bitxor 3 returns 1. This statement is executed in binary form as 0010 xor 0011 which returns 0001.

Related Commands:
bitand
Turtle, Observer, Patch

black

Description:
Reports 0, the number of its particular hue in the color table.

Related Commands:
blue brown cyan gray green lime magenta orange pink purple red sky turquoise white yellow
Turtle, Observer, Patch

blue

Description:
Reports 105, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green lime magenta orange pink purple red sky turquoise white yellow
Turtle, Patch

breed

Description:
Returns the turtle's breed, or if a patch is calling it, the breed of one of the turtles on the patch.

Examples:
if breed = frogs [fd 5] makes all turtles of breed frogs move forward 5 steps.

Related Commands:
breed-at breed-of breed-towards setbreed who
Turtle, Observer, Patch

breed-at xcor ycor

Parameters:
xcor Number offset in the x direction
ycor Number offset in the y direction

Description:
Reports the breed of the turtle xcor units in the x direction and ycor units in the y direction away from the caller.

Examples:
breed-at 5 7 returns the breed of the turtle 5 units to the right and 7 units up from the caller.

Related Commands:
breed breed-of breed-towards setbreed-at
Turtle, Observer, Patch

breed-of number

Parameters:
number Integer id number of the turtle

Description:
Reports the breed of the turtle with ID number.

Examples:
if breed-of 4 = frog [fd 1] makes all the turtles move one step forward if the turtle which who number 4 is of breed frog.

Related Commands:
breed breed-at breed-towards setbreed-of
Turtle, Observer, Patch

breed-towards angle distance

Parameters:
angle Number
distance Number

Description:
Reports the breed of the turtle distance away at an angle of angle.

Examples:
breed-towards 0 1 returns the breed of the turtle one patch ahead of the patch or turtle given the instruction.

Related Commands:
breed breed-at breed-of setbreed-towards
Turtle, Observer

breeds [breed1 breed2 ...]

Parameters:
[breed1 breed2 ...] List or string A list of breed names (usually plural)

Description:
At the top of the Observer or Turtle command centers, place this command:

breeds [frogs toads]

to declare your turtles to have two different breeds, frogs and toads. Once you have done this, you may use any command in the Breeds category to run only on the breed of turtles that you have created.

Examples:
breeds [frogs toads]

to setup
create-frogs 100
create-toads 40
ask-frogs [hop]
ask-toads [ribbit]
end

Related Commands:
patches-own turtles-own
Turtle, Observer, Patch

brown

Description:
Reports 35, the number of its particular hue in the color table.

Related Commands:
black blue cyan gray green lime magenta orange pink purple red sky turquoise white yellow
Turtle, Observer, Patch

butfirst (bf) value

Parameters:
value List or string A list of data or a string

Description:
When passed a list, butfirst returns a new list [list of data] with the first item removed. The input list is not changed.

When passed a string, butfirst returns a new string with the first character removed. The input string is not changed.

Examples:
butfirst [4 5 6 7] returns [5 6 7].

Related Commands:
butlast first last lput sentence
Turtle, Observer, Patch

butlast (bl) value

Parameters:
value List or string The list of data or string to operate on

Description:
When given a list of data, returns the new value of value with the last item removed. The input list is not changed.

When given a string, returns a new string with the last character removed. The input string is not changed.

Examples:
butlast [4 5 6 7] returns [4 5 6].

Related Commands:
butfirst first last lput sentence
Turtle, Observer, Patch

case variable [ anything1 [list-of-commands1] anything2 [list-of-commands2] ]

Parameters:
variable Variable variable to check
[ anything1 [list-of-commands1] List of commands value to match and commands to run
anything2 [list-of-commands2] ] List of commands value to match and commands to run

Description:
Checks if the first argument variable is equal to any of the anythings in the list. If it is equal, the corresponding [list of commands] is executed and control skips to the end of the case statement. A case statement can often be used in place of nested ifelse statements. If nothing matches, no [lists of commands] are executed and control skips to the end of the case statement. You can use true as one of your anythings as a default case.

Examples:
case energy
[
1 [setc blue]
2 [setc yellow]
3 [setc red]
true [setc white]
]

This command will set the turtle's color to blue if energy is 1, yellow if energy is 2, red if energy is 3 and white in any other case.

Notes:
The first input can be an expression as well as a variable.


Turtle, Observer

clear-command-center (cc)

Description:
Clears the command center it is called from. An observer calling cc will clear the observer command center while a turtle calling cc will clear the turtle command center.

Observer

clear-graphics (cg)

Description:
Sets all patches to black.

Observer

clear-info (clearinfo)

Description:
Clears the Information Window.

Related Commands:
clear-output
Observer

clear-output (co)

Description:
Clears all the text in the output window.

Related Commands:
clear-info
Observer

clear-patches

Description:
Sets all patches to black and resets all patch variables to 0.

Observer

clear-plot (clearplot)

Description:
Clears everything drawn by all plot pens in the current plot window, and resets all pens to (0, 0) and their original colors.

Related Commands:
clearplots plot
Observer

clear-turtles (clearturtles) (ct)

Description:
Clears (kills) all of the turtles.

Observer

clearall (ca) (clear-all)

Description:
Kills all turtles, sets all patches to black, and resets all variables to 0.

Observer

clearplots

Description:
Clears all of the plots.

Related Commands:
clear-plot plot
Turtle, Patch

color

Description:
Returns the color of the turtle, or if a patch is calling it, the color of one of the turtles on the patch.

Examples:
if color = black
[fd 3]

has all turtles check if they are black, and if so, move themselves forward by 3 turtle steps.

Related Commands:
color-at color-of color-towards setcolor who
Turtle, Observer, Patch

color-at xcor ycor

Parameters:
xcor Number units in the x direction away from the caller
ycor Number units in the y direction away from the caller

Description:
Reports the color of the turtle xcor units in the x direction and ycor units in the y direction away from the caller .

Examples:
color-at 1 1 reports the color of the turtle one unit to the right and one unit above the patch or turtle given the command.

Related Commands:
color color-of color-towards setc-at
Turtle, Observer, Patch

color-of number

Parameters:
number Number who-number

Description:
Reports the color of the turtle with who number number.

Examples:
color-of 2 returns the color number of the turtle with who-number 2

Related Commands:
color color-at color-towards setc-of
Turtle, Observer, Patch

color-towards angle distance

Parameters:
angle Number angle from the caller
distance Number distance away from the caller

Description:
Reports the color of the turtle distance away at an angle of angle from the caller. Note that the angle is measured from the direction the caller is facing.

Examples:
color-towards 0 1 reports the color of the turtle one patch directly ahead of the caller.

Related Commands:
color color-at color-of setc-towards
Turtle, Observer, Patch

copy-list [list]

Parameters:
[list] List original list to be copied

Description:
Returns a copy of [list] such that if you edit the copy, you will not edit the original.

Examples:
copy-list [1 2 3] returns the list [1 2 3].

Related Commands:
list make-list sentence
Turtle, Observer, Patch

cos angle

Parameters:
angle Number angle in degrees

Description:
Trigonometry function. Returns the cosine of angle. All angles are in degrees.

Related Commands:
acos sin tan
Turtle, Observer, Patch

count-breed

Description:
Returns the number of turtles whose breed is frogs.

Related Commands:
count-breed-at count-breed-here count-breed-towards count-breed-with count-turtles
Turtle, Observer, Patch

count-breed-at xcor ycor

Parameters:
xcor Number units in the x direction away from the caller
ycor Number units in the y direction away from the caller

Description:
Returns the number of turtles whose breed is frogs which are xcor units in the x direction and ycor units in the y direction away from the caller.

Related Commands:
count-breed count-breed-here count-breed-towards count-breed-with count-turtles-at
Turtle, Patch

count-breed-here

Description:
Returns the number of turtles whose breed is frogs which are on the current patch.

Examples:
if count-frogs-here > 2 [setc blue] makes the turtle set its color to blue if there are more than two turtles of type frog on its current patch.

Related Commands:
count-breed count-breed-at count-breed-towards count-breed-with count-turtles-here
Turtle, Observer, Patch

count-breed-towards angle distance

Parameters:
angle Number angle from the direction the caller is facing
distance Number distance away from the caller

Description:
Returns the number of turtles whose breed is frogs which are located at the patch distance away at angle angle.

Examples:
count-frogs-towards 0 1 returns the number of turthles whose breed is frogs one patch ahead of the caller.

Notes:
Note the angle is measured from the direction the caller is facing.

Related Commands:
count-breed count-breed-at count-breed-here count-breed-with count-turtles-towards
Turtle, Observer, Patch

count-breed-with [list of commands]

Parameters:
[list of commands] List of commands condition to determine whether a frog is counted

Description:
Returns the number of turtles whose breed is frogs and satisfy the conditions (must return a boolean of true or false) specified by [list of commands].

Examples:
count-frogs-with [color = blue] returns the number of blue frogs.

Related Commands:
count-breed count-breed-at count-breed-here count-breed-towards count-turtles-with
Turtle, Observer, Patch

count-color color

Parameters:
color Number color of turtles to be counted

Description:
Returns the number of turtles that are the color color.

Examples:
count-color black returns the number of black turtles.

Related Commands:
count-color-range count-pc count-pc-range
Turtle, Observer, Patch

count-color-range mincolor maxcolor

Parameters:
mincolor Number low end of range of color of turtles to be counted
maxcolor Number high end of range of color of turtles to be counted

Description:
Returns the number of turtles that have colors between mincolor and maxcolor, inclusive.

Examples:
count-color-range 13.5 16.5 returns the number of turtles who are red (15) or within 1.5 shades of red. This command is useful if you have scaled your turtle's colors to shades of a particular color using scale-color.

Related Commands:
count-color count-pc count-pc-range
Turtle, Observer, Patch

count-patches

Description:
Returns the number of patches.

Related Commands:
count-patches-with count-turtles
Turtle, Observer, Patch

count-patches-with [list of commands]

Parameters:
[list of commands] Number condition to determine whether to count a turtle

Description:
Returns the number of patches whose [list of commands] is true.

Examples:
count-patches-with [(distance 0 0) < 5] returns the number of patches inside a circle of radius 5 centered at the origin.

Related Commands:
count-patches
Turtle, Observer, Patch

count-pc color

Parameters:
color Number color to determine whether to count a patch

Description:
Returns the number of patches that are the color color.

Examples:
count-pc blue returns the number of blue patches.

Notes:
This command can also be executed by patches, for example within an ask-patches statement.

Related Commands:
count-color count-color-range count-pc-range
Turtle, Observer, Patch

count-pc-range mincolor maxcolor

Parameters:
mincolor Number low end of range of colors to determine whether to count a patch
maxcolor Number high end of range of colors to determine whether to count a patch

Description:
Returns the number of patches that have colors between mincolor and maxcolor, inclusive.

Examples:
count-pc-range 64 66.5 returns the number of patches that are lime (65) or very close to it.

Related Commands:
count-color count-color-range count-pc
Turtle, Observer, Patch

count-plot-pens

Description:
Reports the number of plot pens in the current plot window. Use plotid to set the current plot window.

Related Commands:
set-count-plot-pens
Turtle, Observer, Patch

count-turtles

Description:
Reports the number of turtles.

Related Commands:
count-breed count-patches count-turtles-at count-turtles-here count-turtles-towards count-turtles-with one-of-breed one-of-turtles
Turtle, Observer, Patch

count-turtles-at xcor ycor

Parameters:
xcor Number units in the x direction away from the caller
ycor Number units in the y direction away from the caller

Description:
Reports the number of turtles xcor units in the x direction and ycor units in the y direction away from the caller.

Examples:
count-turtles-at 1 1 reports the number of turtles one patch to the right and one patch above the caller.

Related Commands:
count-breed-at count-turtles count-turtles-here count-turtles-towards count-turtles-with
Turtle, Patch

count-turtles-here

Description:
Reports the number of turtles sitting on the caller's patch.

Examples:
if count-turtles-here > 2 [setc blue] makes the turtle set its color to blue if there are more than two turtles on its current patch.

Related Commands:
count-breed-here count-turtles count-turtles-at count-turtles-towards count-turtles-with one-of-breed-here
Turtle, Observer, Patch

count-turtles-towards angle distance

Parameters:
angle Number angle measured from the direction the caller is facing
distance Number distance from the caller

Description:
Reports the number of turtles distance away at angle angle from the caller.

Examples:
count-turtles-towards 0 1 reports the number of turtles one patch directly in front of the caller.

Notes:
Note the angle is measured from the direction the caller is facing.

Related Commands:
count-breed-towards count-turtles count-turtles-at count-turtles-here count-turtles-with
Turtle, Observer, Patch

count-turtles-with [list of commands]

Parameters:
[list of commands] List of commands condition to determine whether to count a turtle

Description:
Reports the number of turtles whose [list of commands] is true.

Examples:
count-turtles-with [(distance 0 0) < 5] reports the number of turtles inside a circle of radius 5 centered at the origin.

Notes:
Note [list of commands] must be a boolean statement and return true or false.

Related Commands:
count-breed-with count-turtles count-turtles-at count-turtles-here count-turtles-towards myself one-of-turtles-with
Observer

create-breed number

Parameters:
number Number number of turtles to create

Description:
Creates number of turtles and assigns breed as their breed.

Examples:
create-frogs 2 creates two turtles of breed frogs.

create-cars 5 creates five turtles of breed cars.

Related Commands:
create-breed-and-do create-custom-turtles create-turtles
Observer

create-breed-and-do number [list-of-commands]

Parameters:
number Number number of turtles to create
[list-of-commands] List of commands commands for newly created turtles to run

Description:
Creates number of turtles and assigns breed as their breed. The turtles then execute [list-of-commands].

Examples:
create-frogs-and-do 5 [fd 3] would create 5 turtles of breed frogs and make them all move forward 3 steps.

Related Commands:
create-breed create-turtles-and-do
Observer

create-custom-turtles breed number

Parameters:
breed String type of turtles being created
number Number number of turtles to create

Description:
Creates number turtles of type breed.

Examples:
cct frogs 2 will create two turtles of type frog.

Notes:
Most users will use create-foxes directly rather than using create-custom-turtles.

Related Commands:
create-breed create-custom-turtles-and-do create-turtles
Observer

create-custom-turtles-and-do breed number [list of commands]

Parameters:
breed String type of turtles being created
number Number number of turtles to create
[list of commands] List of commands commands newly created turtles will run

Description:
Creates number turtles of type breed and tells them to do [list of commands].

Examples:
cct-and-do foxes 5 [fd 3] would create 5 foxes and make them all move forward 3 steps.

Notes:
Most users will use create-foxes-and-do directly intead of using cct-and-do.

Related Commands:
create-custom-turtles
Observer

create-turtles (crt) number

Parameters:
number Number number of turtles to create

Description:
Creates number turtles.

Examples:
crt 2 creates 2 turtles.

Related Commands:
create-breed create-custom-turtles create-turtles-and-do sprout
Observer

create-turtles-and-do (crt-and-do) number [list of commands]

Parameters:
number Number number of turtles to create
[list of commands] List of commands commands for newly created turtles to run

Description:
Creates number turtles and tells them to do [list of commands].

Related Commands:
create-breed-and-do create-turtles sprout
Turtle, Observer, Patch

cyan

Description:

cyan reports 85, the number of its particular hue in the color table.

Related Commands:
black blue brown gray green lime magenta orange pink purple red sky turquoise white yellow
Turtle

die

Description:
Turtles die, meaning that they stop running all code and disappear forever.

Examples:
if pc = red [die] makes the turtle die if the patch it is on is red.

Related Commands:
kill
Observer

diffuse variable percentage

Parameters:
variable String patch variable to diffuse
percentage Number percentage of patch variable's value to diffuse

Description:
Makes each patch give 1/8 of percentage of variable to each neighboring patch.
percentage should be expressed as a number between 0 and 1. variable should be a patch variable.

Examples:
diffuse food 20 causes each patch to give 1/8 of 20 percent of the variable food to each of its eight neighboring patches.

Notes:
diffuse must be run by the observer, even though it affects patches.

Related Commands:
diffuse4 nsum nsum4
Observer

diffuse4 variable percentage

Parameters:
variable Number patch variable to diffuse
percentage Number percentage of variable's value to diffuse

Description:
Makes each patch give 1/4 of percentage of variable to each non-diagonal (N,E,S,W) neighboring patch.
percentage should be expressed as a number between 0 and 1. variable should be a patch variable.

Examples:
diffuse food 20 causes each patch to give 1/4 of 20 percent of the variable food to each of its four directly-neighboring patches.

Notes:
diffuse4 must be run by the observer, even though it affects patches.

Related Commands:
diffuse nsum nsum4
Observer

display

Description:
Turns Graphics Canvas updating on.

Notes:
By default, display is on.

Related Commands:
no-display
Turtle, Observer, Patch

distance xcor ycor

Parameters:
xcor Number distance in the x direction away from the caller
ycor Number distance in the y direction away from the caller

Description:
Reports the distance from the caller to xcor ycor. The observer is assumed to be at position (0,0). If xcor and/or ycor are off the screen, they will be wrapped to fit within the screen first.

Examples:
distance 3 4 reports 5 when the caller is at (0, 0).
distance 101 101 reports 70.7107 (on a 51x51 screen)

Related Commands:
distance-nowrap towards towards-nowrap
Turtle, Observer, Patch

distance-nowrap xcor ycor

Parameters:
xcor Number units in the x direction away from the caller
ycor Number units in the y direction away from the caller

Description:
Reports the distance from the caller to xcor ycor without wrapping. The observer is assumed to be at position (0,0).

Examples:
distance-nowrap 3 4 returns 5 when the caller is at (0,0).

Notes:
If the patch canvas is 100 patches wide, distance-nowrap 99 0 would return 99 while distance 99 0 would return 1.

Related Commands:
distance towards towards-nowrap
Turtle, Observer, Patch

number1 div number2

Parameters:
number1 Number dividend
number2 Number divisor

Description:
Reports the integer part of the answer to number1 / number2.

Examples:
5 div 2 returns 2.

6 div 2 returns 3.

Related Commands:
mod
Turtle, Observer, Patch

dolist [:loop-variable list] [commands to run]

Parameters:
[:loop-variable list] List of commands On each iteration, :loop-variable is assigned to each element of the list
[commands to run] List of commands Commands to run once for each element of the list

Description:
This command loops over each element of the list, and runs [commands to run] for each one. During each run of [commands to run], the element of the list is bound to loop-variable.

Examples:
dolist [:i [2 4 -1]] [fd :i] loops over the list [1 2 3]. There are three iterations of this loop; in the first, we run fd 2, in the second fd 4 and the third fd -1.

Related Commands:
dotimes
Turtle, Observer, Patch

dotimes [:loop-variable #times] [commands to run]

Parameters:
[:loop-variable #times] List of commands On each iteration, :loop-variable is assigned to each number from 1 to #times
[commands to run] List of commands Commands to run once for each number from 1 to #times

Description:
This command loops over each integer number from 1 to #times, and runs [commands to run] for each one. During each run of [commands to run], the current number is bound to :loop-variable.

Examples:
dotimes [:foo 4] [show :foo] loops 4 times, each time assigning :foo to 1, 2, 3, and then 4. The commands that are run print the value of :foo to the command center.

Related Commands:
dolist
Turtle

dx

Description:
Reports how far the turtle will move in the x-direction if it takes one step forward.

Related Commands:
dy
Turtle

dy

Description:
Reports how far the turtle will move in the y-direction if it takes one step forward.

Related Commands:
dx
Turtle, Observer, Patch

e

Description:
Reports the value of e (approximately 2.718281828).

Related Commands:
exp ln pi
Turtle, Observer, Patch

empty? data

Parameters:
data List or string list or string to test for emptiness

Description:
If data is a list of data, reports true if data is empty.

If data is a string, reports true if data has no characters (i.e. = "").

Examples:
empty? [0 0] returns false.

empty? [] returns true.

empty? "hello" returns false.

Related Commands:
first last make-list sentence
Turtle, Observer, Patch

end

Description:
This command must be placed at the end of every procedure.

Notes:
Note, you can't put anything (even a comment) on the same line as end.

Related Commands:
output startup stop to
Turtle, Observer, Patch

every number [list of commands]

Parameters:
number Number number of seconds to wait between each iteration
[list of commands] List of commands list of commands to run each iteration

Description:
every is just like loop, in that it runs its [list of commands] forever, but it waits number seconds between each iteration. Number can be a decimal as well as an integer.
every is usually used in a non-forever button to run something over and over again with a pause in between.

Examples:
every 2 [fd 1 rt 90] would make all the turtles move forward one step, turn right 90 degrees, and then wait 2 seconds over and over again.


Turtle, Observer, Patch

exp number

Parameters:
number Number exponent to raise e

Description:
Reports e (approximately 2.71828) raised to the power of number.

Related Commands:
e ln
Observer

export-picture-interface

Description:
Brings up the export picture dialog and saves the interface to disk as a PNG

Related Commands:
export-picture-interface-name
Observer

export-picture-interface-name name

Parameters:
name String name of the file

Description:
export-picture-interface-name name exports the interface as a PNG using the file name specified

Related Commands:
export-picture-interface
Observer

export-picture-patches

Description:
Brings up the export picture dialog and saves the patches to disk as a PNG

Related Commands:
export-picture-patches-name
Observer

export-picture-patches-name name

Parameters:
name String name of the file

Description:
Saves the patches to disk as a PNG with the filename name

Related Commands:
export-picture-patches
Observer

export-picture-turtles-and-patches

Description:
Brings up the export picture dialog and saves the turtles and patches to disk as a PNG

Related Commands:
export-picture-turtles-and-patches-name
Observer

export-picture-turtles-and-patches-name name

Parameters:
name String name of the file

Description:
Saves the patches and turtles to disk as a PNG with the filename name

Related Commands:
export-picture-turtles-and-patches
Turtle, Observer, Patch

first [list of data] or string

Parameters:
[list of data] or string List or string List or string to return the first character/element from

Description:
Returns the first element of a [list of data] or the first character of a string.

Examples:
first [3 4 5 6] returns 3.

first "hello" returns "h".

Related Commands:
butfirst butlast empty? fput last lput
Turtle

forward (fd) number

Parameters:
number Number Turtle moves number steps forward.

Description:
Moves turtle forward number steps.

Examples:
fd 3 and forward 3 are equivalent statements which each make turtles move forward 3 steps.

Related Commands:
back jump leap left right step
Turtle, Observer, Patch

fput item

Parameters:
item List or string

Description:
Adds the item into the list as the first element

Examples:
fput 1 [2 3 4] returns [1 2 3 4].

fput "hello" "mom" returns "hellomom".

Related Commands:
first insert last lput reverse sentence
Observer

get-random-seed

Description:
Returns the current random seed.

Notes:
StarLogo uses the random generator provided by Java, which, as of now, is a linear congruential formula (Knuth Art of Computer Programming, Vol 2, Section 3.2.1.), which uses a 48-bit seed. StarLogo only allows you to set the lower 32 bits of this seed.

Related Commands:
set-random-seed setrandom-seed
Observer

get-scheduler-random-seed

Description:
Returns the current value of the scheduler's random seed.

Notes:
Example: One use of get-scheduler-random-seed would be to have repeatable results. If you want to repeat the results of a specific trial, get the scheduler's random seed and simply set the random seed to the same number the next time you run the project.

Related Commands:
scheduler set-scheduler-random-seed switch-scheduler
Turtle, Observer

globals [variable-list]

Parameters:
[variable-list] List

Description:
Creates global variables. The variable-list contains one or more names. The globals declaration should be placed at the top of the observer procedures window or the turtle procedures window.

Examples:
globals [variable1 variable2 variable3] Creates globals variable1, variable2, and variable3.

Related Commands:
patches-own turtles-own
Turtle, Observer, Patch

grab number [list of commands]

Parameters:
number Number
[list of commands] List

Description:
Have turtles number execute [list of commands].

Examples:
grab one-of-turtles-here [setc red setc-of partner blue] This turns the caller red and the grabbed turtle blue. If there are no other turtles on the caller's patch, the [list of commands] does not get executed and no turtles change color.

Notes:
Caller instructs turtles with who number(s) number(s) to execute [list of commands]. The who number of the turtles being grabbed are stored in partner, if there is one, or partners, if there are many. A turtle cannot grab itself.

Grab is only useful for guaranteeing that a turtle you want to talk to is not being talked to by anyone else and cannot talk to anyone else while being grabbed. Note, while one turtle is grabbing another, neither may be grabbed by a third turtle.

Related Commands:
grabbed? partner partners
Turtle

grabbed?

Description:
Returns true if the turtle is currently grabbed by another turtle, otherwise false.

Examples:
if grabbed? [fd 1] Makes all grabbed turtles move forward 1 step.

Related Commands:
grab partner partners
Turtle, Observer, Patch

gray (grey)

Description:
gray reports 5, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan green lime magenta orange pink purple red sky turquoise white yellow
Turtle, Observer, Patch

green

Description:
green reports 55, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green lime magenta orange pink purple red sky turquoise white yellow
Turtle

hatch [list of commands]

Parameters:
[list of commands] List of commands

Description:
Make an exact copy of a turtle, including turtles-own variables and state variables. The [list of commands] is then run on the cloned turtle.

Examples:
hatch [setc blue fd 1] has the caller make a duplicate of itself, and then the duplicate sets its color to blue and moves foward 1.

Related Commands:
sprout
Turtle, Patch

heading

Description:
Returns the direction that the turtle is facing, or if a patch calls it, the direction that one of the turtles on that patch is facing.

Examples:
if heading = 0 [setc blue] Commands the caller to set its color to blue if it is facing straight up.

Related Commands:
heading-at heading-of heading-towards setheading who
Turtle, Observer, Patch

heading-at xcor ycor

Parameters:
xcor Number
ycor Number

Description:
Returns the heading of the turtle xcor units in the x direction and ycor units in the y direction away from the caller.

Examples:
heading-at 1 1 reports the heading of the turtle one unit to the right and one unit above the caller.

Related Commands:
heading heading-of heading-towards seth-at
Turtle, Observer, Patch

heading-of number

Parameters:
number Number who number to identify the turtle

Description:
Reports the heading of the turtle with a who number equal to number.

Examples:
if who = 1 [fd 1] commands the turtle to move forward 1 if its who number is 1.

Related Commands:
heading heading-at heading-towards seth-of
Turtle, Observer, Patch

heading-towards angle distance

Parameters:
angle Number
distance Number

Description:
Reports the heading of the turtle distance away at an angle of angle from the caller.

Examples:
heading-towards 0 1 reports the heading of the turtle 1 unit in front of the caller.

Related Commands:
heading heading-at heading-of seth-towards
Turtle

hideturtle (hide-turtle) (ht)

Description:
Makes calling turtle invisible.

Examples:
if pc = black [ht] commands the caller to make itself invisible if the caller is standing on a black patch.

Related Commands:
setshown?-at setshown?-of setshown?-towards shown? shown?-at shown?-of shown?-towards showturtle
Turtle

home

Description:
Send turtle to coordinates (0,0). This is the same as using setxy 0 0.

Related Commands:
setxy
Turtle, Observer, Patch

if condition [list of commands]

Parameters:
condition Boolean Condition that evaluates to either true or false
[list of commands] List of commands List of commands to execute of condition is true

Description:
Do [list of commands] if and only if condition reports true.

Examples:
if color = black [fd 5 rt 90] makes every black turtle move forward 5 steps and then turn right.

Related Commands:
ifelse
Turtle

if breed = frogs

Description:
Returns true if the breed of the turtle invoking this command is frogs.

Turtle, Observer, Patch

ifelse condition [list of commands1] [list of commands2]

Parameters:
condition Boolean Condition that evalutes to either true or false
[list of commands1] List of commands Runs if condition is true
[list of commands2] List of commands Runs of [list of commands1] is false

Description:
Do [list of commands1] if condition reports true, otherwise do [list of commands2].

Examples:
ifelse color = black [fd 2] [bk 2] would make black turtles move forward 2 steps and all other turtles move back 2 steps.

Related Commands:
if
Turtle, Observer, Patch

ignore expression

Parameters:
expression Anything Expression to evalute for side effects

Description:
Ignores the return value of the expression immediately following it. More useful than it looks, ignore can be used to execute a procedure for its side effects.

Examples:
to compute-and-print-square :x
let [:ans :x * :x]
show :x
output :x

ignore compute-and-print-square 4 shows 16 in the command center, but does nothing with the return value from compute-and-print-square.


Observer

import-picture

Description:
Opens up a dialog box asking the user to select a picture to import onto the Graphics Canvas. It resizes the patchcanvas to the exact dimensions of the picture, in pixels.

Notes:
Importing a picture much larger than 200x200 pixels will likely require too much memory and screen space.

Related Commands:
import-picture-name
Observer

import-picture-name filename

Parameters:
filename String Filename of the picture to import

Description:
Imports onto the Graphics Canvas the picture in the file specified by filename. The file is assumed to be in the current directory (as shown by the Save Project dialog box).

Examples:
import-picture-name strongbad.jpg
imports the picture file named strongbad.jpg in the current directory.

Notes:
Importing a picture much larger than 200x200 will likely require too much memory and screen space.

Related Commands:
import-picture
Turtle, Observer, Patch

info-name

Description:
Returns the current filename of the information window. Returns false if no filename has been set yet.

Related Commands:
output-name project-name save-info save-info-as
Turtle, Observer, Patch

insert index list element

Parameters:
index Number Position in list indicating where to insert
list List
element Anything

Description:
Returns a new modified [list of data] with element inserted into the index position.

Notes:
The input list is not changed.

Related Commands:
fput lput member? remove
Observer

inspect-patch xcor ycor

Parameters:
xcor Number
ycor Number

Description:
Brings up the patch monitor of the patch whose coordinates are (xcor, ycor). A patch monitor allows the user to see all of the information about a patch in real time.

Examples:
inspect-patch 1 1 brings up the patch monitor for the patch at coordinates (1,1).

Related Commands:
inspect-turtle
Observer

inspect-turtle number

Parameters:
number Number who number of turtle to inspect

Description:
Brings up the turtle monitor of the turtle whose who number is number. A turtle monitor allows the user to see all information about a turtle in real time.

Examples:
inspect-turtle 1 brings up the turtle monitor of the turtle with who number equal to one.

Related Commands:
inspect-patch
Turtle, Observer, Patch

int number

Parameters:
number Number A real number to turn into an integer

Description:
Reports the largest integer less than or equal to number. For negative numbers, returns the smallest integer greater than or equal to number.

Examples:
int 5 returns 5.

int 5.9 returns 5

int -3 returns -3

Notes:
int -3.5 returns -3

Related Commands:
round
Turtle, Observer, Patch

item number [list]

Parameters:
number Number
[list] List

Description:
Returns the element of [list] at the number'th position.

Examples:
item 2 [4 6 8] returns 6.

Notes:
Indexing starts from 1.

Related Commands:
position remove remove-element setitem
Turtle

jump number

Parameters:
number Number Amount for turtle to move

Description:
Turtles move number steps in the time it takes to make one normal step.

Examples:
jump 12 makes the caller move forward 12 in the time it normally takes to move forward one step.

Notes:
jump 15 and fd 1 both take the same amount of time to perform. fd 15, however, would take 15 times as long as jump 15.

Related Commands:
forward leap step
Turtle, Observer, Patch

kill number

Parameters:
number Number

Description:
Kills turtle with who number equal to number.

Examples:
kill 2 kills the turtle with a who number equal to 2.

Related Commands:
die
Turtle, Observer, Patch

last [list of data]

Parameters:
[list of data] List or string list of data of which you want the last element

Description:
Returns the last item of [list of data].

Examples:
last [4 5 6 7] returns 7.

Related Commands:
butfirst butlast empty? first fput lput
Turtle

leap number

Parameters:
number Number the number of steps that the turtle will leap

Description:
Turtles jump number steps only if no other turtle is currently on the patch they will land on.

Examples:
leap 5 will have turtle jump 5 spaces ahead if there is no other turtle there.

Notes:
If the project requires that there is only one turtle per patch, all turtles should be set up on unique patches at the beginning of the simulation. Otherwise, the desired invariant of one turtle per patch may not be true.

Related Commands:
forward jump step
Turtle

left (lt) number

Parameters:
number Number number of degrees to turn

Description:
Turtles turn left by number degrees.

Examples:
lt 90

left 90

Related Commands:
back forward right
Turtle, Observer, Patch

length [list of data]

Parameters:
[list of data] List or string list of data for which you want the length

Description:
Returns the length of [list of data].

Examples:
length [] returns 0.

length [4 5 6 7] returns 4.

Related Commands:
list make-list sentence
Turtle, Observer, Patch

let [:variable value]

Parameters:
[:variable String the variable name that you will use
value] Number the value that you are setting the variable to

Description:
Declares variable as a local variable and assigns value to it. All local variables must have names which begin with a colon. You may declare more than one variable in a let statement (ie. let [:variable1 value1 :variable2 value2]. Variables are declared in the order they appear in the let statement. See the Variables page for more information on local variables.

Examples:
let [:myvar 6] declares a local variable :myvar and assigns its value to 6.

Related Commands:
set
Turtle, Observer, Patch

lime

Description:
lime reports 65, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green magenta orange pink purple red sky turquoise white yellow
Turtle, Observer, Patch

list item 1 item 2

Parameters:
item 1 Anything the first item in your list
item 2 Number the second item in your list

Description:
Returns a new [list of data] with item 1 as its first element, and item 2 as its second.

Examples:
list 4 5 returns [4 5].

Related Commands:
copy-list length make-list pick position remove remove-element reverse sentence sublist to-list
Turtle, Observer, Patch

list-of-breed

Description:
Returns a list of the who numbers of the turtles of the breed specified by breed.

Examples:
list-of-frogs returns a list of all of the turtles of breed frogs

list-of-cars returns a list of all of the turtles of breed cars

Related Commands:
list-of-breed-at list-of-breed-here list-of-breed-towards list-of-breed-with list-of-turtles
Turtle, Observer, Patch

list-of-breed-at xcor ycor

Parameters:
xcor Number number of units away in the x direction
ycor Number number of units away in the y direction

Description:
Returns a list of the who numbers of the turtles of the breed specified by breed xcor units in the x direction and ycor units in the y direction away from the caller.

Examples:
list-of-frogs-at 1 1 returns a list of the who numbers of the turtles of breed frogs one unit to the right and one unit above the caller.

list-of-cars-at 3 5 returns a list of the who numbers of the turtles of breed cars three units to the right and five units above the caller.

Related Commands:
list-of-breed list-of-turtles-at
Turtle, Patch

list-of-breed-here

Description:
Returns a list of turtles of the breed specified by breed on the caller's patch.

Examples:
list-of-frogs-here returns a list of turtles of breed frogs on the caller's patch.

list-of-cars-here returns a list of turtles of breed cars on the caller's patch.

Related Commands:
list-of-breed list-of-turtles-here
Turtle, Observer, Patch

list-of-breed-towards angle distance

Parameters:
angle Number angle from the caller
distance Number distance away from the caller

Description:
Returns a list of the who numbers of the turtles of the breed specifed by breed at the patch angle away at angle distance from the caller.

Examples:
list-of-frogs-towards 0 1 returns a list of the turtles of breed frog directly ahead and one patch away from the caller.

list-of-cars-towards 90 5 returns a list of the turtles of breed cars 90 degreses to the right and five patches away from the caller.

Related Commands:
list-of-breed list-of-turtles-towards
Turtle, Observer, Patch

list-of-breed-with [condition]

Parameters:
[condition] List of turtle commands list of commands that evaluates to true or false

Description:
Returns a list of turtles of breed indicated by breed satisfying condition.

Examples:
list-of-frogs-with [color = green] will return a list of turtles that are breed frogs and have color green.

list-of-cars-with [color = black] will return a list of turtles that are breed cars and have color black.

Notes:
Note [condition] must be a boolean statement and return true or false.

Related Commands:
list-of-breed list-of-turtles-with
Turtle, Observer, Patch

list-of-turtles

Description:
Returns a list of the who numbers of all the turtles.

Related Commands:
list-of-breed list-of-turtles-with one-of-breed one-of-turtles
Turtle, Observer, Patch

list-of-turtles-at xcor ycor

Parameters:
xcor Number number of units away in the x direction
ycor Number number of units away in the y direction

Description:
Returns a list of turtles xcor units in the x direction and ycor units in the y direction away from the caller .

Examples:
list-of-turtles-at 1 1 returns a list of turtles one unit to the right and one unit above the caller.

Related Commands:
list-of-breed-at list-of-turtles-here list-of-turtles-towards
Turtle, Patch

list-of-turtles-here

Description:
Returns a list of turtles on the caller's patch.

Related Commands:
list-of-breed-here list-of-turtles-at list-of-turtles-towards list-of-turtles-with one-of-breed-here
Turtle, Observer, Patch

list-of-turtles-towards angle distance

Parameters:
angle Number angle from the caller
distance Number distance away from the caller

Description:
Returns a list of turtles at the patch angle away at angle distance from the caller.

Examples:
list-of-turtles-towards 0 1 returns a list of turtles one unit directly in front of the caller.

Related Commands:
list-of-breed-towards list-of-turtles-at list-of-turtles-here
Turtle, Observer, Patch

list-of-turtles-with [condition]

Parameters:
[condition] List of commands list of commands that evaluates to true or false

Description:
Returns a list of the who numbers of the turtles satisfying condition.

Examples:
list-of-turtles-with [color = red] returns a list of the who numbers of the red turtles.

Related Commands:
list-of-breed-with list-of-turtles list-of-turtles-here myself one-of-turtles-with
Turtle, Observer, Patch

list? thing

Parameters:
thing Number the item, string, list, or variable that you are trying to determine if it is a list

Description:
Returns true if thing is a list.

Examples:
list? 4 returns false.

list? [4] returns true.

Related Commands:
number? word?
Turtle, Observer, Patch

ln number

Parameters:
number Number number of which you want the natural log

Description:
Returns the natural logarithm of number.

Examples:
ln 1 returns 0

ln e returns 1

ln -2 returns NaN (the error message Not a Number)

Related Commands:
e exp log
Turtle, Observer, Patch

log number base

Parameters:
number Number number of which you want the log
base Number base of the log

Description:
Math function. Returns the log of number according to specified base.

Examples:
log 100 10 returns 2

Related Commands:
ln
Turtle, Observer, Patch

loop [list of commands]

Parameters:
[list of commands] List of commands the list of commands that will be run forever

Description:
Do [list of commands] forever.

Examples:
loop [fd 4 rt 45] makes turtles repeatedly move forward 4 steps and turn right 45 degrees.

Related Commands:
output repeat stop
Turtle, Observer, Patch

lput item [list of data]

Parameters:
item Integer the item that you are placing in the list
[list of data] List or string list of data that you are adding to

Description:
Returns the new value of [list of data] with item as its last element. The input list is not changed.

Examples:
lput 4 [1 2 3] returns [1 2 3 4].

Related Commands:
butfirst butlast first fput insert last reverse sentence
Turtle, Observer, Patch

magenta

Description:
magenta reports 125, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green lime orange pink purple red sky turquoise white yellow
Turtle, Observer, Patch

make-list integer element

Parameters:
integer Integer number of times the item will be in the list
element Anything the data that will be repeated in the list

Description:
Returns a list of length integer filled with element.

Examples:
make-list 5 0 returns [0 0 0 0 0]

Related Commands:
copy-list empty? length list sentence to-list
Turtle, Observer, Patch

max-of-breed [list of commands]

Parameters:
[list of commands] List of commands list of commands that evaluate to a number

Description:
Reports the highest value of [list of commands] when run over the turtles of the breed specified by breed.

Examples:
max-of-frogs [speed] returns the turtle of breed frogs with the highest value of speed.

max-of-cars [size] returns the turtle of breed cars with the highest value of size.

Notes:
This command can also be executed by patches, for example within an ask-patches statement.

If [list of commands] contains no numbers, the smallest possible number is returned. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it is not included as part of the calculation.

Related Commands:
average-of-breed max-of-turtles median-of-breed min-of-breed mode-of-breed sdev-of-breed sum-of-breed variance-of-breed
Turtle, Observer, Patch

max-of-breed-with [condition] [list of commands]

Parameters:
[condition] List of commands list of commands that evaluates to true or false
[list of commands] List of commands list of commands that evaluate to a number

Description:
Reports the highest value of [list of commands] when run over the turtles of breed specified by breed that satisfy [condition]. If there are no turtles of this breed for which [condition] is true, returns minnum, the smallest number possible without going into negative infinity.

Examples:
max-of-frogs-with [color = red] [speed] returns the red turtle with the greatest speed of breed frogs.

max-of-cars-with [color = blue] [size] returns the blue turtle with the greatest size of breed cars.

Notes:
This command can also be executed by patches, for example within an ask-patches statement.

If [list of commands] contains no numbers, the smallest possible number is returned. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it is not included as part of the calculation.

Related Commands:
average-of-breed-with median-of-breed-with min-of-breed-with min-of-turtles-with mode-of-breed-with sdev-of-breed-with sum-of-breed-with variance-of-breed-with
Turtle, Observer, Patch

max-of-list list

Parameters:
list List list of which you want the maximum value

Description:
Returns the greatest value in the given list.

Examples:
max-of-list [5 7 1] returns 7.

Related Commands:
average-of-list median-of-list min-of-list mode-of-list sdev-of-list sort-num-list sum-of-list variance-of-list
Turtle, Observer, Patch

max-of-patches [list of commands]

Parameters:
[list of commands] List of commands list of commands that evaluate to a number

Description:
Evaluates the [list of commands] given for every patch. Returns the coordinates of the patch whose [list of commands] value is greatest, or returns a list of coordinates if there is more than one patch with that minimum value.

Examples:
max-of-patches [food] returns the coordinates of the patch whose food variable is the largest.

Notes:
If [list of commands] contains no numbers, the smallest possible number is returned. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

Related Commands:
max-of-turtles median-of-patches min-of-patches mode-of-patches sdev-of-patches sum-of-patches variance-of-patches
Turtle, Observer, Patch

max-of-patches-with [condition] [list of commands]

Parameters:
[condition] List of commands list of commands that evaluates to true or false
[list of commands] List of commands list of commands that evaluate to a number

Description:
Reports the highest value of [list of commands] when run over the turtles that satisfy [condition]. If there are no patches in which [condition] is true, reports minnum, the smallest number possible without going into negative infinity.

Examples:
max-of-patches-with [color = 0] [food] reports the largest food value of the black colored patches.

Notes:
This command can also be executed by patches, for example within an ask-patches statement.

Related Commands:
max-of-turtles-with median-of-patches-with min-of-patches-with mode-of-patches-with sdev-of-patches-with sum-of-patches-with variance-of-patches-with
Turtle, Observer, Patch

max-of-turtles [list of commands]

Parameters:
[list of commands] List of commands list of commands that evaluate to a number

Description:
Reports the highest value of [list of commands] when run over all of the turtles.

Examples:
max-of-turtles-with [speed] reports the speed of the fastest turtle.

Notes:
This command can also be executed by patches, for example within an ask-patches statement.

If [list of commands] contains no numbers, the smallest possible number is returned. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it is not included as part of the calculation.

Related Commands:
max-of-breed max-of-patches max-of-turtles-with median-of-turtles min-of-turtles mode-of-turtles sdev-of-turtles sum-of-turtles variance-of-turtles
Turtle, Observer, Patch

max-of-turtles-with [condition] [list of commands]

Parameters:
[condition] List of commands list of commands that evaluates to true or false
[list of commands] Number list of commands that evaluate to a number

Description:
Reports the highest value of [list of commands] when run over the turtles that satisfy condition. If there are no turtles in which [condition] is true, returns minnum, the smallest number possible without going into negative infinity.

Examples:
max-of-turtles-with [color = red] [speed] reports the speed of the red turtle with the highest speed.

Notes:
This command can also be executed by patches, for example within an ask-patches statement.

If [list of commands] contains no numbers, the smallest possible number is returned. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it is not included as part of the calculation.

Related Commands:
max-of-patches-with max-of-turtles median-of-turtles-with min-of-turtles-with mode-of-turtles-with sdev-of-turtles-with sum-of-turtles-with variance-of-turtles-with
Turtle, Observer, Patch

maximum (max) number 1 number 2

Parameters:
number 1 Number first number that you are comparing
number 2 Number second number that you are comparing

Description:
Reports the larger value of the two numbers.

Examples:
max 4 6 returns 6

Related Commands:
maxnum minimum minnum
Turtle, Observer, Patch

maxnum

Description:
Returns the largest number possible without going into positive infinity.

Related Commands:
maximum minimum minnum
Turtle, Observer, Patch

median-of-breed [list of commands]

Parameters:
[list of commands] List of commands list of commands that evaluate to a number

Description:
Returns the median of the [list of commands] when evaluated across all the turtles of the specified breed.

Examples:
median-of-frogs [speed] returns the median speed of all the turtles of breed frogs.

median-of-cars [size] returns the median size of all the turtles of breed cars.

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it is not included as part of the calculation.

Related Commands:
average-of-breed max-of-breed median-of-turtles min-of-breed mode-of-breed sdev-of-breed sum-of-breed variance-of-breed
Turtle, Observer, Patch

median-of-breed-with [1st list of commands] [2nd list of commands]

Parameters:
[1st list of commands] List of commands list of commands that evaluates to true or false
[2nd list of commands] List of commands list of commands that evaluate to a number

Description:
Returns the median of the [2nd list of commands] when evaluated across all the turtles of the breed specified that satisfy the conditions specified by the [1st list of commands].

Examples:
median-of-frogs-with [color = red] [speed] returns the median speed of all the red turtles of breed frogs.

median-of-cars-with [size > 4] [speed] returns the median speed of all the turtles of size greater than 4 with breed cars.

Notes:
If [2nd list of commands] contains no numbers, an error occurs. If some of the [2nd list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it is not included as part of the calculation.

Related Commands:
average-of-breed-with max-of-breed-with median-of-turtles-with min-of-breed-with mode-of-breed-with sdev-of-breed-with sum-of-breed-with variance-of-breed-with
Turtle, Observer, Patch

median-of-list list

Parameters:
list List list of numbers for which you want the median value

Description:
Returns the median of the given list.

Examples:
median-of-list [ 1 3 5 7 9] returns 5.

Notes:
If an element in list is not a number, an error occurs.

If list contains no numbers, an error occurs. If some of the list, when evaluated, are not numbers, those values are ignored.

Related Commands:
average-of-list max-of-list min-of-list mode-of-list sdev-of-list sum-of-list variance-of-list
Turtle, Observer, Patch

median-of-patches [list of commands]

Parameters:
[list of commands] Number list of commands that evaluate to a number

Description:
Returns the median of the [list of commands] when [list of commands] is evaluated by all patches.

Examples:
median-of-patches [color] returns a number corresponding to the median of the colors of all patches.

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

Related Commands:
average-of-patches max-of-patches median-of-patches-with min-of-patches mode-of-patches sdev-of-patches sum-of-patches variance-of-patches
Turtle, Observer, Patch

median-of-patches-with [1st list of commands] [2nd list of commands]

Parameters:
[1st list of commands] List of commands list of commands that evaluates to true or false
[2nd list of commands] List list of commands that evaluate to a number

Description:
Returns the median of the [2nd list of commands] when evaluated across all the patches that satisfy the conditions specified by the [1st list of commands].

Examples:
median-of-patches-with [color = red] [food] returns the median food of all the red patches.

Notes:
If [2nd list of commands] contains no numbers, an error occurs. If some of the [2nd list of commands], when evaluated, are not numbers, those values are ignored.

Related Commands:
average-of-patches-with max-of-patches-with median-of-patches min-of-patches-with mode-of-patches-with sdev-of-patches-with sum-of-patches-with variance-of-patches variance-of-patches-with
Turtle, Observer, Patch

median-of-turtles [list of commands]

Parameters:
[list of commands] Number

Description:
Returns the median [list of commands] when [list of commands] is evaluated for all turtles.

Examples:
median-of-turtles [color] returns a number corresponding to the median of the colors of all turtles on the screen.

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it is not included as part of the calculation.

Related Commands:
average-of-turtles max-of-turtles median-of-breed median-of-turtles-with min-of-turtles mode-of-turtles sdev-of-turtles sum-of-turtles variance-of-turtles
Turtle, Observer, Patch

median-of-turtles-with [1st list of commands] [2nd list of commands]

Parameters:
[1st list of commands] List of commands list of commands that evaluates to true or false
[2nd list of commands] List list of commands that evaluate to a number

Description:
Returns the median of the [2nd list of commands] when evaluated across all the turtles that satisfy the conditions specified by the [1st list of commands].

Examples:
median-of-patches-with [color = red] [energy] returns the median energy of all the red turtles.

Notes:
If [2nd list of commands] contains no numbers, an error occurs. If some of the [2nd list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it is not included as part of the calculation.

Related Commands:
average-of-turtles-with max-of-turtles-with median-of-breed-with median-of-turtles min-of-turtles-with mode-of-turtles-with sdev-of-turtles-with sum-of-turtles-with variance-of-turtles-with
Turtle, Observer, Patch

member? item [list of data]

Parameters:
item Anything item which you are looking for
[list of data] List or string list of data to search

Description:
Returns true if item is a member of [list of data].

Examples:
member? 4 [1 0 9] returns false.

member? 4 [1 4 9] returns true.

Related Commands:
insert position remove remove-element setitem
Turtle, Observer, Patch

min-of-breed [list of commands]

Parameters:
[list of commands] List of turtle commands list of commands that evaluate to a number

Description:
Reports the lowest value of [list of commands] when run over the turtles of the breed specified by breed.

Examples:
min-of-frogs [speed] reports the speed of the slowest turtle of breed frog.

min-of-cars [mileage] reports the mileage of the turtle of breed car with the lowest mileage.

Notes:
Note: This command can also be executed by patches, for example within an ask-patches statement.

Note: If [list of commands] contains no numbers, the greatest possible number is returned. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

Note: When a turtle calls the command, it is not included as part of the calculation.

Related Commands:
average-of-breed max-of-breed median-of-breed min-of-breed-with mode-of-breed sdev-of-breed sum-of-breed variance-of-breed
Turtle, Observer, Patch

min-of-breed-with [condition] [list of commands]

Parameters:
[condition] List of turtle commands list of commands that evaluates to true or false
[list of commands] List of turtle commands list of commands to that evaluate to a number

Description:
Reports the lowest value of [list of commands] when run over the turtles of the breed specified that satisfy [condition]. If there are no turtles of the breed specified in which [condition] is true, returns maxnum, the largest number possible without going into positive infinity.

Examples:
min-of-frogs-with [habitat = tree] [height] reports the height of the shortest turtle of breed frog with habitat tree.

min-of-cars-with [color = red] [speed] reports the speed of the slowest red turtle of breed car.

Notes:
Note: This command can also be executed by patches, for example within an ask-patches statement.

Note: If [condition] contains no numbers, the greatest possible number is returned. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

Note: When a turtle calls the command, it is not included as part of the calculation.

Related Commands:
average-of-breed-with max-of-breed-with median-of-breed-with min-of-breed mode-of-breed-with sdev-of-breed-with sum-of-breed-with variance-of-breed-with
Turtle, Observer, Patch

min-of-list list

Parameters:
list List list of numbers

Description:
Returns the least value in the given list.

Examples:
min-of-list [1 2 3] returns 1

Notes:
Note: If list contains no numbers, the greatest possibel number is returned. If some of the list, when evaluated, are not numbers, those values are ignored.

Related Commands:
average-of-list max-of-list median-of-list mode-of-list sdev-of-list sort-num-list sum-of-list variance-of-list
Turtle, Observer, Patch

min-of-patches [list of commands]

Parameters:
[list of commands] List of patch commands list of commands that evaluate to a number

Description:
Reports the lowest value of [list of commands] when run over all of the patches.

Examples:
min-of-patches [food] reports the smallest value of the patch variable food for all patches.

Notes:
Note: If [list of commands] contains no numbers, the greatest possible number is returned. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

Related Commands:
average-of-patches max-of-patches median-of-patches min-of-patches-with mode-of-patches sdev-of-list sdev-of-patches sum-of-patches variance-of-patches
Turtle, Observer, Patch

min-of-patches-with [condition] [list of commands]

Parameters:
[condition] List of commands list of commands that evaluate to true or false
[list of commands] List of commands list of commands to that evaluate to a number

Description:
Reports the lowest value of [list of commands] when run over the turtles that satisfy [condition]. If there are no patches in which [condition] is true, reports maxnum, the largest number possible without going into positive infinity.

Examples:
min-of-patches-with [color = red] [food] reports the smallest value of the patch variable food for red patches.

Notes:
Note: If [list of commands] contains no numbers, the greatest possible number is returned. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

Related Commands:
average-of-patches-with max-of-patches-with median-of-patches-with min-of-patches min-of-patches-with mode-of-patches-with sdev-of-patches-with sum-of-patches-with variance-of-patches-with
Turtle, Observer, Patch

min-of-turtles [list of commands]

Parameters:
[list of commands] List of turtle commands list of commands that evaluate to a number

Description:
Reports the lowest value of [list of commands] when run over all of the turtles.

Examples:
min-of-turtles [speed] reports the speed of the slowest turtle.

Notes:
Note: This command can also be executed by patches, for example within an ask-patches statement.

Note: If [list of commands] contains no numbers, the greatest possible number is returned. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

Note: When a turtle calls the command, it is not included as part of the calculation.

Related Commands:
average-of-turtles max-of-turtles median-of-turtles min-of-turtles-with mode-of-turtles sdev-of-turtles sum-of-turtles variance-of-turtles
Turtle, Observer, Patch

min-of-turtles-with [condition] [list of commands]

Parameters:
[condition] List of turtle commands list of commands that evaluate to true or false
[list of commands] List of turtle commands list of commands to that evaluate to a number

Description:
Reports the lowest value of [list of commands] when run over the turtles that satisfy [condition]. If there are no turtles in which [condition] is true, returns maxnum, the largest number possible without going into positive infinity.

Examples:
min-of-turtles-with [color = red] [speed] reports the speed of the slowest red turtle.

Notes:
Note: This command can also be executed by patches, for example within an ask-patches statement.

Note: If [list of commands] contains no numbers, the greatest possible number is returned. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

Note: When a turtle calls the command, it is not included as part of the calculation.

Related Commands:
average-of-turtles-with max-of-breed-with max-of-turtles-with median-of-turtles-with min-of-turtles mode-of-turtles-with sdev-of-turtles-with sum-of-turtles-with variance-of-turtles-with
Turtle, Observer, Patch

minimum (min) number1 number2

Parameters:
number1 Number first number
number2 Number second number

Description:
Reports the smaller value of the two numbers

Examples:
min 3 5 returns 3

Related Commands:
maximum maxnum minnum
Turtle, Observer, Patch

minnum

Description:
Returns the lowest number possible without going into negative infinity.

Related Commands:
maximum maxnum minimum
Turtle, Observer, Patch

number1 mod number2

Parameters:
number1 Number
number2 Number

Description:
Modulo function. number1 mod number2 is equal to the remainder when number1 is divided by number2. The answer to mod is always positive.

Examples:
6 mod 2 returns 0.

10 mod 3 returns 1.

14 mod 5 returns 4.

Related Commands:
div
Turtle, Observer, Patch

mode-of-breed [list of commands]

Parameters:
[list of commands] List of commands list of commands that evaluate to a number

Description:
Returns the mode of the [list of commands] when evaluated across all the turtles of breed specified by breed.

Examples:
mode-of-frogs [speed] returns the mode of the speed of all the turtles of breed frogs.

Notes:
Note: If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

Note: If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

Note: When a turtle calls the command, it is not included as part of the calculation.

Related Commands:
average-of-breed max-of-breed median-of-breed min-of-breed mode-of-breed-with mode-of-turtles sdev-of-breed sum-of-breed variance-of-breed
Turtle, Observer, Patch

mode-of-breed-with [condition] [list of commands]

Parameters:
[condition] List of turtle commands list of commands that evaluate to true or false
[list of commands] List of turtle commands list of commands to that evaluate to a number

Description:
Returns the mode of the [list of commands] when evaluated across all the turtles of the breed specified by breed that satisfy the [condition].

Examples:
mode-of-frogs-with [color = red] [speed] returns the mode of the speed of all the red turtles of breed frogs.

mode-of-cars-with [brand = honda] [mileage] returns the mode of the mileage of all the turtles of breed car with brand honda.

Notes:
Note: If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

Note: When a turtle calls the command, it is not included as part of the calculation.

Related Commands:
average-of-breed-with max-of-breed-with median-of-breed-with min-of-breed-with mode-of-breed mode-of-turtles-with sdev-of-breed-with sum-of-breed-with variance-of-breed-with
Turtle, Observer, Patch

mode-of-list list

Parameters:
list List

Description:
Returns the mode of the given list.

Examples:
mode-of-list [1 1 2 2 2] returns 2.

Notes:
Note: If list contains no numbers, an error occurs. If some of the list, when evaluated, are not numbers, those values are ignored.

Related Commands:
average-of-list max-of-list median-of-list min-of-list mode-of-list sdev-of-list sort-num-list sum-of-list variance-of-list
Turtle, Observer, Patch

mode-of-patches [list of commands]

Parameters:
[list of commands] List of patch commands list of commands that evaluate to a number

Description:
Returns the mode of the given [list of commands] when evaluated across all the patches.

Examples:
mode-of-patches [food] returns the mode of the food value for all patches.

Notes:
Note: If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

Related Commands:
average-of-patches max-of-patches median-of-patches min-of-patches mode-of-patches-with sdev-of-list sdev-of-patches sum-of-patches variance-of-patches
Turtle, Observer, Patch

mode-of-patches-with [condition] [list of commands]

Parameters:
[condition] List of patch commands list of commands that evaluate to true or false
[list of commands] List of patch commands list of commands to that evaluate to a number

Description:
Returns the mode of the [list of commands] when evaluated across all the patches that satisfy the [condition]

Examples:
mode-of-patches-with [color = red] [food] returns the mode of the food of all the red patches.

Notes:
Note: If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

Related Commands:
average-of-patches-with max-of-patches-with median-of-patches-with min-of-patches-with mode-of-patches sdev-of-patches-with sum-of-patches-with variance-of-patches-with
Turtle, Observer, Patch

mode-of-turtles [list of commands]

Parameters:
[list of commands] List of turtle commands list of commands that evaluate to a number

Description:
Returns the mode of the given [list of commands] when run over all the turtles.

Examples:
mode-of-turtles [speed] returns the mode of the speed value of all turtles.

Notes:
Note: If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

Note: When a turtle calls the command, it is not included as part of the calculation.

Related Commands:
average-of-turtles max-of-turtles median-of-turtles min-of-turtles mode-of-breed mode-of-turtles-with sdev-of-turtles sum-of-turtles variance-of-turtles
Turtle, Observer, Patch

mode-of-turtles-with [condition] [list of commands]

Parameters:
[condition] List of turtle commands list of commands that evaluate to true or false
[list of commands] List of turtle commands list of commands to that evaluate to a number

Description:
Returns the mode of the [list of commands] when evaluated across all the turtles that satisfy the [condition]

Examples:
mode-of-turtles-with [color = red] [speed] returns the mode of the speed of all the red turtles.

Notes:
Note: If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

Note: When a turtle calls the command, it is not included as part of the calculation.

Related Commands:
average-of-turtles-with max-of-turtles-with median-of-turtles-with min-of-turtles-with mode-of-breed-with mode-of-turtles sdev-of-turtles-with sum-of-turtles-with variance-of-turtles-with
Turtle, Observer, Patch

mouse-down?

Description:
Returns a boolean. If any of the mouse buttons are clicked, it returns true. If the mouse buttons all are not clicked, it returns false.

Related Commands:
mouse-xcor mouse-ycor
Turtle, Observer, Patch

mouse-xcor

Description:
Returns the value of the xcor where the mouse was most recently.

Examples:
Run this code in a forever button:
seth towards mouse-xcor mouse-ycor fd .5
Turtles will follow the mouse (pointer tool) around the graphics canvas.

Related Commands:
mouse-down? mouse-ycor
Turtle, Observer, Patch

mouse-ycor

Description:
Returns the value of the ycor where the mouse was most recently.

Examples:
Run this code in a forever button:
seth towards mouse-xcor mouse-ycor fd .5
Turtles will follow the mouse (pointer tool) around the graphics canvas.

Related Commands:
mouse-down? mouse-xcor
Turtle, Observer, Patch

myself

Description:
During a count-turtles-with command, myself reports the who number of the turtle which called it.

Examples:
count-turtles-with [(distance xcor-of myself ycor-of myself) < 5] counts all turtles within a radius of 5 units of the caller.

Related Commands:
count-turtles-with list-of-turtles-with one-of-turtles-with
Observer

no-display

Description:
Turns off Graphics Canvas updating. (By default, Graphics Canvas updating is on.) Preliminary experiments show a 25x speedup for a test of 100 turtles moving forward 100 steps. Anything graphics intensive should speed up dramatically with the display turned off.

Related Commands:
display
Turtle, Observer, Patch

nobody

Description:
An alias for -1. Commands that return turtle numbers return nobody when there is no appropriate turtle to return.

Examples:
nobody returns -1.

if one-of-frogs != nobody [show "There are frogs!"] will return "There are frogs!" if there are any frogs.


Turtle, Observer, Patch

not condition1

Parameters:
condition1 Boolean

Description:
Reports true if condition1 reports false.

Related Commands:
and or xor
Observer

nsum neighbor-variable patch-sum-variable

Parameters:
neighbor-variable Variable the variable of the neighbor you would like to sum up
patch-sum-variable Variable the variable that should be set to the sum of the neighbors' variables

Description:
For each patch, takes the sum of neighbor-variable from all neighboring patches and places it in patch-sum-variable. Both neighbor-variable and patch-sum-variable should be patch variables.

Examples:
nsum food surrounding-food takes the food variable of all the surrounding patches and stores the value of their sum in the patch-variable surrounding-food.

Notes:
nsum must be run by the observer even though it affects patches.

Related Commands:
diffuse diffuse4 nsum4
Observer

nsum4 neighbor-variable patch-sum-variable

Parameters:
neighbor-variable Variable the variable of the neighbor you would like to sum up
patch-sum-variable Variable the variable that should be set to the sum of the neighbors' variables

Description:
For each patch, takes the sum of neighbor-variable from the non-diagonal (N,E,S,W) neighboring patches and places it in patch-sum-variable. Variable should be a patch variable.

Examples:
nsum4 grass totalgrass adds up the value of grass in the non-diagonal patches and places it in totalgrass.

Notes:
nsum4 must be run by the observer even though it affects patches.

Related Commands:
diffuse diffuse4 nsum
Turtle, Observer, Patch

number? thing

Parameters:
thing Anything

Description:
Returns true if thing is a number.

Examples:
number? 5.3 returns true.

number? [3] returns false.

Related Commands:
list? word?
Turtle, Observer, Patch

one-of-breed

Description:
Returns a random turtle from the specified breed.

Related Commands:
count-turtles list-of-turtles one-of-breed-at one-of-breed-at-with one-of-breed-here one-of-breed-here-with one-of-breed-towards one-of-breed-towards-with one-of-breed-with one-of-turtles
Turtle, Observer, Patch

one-of-breed-at xcor ycor

Parameters:
xcor Number x-coordinate
ycor Number y-coordinate

Description:
Returns a random turtle of breed breed xcor units in the x direction and ycor units in the y direction away from the caller.

Examples:
one-of-frogs-at 1 1 returns a random turtle of breed frogs one unit to the right and one unit above the caller.

Related Commands:
one-of-breed one-of-breed-at-with one-of-breed-here one-of-breed-towards one-of-turtles-at
Turtle, Observer, Patch

one-of-breed-at-with xcor ycor [condition]

Parameters:
xcor Number number of steps in the x-direction from the caller
ycor Number number of steps in the y-direction from the caller
[condition] List of commands list of commands that returns true or false

Description:
Returns a random turtle of the breed specified that satisfies [condition] that is on the patch xcor units away in the x direction and ycor units away in the y direction

Examples:
one-of-dogs-at-with 1 1 [color = brown] returns a turtle of breed dog that is 1 unit away in the x direction, 1 unit away in the y direction and is brown

Related Commands:
one-of-breed one-of-breed-at one-of-breed-here-with one-of-breed-towards-with one-of-turtles-at-with
Turtle, Patch

one-of-breed-here

Description:
Returns a random turtle of the specified breed on the caller's patch other than the caller.

Examples:
kill one-of-frogs-here commands the caller to kill a random turtle of breed frogs that is on the caller's patch.

Related Commands:
count-turtles-here list-of-turtles-here one-of-breed one-of-breed-at one-of-breed-here-with one-of-breed-towards one-of-turtles-here
Turtle, Patch

one-of-breed-here-with [list of commands]

Parameters:
[list of commands] List of commands list of commands that evaluates to either true or false

Description:
Returns a random turtle of the breed specified that satisfies [list of commands] and is on the same patch as the caller.

Examples:
one-of-cars-here-with [color = red] returns a turtle of breed car on the same patch as the color that is red.

Related Commands:
one-of-breed one-of-breed-at-with one-of-breed-here one-of-breed-towards-with one-of-turtles-here-with
Turtle, Observer, Patch

one-of-breed-towards angle distance

Parameters:
angle Number
distance Number

Description:
Returns a random turtle of the specified breed at the patch angle away at angle distance from the caller.

Examples:
one-of-frogs-towards 0 1 returns a random turtle of breed frogs one unit directly in front of the caller.

Related Commands:
one-of-breed one-of-breed-at one-of-breed-here one-of-breed-towards-with one-of-turtles-towards-with
Turtle, Observer, Patch

one-of-breed-towards-with angle distance [condition]

Parameters:
angle Number angle from caller
distance Number distance from caller
[condition] List of turtle commands list of commands that returns true or false

Description:
Returns a random turtle of the breed specified that is at a distance distance and an angle angle from the caller that satisfies [condition]

Examples:
one-of-mice-towards-with 180 1 [color = blue] returns a random turtle of breed mice and color blue that is one space behind the caller

Related Commands:
one-of-breed one-of-breed-at-with one-of-breed-here-with one-of-breed-towards one-of-turtles-towards-with
Turtle, Observer, Patch

one-of-breed-with [condition]

Parameters:
[condition] List of commands list of commands that evaluates to either true or false

Description:
Returns a random turtle that satisfies [condition].

Examples:
one-of-frogs-with [color = red] returns a random turtle that is red and of breed frogs

Related Commands:
one-of-breed one-of-turtles-with
Turtle, Observer, Patch

one-of-turtles

Description:
Returns a random turtle.

Related Commands:
count-turtles list-of-turtles one-of-breed one-of-turtles-at one-of-turtles-here one-of-turtles-towards one-of-turtles-with
Turtle, Observer, Patch

one-of-turtles-at xcor ycor

Parameters:
xcor Number x-coordinate
ycor Number y-coordinate

Description:
Returns a random turtle xcor units in the x direction and ycor units in the y direction away from the caller.

Examples:
one-of-turtles-at 1 1 returns a random turtle one unit to the right and one unit above the caller.

Related Commands:
one-of-breed-at one-of-turtles one-of-turtles-at-with one-of-turtles-towards one-of-turtles-with
Turtle, Observer, Patch

one-of-turtles-at-with xcor ycor [condition]

Parameters:
xcor Number number of steps in the x-direction from the caller
ycor Number number of steps in the y-direction from the caller
[condition] List of commands list of commands that returns true or false

Description:
Returns a random turtle that satisfies [condition] that is on the patch xcor units away in the x direction and ycor units away in the y direction

Examples:
one-of-turtles-at-with 1 1 [color = red] returns a red turtle that is one unit away in the x direction and 1 unit away in the y diretion

Related Commands:
one-of-breed-at-with one-of-turtles-at one-of-turtles-here-with one-of-turtles-towards-with
Turtle, Patch

one-of-turtles-here

Description:
Returns a random turtle on the caller's patch other than the caller.

Examples:
kill one-of-turtles-here commands the caller to kill a random turtle that is on the caller's patch.

Related Commands:
one-of-breed-here one-of-turtles one-of-turtles-here-with one-of-turtles-towards
Turtle, Patch

one-of-turtles-here-with [condition]

Parameters:
[condition] List of turtle commands the condition that the turtle to be returned must meet

Description:
Returns a random turtle on the caller's patch that meets [condition]. The returned turtle is different than the caller.

Related Commands:
one-of-breed-here-with one-of-turtles-at-with one-of-turtles-here one-of-turtles-towards-with
Turtle, Observer, Patch

one-of-turtles-towards angle distance

Parameters:
angle Number
distance Number

Description:
Returns a random turtle at the patch distance away at angle angle from the caller.

Examples:
one-of-turtles-towards 0 1 returns a random turtle one unit directly in front of the caller.

Related Commands:
one-of-turtles one-of-turtles-at one-of-turtles-here one-of-turtles-towards-with
Turtle, Observer, Patch

one-of-turtles-towards-with angle distance [condition]

Parameters:
angle Number angle from caller
distance Number distance from caller
[condition] List of turtle commands list of commands that returns true or false

Description:
Returns a random turtle that is distance distance away at an angle angle that satisfies [condition].

Examples:
one-of-turtles-towards-with 0 1 [color = red] returns a red turtle that is 1 space away and directly in front of the caller.

Related Commands:
one-of-breed-towards one-of-breed-towards-with one-of-turtles-at-with one-of-turtles-here-with one-of-turtles-towards
Turtle, Observer, Patch

one-of-turtles-with [condition]

Parameters:
[condition] List of commands condition the turtle must meet
Number

Description:
Chooses a turtle based on the following [condition].

Examples:
one-of-turtles-with [color = red] [setc blue] chooses a red turtle

Related Commands:
count-turtles-with list-of-turtles-with myself one-of-breed-with one-of-turtles one-of-turtles-at
Turtle, Observer, Patch

condition1 or condition2

Parameters:
condition1 Boolean
condition2 Boolean

Description:
Reports true if either condition1 or condition2 reports true.

Examples:
if (color = black) or (color = red) [fd 2] makes all black or red turtles move forward 2 steps.

Related Commands:
and not xor
Turtle, Observer, Patch

orange

Description:
Reports 25, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green lime magenta pink purple red sky turquoise white yellow
Turtle, Observer, Patch

output something

Parameters:
something Anything the value to be returned

Description:
Exits the current procedure and returns something.

Examples:
output "hello" exits the current procedure and returns the string "hello".

Related Commands:
end loop stop to
Turtle, Observer, Patch

output-name

Description:
Returns the current filename of the output window. Returns false if no filename has been set yet.

Related Commands:
info-name project-name save-output save-output-as set-output-name
Turtle, Observer, Patch

partner

Description:
Returns the who number of the turtle being grabbed, or nobody if no turtle is being grabbed.

Examples:
grab one-of-turtles-here
[if (color-of partner) = red [die]]

These statements will cause a turtle to partner with another turtle on the same spot and die if that partner is red.

Notes:
Must be used inside of a grab statement.

Related Commands:
grab grabbed? partners
Turtle, Observer, Patch

partners

Description:
Returns a dlist of the turtles being grabbed, or [ ] if no turtles are being grabbed.

Examples:
grab list-of-turtles-here
[if (first partners) = 0 [fd 1]]

These statements will cause the turtle to partner with all of the turtles on the patch, and move forward one space if the first one in the list is the turtle with who 0.

Related Commands:
grab grabbed? partner
Turtle, Patch

patchcolor (pc)

Description:
Reports the color of the patch the turtle is on.

Examples:
if pc = red [fd 1] commands the turtle to move forward one unit if the color of the patch the turtle is on is red.

Notes:
This command can also be executed by patches, for example within an ask-patches statement.

Related Commands:
pc-ahead pc-ahead-one-patch pc-at pc-towards setbg setpc stamp
Observer

patches-own [variable-list]

Parameters:
[variable-list] Variable a list of patch variables separated by spaces

Description:
Defines a set of variables to be properties of patches. The [variable-list] contains one or more names separated by spaces

Examples:
patches-own [size value] declares two patch variables - size and value.

Notes:
patches-own must only be used once in any program, and remain outside of any procedures. Typically patches-own is defined once at the top of the Observer Procedures window.

Related Commands:
breeds globals turtles-own
Turtle

pc-ahead (pc-ahead-one-step)

Description:
Reports the color of the patch one space ahead in the direction that the turtle is facing. If called by the observer, it will assume coordinates of (0,0).

Notes:
if pc-ahead = blue [fd 1] commands the caller to move forward 1 if the patch ahead of it is blue.

Related Commands:
patchcolor pc-ahead-one-patch pc-at pc-towards
Turtle

pc-ahead-one-patch

Description:
Returns the color of the patch one patch ahead. This is equivalent to pc-at round dx round dy

Examples:
pc-ahead-one-patch will return the color of the next patch in front of the turtle

Notes:
The patch returned may or may not be the same as pc-ahead. In this version the patch returned is never the same as the patch that the caller is on.

Related Commands:
patchcolor pc-ahead
Turtle, Observer, Patch

pc-at xcor ycor

Parameters:
xcor Number
ycor Number

Description:
Reports the color of the patch xcor units in the x direction and ycor units in the y direction away from the caller.

Examples:
pc-at 1 1 reports the color of the patch one unit to the right and one unit above the caller.

Notes:
This command can also be executed by patches, for example within an ask-patches statement.

Related Commands:
patchcolor pc-ahead pc-towards stamp-at
Turtle, Observer, Patch

pc-towards angle distance

Parameters:
angle Number
distance Number

Description:
Reports the color of the patch angle away at an angle distance from the caller.

Examples:
pc-towards 0 1 returns the color of the patch which is one unit directly in front of the caller.

Notes:
This command can also be executed by patches, for example within an ask-patches statement.

Related Commands:
patchcolor pc-ahead pc-at stamp-towards
Turtle

pendown (pd)

Description:
Turtles put down their pens, meaning that they draw when they move, leaving a trail behind them. The color of the pen is that of the turtle.

Examples:
if pc = blue [pd] commands the caller to put its pen down and leave a trail behind it if the patch it is on is blue.

Notes:
Only fd and bk will draw a line.

Related Commands:
pendown? pendown?-of pendown?-towards penup setpendown?-at setpendown?-of setpendown?-towards
Turtle

pendown?

Description:
Returns true if the turtle's pen is down, otherwise false.

Examples:
if pendown? [setc blue] commands the caller to set its color to blue if its pen is down.

Related Commands:
pendown pendown?-at pendown?-towards penup
Turtle, Observer, Patch

pendown?-at xcor ycor

Parameters:
xcor Number
ycor Number

Description:
Reports whether the pen of the turtle at xcor ycor, relative to the caller, is down.

Examples:
pendown?-at 1 1 reports whether the pen of the turtle is down one unit to the right and one unit above the caller.

Related Commands:
pendown? pendown?-towards setpendown?-at
Turtle, Observer, Patch

pendown?-of number

Parameters:
number Number a who number

Description:
Reports whether the pen of the turtle with who number number is down.

Examples:
pendown?-of 2 reports whether the pen of the turtle with who number 2 is down.

Related Commands:
pendown penup setpendown?-of
Turtle, Observer, Patch

pendown?-towards angle distance

Parameters:
angle Number
distance Number

Description:
Reports whether the pen of a turtle angle away at an angle of distance from the caller is down.

Examples:
pendown?-towards 0 1 reports whether the pen of a turtle one unit directly in front of the caller is down.

Related Commands:
pendown pendown? pendown?-at penup
Turtle

penup (pu)

Description:
Turtles pick up their pens, meaning that they no longer draw when they move.

Examples:
if pc-ahead = red [pu] commands the caller to lift its pen up and stop drawing as it moves if the patch ahead of it is red.

Related Commands:
pendown pendown? pendown?-of pendown?-towards setpendown?-at setpendown?-of setpendown?-towards
Turtle, Observer, Patch

pi

Description:
Returns the value of pi (approximately 3.14159).

Related Commands:
e
Turtle, Observer, Patch

pick [list of data]

Parameters:
[list of data] List or string

Description:
Returns a random element of the [list of data]. Returns false if the list is empty.

Examples:
pick [1 2] would return 1 half of the time and would return 2 half of the time.

Related Commands:
list random sentence to-list
Turtle, Observer, Patch

pink

Description:
pink reports 135, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green lime magenta orange purple red sky turquoise white yellow
Turtle, Observer, Patch

plot y-value

Parameters:
y-value Number

Description:
Plots a point at y-value, then increments the x-value of the plot pen by 1. The pen will rescale itself when it reaches plot-xmax.

Examples:
plot speed plots the speed of the turtle over time.

Related Commands:
clear-plot clearplots plotid plotxy pp ppreset view-plot
Turtle, Observer, Patch

plot-grid-off

Description:
Turns the plot grid off.

Related Commands:
plot-grid-on plot-grid?
Turtle, Observer, Patch

plot-grid-on

Description:
Turns the plot grid on.

Related Commands:
plot-grid-off plot-grid?
Turtle, Observer, Patch

plot-grid?

Description:
Returns a boolean. If the plot grid is on, true is returned. If the plot grid is off, false is returned.

Examples:
show plot-grid? will return false if the plot grid is not on.

Related Commands:
plot-grid-off plot-grid-on
Turtle, Observer, Patch

plot-title

Description:
Returns the title of the plot

Related Commands:
setplot-title
Turtle, Observer, Patch

plot-xlabel

Description:
Returns the value of the label of the x-axis of the graph.

Related Commands:
plot-ylabel setplot-xlabel
Turtle, Observer, Patch

plot-xmax

Description:
Returns the current maximum x-value of the plot.

Related Commands:
plot-xmin plot-ymax setplot-xmax setplot-xrange
Turtle, Observer, Patch

plot-xmin

Description:
Returns the current minimum x-value of the plot.

Related Commands:
plot-xmax plot-ymin setplot-xmin setplot-xrange
Turtle, Observer, Patch

plot-ylabel

Description:
Returns the value of the label of the y-axis of the graph.

Related Commands:
plot-xlabel setplot-ylabel
Turtle, Observer, Patch

plot-ymax

Description:
Returns the current maximum y-value of the plot.

Related Commands:
plot-xmax plot-ymin setplot-ymax setplot-yrange
Turtle, Observer, Patch

plot-ymin

Description:
Returns the current minimum y-value of the plot.

Related Commands:
plot-xmin plot-ymax setplot-ymin setplot-yrange
Turtle, Observer, Patch

plotid number

Parameters:
number Number

Description:
Sets the current plot to number, where number is the id number of an existing plot. Plot procedures now operate on this current plot.

Examples:
plotid 2 sets the current plot to plot number 2

Notes:
This command does not change the name of the plot, it just changes which of the plots is currently being addressed.

Related Commands:
plot pp view-plot
Turtle, Observer, Patch

plotxy x-value y-value

Parameters:
x-value Number
y-value Number

Description:
Plots a point at the location (x-value, y-value). This procedure is used for X-Y plots and scatterplots.

Examples:
plotxy 1 1 plots a point at the coordinate (1,1).

Related Commands:
plot
Turtle, Observer, Patch

position item [list of data]

Parameters:
item Integer
[list of data] List or string

Description:
Returns the position of item in the [list of data]

Examples:
position 1 [6 7 1] returns 3

Related Commands:
item list member? remove remove-element sentence setitem
Turtle, Observer, Patch

pp number

Parameters:
number Integer

Description:
Selects the plot pen specified by number. Subsequent plotting commands are executed by the selected plot pen. There are ten plot pens, numbered 1 through 10. The space between pp and integer is optional.

Examples:
pp 1 selects the first plot pen

Related Commands:
plot plotid ppc ppd ppreset ppu ppxcor ppycor setppc
Turtle, Observer, Patch

ppc

Description:
Returns the current plot pen color.

Related Commands:
pp ppd ppreset ppu ppxcor ppycor setppc
Turtle, Observer, Patch

ppd

Description:
Puts the plot pen down, so that it draws connected graphs.

Related Commands:
pp ppc ppd ppreset ppu ppxcor ppycor
Turtle, Observer, Patch

ppreset

Description:
Clears everything that the currently selected plot pen has drawn and resets it position to (0,0).

Related Commands:
plot pp ppc ppd ppreset ppu ppxcor ppycor
Turtle, Observer, Patch

ppu

Description:
Lifts up the plot pen, so that it plots points individually (not connected).

Related Commands:
pp ppc ppd ppreset ppxcor ppycor
Turtle, Observer, Patch

ppxcor

Description:
Returns the x-value of the current plot pen.

Related Commands:
pp ppc ppd ppreset ppu ppycor
Turtle, Observer, Patch

ppycor

Description:
Returns the y-value of the current plot pen.

Related Commands:
pp ppc ppd ppreset ppu ppxcor
Turtle, Observer, Patch

print string/numbers

Parameters:
string/numbers Anything

Description:
Prints the string/numbers in the output window followed by a carriage return.

Examples:
print color-of 0 prints the color of the turtle with who 0.

Related Commands:
print-status show type
Turtle, Observer, Patch

print-status string/numbers

Parameters:
string/numbers Anything

Description:
Prints the string/numbers to the status bar. The status bar is located at the bottom left of the Interface Window, to the right of the X and Y coordinates.

It prints to the browser's status bar when a project is running as an applet.

Examples:
print-status color-of 0 prints the color of the turtle with who 0.

Related Commands:
print show type
Turtle, Observer, Patch

project-name

Description:
returns the current filename of the project. Returns false if no filename has been set yet.

Related Commands:
info-name output-name save-project save-project-as set-project-name
Patch

pstamp color

Parameters:
color Color

Description:
Allows patches to set the color of the turtle that is on it to color.

Examples:
pstamp blue sets the color of the turtles on top of the called patch to blue.

Related Commands:
pstamp-at pstamp-towards stamp
Patch

pstamp-at xcor ycor color

Parameters:
xcor Number
ycor Number
color Color

Description:
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.

Examples:
pstamp-at 1 1 blue commands the patch to set the color of the turtles one unit to the right and one unit above the called patch to the color blue.

Related Commands:
pstamp pstamp-towards stamp-at
Patch

pstamp-towards angle distance color

Parameters:
angle Number
distance Number
color Color

Description:
Allows patches to set the color of the turtle distance units away at an angle of angle to color.

Examples:
pstamp-towards 0 1 blue sets the color of the turtles one unit directly ahead of the called patch to the color blue.

Related Commands:
pstamp pstamp-at stamp-towards
Turtle, Observer, Patch

purple

Description:
violet reports 115, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green lime magenta orange pink red sky turquoise white yellow
Turtle, Observer, Patch

random number

Parameters:
number Number upper-limit of range of random numbers to generate

Description:
Reports a random number between 0 and number, including 0 but not number, based on a uniform distribution.

Examples:
random 2 reports either 0 or 1, each with fifty percent probability.

Notes:
StarLogo uses the random generator provided by Java, which, as of now, is a linear congruential formula (Knuth Art of Computer Programming, Vol 2, Section 3.2.1.), which uses a 48-bit seed. StarLogo only allows you to set 32 bits of this seed.

Related Commands:
pick random-gaussian set-random-seed setrandom-seed
Turtle, Observer, Patch

random-gaussian number

Parameters:
number Number standard deviation of Gaussian distribution

Description:
Reports a random number with mean 0 and standard deviation number.

Examples:
random-gaussian 5 returns a random number with mean 0 and standard deviation 5.

Notes:
StarLogo uses the random generator provided by Java, which, as of now, is a linear congruential formula (Knuth Art of Computer Programming, Vol 2, Section 3.2.1.), which uses a 48-bit seed. StarLogo only allows you to set 32 bits of this seed.

Related Commands:
random set-random-seed setrandom-seed
Turtle, Observer, Patch

red

Description:
red reports 15, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green lime magenta orange pink purple sky turquoise white yellow
Turtle, Observer, Patch

remove index [list]

Parameters:
index Number position in list of element to remove
[list] List list with element to remove

Description:
Reports the new list with the element in the index position removed from the specified list. The input list is not changed.

Examples:
remove 5 [2 4 6 8 10 12] reports [2 4 6 8 12].

Related Commands:
insert item list member? position remove-element sentence setitem
Turtle, Observer, Patch

remove-element element [list]

Parameters:
element Anything element to be removed
[list] List list with element to be removed

Description:
Reports the new list when all instances of the specified element are removed from list. The input list is not changed.

Examples:
remove-element [1 2] [3 [4 5] [1 2] 6 [1 2]] returns [3 [4 5] 6]

Notes:
"=" is used as the comparison operator.

Related Commands:
item list member? position remove sentence setitem
Turtle, Observer, Patch

repeat number [list of commands]

Parameters:
number Number number of times to iterate
[list of commands] List of commands list of commands to run on each iteration

Description:
Do [list of commands] number times.

Examples:
repeat 4 [fd 4 lt 90] makes turtles move forward 4 steps and then turn left 90 degrees 4 times.

Related Commands:
loop
Turtle, Observer, Patch

reset-timer (resett)

Description:
Resets the timer.

Examples:
If you want to time how long a process takes, do this:
reset-timer fd 1000 show timer

Related Commands:
timer
Turtle, Observer, Patch

reverse [list]

Parameters:
[list] List list to be reversed

Description:
Reports the new list with the order of the elements in [list] reversed. The input [list] is not changed.

Examples:
reverse [1 2 3] reports the list [3 2 1].

Related Commands:
fput list lput sentence
Turtle

right (rt) angle

Parameters:
angle Number number of degrees to turn

Description:
Turtles turn right by angle degrees.

Examples:
rt 90

Related Commands:
back forward left setheading
Turtle, Observer, Patch

round number

Parameters:
number Number number to be rounded

Description:
Reports the integer closest to number.

Examples:
round 4.6 returns 5.

Related Commands:
int
Observer

save-info

Description:
Saves the information window.

Related Commands:
info-name save-info-as save-output save-project
Observer

save-info-as

Description:
Saves the information window using a different name than presently specified. A dialog box will appear to ask for the new file name.

Related Commands:
info-name save-info save-output-as save-project-as
Observer

save-next-version

Description:
Saves the current project using the same name as the previous version except with a number at the end, incremented by one each time a new version is saved.

Examples:
If the current project is called Turtles1.slogo, save-next-version will save the current project as Turtles2.slogo.

Related Commands:
save-project save-project-as
Observer

save-output

Description:
Saves output window to a file.

Related Commands:
output-name save-info save-output-as save-project set-output-name
Observer

save-output-as

Description:
Saves the output window using a different name than presently specified. A dialog box will appear to ask for the new file name.

Related Commands:
output-name save-info-as save-output save-project-as set-output-name
Observer

save-project

Description:
Saves the current project to a file.

Related Commands:
project-name save-info save-next-version save-output save-project-as set-project-name
Observer

save-project-as

Description:
Saves the current project using a different name than presently specified. A dialog box will appear to ask for the new file name.

Related Commands:
project-name save-info-as save-next-version save-output-as save-project set-project-name
Turtle, Patch

scale-color color variable limit1 limit2

Parameters:
color Number Color
variable Number Variable color
limit1 Number Lower limit
limit2 Number Upper limit

Description:
Turtles set their color to a shade of color based on their value of variable. limit1 and limit2 determine the amount of gradation. If a patch calls this, all turtles on that patch scale their color.

Examples:
scale-color blue energy 0 20 Turtles turn one of twenty shades of blue. Turtles with lower energy turn darker blue.

scale-color blue energy 20 0
Turtles turn one of twenty shades of blue. Turtles with lower energy turn lighter blue.

Notes:
If the turtle exceeds the limits, it turns black on the dark end of the specturm and turns white on the bright end of the spectrum.

Related Commands:
scale-pc
Turtle, Patch

scale-pc color variable limit1 limit2

Parameters:
color Number Color
variable Number
limit1 Number Lower limit
limit2 Number Upper limit

Description:
Patches set their color to a shade of color based on their value of variable. limit1 and limit2 determine the amount of gradation. If a turtle calls this, the patch underneath the turtle scale its patch color.

Examples:
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.

Notes:
This is a patch command. It must be called from within an ask-patches or ask-patch-at statement.

If the patch exceeds the limits, it turns black on the dark end of the specturm and turns white on the bright end of the spectrum.

Related Commands:
scale-color setpc
Observer

scheduler

Description:
Reports the current scheduler, either 'fixed' or 'random'.

Related Commands:
get-scheduler-random-seed set-scheduler-random-seed switch-scheduler
Turtle, Observer, Patch

screen-half-height

Description:
Returns half of the height of the screen.

Related Commands:
screen-half-width screen-height screen-width
Turtle, Observer, Patch

screen-half-width

Description:
Returns half of the width of the screen.

Related Commands:
screen-half-height screen-height screen-width
Turtle, Observer, Patch

screen-height

Description:
Returns the height of the screen. The height is always an odd number, and the lowest possible value is 3. To change the screen-height, drag the mouse over the graphics canvas and use the handles to resize it.

Related Commands:
screen-half-height screen-half-width screen-width
Turtle, Observer, Patch

screen-width

Description:
Returns width of the screen. The width is always an odd number, and the lowest possible value is 3. To change the screen-width, drag the mouse over the graphics canvas and use the handles to resize it.

Related Commands:
screen-half-height screen-half-width screen-height
Turtle, Observer, Patch

sdev-of-breed [list of commands]

Parameters:
[list of commands] List of commands

Description:
Returns the standard deviation of the [list of commands] when evaluated across all the turtles of breed frogs.

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it is not included as part of the calculation.

Related Commands:
max-of-breed median-of-breed min-of-breed mode-of-breed sdev-of-breed-with sdev-of-turtles sum-of-breed variance-of-breed
Turtle, Observer, Patch

sdev-of-breed-with [first list of commands] [second list of commands]

Parameters:
[first list of commands] List of commands
[second list of commands] List of commands

Description:
Returns the standard deviation of the [second list of commands] when evaluated across all the turtles of breed frogs that satisfy the conditions (must return a boolean of true or false) specified by the [first list of commands].

Examples:
sdev-of-frogs-with [color = red] [speed] returns the standard deviation of the speed of all the red turtles of breed frogs.

Notes:
If [second list of commands] contains no numbers, an error occurs. If some of the [second list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it is not included as part of the calculation.

Related Commands:
max-of-breed-with median-of-breed-with min-of-breed-with mode-of-breed-with sdev-of-breed sdev-of-turtles-with sum-of-breed-with variance-of-breed-with
Turtle, Observer, Patch

sdev-of-list list

Parameters:
list List

Description:
Reports the standard deviation of the given list.

Examples:
sdev-of-list [2 2 2] returns 0.

Notes:
If list contains no numbers, an error occurs. If some elements of the list, when evaluated, are not numbers, those elements are ignored.

Related Commands:
average-of-list max-of-list median-of-list min-of-list min-of-patches mode-of-list mode-of-patches sort-num-list sum-of-list variance-of-list
Turtle, Observer, Patch

sdev-of-patches [list of commands]

Parameters:
[list of commands] List of commands

Description:
Returns the standard deviation of the given [list of commands] when evaluated across all the patches.

Examples:
sdev-of-patches [food] returns the stadard deviation of the food amongst all the patches.

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

Related Commands:
max-of-patches median-of-patches min-of-patches mode-of-patches sdev-of-patches-with sum-of-patches variance-of-patches
Turtle, Observer, Patch

sdev-of-patches-with [first list of commands] [second list of commands]

Parameters:
[first list of commands] List of commands
[second list of commands] List of commands

Description:
Returns the standard deviation of the [second list of commands] when evaluated across all the patches that satisfy the conditions (must return a boolean of true or false) specified by the [first list of commands].

Examples:
sdev-of-patches-with [color = red] [food] returns the standard deviation of the food of all the red patches.

Notes:
If [second list of commands] contains no numbers, an error occurs. If some of the [second list of commands], when evaluated, are not numbers, those values are ignored.

Related Commands:
max-of-patches-with median-of-patches-with min-of-patches-with mode-of-patches-with sdev-of-patches sum-of-patches-with variance-of-patches-with
Turtle, Observer, Patch

sdev-of-turtles [list of commands]

Parameters:
[list of commands] List of commands

Description:
Returns the standard deviation of the [list of commands] when evaluated across all the turtles.

Examples:
sdev-of-turtles [speed] returns the standard devation of the speed of all the turtles.

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it is not included as part of the calculation.

Related Commands:
max-of-turtles median-of-turtles min-of-turtles mode-of-turtles sdev-of-breed sdev-of-turtles-with sum-of-turtles variance-of-turtles
Turtle, Observer, Patch

sdev-of-turtles-with [first list of commands] [second list of commands]

Parameters:
[first list of commands] List of commands
[second list of commands] List of commands

Description:
Returns the standard deviation of the [second list of commands] when evaluated across all the turtles that satisfy the conditions (must return a boolean of true or false) specified by the [first list of commands].

Examples:
sdev-of-turtles-with [color = red] [speed] returns the standard deviation of the speed of all the red turtles.

Notes:
If [second list of commands] contains no numbers, an error occurs. If some of the [second list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it is not included as part of the calculation.

Related Commands:
max-of-turtles-with median-of-turtles-with min-of-turtles-with mode-of-turtles-with sdev-of-breed-with sdev-of-turtles sum-of-turtles-with variance-of-turtles-with
Turtle, Observer, Patch

sentence (se) anything1 anything2

Parameters:
anything1 Anything
anything2 Anything

Description:
Returns a list. If anything1 and anything2 are lists, it concatenates the two lists (combines their items into one list). If anything1 is a list and anything2 is not, it puts anything2 at the end of the first list. If anything1 is not a list and anything2 is a list, it puts anything1 at the front of the second list. If both anything1 and arg2 are not lists, it creates a new list containing both anything1 and anything2.

Examples:
se 1 2 returns [1 2]


se [1] 2 returns [1 2]


se 1 [2] returns [1 2]


se [1] [2] returns [1 2]

Related Commands:
butfirst butlast copy-list empty? fput length list lput make-list pick position remove remove-element reverse sublist to-list
Turtle, Observer, Patch

set set value

Parameters:
set Variable variable that gets redefined
value Anything value to be assigned to variable

Description:
Assigns value to set, where set is any variable which has already been declared. For more information on local variables, see the Variables page.

Examples:
set energy 5 makes the variable energy have value 5 for every turtle, assuming energy has been declared as a turtle variable.

Related Commands:
let setslidervar setvariable setvariable-at setvariable-of setvariable-towards variable
Observer

set-count-plot-pens number

Parameters:
number Number

Description:
Sets the number of plot pens to number.

Examples:
set-count-plot-pens 2 sets the number of plot pens to 2.

Related Commands:
count-plot-pens
Observer

set-info-name name

Parameters:
name String The name of the file

Description:
Sets the name of the file that the info window will be saved as to name.

Related Commands:
set-output-name set-project-name
Observer

set-output-name name

Parameters:
name String name of the file

Description:
Sets the name of the file that the output window will be saved as to name

Examples:
set-output-name filename sets the name of the output file to filename

Related Commands:
output-name save-output save-output-as set-info-name set-project-name
Observer

set-project-name name

Parameters:
name String The name for the project

Description:
Sets the name of the current project to name.

Examples:
set-project-name "rabbits" sets the name of the current project to "rabbits".

Related Commands:
project-name save-project save-project-as set-info-name set-output-name
Observer

set-random-seed num

Parameters:
num Integer The seed for the random number generator

Description:
Sets the random seed to num. Integers allowed are in the range -231 to 231-1.

Notes:
StarLogo uses the random generator provided by Java, which, as of now, is a linear congruential formula (Knuth Art of Computer Programming, Vol 2, Section 3.2.1.), which uses a 48-bit seed. StarLogo only allows you to set 32 bits of this seed.

Related Commands:
get-random-seed random random-gaussian
Observer

set-scheduler-random-seed seed

Parameters:
seed Integer The seed for the random number generator

Description:
Sets the random seed of the thread scheduler to seed. Integers allowed are in the range -2^31 to 2^31-1.

This is not the same seed as used by the random command.

Notes:
Note: StarLogo uses the random generator provided by Java, which, as of now, is a linear congruential formula (Knuth Art of Computer Programming, Vol 2, Section 3.2.1.), which uses a 48-bit seed. StarLogo only allows you to set 32 bits of this seed.

Related Commands:
get-scheduler-random-seed scheduler switch-scheduler
Observer

setbg color

Parameters:
color Color

Description:
Sets the color of all the patches to color.

Examples:
setbg blue sets the color of all the patches to blue.

Related Commands:
ask-patches patchcolor setpc
Turtle

setbreed breedname

Parameters:
breedname Breed

Description:
Sets the turtle's breed to breedname.

Examples:
setbreed frogs sets the turtle's breed to frogs.

Related Commands:
breed setbreed-at setbreed-of setbreed-towards
Turtle, Observer, Patch

setbreed-at xcor ycor breedname

Parameters:
xcor Number x offset
ycor Number y offset
breedname Breed

Description:
Sets the breed of the turtle xcor units in the x direction and ycor units in the y direction away from the caller to breedname.

Examples:
setbreed-at 1 1 fish sets the breed of the turtle one unit to the right and one unit above the caller to fish.

Related Commands:
breed-at setbreed setbreed-of setbreed-towards
Turtle, Observer, Patch

setbreed-of number breedname

Parameters:
number Number
breedname Breed

Description:
Sets the breed of the turtle with who number number to the breed breedname.

Examples:
setbreed-of 2 fish sets the breed of the turtle with who number 2 to fish.

Related Commands:
breed-of setbreed setbreed-at setbreed-towards
Turtle, Observer, Patch

setbreed-towards angle distance breedname

Parameters:
angle Number
distance Number
breedname Breed

Description:
Sets the breed of the turtle angle away in the direction arg2 to breedname.

Examples:
setbreed towards 0 1 fish sets the breed of the turtle one unit directly in front of the caller to fish.

Related Commands:
breed-towards setbreed setbreed-at setbreed-of
Turtle, Observer, Patch

setc-at xcor ycor color

Parameters:
xcor Number
ycor Number
color Color

Description:
Sets the color of the turtle at (xcor, ycor) to color.

Examples:
setc-at 1 1 0 sets the color of the turtle at (1,1) to black.

Related Commands:
color-at setc-of setc-towards setcolor
Turtle, Observer, Patch

setc-of turtleid color

Parameters:
turtleid Number who number of the turtle whose color should be changed
color Color

Description:
Sets the color of the turtle with ID turtleid$ to color color.

Examples:
setc-of 2 0 sets the color of the turtle with who number 2 to black.

Related Commands:
color-of setc-at setc-towards setcolor
Turtle, Observer, Patch

setc-towards angle distance color

Parameters:
angle Number
distance Number
color Color

Description:
Sets the color of the turtle angle away at angle distance from the caller to color.

Examples:
setc-towards 0 1 0 sets the color of the turtle one unit directly in front of the caller to black.

Related Commands:
color-towards setc-at setc-of setcolor
Turtle

setcolor (setc) colorname

Parameters:
colorname Color

Description:
Turtles set their color to colorname.

Examples:
setc brown

setc 45

Related Commands:
color setc-at setc-of setc-towards
Turtle, Observer, Patch

seth-at xcor ycor

Parameters:
xcor Number
ycor Number

Description:
Sets the heading of the turtle xcor units in the x direction and ycor units in the y direction away from the caller to $arg3.

Examples:
seth-at 1 1 5 sets the heading of the turtle one unit to the right and one unit above the caller to 5.

Related Commands:
heading-at seth-of seth-towards setheading
Turtle, Observer, Patch

seth-of seth-of heading

Parameters:
seth-of Number turtleid
heading Number the angle to which the turtle's heading should be set

Description:
Sets the heading of the turtle with ID seth-of to heading.

Examples:
seth-of 45 sets the heading of the turtle with who number 2 to 45.

Related Commands:
heading-of seth-at seth-towards setheading
Turtle, Observer, Patch

seth-towards angle distance heading

Parameters:
angle Number
distance Number
heading Number

Description:
seth-towards 0 1 45 sets the heading of the turtle one unit directly in front of the caller to 45.

Related Commands:
heading-towards seth-at seth-of setheading
Turtle

setheading (seth) angle

Parameters:
angle Number

Description:
Turtles set their heading to angle.
angle should be from 0 to 360 degrees, inclusive.

Examples:
seth 0 sets the turtle's heading to the top of the screen.

seth 90 sets the turtle's heading to the right of the screen.

Related Commands:
heading right seth-at seth-of seth-towards
Turtle, Observer, Patch

setitem setitem list newvalue

Parameters:
setitem Integer position in the list
list List list of items
newvalue Anything item to be inserted into the list

Description:
Sets the item at position setitem in list list to newvalue.

Examples:
setitem 2 [1 3 3 4] 5 changes the list to [1 5 3 4].

Related Commands:
item member? position remove remove-element
Patch

setpc (setpatchcolor) color

Parameters:
color Color

Description:
This command is run as a patch command inside an ask-patches statement. The patches being asked will set their color to color. Use stamp if you want to have a turtle change the color of a patch.

Examples:
ask-patches [setpc blue] commands the patches to set their color to blue.

Related Commands:
patchcolor scale-pc setbg stamp
Turtle, Observer, Patch

setpendown?-at xcor ycor boolean

Parameters:
xcor Number
ycor Number
boolean Boolean

Description:
Sets the pendown state of the turtle xcor units in the x direction and $ycor units in the y direction away from the caller to boolean.

Examples:
setpendown?-at 1 1 true sets the pendown state of the turtle one unit to the right and one unit above the caller to true.

Related Commands:
pendown pendown?-at penup
Turtle, Observer, Patch

setpendown?-of number boolean

Parameters:
number Number
boolean Boolean

Description:
Sets the pendown state of the turtle with who number number to boolean.

Examples:
setpendown?-of 2 true sets the pendown state of the turtle with who number 2 to true.

Related Commands:
pendown pendown?-of penup
Turtle, Observer, Patch

setpendown?-towards angle distance boolean

Parameters:
angle Number
distance Number
boolean Number

Description:
Sets the pendown state of a turtle at distance angle away at angle distance of the caller to boolean.

Examples:
setpendown?-towards 0 1 true sets the pendown state of a turtle one unit directly in front of the caller to true.

Related Commands:
pendown penup
Turtle, Observer, Patch

setplot-bar-width width

Parameters:
width Number

Description:
Sets the width of the bars in the histogram plot to width.

Examples:
set-bar-width 2 sets the width of the bars in the historgram to 2.

Notes:
For use only with the histogram plot.


Turtle, Observer, Patch

setplot-title name

Parameters:
name String

Description:
Sets the title of the plot to name.

Examples:
setplot-title "fire" sets the title of the current plot to the name "fire".

Related Commands:
plot-title
Turtle, Observer, Patch

setplot-xlabel label

Parameters:
label String

Description:
Sets the label of the x-axis of the graph to label.

Related Commands:
plot-xlabel setplot-ylabel
Turtle, Observer, Patch

setplot-xmax value

Parameters:
value Number

Description:
Sets the maximum value of the x-axis to be value.

Related Commands:
plot-xmax setplot-xmin setplot-xrange
Turtle, Observer, Patch

setplot-xmin value

Parameters:
value Number

Description:
Sets the minimum value of the x-axis to be value.

Related Commands:
plot-xmin setplot-xmax setplot-xrange
Turtle, Observer, Patch

setplot-xrange min max

Parameters:
min Number the minimum value of the x-axis
max Number the maximum value of the x-axis

Description:
Sets the minimum value of the x-axis to be min and the maximum value of the x-axis to be max.

Related Commands:
plot-xmax plot-xmin setplot-xmax setplot-xmin
Turtle, Observer, Patch

setplot-ylabel label

Parameters:
label String

Description:
Sets the label of the y-axis of the graph to label.

Related Commands:
plot-ylabel setplot-xlabel
Turtle, Observer, Patch

setplot-ymax value

Parameters:
value Number

Description:
Sets the maximum value of the y-axis to be value.

Related Commands:
plot-ymax setplot-ymin setplot-yrange
Turtle, Observer, Patch

setplot-ymin value

Parameters:
value Number

Description:
Sets the minimum value of the y-axis to be value.

Related Commands:
plot-ymin setplot-ymax setplot-yrange
Turtle, Observer, Patch

setplot-yrange min max

Parameters:
min Number
max Number

Description:
Sets the minimum value of the y-axis to be min and the maximum value of the y-axis to be max.

Related Commands:
plot-ymax plot-ymin setplot-ymax setplot-ymin
Turtle, Observer, Patch

setppc color

Parameters:
color Color

Description:
Sets the color of the current plot pen to be color.

Examples:
setppc black sets the current plot pen to black.

Related Commands:
pp ppc
Observer

setrandom-seed seed

Parameters:
seed Integer The new seed

Description:
Sets the random seed to seed. Integers allowed are in the range -(2^31) to (2^31 -1). Don't pick 0.

Examples:
set-random-seed 345612 sets the random-seed to 345612.

Notes:
StarLogo uses the random generator provided by Java, which, as of now, is a linear congruential formula (Knuth Art of Computer Programming, Vol 2, Section 3.2.1.), which uses a 48-bit seed. StarLogo only allows you to set the bottom 32 bits of this seed.

Related Commands:
get-random-seed random random-gaussian
Turtle

setshape shape-name-or-number

Parameters:
shape-name-or-number Number The name or number of the shape

Description:
Turtles set their shape to shape-name-or-number.

Examples:
setshape turtle-shape sets the shape of all of the turtles to the turtle-shape.

if i-got-sick? [setshape sick-shape]. If the turtle has gotten sick, update his visible shape to the sick person shape.

Notes:
Names for shapes can be found and edited in the Shape Chooser window.

Related Commands:
setshape-at setshape-of setshape-towards shape
Turtle, Observer, Patch

setshape-at xcor ycor shape-name-or-number

Parameters:
xcor Number Distance in the x direction
ycor Number Distance in the y direction
shape-name-or-number Number The name or number of the shape

Description:
Turtles xcor units to the right and ycor units up of the caller, set their shape to shape-name-or-number.

Examples:
setshape-at 1 2 person-shape causes the turtle one to the right and two units above the caller to set its shape to person-shape.

Notes:
Names for shapes can be found and edited in the Shape Chooser window.

Related Commands:
setshape setshape-of setshape-towards shape-at
Turtle, Observer, Patch

setshape-of who-number shape-name-or-number

Parameters:
who-number Integer The who id of a turtle
shape-name-or-number Number The name or number of a shape

Description:
Turtle with ID who-number sets its shape to shape-name-or-number.

Examples:
setshape-of one-of-turtles-here turtle-shape sets the shape of one of the turtles on this spot (not including yourself) to the turtle-shape.

Notes:
Names for shapes can be found and edited in the Shape Chooser window.

Related Commands:
setshape setshape-at setshape-towards shape-of
Turtle, Observer, Patch

setshape-towards angle distance shape-name-or-number

Parameters:
angle Number An angle from 0 to 360
distance Number A number of units away
shape-name-or-number Number The name or number of a shape

Description:
The turtle distance units away at angle angle from the caller sets its shape to shape-name-or-number.

Examples:
setshape-towards 0 2 3 causes the turtle two patches directly ahead of the caller to set its shape to shape 3.

Related Commands:
setshape setshape-at setshape-of shape-towards
Turtle, Observer, Patch

setshown?-at xcor ycor value

Parameters:
xcor Number The distance in the x direction
ycor Number The distance in the y direction
value Boolean An expression that returns true or false

Description:
Sets the visibility of the turtle xcor units in the x direction and ycor units in the y direction away from the caller to value.

Examples:
setshown?-at 1 1 true sets the visibility of the turtle one unit to the right and one unit above the caller to true.

Related Commands:
hideturtle shown?-at showturtle
Turtle, Observer, Patch

setshown?-of who-number value

Parameters:
who-number Integer The who id of a turtle
value Boolean An expression that returns true or false

Description:
Sets the visibility of the turtle with ID who-number to value.

Examples:
setshown?-of 2 true sets the visibility of the turtle with ID 2 to true.

Related Commands:
hideturtle shown?-of showturtle
Turtle, Observer, Patch

setshown?-towards angle distance value

Parameters:
angle Number An angle from 0 to 360
distance Number The distance away in steps
value Number An expression that returns true or false

Description:
Sets the visibility of a turtle distance away at an angle of angle from the caller to value.

Examples:
setshown?-towards -25 -25 true sets the visibility of a turtle 25 units to the left and 25 units down from the caller to true.

Related Commands:
hideturtle shown?-towards showturtle
Turtle, Observer, Patch

setslidervar value

Parameters:
value Number The value you want to set the slider to

Description:
Sets the value of a slider variable (named in the command name) to value from within code.

Examples:
setnumber-of-turtles 100 would set the value of the slider number-of-turtles to 100.

Related Commands:
set
Turtle, Observer, Patch

setvariable value

Parameters:
value Anything the value to set the variable to

Description:
Sets the variable to the value specified

Examples:
setheight 5 Sets the height of the caller to 5.

Notes:
variables must first be declared in a turtles-own, breeds-own, patches-own or globals

Related Commands:
set setvariable-at setvariable-of setvariable-towards variable
Turtle, Observer, Patch

setvariable-at xcor ycor value

Parameters:
xcor Number number of steps in the x-direction from the caller
ycor Number number of steps in the y-direction from the caller
value Anything value to set the variable to

Description:
Sets the value of the variable of the turtle xcor units away in the x direction and ycor units away in the y direction to the value value

Examples:
setheight-at 1 1 5 sets the height of the turtle one unit away in the x direction and one unit away in the y direction to 5

Notes:
variables must first be declared in a turtles-own, breeds-own, patches-own or globals

Related Commands:
set setvariable setvariable-of setvariable-towards variable-at
Turtle, Observer, Patch

setvariable-of number value

Parameters:
number Number who of a turtle
value Anything value to set the variable to

Description:
Sets the variable specified of the turtle number to the value value

Examples:
setspots-of 5 10 sets the number of spots of turtle number 5 to 10

Notes:
variables must first be declared in a turtles-own, breeds-own, patches-own or globals

Related Commands:
set setvariable setvariable-at setvariable-towards variable-of
Turtle, Observer, Patch

setvariable-towards angle distance value

Parameters:
angle Number angle from caller
distance Number distance from caller
value Anything value to set the variable to

Description:
Sets the value of the variable specified at distance distance and angle angle from the caller to value

Examples:
sethappiness-towards 0 1 5 sets the happiness of the turtle directly in front of and one space beyond the caller to 5

Notes:
variables must first be declared in a turtles-own, breeds-own, patches-own or globals

Related Commands:
set setvariable setvariable-at setvariable-of variable-towards
Turtle

setxcor (setx) coordinate

Parameters:
coordinate Number A coordinate on the x-axis

Description:
Turtles set their x-coordinate to coordinate.

Examples:
setxcor 2

Related Commands:
setxcor-at setxcor-of setxcor-towards setxy setycor step xcor
Turtle, Observer, Patch

setxcor-at (setx-at) xcor ycor coordinate

Parameters:
xcor Number A horizontal distance
ycor Number A vertical distance
coordinate Number A coordinate on the x-axis

Description:
Sets the x-coordinate of the turtle xcor units in the x direction and ycor units in the y direction away from the caller to coordinate.

Examples:
setxcor-at 1 1 5 sets the x-coodinate of the turtle one unit above and one unit to the right of the caller to 5.

Related Commands:
setxcor setxcor-of setxcor-towards setxy-at setycor-at xcor-at
Turtle, Observer, Patch

setxcor-of (setx-of) who-number x-coordinate

Parameters:
who-number Integer The who id of a turtle
x-coordinate Number A coordinate on the x-axis

Description:
Sets the x-coordinate of the turtle with ID who-number to x-coordinate.

Examples:
setxcor-of 2 5 sets the x-coordinate of turtle 2 to 5.

Related Commands:
setxcor setxcor-at setxcor-towards setxy-of setycor-of xcor-of
Turtle, Observer, Patch

setxcor-towards (setx-towards) angle distance x-coordinate

Parameters:
angle Number An angle from 0 to 360
distance Number A number of units away
x-coordinate Number A coordinate on the x-axis

Description:
Sets the x-coordinate of the turtle distance away at an angle of angle from the caller to x-coordinate.

Examples:
setxcor-towards 0 1 5 sets the x-coordinate of the turtle one unit above the caller to 5.

Related Commands:
setxcor setxcor-at setxcor-of setxy-towards setycor-towards xcor-towards
Turtle

setxy xcor ycor

Parameters:
xcor Number A coordinate on the x-axis
ycor Number A coordinate on the y-axis

Description:
Turtles set their x-coordinate to xcor and their y-coordinate to ycor.

Examples:
setxy 1 2

Related Commands:
home setxcor setxy-at setxy-of setxy-towards setycor step
Turtle, Observer, Patch

setxy-at xcor ycor x-coordinate y-coordinate

Parameters:
xcor Number A distance along the x direction
ycor Number A distance along the y direction
x-coordinate Number A coordinate on the x-axis
y-coordinate Number A coordinate on the y-axis

Description:
Sets the x-coordinate of the turtle xcor units in the x direction and ycor units in the y direction away from the caller to xcor and sets the y-coordinate of the same turtle to ycor.

Examples:
setxy-at 1 1 5 6 sets the x-coordinate of the turtle one unit to the right and one unit above the caller to 5, and it also sets the y-coordinate of the same turtle to 6.

Related Commands:
setxcor-at setxy setxy-of setxy-towards setycor-at
Turtle, Observer, Patch

setxy-of who-number xcor ycor

Parameters:
who-number Number The who id of a turtle
xcor Number A coordinate on the x-axis
ycor Number A coordinate on the y-axis

Description:
Sets the x-coordinate of the turtle with ID who-number to xcor and sets the y-coordinate of the same turtle to ycor.

Examples:
setxy-of 1 2 3 sets the x-coordinate of the turtle with who ID 1 to 2, and it also sets the y-coordinate of the same turtle to 3.

Related Commands:
setxcor-of setxy setxy-at setxy-towards setycor-of
Turtle, Observer, Patch

setxy-towards angle distance number1 number2

Parameters:
angle Number angle from caller
distance Number distance from caller
number1 Number x-coordinate to set
number2 Number y-coordinate to set

Description:
Sets the x-coordinate of the turtle distance away at angle angle from the caller to number1 and sets the y-coordinate of the same turtle to number2.

Examples:
setxy-towards 0 1 4 5 sets the x-coordinate of the turtle one unit directly in front of the caller to 4, and also sets the y-coordinate of the same turtle to 5.

Related Commands:
setxcor-towards setxy setxy-at setxy-of
Turtle

setycor (sety) number

Parameters:
number Number A coordinate on the y-axis

Description:
Turtles set their y-coordinate to number

Examples:
sety 2 will move the turtle so that its y-coordinate is 2 (and leaves the x-coordinate the same)

Related Commands:
setxcor setxy setycor-at setycor-of setycor-towards step ycor
Turtle, Observer, Patch

setycor-at (sety-at) xcor ycor number

Parameters:
xcor Number number of units away in the x direction
ycor Number number of units away in the y direction
number Number the value to set the y-coordinate to

Description:
Sets the y-coordinate of the turtle xcor units in the x direction and ycor units in the y direction away from the caller to number.

Examples:
setycor-at 1 1 5 sets the y-coordinate of the turtle one unit to the right and one unit above the caller to 5.

Related Commands:
setxcor-at setxy-at setycor setycor-of setycor-towards ycor-at
Turtle, Observer, Patch

setycor-of (sety-of) number1 number2

Parameters:
number1 Number who of a turtle
number2 Number y-coordinate to be set

Description:
Sets the y-coordinate of the turtle with who number number1 to number2.

Examples:
setycor-of 2 5 sets the y-coordinate of the turtle with who number 2 to 5.

Related Commands:
setxcor-of setxy-of setycor setycor-at setycor-towards ycor-of
Turtle, Observer, Patch

setycor-towards (sety-towards) angle distance number

Parameters:
angle Number angle from caller
distance Number distance from caller
number Number y-coordinate that will be set

Description:
Sets the y-coordinate of the turtle distance away at angle angle from the caller to number.

Examples:
setycor-towards 0 1 5 sets the y-coordinate of the turtle one unit above and one unit to the right of the caller to 5.

Related Commands:
setxcor-towards setycor setycor-at setycor-of ycor-towards
Turtle, Patch

shape

Description:
Returns the shape number a turtle is set to. If a patch calls this, it returns the shape number of a turtle on that patch.

Examples:
setshape turtle-shape sets the turtles shape to the one named turtle-shape

if shape = turtle-shape [fd 1] has all of the turtles with shape turtle-shape move forward one step

Notes:
Default shape is turtle-shape.

Related Commands:
setshape shape-at shape-of shape-towards who
Turtle, Observer, Patch

shape-at xcor ycor

Parameters:
xcor Number number of units away in the x direction
ycor Number number of units away in the y direction

Description:
Returns the shape of the turtle xcor units to the right and ycor units above the caller.

Examples:
shape-at 0 1 returns the shape of the turtle one unit above the caller.

Related Commands:
setshape-at shape shape-of shape-towards
Turtle, Observer, Patch

shape-of number

Parameters:
number Integer Who number

Description:
Reports the shape of the turtle with who number number.

Examples:
show shape-of 34 prints the shape of turtle 34 to the command center.

Related Commands:
setshape-of shape shape-at shape-towards
Turtle, Observer, Patch

shape-towards angle distance

Parameters:
angle Number angle from the caller
distance Number distance from the caller

Description:
Returns the shape of the turtle distance patches away at heading angle from the caller.

Examples:
shape-towards 0 1 returns the shape of the turtle one unit directly in front of the caller.

Related Commands:
setshape-towards shape shape-at shape-of
Turtle, Observer, Patch

show anything

Parameters:
anything Anything

Description:
Prints anything in the command center that calls show.

Related Commands:
print print-status type
Turtle

shown?

Description:
Returns true if the turtle is currently visible, otherwise false.

Examples:
if shown? [fd 1] makes all visible turtles move forward 1 step.

Related Commands:
hideturtle shown?-at shown?-of shown?-towards showturtle
Turtle, Observer, Patch

shown?-at xcor ycor

Parameters:
xcor Number number of steps in the x-direction from the caller
ycor Number number of steps in the y-direction from the caller

Description:
Reports whether the turtle xcor units in the x direction and ycor units in the y direction away from the caller is visible.

Examples:
shown?-at 1 1 reports whether the turtle one unit to the right and one unit above the caller is visible.

Related Commands:
hideturtle setshown?-at shown? shown?-of shown?-towards showturtle
Turtle, Observer, Patch

shown?-of number

Parameters:
number Number who of a turtle

Description:
Reports whether the turtle with who number number is visible.

Examples:
shown?-of 2 reports whether the turtle with who number 2 is visible.

Related Commands:
hideturtle setshown?-of shown? shown?-at shown?-towards showturtle
Turtle, Observer, Patch

shown?-towards angle distance

Parameters:
angle Number angle from the caller
distance Number distance from the caller

Description:
Reports whether the turtle distance away at an angle of angle from the caller is visible.

Examples:
shown?-towards 0 1 reports whether the turtle one unit directly in front of the caller is visible.

Related Commands:
hideturtle setshown?-towards shown? shown?-at shown?-of showturtle
Turtle

showturtle (show-turtle) (st)

Description:
Hidden turtles make themselves visible.

Examples:
if pc-ahead = blue [st] commands the caller to make itself visible if the patch ahead of it is blue.

Related Commands:
hideturtle setshown?-at setshown?-of setshown?-towards shown? shown?-at shown?-of shown?-towards
Turtle, Observer, Patch

sin number

Parameters:
number Number angle

Description:
Trigonometry function. Returns the sine of the specified angle. All angles are in degrees.

Examples:
sin 30 returns .5.

Related Commands:
acos asin atan cos tan
Turtle, Observer, Patch

sky

Description:
sky reports 95, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green lime magenta orange pink purple red turquoise white yellow
Turtle, Observer, Patch

sort-num-list list-of-data

Parameters:
list-of-data List or string

Description:
Returns the list list-of-data sorted in increasing order. All elements of the list must be numbers.

Examples:
sort-num-list [3 1 2] returns [1 2 3]

Related Commands:
max-of-list min-of-list mode-of-list sdev-of-list sort-num-list sum-of-list variance-of-list
Patch

sprout [list of commands]

Parameters:
[list of commands] List of commands commands to be executed by new turtles

Description:
Each patch creates a turtle, which then executes [list of commands].

Examples:
ask-patches [sprout [setc green fd 1]] asks each patch to create a turtle, which sets its color to green and moves forward 1 unit.

Related Commands:
create-turtles create-turtles-and-do hatch
Turtle, Observer, Patch

sqrt number

Parameters:
number Number

Description:
Finds the square root of number.

Examples:
sqrt 16 returns 4


Turtle

stamp color

Parameters:
color Number

Description:
Sets color of patch under turtle to color

Examples:
stamp red sets the patch under the turtle to red

stamp 0 sets the patch under the turtle to color 0 (black)

stamp color sets the patch under the turtle to the color of the turtle

Related Commands:
patchcolor pstamp setpc stamp-at stamp-towards
Turtle, Observer, Patch

stamp-at xcor ycor color

Parameters:
xcor Number number of patches away in the x direction
ycor Number number of patches away in the y direction
color Number color to set

Description:
Sets the color of the patch at xcor ycor relative to the caller to color.

Examples:
stamp-at 1 1 0 sets the color of the patch one unit to the right and one unit above the caller to black (color 0).

Related Commands:
pc-at pstamp-at stamp stamp-towards
Turtle, Observer, Patch

stamp-towards angle distance color

Parameters:
angle Number angle from the caller
distance Number distance from the caller
color Number color to set

Description:
Sets the color of the patch distance away at an angle angle from the caller to color.

Examples:
stamp-towards 0 1 0 sets the color of the patch one unit directly in front of the caller to black (color 0).

Related Commands:
pc-towards pstamp-towards stamp stamp-at
Observer

startbuttonname

Description:
Starts the button of name buttonname

Examples:
startgo will start the button named go

Related Commands:
stopbuttonname
Observer

startup

Description:
This is a special procedure name. Anything within the startup procedure will be executed each time the project is opened.

Examples:
to startup
clear-turtles ;save the patches
crt 100
ask-turtles [setc blue]
end

This process of clearing the turtles, and creating 100 new blue ones will occur everytime the project is opened.

Related Commands:
end to
Turtle

step

Description:
A synonym for fd 1.

Examples:
if pc-ahead = blue [step] commands the caller to move forward 1 unit if the patch ahead of it is blue.

Related Commands:
forward jump leap setxcor setxy setycor
Turtle, Observer, Patch

stop

Description:
Exits the current procedure immediately.

Examples:
to check-patch-color
if pc-ahead = red [rt 90 stop]
if pc-ahead = green [lt 90 stop]
fd 1
end

This procedure will cause turtles to turn right and then exit the procedure if the the patch ahead is red, turn left and exit the procedure if the patch ahead is green, and only move forward one if the patch ahead was not green or red.

Notes:
Note: stop does not stop any callers of the procedure, only the procedure itself.

Related Commands:
end loop output to
Turtle, Observer, Patch

stopall

Description:
Tells everything to stop running, including procedures, buttons, monitors, and command centers.

Related Commands:
stopbuttonname
Observer

stopbuttonname

Description:
Stops the button of name buttonname

Examples:
stopgo will stop the button named go

Related Commands:
startbuttonname stopall
Turtle, Observer, Patch

sublist list begin end

Parameters:
list List List that you want to subset
begin Integer The beginning index that you want to keep
end Integer The ending index that you want to keep

Description:
Return a new list that is a subset of the original list. The new list will be end - begin + 1 elements long, and will contain the elements of list from and including begin up to end.

Examples:
sublist [1 2 3 4 5] 2 4 returns [2 3 4].

sublist [1 2 3 4 5] 0 0 returns [1].

sublist [1 2 3 4 5] 4 5 returns [4 5].

Related Commands:
list sentence to-list
Turtle, Observer, Patch

sum-of-breed [list-of-commands]

Parameters:
[list-of-commands] List of commands list of commands that return a number

Description:
Reports the sum of [list-of-commands] for all the turtles of the breed specified.

Examples:
sum-of-frogs [weight] returns the sum of all the frogs' weights.

sum-of-cars [speed] returns the sum of all the cars' weights.

Notes:
When a turtle calls the command, it is not included as part of the calculation.

Related Commands:
average-of-breed max-of-breed median-of-breed min-of-breed mode-of-breed sdev-of-breed sum-of-breed-with sum-of-turtles variance-of-breed
Turtle, Observer, Patch

sum-of-breed-with [condition] [list-of-commands]

Parameters:
[condition] List of commands list of commands that evalutes to true or false
[list-of-commands] List of commands list of commands that return a number

Description:
Reports the total value of [list-of-commands] when run over the turtles of the breed specified that satisfy [condition]. If there are no turtles of the specified breedin which [list-of-commands] is true, 0 is returned.

Notes:
Note: This command can
also be executed by patches, for example within an ask-patches statement.

Related Commands:
average-of-breed-with max-of-breed-with median-of-breed-with min-of-breed-with mode-of-breed-with sdev-of-breed-with sum-of-breed sum-of-turtles-with variance-of-breed-with
Turtle, Observer, Patch

sum-of-list list

Parameters:
list List List of numbers

Description:
Returns the sum of the numbers in the list.

Examples:
sum-of-list [1 2 -3 4.5 5] returns 9.5.

Notes:
Note: If list contains no numbers, an error occurs. If some of the list, when evaluated, are not numbers, those values are ignored.

Related Commands:
average-of-list max-of-list median-of-list min-of-list mode-of-list sdev-of-list sort-num-list variance-of-list
Turtle, Observer, Patch

sum-of-patches [list-of-commands]

Parameters:
[list-of-commands] List of commands list of commands that return a number

Description:
Reports the sum of [list-of-commands] for every patch.

Examples:
show sum-of-patches [food] prints the total amount of food in the world.

Related Commands:
average-of-patches max-of-patches median-of-patches min-of-patches mode-of-patches sdev-of-patches sum-of-patches-with variance-of-patches
Turtle, Observer, Patch

sum-of-patches-with [condition] [list-of-commands]

Parameters:
[condition] List of commands list of commands that evaluates to either true or false
[list-of-commands] List of commands list of commands that returns a number

Description:
Reports the total value of [list-of-commands] when run over the turtles that satisfy [condition]. If there are no patches in which [condition] is true, it reports 0.

Examples:
sum-of-patches-with [pc = green or pc = blue] [density] returns the sum of the densities of all patches which are blue or green.

Notes:
This command can also be executed by patches, for example within an ask-patches statement.

Related Commands:
average-of-patches-with max-of-patches-with median-of-patches-with min-of-patches-with mode-of-patches-with sdev-of-patches-with sum-of-patches variance-of-patches-with
Turtle, Observer, Patch

sum-of-turtles [list-of-commands]

Parameters:
[list-of-commands] List of commands list of commands which evaluate to a number

Description:
Reports the sum of [list-of-commands] for every turtle.

Examples:
show sum-of-turtles [weight * weight] prints the sum of every turtle's weight squared.

Notes:
When a turtle calls the command, it is not included as part of the calculation.

Related Commands:
average-of-turtles max-of-turtles median-of-turtles min-of-turtles mode-of-turtles sdev-of-turtles sum-of-breed sum-of-turtles-with variance-of-turtles
Turtle, Observer, Patch

sum-of-turtles-with [condition] [list-of-commands]

Parameters:
[condition] List of commands list of commands which returns either true or false
[list-of-commands] List of commands list of commands which returns a number

Description:
Reports the total value of [list-of-commands] when run over the turtles that satisfy [condition]. If there are no turtles in which the [condition] is true, returns 0.

Examples:
sum-of-turtles-with [color = red] [age] returns the sum of the ages of all the red turtles.

Notes:
This command can also be executed by patches, for example within an ask-patches statement.

Related Commands:
average-of-turtles-with max-of-turtles-with median-of-turtles-with min-of-turtles-with mode-of-turtles-with sdev-of-turtles-with sum-of-breed-with sum-of-turtles variance-of-turtles-with
Observer

switch-scheduler

Description:
Toggles back and forth between fixed order scheduling and randomized scheduling.

Related Commands:
get-scheduler-random-seed scheduler set-scheduler-random-seed
Turtle, Observer, Patch

tan angle

Parameters:
angle Number Angle in degrees

Description:
Trigonometric function. Returns the tangent of the specified angle. All angles are in degrees.

Examples:
tan 45 returns 1

Related Commands:
acos asin atan cos sin
Turtle, Observer, Patch

timer

Description:
Reports the current value of the timer in seconds (since the last call to reset-timer).

Each thread of execution has its own timer. A thread of execution is started for each turtle when a turtle button is pressed, or code is entered in the turtle command center. A thread of execution is started for the observer if an observer button is pressed, or code is entered in the observer command center. When turtles, patches or observer are asked to do something (e.g. using ask-turtles, ask-patches or ask-observer), a new timer is created and used for that list-to-run.

Examples:
If you want to time how long it takes for a turtle to move 1000 steps, do this: reset-timer fd 1000 show timer.

Related Commands:
reset-timer
Turtle, Observer

to procedure-name

Parameters:
procedure-name Anything A single word which is the name of the procedure you wish to define

Description:
When you create a procedure, the first line of it must be to procedure-name where procedure-name is a one-word title for your procedure. procedure-name cannot be any command already recognized by StarLogo (this includes both built-in commands and the procedure names of other procedures you may already have written).

To add parameters to a procedure, write them after the procedure-name with a colon in front of them, like this:
to my-procedure :x :y :z

Inside the procedure body, you may use :x, :y and :z to refer to the values of the arguments passed in by the caller of the procedure.

All procedures must be ended with the word end on a line by itself (no comments may be on that line).

Procedures defined in the turtle procedures pane are only callable by turtles. Procedures defined in the observer procedures pane are only callable by the observer. Patches may not have procedures.

Examples:
to go
fd 1
rt 90
end

Now you may use go as a command in other parts of your program.

Related Commands:
end output startup stop
Turtle, Observer, Patch

to-delimited-string [list of commands]

Parameters:
[list of commands] List of commands

Description:
Takes a list of instructions (variables, reporters, strings) and separates them with commas and then concatenates them, returning the concatenated string.

Notes:
This function is helpful in outputting to a spreadsheet program.

Related Commands:
to-list to-string
Turtle, Observer, Patch

to-list [list of commands]

Parameters:
[list of commands] List of commands Commands to execute whose return values will form the list

Description:
Runs then commands in [list of commands] and makes a new list from each command's return value.

Examples:
globals [foo]

set foo 45
to-list [1 2 + 4 foo] returns the list [1 6 45].

Related Commands:
list make-list pick sentence sublist to-delimited-string to-string
Turtle, Observer, Patch

to-string [list of commands]

Parameters:
[list of commands] List of commands Commands to execute whose return values will form the string

Description:
Takes a list of instructions (variables, reporters, strings), executes them, and concatenates their return values, returning the concatenated string.

Related Commands:
to-delimited-string to-list
Turtle, Observer, Patch

towards xcor ycor

Parameters:
xcor Number X coordinate on the screen
ycor Number Y coordinate on the screen

Description:
Returns the angle from the caller's xcor and ycor to the specified absolute position specified by xcor and ycor.

Examples:
towards 1 1 returns 45 when run by a turtle at (0, 0).

towards 1000 1000 returns 225 when run by a turtle at (0, 0) and the screen-width and screen-height are both 101.

Notes:
The observer is considered to be located at (0, 0).

The StarLogo world wraps, so if you want to know the angle to an xcor and ycor that are off the screen, they will be modded by screen-width and screen-height until they point to a position within the screen and that angle returned. Thus if you want to see the direction towards (1000, 1000) it might just be off to the lower left of you instead of the upper right.

Related Commands:
distance distance-nowrap towards-nowrap
Turtle, Observer, Patch

towards-nowrap xcor ycor

Parameters:
xcor Number X coordinate on the screen
ycor Number Y coordinate on the screen

Description:
Returns the angle from the caller's xcor and ycor to the specified absolute position specified by xcor and ycor (without wrapping).

Examples:
towards-nowrap 1 1 returns 45 when run by a turtle at (0, 0).

towards-nowrap 1000 1000 returns 45 when run by a turtle at (0, 0).

Related Commands:
distance distance-nowrap towards
Turtle, Observer, Patch

turquoise

Description:
turquoise reports 75, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green lime magenta orange pink purple red sky white yellow
Turtle

turtles-own [list of variables]

Parameters:
[list of variables] List A list of variable names to define as turtle variables

Description:
Defines a set of variables to be properties of turtles. The [list of variables] contains one or more names. This line of code should be placed at the top of the Turtle Command Center. It does not go inside procedures.


A variable name may be followed by a list of state values. This variable may only have the values listed in the state value list. This can be used to assign named constants to a variable instead of using numbers.

Examples:
turtles-own [size energy]

turtles-own [weather [sunny cloudy rainy]]

set weather rainy
set weather cloudy
if weather = sunny [ setcolor yellow ]

Notes:
turtles-own declarations should appear outside of any procedure, usually at the top of the turtle procedures pane.

turtles-own declarations can contain more than one variable. If you have more than one turtles-own, consider consolidating them into a single turtles-own.

Related Commands:
breeds globals patches-own
Turtle, Observer, Patch

type expression

Parameters:
expression Anything The value you want to print

Description:
Prints expression in the output window. No carriage return to the next line is printed.

Related Commands:
print print-status show
Turtle, Observer, Patch

variable

Description:
Returns the value of the variable specified

Examples:
height returns the value of the variable named height

Notes:
variables must first be declared in a turtles-own, breeds-own, patches-own or globals

Related Commands:
set setvariable variable-at variable-of variable-towards
Turtle, Observer, Patch

variable-at xcor ycor

Parameters:
xcor Number number of steps in the x-direction from the caller
ycor Number number of steps in the y-direction from the caller

Description:
Returns the value of the variable specified at a distance of xcor in the x direction and ycor in the y direction from the caller

Examples:
size-at 1 1 returns the size of the turtle one patch away in the x direction and y patch away in the y direction

Notes:
variables must first be declared in a turtles-own, breeds-own, patches-own or globals

Related Commands:
setvariable-at variable variable-of variable-towards
Turtle, Observer, Patch

variable-of number1

Parameters:
number1 Number turtle who number

Description:
Returns the value of the variable specified for the turtle with who number number1

Examples:
height-of 0 returns the height of turtle number 0

Notes:
variables must first be declared in a turtles-own, breeds-own, patches-own or globals

Related Commands:
setvariable-of variable variable-at variable-towards
Turtle, Observer, Patch

variable-towards angle distance

Parameters:
angle Number angle from caller
distance Number distance from caller

Description:
Returns the value of the variable specified at an angle of angle and distance of distance away from the caller

Examples:
happiness-towards 0 1 returns the happiness of the turtle directly in front of and one space beyond the caller

Notes:
variables must first be declared in a turtles-own, breeds-own, patches-own or globals

Related Commands:
setvariable-towards variable variable-at variable-of
Turtle, Observer, Patch

variance-of-breed [list of commands]

Parameters:
[list of commands] List of turtle commands A list of commands for the frogs to run which returns a number

Description:
Returns the numerical variance of the [list of commands] when evaluated across all the turtles of breed frogs.

Examples:
variance-of-frogs [speed] returns the variance of the speeds of all the turtles of breed frogs.

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it, itself, is not included as part of the calculation.

Related Commands:
average-of-breed max-of-breed median-of-breed min-of-breed mode-of-breed sdev-of-breed sum-of-breed variance-of-breed-with variance-of-turtles
Turtle, Observer, Patch

variance-of-breed-with [condition] [list of commands]

Parameters:
[condition] List of turtle commands An expression that returns a true or false value
[list of commands] List of turtle commands A list of commands for the turtles to run which returns a number

Description:
Returns the numerical variance of the [list of commands] when evaluated across all the turtles of breed frogs that satisfy the condition (must return a boolean of true or false) specified by the [condition].

Examples:
variance-of-frogs-with [color = red] [speed] returns the variance of the speeds of all the red turtles of breed frogs.

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it, itself, is not included as part of the calculation.

Related Commands:
average-of-breed-with max-of-breed-with median-of-breed-with min-of-breed-with mode-of-breed-with sdev-of-breed-with sum-of-breed-with variance-of-breed variance-of-turtles-with
Turtle, Observer, Patch

variance-of-list [list of values]

Parameters:
[list of values] Number List of values to average

Description:
Returns the numerical variance of values in the given list.

Examples:
variance-of-list [1 3 5] returns 2.666.

Notes:
If [list of values] contains no numbers, an error occurs. If some of the [list of values] are not numbers, those values are ignored.

Related Commands:
average-of-list max-of-list median-of-list min-of-list mode-of-list sdev-of-list sort-num-list sum-of-list
Turtle, Observer, Patch

variance-of-patches [list of commands]

Parameters:
[list of commands] List of patch commands A list of commands for the patches to run which returns a number

Description:
Returns the numerical variance of the [list of commands] when evaluated across all the patches.

Examples:
variance-of-patches [pc] returns the variance of the patch color of all of the patches.

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

Related Commands:
average-of-patches max-of-patches median-of-patches median-of-patches-with min-of-patches mode-of-patches sdev-of-patches sum-of-patches variance-of-patches-with
Turtle, Observer, Patch

variance-of-patches-with [condition] [list of commands]

Parameters:
[condition] List of patch commands An expression that returns a true or false value
[list of commands] List of patch commands A list of commands for the patches to run which returns a number

Description:
Returns the numerical variance of the [list of commands] when evaluated across all the patches that satisfy the condition (must return a boolean of true or false) specified by the [condition].

Examples:
variance-of-patches-with [color = red] [food] returns the variance of food of all the red patches.

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

Related Commands:
average-of-patches-with max-of-patches-with median-of-patches-with min-of-patches-with mode-of-patches-with sdev-of-patches-with sum-of-patches-with variance-of-patches
Turtle, Observer, Patch

variance-of-turtles [list of commands]

Parameters:
[list of commands] List of turtle commands A list of commands for the turtles to run which returns a number

Description:
Returns the numerical variance of the [list of commands] when evaluated across all the turtles.

Examples:
variance-of-turtles [speed] returns the variance of the speeds of all the turtles.

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it, itself, is not included as part of the calculation.

Related Commands:
average-of-turtles max-of-turtles median-of-turtles min-of-turtles mode-of-turtles sdev-of-turtles sum-of-turtles variance-of-breed variance-of-turtles-with
Turtle, Observer, Patch

variance-of-turtles-with [condition] [list of commands]

Parameters:
[condition] List of turtle commands An expression that returns a true or false value
[list of commands] List of turtle commands A list of commands for the turtles to run which returns a number

Description:
Returns the numerical variance of the [list of commands] when evaluated across all the turtles that satisfy the conditions (must return a boolean of true or false) specified by the [condition].

Examples:
variance-of-turtles-with [color = red] [energy] returns the variance of the energy of all the red turtles.

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it, itself, is not included as part of the calculation

Related Commands:
average-of-turtles-with max-of-turtles-with median-of-turtles-with min-of-turtles-with mode-of-turtles-with sdev-of-turtles-with sum-of-turtles-with variance-of-breed-with variance-of-turtles
Turtle, Observer, Patch

view-plot

Description:
Opens the plot window for the currently selected plot.

Related Commands:
plot plotid
Turtle, Observer, Patch

wait seconds

Parameters:
seconds Number A number of seconds. Decimals are allowed.

Description:
Caller waits seconds seconds before continuing.

This command is per-thread - meaning if you have two buttons that each call wait, they will not wait for one another.

Examples:
to crawl
fd 1
wait 2.1
end

crawl

The turtles go forward 1 step and then wait for 2.1 seconds.

Related Commands:
wait-until
Turtle, Observer, Patch

wait-until [condition]

Parameters:
[condition] List of commands A predicate that is run over and over again until it is true.

Description:
The caller waits until the [condition] is true. This command is used to make a button or procedure stop until some other event in your model occurs.

Examples:
wait-until [game-over = true] makes the caller wait until the game is over.

Related Commands:
wait
Turtle, Observer, Patch

white

Description:
white reports 9, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green lime magenta orange pink purple red sky turquoise yellow
Turtle

who

Description:
Returns the who number (ID number) of the turtle.

Examples:
if who = 1 [fd 1] commands all turtles to check if they're turtle 1, and if so, move forward 1 step.

Related Commands:
breed color heading shape xcor ycor
Turtle, Observer, Patch

who-max-of-breed [list of commands]

Parameters:
[list of commands] List of turtle commands A list of commands for the frogs to run which returns a number

Description:
Returns a list of two elements: the turtle ID with the maximum value of the [list of commands] when evaluated across all the turtles of breed frogs, and that maximum value.

Examples:
who-max-of-frogs [energy] returns a list with the who number of the frog with the most energy and the highest energy value: [2 5].

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it, itself, is not included as part of the calculation.

Related Commands:
who-max-of-breed-with who-max-of-turtles who-min-of-breed
Turtle, Observer, Patch

who-max-of-breed-with [condition] [list of commands]

Parameters:
[condition] List of turtle commands An expression that returns a true or false value
[list of commands] List of turtle commands A list of commands for the turtles to run which returns a number

Description:
Returns a list of the turtle with the maximum value of [list of commands] when evaluated across all the turtles of breed frogs that satisfy the condition (must return a boolean of true or false) specified by the [condition]., and the maximum value.

Examples:
who-max-of-frogs-with [color = red] [energy] returns a list with the who number of the red frog with the most energy and the highest energy value: [2 5].

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

If no turtles satisfy [condition], who-max-of-frogs-with returns [nobody minnum].

When a turtle calls the command, it, itself, is not included as part of the calculation.

Related Commands:
who-max-of-breed who-max-of-turtles-with who-min-of-breed-with
Turtle, Observer, Patch

who-max-of-turtles [list of commands]

Parameters:
[list of commands] List of turtle commands A list of commands for the turtles to run which returns a number

Description:
Returns a list of two elements: the turtle ID with the maximum value of the [list of commands] when evaluated across all the turtles, and that maximum value.

Examples:
who-max-of-turtles [energy] returns a list with the who number of the turtle with the most energy and the highest energy value: [2 5].

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it, itself, is not included as part of the calculation.

Related Commands:
who-max-of-breed who-max-of-turtles-with who-min-of-turtles
Turtle, Observer, Patch

who-max-of-turtles-with [condition] [list of commands]

Parameters:
[condition] List of turtle commands An expression that returns a true or false value
[list of commands] List of turtle commands A list of commands for the turtles to run which returns a number

Description:
Returns a list of the turtle with the maximum value of [list of commands] when evaluated across all the turtles that satisfy the condition (must return a boolean of true or false) specified by the [condition], and the maximum value.

Examples:
who-max-of-turtles-with [color = red] [energy] returns a list with the who number of the red turtle with the most energy and the highest energy value: [2 5].

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

If no turtles satisfy [condition], who-max-of-turtles-with returns [nobody minnum].

When a turtle calls the command, it, itself, is not included as part of the calculation.

Related Commands:
who-max-of-breed-with who-max-of-turtles who-min-of-turtles-with
Turtle, Observer, Patch

who-min-of-breed [list of commands]

Parameters:
[list of commands] List of turtle commands A list of commands for the turtles to run which returns a number

Description:
Returns a list of two elements: the turtle ID with the minimum value of the [list of commands] when evaluated across all the turtles of breed frogs, and that minimum value

Examples:
who-min-of-frogs [energy] returns a list with the who number of the frog with the least energy and the smallest energy value: [34 0.4].

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it, itself, is not included as part of the calculation.

Related Commands:
who-max-of-breed who-min-of-breed-with who-min-of-turtles
Turtle, Observer, Patch

who-min-of-breed-with [condition] [list of commands]

Parameters:
[condition] List of turtle commands An expression that returns a true or false value
[list of commands] List of turtle commands A list of commands for the turtles to run which returns a number

Description:
Returns a list of the turtle with the minimum value of [list of commands] when evaluated across all the turtles of breed frogs that satisfy the condition (must return a boolean of true or false) specified by the [condition]., and the minimum value.

Examples:
who-min-of-frogs-with [color = red] [energy] returns a list with the who number of the red frog with the least energy and the smallest energy value: [34 0.4].

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

If no turtles satisfy [condition], who-min-of-frogs-with returns [nobody maxnum].

When a turtle calls the command, it, itself, is not included as part of the calculation.

Related Commands:
who-max-of-breed-with who-min-of-breed
Turtle, Observer, Patch

who-min-of-turtles [list of commands]

Parameters:
[list of commands] List of turtle commands A list of commands for the turtles to run which returns a number

Description:
Returns a list of two elements: the turtle ID with the minimum value of the [list of commands] when evaluated across all the turtles, and that minimum value.

Examples:
who-min-of-turtles [energy] returns a list with the who number of the turtle with the least energy and the smallest energy value: [34 0.4].

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

When a turtle calls the command, it, itself, is not included as part of the calculation.

Related Commands:
who-max-of-turtles who-min-of-breed who-min-of-turtles-with
Turtle, Observer, Patch

who-min-of-turtles-with [condition] [list of commands]

Parameters:
[condition] List of turtle commands An expression that returns a true or false value
[list of commands] List of turtle commands A list of commands for the turtles to run which returns a number

Description:
Returns a list of the turtle with the minimum value of [list of commands] when evaluated across all the turtles that satisfy the condition (must return a boolean of true or false) specified by the [condition], and the minimum value.

Examples:
who-min-of-turtles-with [color = red] [energy] returns a list with the who number of the red turtle with the least energy and the smallest energy value: [34 0.4].

Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.

If no turtles satisfy [condition], who-min-of-turtles-with returns [nobody maxnum].

When a turtle calls the command, it, itself, is not included as part of the calculation.

Related Commands:
who-max-of-turtles-with who-min-of-turtles
Turtle, Observer, Patch

word? thing

Parameters:
thing Anything Any value

Description:
Returns true if thing is a word or string.

Examples:
word? 2 returns true

word? [1 2 3] returns false

Notes:
See the Data Types documentation for what constitutes a word or string.

Related Commands:
list? number?
Turtle, Patch

xcor

Description:
Returns the x-coordinate of the turtle or patch.

Examples:
if xcor = 2 [setc red] commands the turtle to set its color to red of its x-coordinate is equal to 2.

Related Commands:
setxcor who xcor-at xcor-of xcor-towards ycor
Turtle, Observer, Patch

xcor-at xcor ycor

Parameters:
xcor Number units in the x direction away from the caller
ycor Number units in the y direction away from the caller

Description:
Reports the x-coordinate of the turtle xcor units in the x direction and ycor units in the y direction away from the caller.

Examples:
xcor-at 1 1 reports the x-coordinate of the turtle one unit to the right and one unit above the caller.

Related Commands:
setxcor-at xcor xcor-of xcor-towards ycor-at
Turtle, Observer, Patch

xcor-of number

Parameters:
number Number who number

Description:
Reports the x-coordinate of the turtle with who number number.

Examples:
xcor-of 3 returns the x-coordinate of the turtle with who number 3.

Related Commands:
setxcor-of xcor xcor-at xcor-towards ycor-of
Turtle, Observer, Patch

xcor-towards angle distance

Parameters:
angle Number angle away from caller
distance Number distance away from caller

Description:
Reports the x-coordinate of the turtle distance away at angle angle from the caller.

Related Commands:
setxcor-towards xcor xcor-at xcor-of ycor-towards
Turtle, Observer, Patch

condition1 xor condition2

Parameters:
condition1 Number first condition
condition2 Number second condition

Description:
Reports the value of condition1 xor condition2

Examples:
(energy = 5) xor (size = 4) returns true if the turtle's energy is 5 or if the turtles size is 4, but not if both are true or neither are true.

Related Commands:
and not or
Turtle, Patch

ycor

Description:
Returns the y-coordinate of the turtle or patch.

Examples:
if ycor = 2 [setc red] commands the turtle to set its color to red of its y-coordinate is equal to 2.

Related Commands:
setycor who xcor ycor-at ycor-of ycor-towards
Turtle, Observer, Patch

ycor-at xcor ycor

Parameters:
xcor Number units away from caller in the x direction
ycor Number units away from caller in the y direction

Description:
Reports the y-coordinate of the turtle xcor units in the x direction and ycor units in the y direction away from the caller.

Examples:
ycor-at 1 1 reports the y-coordinate of the turtle one unit to the right and one unit above the caller.

Related Commands:
setycor-at xcor-at ycor ycor-of ycor-towards
Turtle, Observer, Patch

ycor-of number

Parameters:
number Integer Who number

Description:
Reports the y-coordinate of the turtle with who number number.

Examples:
ycor-of 3 returns the y-coordinate of the turtle with who number 3.

Related Commands:
setycor-of xcor-of ycor ycor-at ycor-towards
Turtle, Observer, Patch

ycor-towards angle distance

Parameters:
angle Number angle away from caller
distance Number distance away from caller

Description:
Reports the y-coordinate of the turtle distance away at angle angle from the caller.

Examples:
ycor-towards 0 1 reports the y-coordinate of the turtle one unit directly in front of the caller.

Related Commands:
setycor-towards xcor-towards ycor ycor-at ycor-of
Turtle, Observer, Patch

yellow

Description:
yellow reports 45, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green lime magenta orange pink purple red sky turquoise white