Command List

These are some of the most commonly used commands in Starlogo.

Turtle, Observer, Patch

condition1 and condition2

Parameters:
condition1 Boolean
condition2 Boolean

Description:
Reports true if condition1 and condition2 report true.

Related Commands:
not or xor
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-patches [list of commands]

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

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

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

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

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

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

back (bk) steps

Parameters:
steps Number Number of turtle steps to move

Description:
Turtles move $steps$ backward.

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

Related Commands:
forward left right
Turtle, Observer, Patch

black

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

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

blue

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

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

breed

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

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

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

brown

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

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

clear-graphics (cg)

Description:
Sets all patches to black.

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

die

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

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

Related Commands:
kill
Observer

diffuse variable percentage

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

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

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

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

Related Commands:
diffuse4 nsum nsum4
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

end

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

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

Related Commands:
output startup stop to
Turtle

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

globals [variable-list]

Parameters:
[variable-list] List

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

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

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

grab number [list of commands]

Parameters:
number Number
[list of commands] List

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

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

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

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

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

gray (grey)

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

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

green

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

Related Commands:
black blue brown cyan gray green lime magenta orange pink purple red sky turquoise white yellow
Turtle, 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

if condition [list of commands]

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

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

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

Related Commands:
ifelse
Turtle, Observer, Patch

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

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

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

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

Related Commands:
if
Turtle

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

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

not condition1

Parameters:
condition1 Boolean

Description:
Reports true if condition1 reports false.

Related Commands:
and or xor
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, 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, 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, Observer, Patch

one-of-turtles-with [condition]

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

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

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

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

condition1 or condition2

Parameters:
condition1 Boolean
condition2 Boolean

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

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

Related Commands:
and not xor
Turtle, Observer, Patch

orange

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

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

output something

Parameters:
something Anything the value to be returned

Description:
Exits the current procedure and returns something.

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

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

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

patchcolor (pc)

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

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

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

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

patches-own [variable-list]

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

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

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

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

Related Commands:
breeds globals turtles-own
Turtle

pc-ahead-one-patch

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

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

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

Related Commands:
patchcolor pc-ahead
Turtle

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

penup (pu)

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

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

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

plot y-value

Parameters:
y-value Number

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

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

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

purple

Description:
violet reports 115, the number of its particular hue in the color table.

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

random number

Parameters:
number Number upper-limit of range of random numbers to generate

Description:
Reports a random number between 0 and number, including 0 but not number, based on a uniform distribution.

Examples:
random 2 reports either 0 or 1, each with fifty percent probability.

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

Related Commands:
pick random-gaussian set-random-seed setrandom-seed
Turtle, Observer, Patch

red

Description:
red reports 15, the number of its particular hue in the color table.

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

repeat number [list of commands]

Parameters:
number Number number of times to iterate
[list of commands] List of commands list of commands to run on each iteration

Description:
Do [list of commands] number times.

Examples:
repeat 4 [fd 4 lt 90] makes turtles move forward 4 steps and then turn left 90 degrees 4 times.

Related Commands:
loop
Turtle

right (rt) angle

Parameters:
angle Number number of degrees to turn

Description:
Turtles turn right by angle degrees.

Examples:
rt 90

Related Commands:
back forward left setheading
Turtle, Observer, Patch

round number

Parameters:
number Number number to be rounded

Description:
Reports the integer closest to number.

Examples:
round 4.6 returns 5.

Related Commands:
int
Turtle, Patch

scale-color color variable limit1 limit2

Parameters:
color Number Color
variable Number Variable color
limit1 Number Lower limit
limit2 Number Upper limit

Description:
Turtles set their color to a shade of color based on their value of variable. limit1 and limit2 determine the amount of gradation. If a patch calls this, all turtles on that patch scale their color.

Examples:
scale-color blue energy 0 20 Turtles turn one of twenty shades of blue. Turtles with lower energy turn darker blue.

scale-color blue energy 20 0
Turtles turn one of twenty shades of blue. Turtles with lower energy turn lighter blue.

Notes:
If the turtle exceeds the limits, it turns black on the dark end of the specturm and turns white on the bright end of the spectrum.

Related Commands:
scale-pc
Turtle, Patch

scale-pc color variable limit1 limit2

Parameters:
color Number Color
variable Number
limit1 Number Lower limit
limit2 Number Upper limit

Description:
Patches set their color to a shade of color based on their value of variable. limit1 and limit2 determine the amount of gradation. If a turtle calls this, the patch underneath the turtle scale its patch color.

Examples:
scale-color green density 0 20
Patches turn one of twenty shades of green. Patches with lower density turn darker green.

scale-color blue energy 20 0
Patches turn one of twenty shades of green. Patches with lower density turn lighter green.

Notes:
This is a patch command. It must be called from within an ask-patches or ask-patch-at statement.

If the patch exceeds the limits, it turns black on the dark end of the specturm and turns white on the bright end of the spectrum.

Related Commands:
scale-color setpc
Turtle, Observer, Patch

screen-height

Description:
Returns the height of the screen. The height is always an odd number, and the lowest possible value is 3. To change the screen-height, drag the mouse over the graphics canvas and use the handles to resize it.

Related Commands:
screen-half-height screen-half-width screen-width
Turtle, Observer, Patch

screen-width

Description:
Returns width of the screen. The width is always an odd number, and the lowest possible value is 3. To change the screen-width, drag the mouse over the graphics canvas and use the handles to resize it.

Related Commands:
screen-half-height screen-half-width screen-height
Turtle, Observer, Patch

set set value

Parameters:
set Variable variable that gets redefined
value Anything value to be assigned to variable

Description:
Assigns value to set, where set is any variable which has already been declared. For more information on local variables, see the Variables page.

Examples:
set energy 5 makes the variable energy have value 5 for every turtle, assuming energy has been declared as a turtle variable.

Related Commands:
let setslidervar setvariable setvariable-at setvariable-of setvariable-towards variable
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

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
Patch

setpc (setpatchcolor) color

Parameters:
color Color

Description:
This command is run as a patch command inside an ask-patches statement. The patches being asked will set their color to color. Use stamp if you want to have a turtle change the color of a patch.

Examples:
ask-patches [setpc blue] commands the patches to set their color to blue.

Related Commands:
patchcolor scale-pc setbg stamp
Turtle

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

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

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

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

show anything

Parameters:
anything Anything

Description:
Prints anything in the command center that calls show.

Related Commands:
print print-status type
Turtle

stamp color

Parameters:
color Number

Description:
Sets color of patch under turtle to color

Examples:
stamp red sets the patch under the turtle to red

stamp 0 sets the patch under the turtle to color 0 (black)

stamp color sets the patch under the turtle to the color of the turtle

Related Commands:
patchcolor pstamp setpc stamp-at stamp-towards
Observer

startbuttonname

Description:
Starts the button of name buttonname

Examples:
startgo will start the button named go

Related Commands:
stopbuttonname
Turtle, Observer, Patch

stop

Description:
Exits the current procedure immediately.

Examples:
to check-patch-color
if pc-ahead = red [rt 90 stop]
if pc-ahead = green [lt 90 stop]
fd 1
end

This procedure will cause turtles to turn right and then exit the procedure if the the patch ahead is red, turn left and exit the procedure if the patch ahead is green, and only move forward one if the patch ahead was not green or red.

Notes:
Note: stop does not stop any callers of the procedure, only the procedure itself.

Related Commands:
end loop output to
Observer

stopbuttonname

Description:
Stops the button of name buttonname

Examples:
stopgo will stop the button named go

Related Commands:
startbuttonname stopall
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

to procedure-name

Parameters:
procedure-name Anything A single word which is the name of the procedure you wish to define

Description:
When you create a procedure, the first line of it must be to procedure-name where procedure-name is a one-word title for your procedure. procedure-name cannot be any command already recognized by StarLogo (this includes both built-in commands and the procedure names of other procedures you may already have written).

To add parameters to a procedure, write them after the procedure-name with a colon in front of them, like this:
to my-procedure :x :y :z

Inside the procedure body, you may use :x, :y and :z to refer to the values of the arguments passed in by the caller of the procedure.

All procedures must be ended with the word end on a line by itself (no comments may be on that line).

Procedures defined in the turtle procedures pane are only callable by turtles. Procedures defined in the observer procedures pane are only callable by the observer. Patches may not have procedures.

Examples:
to go
fd 1
rt 90
end

Now you may use go as a command in other parts of your program.

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

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

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

wait seconds

Parameters:
seconds Number A number of seconds. Decimals are allowed.

Description:
Caller waits seconds seconds before continuing.

This command is per-thread - meaning if you have two buttons that each call wait, they will not wait for one another.

Examples:
to crawl
fd 1
wait 2.1
end

crawl

The turtles go forward 1 step and then wait for 2.1 seconds.

Related Commands:
wait-until
Turtle, Observer, Patch

white

Description:
white reports 9, the number of its particular hue in the color table.

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

who

Description:
Returns the who number (ID number) of the turtle.

Examples:
if who = 1 [fd 1] commands all turtles to check if they're turtle 1, and if so, move forward 1 step.

Related Commands:
breed color heading shape xcor ycor
Turtle, Observer, Patch

yellow

Description:
yellow reports 45, the number of its particular hue in the color table.

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