Command List

These are all the commands that affect properties of a turtle. A turtle has several built-in properties: xcor, ycor, color, heading, shape, breed, who, pen position (up or down) and whether or not the turtle is visible. Additional properties may be declared by you, with the turtles-own command.

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?
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-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

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-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, 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
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.

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

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-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

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
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

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

forward (fd) number

Parameters:
number Number Turtle moves $arg1 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

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

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
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

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

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 beggining 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

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 list-of-turtles-at-with
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-breed-towards-with 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-at-with 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 list-of-turtles-towards-with
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

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-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

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-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

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-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

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-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

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-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

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

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
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

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, 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, 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-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

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

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

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

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

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

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
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

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

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-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
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

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

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-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

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, 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, 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