<ARRAY-VARIABLE>-ref
Turtle CommandPatch CommandObserver Command
<ARRAY-VARIABLE>-ref index

Reports the ith(index) value in <ARRAY-VARIABLE> to value.

Example:
settemp array-ref 0 random 100 ;; sets temp to the first value
;; in array.


<ARRAY-VARIABLE>-ref-at
Turtle CommandPatch Command
<ARRAY-VARIABLE>-ref-at index x y

Reports the ith(index) value in <ARRAY-VARIABLE> of the turtle or patch that is (x, y) units away from the caller.

Example:
settemp array-ref-at 0 0 1
;; sets temp to the first value
;; in the array of the turtle directly
;; above this turtle.


<ARRAY-VARIABLE>-ref-of
Turtle CommandPatch CommandObserver Command
<ARRAY-VARIABLE>-ref-of index who

Reports the ith(index) value in <ARRAY-VARIABLE> of turtle with the turtle id who.

Example:
settemp array-ref 0 one-of-turtles ;; sets temp to the first value
;; in array of a random turtle.


<PATCH-VARIABLE>-at
Turtle CommandObserver Command
<PATCH-VARIABLE>-at dx dy

Reports the value of <VARIABLE> for a patch that is (dx, dy) units away.

NOTE: The observer behaves as if it were located at (0, 0).

Example:
;Suppose my patch variable was called "isweird". I could say:
show isweird-at 1 1
;This prints the value of "isweird" 1 patch up and 1 patch to the right of the caller.


<SLIDER-VARIABLE>-inc
Observer Command
<SLIDER-VARIABLE>-inc

Reports the value of the <SLIDER-VARIABLE>'s current increment value.

Example:
;Suppose my slider variable was called "range". I could say:
if (range-inc = 1) [rt 90]
;Which turns every turtle 90 degrees to the right if the increment value of "range" equals one.


<SLIDER-VARIABLE>-max
Observer Command
<SLIDER-VARIABLE>-max

Reports the maximum value of <SLIDER-VARIABLE>.

Example:
;Suppose my slider variable was called "range". I could say:
if (range-max < 10) [fd 1]
;Which moves each turtle forward one step if the maximum value of "range" is less than 10.


<SLIDER-VARIABLE>-min
Observer Command
<SLIDER-VARIABLE>-min

Reports the minimum value of <SLIDER-VARIABLE>.

Example:
;Suppose my slider variable was called "range". I could say:
if (range-min > 10) [fd 1]
;Which moves each turtle forward one step if the minimum value of "range" is greater than 10.


<TEXTBOXNAME>-color
Observer Command
<TEXTBOXNAME>-color

Reports the textbox's background color.

Example:
;Suppose my textbox name was "trees". I could say:
setc trees-color
;This sets the turtles' color to the textbox's background color.


<TEXTBOXNAME>-text
Observer Command
<TEXTBOXNAME>-text

Reports the string currently displayed in the textbox.

Note: A string is any sequence of letters, numerals, or symbols. "LAURA" "JR19!" and "***" are all examples of strings.

Example:
;Suppose my textbox name was "trees". I could say:
show trees-text
;This shows the text in the textbox "trees".


<TEXTBOXNAME>-textcolor
Observer Command
<TEXTBOXNAME>-textcolor

Reports the color of the text in TEXTBOXNAME.

Example:
;Suppose my textbox name was "trees". I could say:
if (trees-textcolor = green) [die]
;Which kills all the turtles if the textcolor of the textbox "trees" is green.


<TURTLE-VARIABLE>-at
Turtle CommandObserver Command
<TURTLE-VARIABLE>-at dx dy

Reports the value of VARIABLE for a turtle that is (dx, dy) units away from the caller.

NOTE: The observer behaves as if it were located at (0, 0).

Example:
;Suppose my turtle variable was called "chemical". I could say:
show chemical-at 1 1
;This prints the value of "chemical" of the turtle 1 patch up and 1 patch to the right of the caller.


<TURTLE-VARIABLE>-of
Turtle Command
<TURTLE-VARIABLE>-of ID-number

Reports the value of another turtle's TURTLE-VARIABLE with the given ID-number.

Example:
;Suppose my turtle variable was called "chemical" and the ID-Number of the turtle was "who". I could say:
if ( (chemical-of who) = 0) [die]
;Which means if the chemical of the turtle "who" equals 0, kill "who".


, [comma]
Turtle Command
<COMMAND>,

Suspends parallel execution to wait until all turtles have have finished executing <COMMAND>. Used to synchronize turtle behavior.

NOTE: The comma can be - but does not need to be - offset from <COMMAND> by any number of spaces and/or newlines.

Example:
crt 100
repeat 1000
[fd 1]
; Turtles move at random speeds

crt 100
repeat 1000
[fd 1,]
; Turtles move synchronously


abs
Turtle CommandPatch CommandObserver Command
abs number

Reports the absolute value of number.

Example:
fd abs -7
;Turtles move forward 7 steps.


alive?
Turtle Command

Reports true if the turtle is alive.

In StarLogoT, 'false' evaluates to 1, and 'true' evaluates to 0. This may change in future versions or in N-Logo, so it is best to use "true" and false" rather than numerical values.


alive?-of
Turtle CommandPatch CommandObserver Command
alive?-of ID-number

Reports true if turtle with the given ID-number is alive.

In StarLogoT, 'false' evaluates to 1, and 'true' evaluates to 0. This may change in future versions or in N-Logo, so it is best to use "true" and false" rather than numerical values.


and
Turtle CommandPatch CommandObserver Command
condition1 and condition2

Reports true if both condition1 and condition2 are true.

Example:
if (ycor > 0) and (xcor > 0) [setpc blue]
;The upper-right quadrant of patches turn blue.


Arithmetic Operators (+, *, -, /, ^, <, >, =, !=, <=, >=)
Turtle CommandPatch CommandObserver Command

All of these operators take two inputs, and all act as "infix operators" (going between the two inputs, as in standard mathematics use). StarLogoT correctly supports order of operations for infix operators.

The operators work as follows: + is addition, * is multiplication, - is subtraction, / is division, ^ is exponentiation, < is less than, > is greater than, = is equal to, != is not equal to, <= is less than or equal, >= is greater than or equal.

If you are not sure how StarLogoT will interpret your expression, you should insert parentheses.

Example:
show 5 * 6 + 6 / 3
=> 32;
show 5 * (6 + 6) / 3
=> 20


ask-<BREED>
Turtle Command
ask-<BREED> [commands]

Takes a list of commands that only <BREED> turtles will run.

Example:
;Suppose the name of my breed was "lambs", I could say:
ask-lambs [fd 1]
;Which would tell all the turtles whose breed is of type "lambs" to move forward one step.


atan
Turtle CommandPatch CommandObserver Command
atan x y

Reports the arctangent, in degrees (from 0 to 359), of x divided by y.

When y is zero: if x is positive, atan reports 90 degrees; if x is negative, atan reports 270 degrees.

Note: atan is accurate to only two or three decimal places.

Example:
show atan 1 -1
;Prints 135.0 to the command center.
show atan -1 1
;Prints 315.0 to the command center.


auto-plot-off

See: auto-plot-on


auto-plot-on
Observer Command

This pair of commands is used to control the StarLogoT feature of 'auto-plotting' in the current plot window. Auto-plotting will automatically update the x and y axes of the graph whenever the current pen exceeds these boundaries. It is most useful when plotting a single value over time.


back
bk
Turtle Command
back number

Turtles move backward by number steps.


beep
Observer Command

Calls the current system alert sound.


bf

See: butfirst


bit
Turtle CommandPatch CommandObserver Command
bit number1 number2

Reports the bitvalue of number1 in position number2.


bitand
Turtle CommandPatch CommandObserver Command
number1 bitand number2

Reports the "bitwise and" of its two inputs.

Note: For best results, inputs should be limited to 16-bit integers.


bitneg
Turtle CommandPatch CommandObserver Command
bitneg number

Reports the bitwise negation of its input.

Note: For best results, inputs should be limited to 16-bit integers.


bitor
Turtle CommandPatch CommandObserver Command
number1 bitor number2

Reports the "bitwise or" of its two inputs.

Note: For best results, inputs should be limited to 16-bit integers.


bitset
Turtle CommandPatch CommandObserver Command
bitset number1 number2 number3

Reports the value of number1 with the number2th bit set to number3.


bitstring
Observer Command
bitstring number

Reports a string of 32 zeros and ones which is the bitstring representation of number.

Note: A string is any sequence of letters, numerals, or symbols. "LAURA" "JR7!" and "***" are all examples of strings.


bitxor
Turtle CommandPatch CommandObserver Command
number1 bitxor number2

Reports the "bitwise xor" of its two inputs.

Note: For best results, inputs should be limited to 16-bit integers.


bk
Turtle Command

See: back


bl

See: butlast


breed
Turtle CommandPatch Command

Reports the breed of the turtle.


breed-at
Turtle CommandPatch CommandObserver Command
breed-at dx dy

Reports the breed of any turtle in the patch (dx, dy) units away from the caller. If there are no turtles in that patch, reports 0.

NOTE: The observer behaves as if it were located at (0, 0).


breed-of
Turtle CommandPatch CommandObserver Command
breed-of ID-number

Reports the breed of the turtle with the given ID-number.


butfirst
bf
Observer Command
butfirst [data]
bf [data]

Reports the list of data with its first element removed.

Example:
;If you have a global variable a, you can write the following code:
seta list 1 2
;Sets global variable a to "data" with data elements 1 and 2.
show butfirst a
;Prints 2 to the command center, which is the data a with the first element removed.


butlast
bl
Observer Command
butlast [data]
bl [data]

Reports the list of data with its last element removed.


ca

See: clearall


camera-brightness
Observer Command

Reports a number between 0 and 100, indicating the brightness of the camera used with the camera-click command.


camera-click
Observer Command
camera-click patch-variable

Grabs an image from QuickTime-compatible camera and puts a gray-scale version of the image in given patch-variable. If the image is larger than the screen size, takes the middle of the image. (You must initialize the camera with camera-init.)


camera-init
Observer Command

Initializes QuickTime-compatible video camera plugged into computer. (Camera can be used to import images into StarLogoT patches.)

Note: Calling this command with no camera connected may cause StarLogoT to crash.


camera-set-brightness
Observer Command
camera-set-brightness number

Sets the brightness of the camera used with the camera-click command. The input number must be between 0 and 100.


cc
Observer Command

Stands for "clear command center"

Clears all text in the command center.


cct
Turtle Command

See: create-custom-turtles


cct-random
Observer Command

See: create-random-custom-turtles


ceiling
Turtle CommandPatch CommandObserver Command
ceiling number

Reports the largest integer greater than or equal to number.

Example:
show ceiling 4.5
;Prints 5 to the command center.
show ceiling -4.5
;Prints -4 to the command center.


cg

See: cleargraphics


choose-directory-dialog
Observer Command

Pops up a dialog and lets the user pick a directory.

Returns the directory that the user picked or false if the cancel button was pressed.


choose-file-dialog
Observer Command

Pops up a dialog and lets the user pick a file.

It returns the full pathname of the file that the user picked or false if the cancel button was pressed.


choose-new-file-dialog
Observer Command

Pops up a dialog and lets the user create a new file name.

It returns the full pathname of the file that the user created or false if the cancel button was pressed.


clear-output
co

See: clearoutput


clearall
ca
Observer Command

Kills all turtles, clears all of the patches, and clears the plot window.


cleargraphics
cg
Observer Command

Sets the color of all patches to black.


clearoutput
co
Observer Command

Clears all text in the output window.


clearpatches

See: cleargraphics


clearplot
Observer Command

Clears everything drawn by all plot pens, and resets all pens to (0, 0) in the current plot window.

All other plot windows are unaffected.


close-movie
Observer Command

Stops recording a StarLogoT movie and saves it. The movie is created in PICS format.

Note: StarLogoT writes PICS format movie files for simplicity. To convert these to QuickTime Movie format, one needs a graphics utility.


co

See: clearoutput


color
Turtle Command

Reports the color of the turtle.

Example:
if color = white [fd 20]
;all white turtles move forward 20 steps.


color-at
Turtle CommandPatch CommandObserver Command
color-at dx dy

Reports the color of any turtle in the patch (dx, dy) units away from the caller. If there are no turtles in that patch, reports 0.

NOTE: The observer behaves as if it were located at (0, 0).


color-of
Turtle CommandPatch CommandObserver Command
color-of ID-number

Reports the color of the turtle with the given ID-number.


cos
Turtle CommandPatch CommandObserver Command
cos angle

Reports the cosine of angle. Assumes the angle is given in degrees.

Note: cos is only accurate to three or four decimal places.

Example:
show cos 180
;Prints -1.0 in the command center.


count-<BREED>
Turtle CommandPatch CommandObserver Command
count-<BREED>

Reports the current number of turtles of the breed <BREED>.

Example:
;Suppose the name of my breed was "lambs", I could say:
count-lambs
;Which would report the total number of turtles whose breed type is "lambs".


count-<BREED>-at
Turtle CommandPatch CommandObserver Command
count-<BREED>-at dx dy

Reports the number of turtles of the breed type <BREED> (dx, dy) units away from the caller.

NOTE: The observer behaves as if it were located at (0, 0).

Example:
;Suppose the name of my breed was "lambs", I could say:
count-lambs-at 1 0
;Which would report the total number of turtles of the breed type "lambs" at the point (1,0) away from the caller.


count-<BREED>-here
Turtle CommandPatch Command
count-<BREED>-here

Reports the current number of turtles of the breed type <BREED> in the patch.

Example:
;Suppose the name of my breed was "lambs", I could say:
count-lambs-here
;Which would report the total number of turtles of the breed type "lambs" on the patch.


count-color
Observer Command
count-color number

Reports the number of turtles with the color number.

Note: Another way to say this command is:
count-turtles-with [color = number].

Example:
show count-color red
;Prints the number of red turtles.


count-color-range
Observer Command
count-color-range color1 color2

Counts how many turtles have a color between color1 and color2.

Note: Another way to say this command is: count-turtles-with [(color >= color1) and (color <= color2)].


count-pc
pc-count
Observer Command
count-pc color

(count-patch color )

Reports the number of color patches.

Example:
show count-pc green
;Prints the number of green patches.


count-pc-range
Observer Command
count-pc-range color1 color2

Counts how many patches have a color between color1 and color2.


count-turtles
Turtle CommandPatch CommandObserver Command

Reports the total number of turtles.


count-turtles-at
turtles-at
Turtle CommandPatch CommandObserver Command
count-turtles-at dx dy

Reports the number of turtles in the patch that is (dx, dy) units away from the caller.

NOTE: The observer behaves as if it were located at (0, 0).

Example:
;I could say:
count-turtles-at 1 1
;Which would count the number of turtles on the patch to the upper right of the caller.


count-turtles-here
turtles-here
Turtle CommandPatch Command

Reports the number of turtles in the patch, including the current turtle.


count-turtles-with
Turtle CommandObserver Command
count-turtles-with [condition]

Counts the number of turtles for which condition is true.

Note: If this command is called from a turtle, it will not count itself even if it meets the condition

Note: If this command is called by the observer it reports all turtles that satisfy the condition

Note: Another way to say this command is: sum-of-turtles-with condition [true].


cp
Observer Command

Clears the patches.


create-<BREED>
Observer Command
create-<BREED> number

Creates number new turtles, all who have the breed <BREED>.

Example:
;Suppose the name of my breed was "lambs", I could say:
create-lambs 20
;Which would create twenty turtles of the breed type "lambs".


create-custom-turtles
Observer Command
create-custom-turtles number xcor ycor heading color shape breed-name

Creates number new turtles. New turtles each start with the given values for the argument variables.

Note: Unlike create-random-custom-turtles, the observer evaluates the arguments once and creates a set of number identical turtles.

Example:
create-custom-turtles 50 (random 50) 5 90 blue turtle-shape frog
;The expression given for xcor, 'random 50', gets evaluated once
;by the observer, and all 50 turtles get the same xcor.
;NOTE: In this example, the breed is set to frog.
;If you do not want to set a breed, set it to 0.


create-random-<BREED>
Observer Command
create-random-<BREED> number

Creates a number of new turtles, all of breed <BREED>, each of which has a randomly determined heading and color.

Example:
;Suppose the name of my breed was "lambs", I could say:
create-random-lambs 20
;Which would create twenty turtles of the breed type "lambs" each of which has a random heading and color.


create-random-custom-turtles
Observer Command
create-random-custom-turtles number xcor ycor heading color shape breed-name

Creates number new turtles. New turtles each start with values for the appropriate variables based on how they evaluate the arguments.

Note: Unlike create-custom-turtles, each turtle evaluates its arguments individually when it is created.

Example:
create-random-custom-turtles 50 (random 50) 5 90 blue turtle-shape frog
;The expression given for xcor, 'random 50',gets
; evaluated by every turtle, so each turtle will have a random xcor.
;NOTE: In this example, the breed is set to frog.
;If you do not want to set a breed, set it to 0.


create-random-turtles
crt-random
Observer Command
create-random-turtles number

Creates number new turtles. New turtles start at position (0, 0). New turtles are created with the 14 primary colors and have headings from 0 to 360. Colors and headings are randomly distributed.


create-turtles
crt
Observer Command
create-turtles number

Creates number new turtles. New turtles start at position (0, 0). New turtles are created with the 14 primary colors and have headings from 0 to 360, evenly spaced.


crt

See: create-turtles


crt-random
Observer Command

See: create-random-turtles


ct
Observer Command

Clears turtles.

See: die


die
Turtle Command

The turtle dies.

Example:
if [xcor > 20] [die]
;all turtles with xcor greater than 20 die

See: ct


diffuse
Observer Command
diffuse patch-variable number

Tells each patch to share (number * 100) percent of the value of patch-variable with its eight neighboring patches. number should be between 0 and 1.

Example:
diffuse chemical 0.5
;Each patch diffuses 50% of its variable
;chemical to its neighboring 8 patches. Thus,
;each patch gets 1/8 of 50% of the chemical
;from each neighboring patch.)


display
Observer Command

Turns on the StarLogoT graphics display. (It is sometimes useful to turn off the display to improve performance.)

See: no-display


distance
Turtle CommandPatch Command
distance xcor ycor

Reports the distance to the point (xcor, ycor)

With distance, turtles and patches use the wrapped distance (around the edges of the screen) if that distance is shorter than the on-screen distance.

Example:
if (distance 0 0) > 10 [setc green]
;All turtles more than 10 units from
;the center of the screen turn green.


distance-nowrap
Turtle CommandPatch Command
distance-nowrap xcor ycor

Reports the distance to the point (xcor, ycor)

With distance-nowrap, turtles and patches always use the on-screen distance.

Example:
if (distance-nowrap 0 0) > 10 [setc green]
;All turtles more than 10 units from
;the center of the screen turn green.


distribute-random-exponential
Observer Command
distribute-random-exponential turtle-or-patch-variable number

Assigns a random floating-point number exponentially-distributed with mean number to each agent which has the variable turtle-or-patch-variable.


distribute-random-normal
Observer Command
distribute-random-normal turtle-or-patch-variable number1 number2

Assigns a random number normally-distributed with mean number1 and standard deviation number2 to each agent which has the variable turtle-or-patch-variable.


distribute-random-poisson
Observer Command
distribute-random-poisson turtle-or-patch-variable number

Assigns a random integer distributed according to the Poisson distribution with mean number to each agent which has the variable turtle-or-patch-variable.


downhill
Turtle Command
downhill patch-variable

Reports the turtle heading (between 0 and 359 degrees) in the direction of the minimum value of the patch variable patch-variable, in the eight patches directly surrounding the turtle.

Note that 'patch-variable' must be defined in the 'patches-own' list.

Example:
seth downhill chemical
;Each turtle sets its heading in the direction of the
;patch with the lowest value of the 'chemical' variable,
;over the eight surrounding patches.


downhill4
Turtle Command
downhill4 patch-variable

Reports the turtle heading (between 0 and 359 degrees) in the direction of the minimum value of the patch variable patch-variable', in the four patches directly above, below, to the left, and to the right of the turtle.

Note that patch-variable must be defined in the 'patches-own' list.

Example:
seth downhill4 chemical
;Each turtle sets its heading in the direction of the
;patch with the lowest value of the 'chemical' variable,
;over the four patches in the cardinal directions.


dx
dy
Turtle Command

Reports the x-increment or y-increment if the turtle were to take one step forward in its current heading.

This primitive is useful for "testing" the patch ahead of the turtle before moving.

Example:
;if the patch variable 'food' one step in front of the turtle
;is greater than 1, execute eat-one-piece-of-food
if (food-at dx dy) > 0 [eat-one-piece-of-food]


e
Turtle CommandPatch CommandObserver Command

Returns 2.718


empty?
Observer Command
empty? [data]

Reports true(0) if there are no elements in the list of data; false(1) otherwise.


every
Observer Command
every number [commands]

Runs commands every number seconds. Can be used only inside of a "forever" button.


exp
Observer Command
exp number

Reports the value of e raised to the number power.

Note: This is the same as e ^ number.


export-graphs
Observer Command

Saves each of the modified plotwindows individually as PICT files. One file dialog will be brought up for each plotwindow used in the project.


export-output
Observer Command

Saves the output window to a file.

Note: If no output file has been set with set-output-filename, a dialog box will pop up to prompt you for the filename.


export-patches
Observer Command
export-patches filename

Saves the patches and all of their states to a file named filename.


export-turtles
Observer Command
export-turtles filename

Saves the turtles and all of their states to a file named filename.


export-turtles-and-patches
Observer Command
export-turtles-and-patches filename

Saves the turtles and the patches and all of their states to a file named filename.


false
Turtle CommandPatch CommandObserver Command

This is the boolean value of "false".
In StarLogoT, 'false' evaluates to 1, and 'true' evaluates to 0. This may change in future versions or in N-Logo, so it is best to use "true" and false" rather than numerical values.


fd
Turtle Command

See: forward


first
Observer Command
first [data]

Reports the first element of the list of data.


floor
Turtle CommandPatch CommandObserver Command
floor number

Reports the largest integer less than or equal to number.

Example:
show floor 4.5
;Prints 4 to the command center.
show floor -4.5
;Prints -5 to the command center.


forward
fd
Turtle Command
forward, fdnumber

Turtles move forward by number steps.


fput
Observer Command
fput item [data]

Reports the list of data with item inserted as its first element.

Example:
;If you have a global variable a, you can write the following code:
seta list 1 2
;Sets global variable 'a' to a [data] with data elements 1 and 2.
show fput 3 a
;Prints '3 1 2' to the command center, which is the [data] 'a' with the new item, 3,
;inserted as first element.


get-date-and-time
Observer Command

Reports the current date and time as a character string.


hatch
Turtle Command
hatch [commands]

Each turtle creates a new turtle, identical to itself, and tells the new turtle to execute commands.

Note: While executing commands, newly hatched turtles will not run forever buttons.

Example:
hatch [lt 45 fd 1]
;Each turtle creates a new turtle,
;angled to the left, that moves forward 1


heading
Turtle Command

Reports the heading of the turtle.

Note: Heading 0 is due north, 90 is east, 180 is south, and 270 is west.


heading-at
Turtle CommandPatch CommandObserver Command
heading-at dx dy

Reports the heading of any turtle in the patch (dx, dy) units away from the caller.

NOTE: The observer behaves as if it were located at (0, 0).


heading-of
Turtle CommandPatch CommandObserver Command
heading-of ID-number

Reports the heading of the turtle with the given ID-number.


hidden?-of
Observer Command
hidden?-of ID-number

Returns true if the turtle with the given ID-number is hidden.


hideturtle
ht
Turtle Command

Turtles hide themselves, becoming invisible.

See: showturtle


histogram-<BREED>
Observer Command
histogram-<BREED> [turtle-or-patch-expression]

Creates a histogram of turtle-or-patch-expression for all turtles of type <BREED>.

See: histogram-turtles


histogram-<BREED>-with
Observer Command
histogram-<BREED>-with [condition] [turtle-or-patch-expression]

Creates a histogram of turtle-or-patch-expression for all turtles of type <BREED> that satisfy the given condition. If no turtles of type <BREED> satisfy the given condition, there will be no bars in the histogram.

See: histogram-turtles


histogram-list
Observer Command
histogram-list [data]

Creates a histogram of the number of times each value occurs in the data list.

NOTE: histogram-list will not graph negative data items.

NOTE: histogram-list treats the minimum value of hist-xrange as 0 on the x-axis.

Example:
sethist-xrange 0 5
histogram-list [ 1 1 3 ]
; Creates a bar of height 2 @ x = 1,
; and a bar of height 1 @ x = 3.

sethis-xrange -5 5
histogram-list [ 0 0 1 ]
; Creates a bar of height 2 @ x = -5,
; and a bar of height 1 @ x = -4.


histogram-turtles
Observer Command
histogram-turtles [turtle-or-patch-expression]

Creates a histogram of turtle-or-patch-expression.

For a turtle expression: creates a histogram of the values returned when all turtles execute the expression.

For a patch expression: creates a histogram of the values returned when all patches that contain turtles execute the expression. If a patch contains more than one turtle, it will exectue the expression once for each turtle it contains.

NOTE: turtle-or-patch-expression must return a numerical value.


histogram-turtles-with
Observer Command
histogram-turtles-with [condition] [turtle-or-patch-expression]

Creates a histogram of turtle-or-patch-expression for all turtles that satisfy the given condition. If no turtles satisfy the given condition, there will be no bars in the histogram.

See: histogram-turtles


home
Turtle Command

Turtles move to coordinates (0, 0).

Note: This command is equivalent to setxy 0 0


ht
Turtle Command

See: hideturtle showturtle


if
Turtle CommandPatch CommandObserver Command
if (condition) [commands]

If condition evaluates to true, executes commands.

Example:
if (xcor > 0) [setc blue]
;Turtles on the right half of the screen turn blue.


ifelse
Turtle CommandPatch CommandObserver Command
ifelse condition [commands1] [commands2]

If condition evaluates to true, then executes commands1.

If condition evaluates to false, then executes commands2.

Condition may have different values for different objects, so some objects may execute commands1 while others execute commands2.

Example:
ifelse (xcor > 0) [setpc blue] [setpc red]
;The left half of the screen turns red and the right half turns blue.


ifelse-report
Turtle CommandPatch CommandObserver Command
ifelse-report condition [commands1] [commands2]

If condition is true, executes commands1 and returns its value.

If condition is false, executes commands2 and returns its value.

Example:
show (sum-of-turtles [ ifelse-report participate? [ (2 * my-value)] [my-value]])
;Shows the "weighted sum" of the variable
;my-value over all turtles, giving twice
;as much weight to turtles for which the
;variable participate? is true.


import-patches
Observer Command

Loads patches from a file. This pops up a dialog from which you can pick the file.

Note: StarLogoT tries to reconcile differences in the saved state of these patches and the current procedures page. If a saved patch has a variable with a name that does not exist in the current procedures page, that variable will not be accessible. If the procedures page has a variable that the saved patches don't have, that variable will be set to a random value.


import-turtles
Observer Command

Loads turtles from a file. This pops up a dialog from which you can pick the file.

Note: StarLogoT tries to reconcile differences in the saved state of these turtles andthe current procedures page. If a saved turtle has a variable with a name that does not exist in the current procedures page, that variable will not be accessible. If the procedures page has a variable that the saved turtles don't have, that variable will be set to a random value.


import-turtles-and-patches
Observer Command

Loads turtles and patches from a file. This pops up a dialog from which you can pick the file.

Note: StarLogoT tries to reconcile differences in the saved state of these turtle and patches andthe current procedures page. If a saved turtle or patch has a variable with a name that does not exist in the current procedures page, that variable will not be accessible. If the procedures page has a variable that the saved turtles or patches don't have, that variable will be set to a random value.


inspect
Observer Command
inspect ID-number

Pops up a turtle monitor for the turtle with the given ID-number. A double-click with the mouse-pointer on a turtle does the same thing.


inspect-patch
Observer Command
inspect-patch xcor ycor

Pops up the patch monitor for the patch at xcor ycor. A shift-click with the mouse-pointer on a patch does the same thing.


int
Turtle CommandPatch CommandObserver Command
int number

Reports the integer portion of number.

Example:
show int 4.5
;Prints 4 to the command center.
show int -4.5
;Prints -4 to the command center.


item
Observer Command
item number [data]

Reports the numberth item of the list of data.

Note: Numbering of data's items starts at 0.


jump
Turtle Command
jump number

Turtles move forward by number units in one "big step" (in one unit of time).

This command is useful for synchronizing turtle movements. The command forward 15 takes 15 times longer to execute than forward 1, but jump 15 executes in the same amount of time as forward 1.

Note: When turtles jump, they do not step on any of the patches along their path.


last
Observer Command
last [data]

Reports the last item of the list of data.


left
lt
Turtle Command
left number

Turtles turn left by number degrees.


length
Observer Command
length [data]

Reports the length of the list of data.


list
Observer Command
list item1 item2

Reports a new list of data with item1 as its first element, and item2 as its second element.

Items may be any letter, numeral, or symbol.


list-max
Observer Command
list-max [data]

Reports the maximum numeric element of the list of data. Ignores non-numeric elements.

Example:
show list-max [1 4 10]
;Prints 10 to the command center.


list-min
Observer Command
list-min [data]

Reports the minimum numeric element of the list of data. Ignores non-numeric elements.

Example:
show list-min [1 4 10]
;Prints 1 to the command center.


list-turtles-at
Observer Command
list-turtles-at xcor ycor

Reports a list of all turtles at the coordinates xcor, ycor.


list?
Observer Command
list? thing

Reports true if thing is a list; false otherwise.


ln
Observer Command
ln number

Reports the natural logarithm of number.

Note: ln is only accurate to three or four decimal places.


load-pict
Observer Command
load-pict filename patch-variable

Takes a graphic image (in PICT format) from the given filename and loads the image into the given patch-variable. This command resizes the image to fit in the StarLogoT graphics window.

Note: If no directory is given with filename, StarLogoT will look for filename in the StarLogoT application directory, and then the project directory.


lput
Observer Command
lput item [data]

Reports the list of data with item inserted as its last element.

Example:
;If you have a global variable 'a', you can write the following code:
seta list 1 2
;Sets global variable 'a' to a [data] with data elements 1 and 2.
show lput 3 a
;Prints '1 2 3' to the command center, which is the [data] 'a' with the new item, 3,
;inserted as last element.


lt
Turtle Command

See: left


make-bitarray
Observer Command
make-bitarray "|string|

Reports the numerical representation of string, which must be a string of zeros, ones, and spaces enclosed by vertical bars (||).

Example:
show make-bitarray "|110 00111001 00000000|
;Prints 6.2227 to the command center.


max
Turtle CommandPatch CommandObserver Command
max number1 number2

Returns the maximum of the two numbers.

Note: This command has changed from StarLogo 1.5. To get the maximum value of a variable,you should now use max-of-turtles [variable] for turtle variables,and max-of-patches [variable] for patch variables.


max-of-<BREED>
Turtle CommandObserver Command
max-of-<BREED> [numerical-expression]

Reports the maximum value of the given numerical-expression over all turtles of breed type <BREED>.

Example:
;Suppose the name of my breed was "lambs", I could say:
max-of-lambs [hairs]
;Which would report the maximum number of "hairs" on all "lambs".


max-of-<BREED>-with
Turtle CommandObserver Command
max-of-<BREED>-with [condition] [numerical-expression]

Reports the maximum value of the given expression over all turtles with the breed type <BREED> for whom the given condition is true.

Example:
;Suppose the name of my breed was "cod", I could say:
max-of-cod-with [age > 5] [size]
Which would report the maximum of "size" for cod that are more than 5 years old.


max-of-patches
Observer Command
max-of-patches [numerical-expression]

Reports the maximum value of numerical-expression over all the patches.

Example:
show max-of-patches [heat * speed]
;prints the maximum value for the patch
;expression (heat * speed) over all patches.


max-of-turtles
Turtle CommandObserver Command
max-of-turtles [numerical-expression]

Reports the maximum value of numerical-expression over the turtles.

Example:
setmax-temperature (max-of-turtles [temperature])
;sets the variable 'max-temperature' to the maximum value of 'temperature' over all turtles.


max-of-turtles-with
Turtle CommandObserver Command
max-of-turtles-with [condition] [numerical-expression]

Reports the maximum value of numerical-expression when run over the turtles that satisfy condition.

If there are no turtles for which condition is true, this reports minnum.

Example:
setmax-temperature (max-of-turtles-with [temperature > 50] [temperature])
;sets the variable 'max-temperature' to the maximum value of 'temperature'
;over all turtles for which 'temperature' exceeds 50.


max-turtles
Turtle CommandPatch CommandObserver Command

Reports the maximum number of turtles allowed in StarLogoT under the current settings. You can change this value by selecting the "Settings..." item from the Edit menu.


maxint
Turtle CommandPatch CommandObserver Command

Returns 32767

This is value that may be returned when StarLogoT is looking for a maximum or minimum value (over turtles or patches) but doesn't find any relevant turtles or patches.


maxnum
Turtle CommandPatch CommandObserver Command

Returns 32767.99998 (or 32767 65535/65536)

This is value that may be returned when StarLogoT is looking for a maximum or minimum value (over turtles or patches) but doesn't find any relevant turtles or patches.


mean
Observer Command
mean [data]

Reports the statistical mean of the numeric elements of data. Ignores non-numeric elements. The mean is the average, i.e. the sum of the elements divided by the total number of elements.

Example:
show mean [1 4 10]
;Prints 5 to the command center.


member?
Observer Command
member? item data

Reports true if item is an element of data; false otherwise.


message
Observer Command
message "|text|

Opens a dialog with text displayed as the message.


min
Turtle CommandPatch CommandObserver Command
min number1 number2

Returns the minimum of the two numbers.

Note: This command has changed from StarLogo 1.5. To get the minimum value of a variable,you should now use min-of-turtles [variable] for turtle variables, andmin-of-patches [variable] for patch variables.


min-of-<BREED>
Turtle CommandObserver Command
min-of-<BREED> [numerical-expression]

Reports the minimum value of the given numerical-expression over all turtles of the breed type <BREED>.

Example:
;Suppose the name of my breed was "lambs", I could say:
min-of-lambs [hairs]
Which would report the minimum number of "hairs" on all "lambs".


min-of-<BREED>-with
Turtle CommandObserver Command
min-of-<BREED>-with [condition] [numerical-expression]

Reports the minimum value of the given numerical-expression over all turtles of the breed type <BREED> for whom the given condition is true.

Example:
;Suppose the name of my breed was "cod", I could say:
min-of-cod-with [age > 5] [size]
Which would report the minimum of "size" for cod that are more than 5 years old.


min-of-patches
Observer Command
min-of-patches [numerical-expression]

Reports the minimum value of numerical-expression over the patches.

Example:
show min-of-patches [heat * speed]
;Prints the minimum value for the
;patch expression heat * speed over all patches.


min-of-turtles
Turtle CommandObserver Command
min-of-turtles [numerical-expression]

Reports the minimum value of numerical-expression over the turtles.

Example:
show max-of-turtles [age]
;Prints the maximum value for the
;turtle variable age over all turtles.


min-of-turtles-with
Turtle CommandObserver Command
min-of-turtles-with [condition] [numerical-expression]

Reports the minimum value of the numerical expression when run over the turtles that satisfy condition.

If there are no turtles for which condition is true, this reports maxnum.

Example:
setmin-temperature (min-of-turtles-with [temperature > 50] [temperature])
;sets the variable 'min-temperature' to the minimum value of 'temperature'
;over all turtles for which 'temperature' exceeds 50.


minint
Turtle CommandPatch CommandObserver Command

Returns -32768

This is value that may be returned when StarLogoT is looking for a maximum or minimum value (over turtles or patches) but doesn't find any relevant turtles or patches.


minnum
Turtle CommandPatch CommandObserver Command

Returns -32768.0

This is value that may be returned when StarLogoT is looking for a maximum or minimum value (over turtles or patches) but doesn't find any relevant turtles or patches.


mod
Turtle CommandPatch CommandObserver Command
number1 mod number2

Reports number1 modulo number2: that is, the remainder when number1 is divided by number2.

Note that mod is "infix" -- it comes between its two inputs.

Example:
show 62 mod 5
;Prints 2 to the command center.


mouse-down?
Turtle CommandPatch CommandObserver Command

Reports true if the mouse button is down.

Note: If the mouse is outside of the StarLogoT graphics window, mouse-down? will report false.


mouse-xcor
Turtle CommandPatch CommandObserver Command

Reports the StarLogoT x-coordinate of the mouse.

Note: If the mouse is outside of the StarLogoT graphics window, mouse-xcor reports the value at the window boundaries.

Example:
;mouse can "draw" in red
if((xcor = mouse-xcor) and (ycor = mouse-ycor)) [ setpc red ]


mouse-ycor
Turtle CommandPatch CommandObserver Command

Reports the StarLogoT y-coordinate of the mouse.

Note: If the mouse is outside of the StarLogoT graphics window, mouse-ycor reports the value at the boundaries of the window.

Example:
;mouse can "draw" in red
if((xcor = mouse-xcor) and (ycor = mouse-ycor)) [ setpc red ]


movie-snapshot
Observer Command

See: snapshot


myself
Turtle Command

During a command (usually a sum-of-turtles, min-of-turtles, max-of-turtles, who-min-of-turtles,who-max-of-turtles, sum-of-turtles-with, min-of-turtles-with, max-of-turtles-with,who-min-of-turtles-with, who-max-of-turtles-with, count-turtles-with, or one-of-turtles-with command), it reports the ID-number of the turtle who called it.

Example:
setclosest-turtle who-min-of-turtles [distance xcor-of myself ycor-of myself]
;All turtles set their turtle-variable
;closest-turtle to the ID-number of the closest turtle.


nmax-report
Patch Command
nmax-report patch-variable

Reports the maximum value of the patch variable over the eight surrounding patches of each patch. Note that this does not include the patch itself, and that 'patch-variable' must be defined in the 'patches-own' list.

Example:
settemperature (nmax-report temperature)
;Each patch sets its temperature variable to
;the maximum temperature surrounding it


nmax4-report
Patch Command
nmax4-report patch-variable

Reports the maximum value of the patch variable over the four surrounding patches directly above, below, to the left, and to the right of each patch. Note that this does not include the patch itself, and that 'patch-variable' must be defined in the 'patches-own' list.

Example:
settemperature (nmax4-report temperature)
;Each patch sets its temperature variable to
;the maximum temperature surrounding it
;(in the four main directions)


nmin-report
Patch Command
nmin-report patch-variable

Reports the minimum value of the patch variable over the eight surrounding patches of each patch. Note that this does not include the patch itself, and that 'patch-variable' must be defined in the 'patches-own' list.

Example:
settemperature (nmin-report temperature)
;Each patch sets its temperature variable to
;the minimum temperature surrounding it


nmin4-report
Patch Command
nmin4-report patch-variable

Reports the minimum value of the patch variable over the four surrounding patches directly above, below, to the left, and to the right of each patch. Note that this does not include the patch itself, and that 'patch-variable' must be defined in the 'patches-own' list.

Example:
settemperature (nmin4-report temperature)
;Each patch sets its temperature variable to
;the minimum temperature surrounding it
;(in the four main directions)


no-display
Observer Command

Turns off the StarLogoT graphics display. (It is sometimes useful to turn off the display to improve performance.)

See: display


nobody
Turtle CommandPatch CommandObserver Command

Same as the value -1, returned by one-of-turtles-here and similar commands if there are no valid turtles.


not
Turtle CommandPatch CommandObserver Command
not condition

Reports true if condition evaluates to false. Reports false if condition evaluates to true.

Example:
if not color = blue [fd 10]
;All non-blue turtles move forward 10 steps.


nsum
Observer Command
nsum patch-variable1 patch-variable2

For each patch, sums the values of patch-variable1 in the surrounding patches and puts the resulting sum in its patch-variable2.

Example:
nsum chemical temp
;Each patch sums the values of chemical
;in the eight neighboring patches and puts
;the resulting sum in its variable temp.


nsum-report
Patch Command
nsum-report patch-variable

Reports the total summed value of the patch variable over the eight surrounding patches of each patch. Note that this does not include the patch itself, and that 'patch-variable' must be defined in the 'patches-own' list.

Example:
settemperature (nsum-report temperature)
;Each patch sets its temperature variable to
;the total temperature surrounding it


nsum4
Observer Command
nsum4 patch-variable1 patch-variable2

For each patch, sums the values of patch-variable1 in the 4 surrounding patches and puts the resulting sum in patch-variable2. NOTE: nsum4 uses four neighboring patches (north, east, west, south), while nsum uses eight neighboring patches (including diagonals).

Example:
nsum4 chemical temp
;Each patch sums the values of chemical
;in the four neighboring patches and
;puts the resulting sum in its variable temp.


nsum4-report
Patch Command
nsum4-report patch-variable

Reports the total summed value of the patch variable over the four surrounding patches directly above, below, to the left, and to the right of each patch. Note that this does not include the patch itself, and that 'patch-variable' must be defined in the 'patches-own' list.

Example:
settemperature (nsum4-report temperature)
;Each patch sets its temperature variable to
;the total temperature surrounding it
;(in the four main directions)


one-of-<BREED>
Turtle CommandPatch CommandObserver Command
one-of-<BREED>

Reports the ID-number of a random turtle, whose breed type is <BREED>, other than yourself (if called by a turtle of breedy type <BREED>). If there is no such turtle, this returns -1.

Example:
;Suppose the name of my breed was "lambs", I could say:
one-of-lambs
Which would report the ID-number of a random "lambs" other than myself.


one-of-<BREED>-at
Turtle CommandPatch CommandObserver Command
one-of-<BREED>-at dx dy

Reports the ID-number of a random turtle of breed type <BREED> other than yourself (if called by a turtle of breed type <BREED>) in the patch (dx,dy) units away from the caller. If there is no such turtle, this returns -1.

NOTE: The observer behaves as if it were located at (0, 0).

Example:
;Suppose the name of my breed was "lambs", I could say:
one-of-lambs-at -2 2
Which would report the ID-number of a random "lambs" at the point (-2,2).


one-of-<BREED>-here
Turtle CommandPatch Command
one-of-<BREED>-here

Reports the ID-number of a random turtle of breed type <BREED> other than yourself (if called by a turtle of breed type <BREED>) in the current patch. If there is no such lamb, this returns -1.

Example:
;Suppose the name of my breed was "lambs", I could say:
one-of-lambs-here
Which would report the ID-number of a random turtle in the current patch.


one-of-<BREED>-with
Turtle CommandObserver Command
one-of-<BREED>-with [condition]

Reports the ID-number of a random turtle, whose breed is of type <BREED>, other than yourself (if called by a turtle of breed type <BREED>), for whom the given condition is true. If there is no such turtle, this returns -1.

Example:
;Suppose the name of my breed was "moose", I could say:
one-of-moose-with [horns? = true]
;Which would report the ID-number of a random "moose" with horns besides myself.


one-of-turtles
Turtle CommandPatch CommandObserver Command

Reports the ID-number of a random live turtle that is not yourself.If there are no other turtles, this returns -1.


one-of-turtles-at
Turtle CommandPatch CommandObserver Command
one-of-turtles-at dx dy

Reports the ID-number of a turtle in the patch that is (dx, dy) units away from the caller. The specific turtle is chosen at random. If there are several turtles in the patch, an arbitrary (other) turtle is picked. If there are no turtles in the indicated patch, it reports -1.

NOTE: The observer behaves as if it were located at (0, 0).


one-of-turtles-here
Turtle CommandPatch Command

Reports the ID-number of another turtle on the same patch. If there are several turtles on the patch, an arbitrary (other) turtle is picked.If there are no turtles in the patch, it reports -1.


one-of-turtles-with
Turtle CommandPatch CommandObserver Command
one-of-turtles-with [condition]

Reports the ID-number of a random turtle that satisfies condition.If there are no turtles for which condition is true, this reports -1.

Example:
one-of-turtles-with [color = blue]
;would report the ID-number of a random blue turtle besides myself.


open-movie
setup-movie
Observer Command
open-movie file-name
setup-movie file-name

Sets up StarLogoT to create a new movie called file-name. The movie is created in PICS format.

Example:
;creates a movie file in the current directory.
;note that the filename needs the | characters
;around it because it contains a space
open-movie "|My Movie|


or
Turtle CommandPatch CommandObserver Command
condition1 or condition2

Reports true if either condition1 or condition2 evaluates to true.

Example:
if (xcor > 0) or (ycor > 0) [setpc red]
;All patches turn red, except those
;in the lower-left quadrant.


oset<TURTLE-VARIABLE>-of
Observer Command
oset<TURTLE-VARIABLE>-of ID-number numerical-expression

Observer sets the value of <TURTLE-VARIABLE> for the turtle with the given ID-number, to numerical-expression.

Example:
;Suppose my turtle variable was called "chemical". I could say:
osetchemical-of 5 25
;Where the observer sets the chemical variable of turtle with ID-number 5, to 25.


oset<VARIABLE>-at
Observer Command
oset<VARIABLE>-at dx dy numerical-expression

Observer sets the <VARIABLE> of the patch at some given location, to numercial-expression.

Example:
;Suppose my patch variable was called "shade". I could say:
osetshade-at 0 0 25


osetbreed-at
Observer Command
osetbreed-at xcor ycor breed-name

Used by the observer to set the breed of all turtles at (xcor, ycor) to breed-name.


osetbreed-of
Observer Command
osetbreed-of ID-number breed-name

Used by the observer to set the breed of the turtle with the given ID-number to breed-name.


osetc-of
Observer Command
osetc-of ID-number numerical-expression

Used by the observer to set the color of the turtle with the given ID-number to numerical-expression.


oseth-of
Observer Command
oseth-of ID-number expression

Used by the observer to set the heading of the turtle with the given ID-number to expression.


osetpc-at
Observer Command
osetpc-at xcor ycor numerical-expression

Used by the observer to set the color of patch at (xcor, ycor) to numerical-expression.


osetshape-at
Observer Command
osetshape-at xcor ycor shape

Used by the observer to set the shape of all turtles at (xcor, ycor) to name.

shape can be either a name or a number.


osetshape-of
Observer Command
osetshape-of ID-number shape

Used by the observer to set the shape of the turtle with the given ID-number to shape.

shape can be either a name or a number.


osetx-of
Observer Command
osetx-of ID-number xcor

Used by the observer to set the x-coordinate of the turtle with the given ID-number to xcor.


osetxy-of
Observer Command
osetxy-of ID-number xcor ycor

Used by the observer to set the x- and y-coordinates of the turtle with the given ID-number to (xcor, ycor).


osety-of
Observer Command
osety-of ID-number ycor

Used by the observer to set the y-coordinate of the turtle with the given ID-number to ycor.


output
Turtle CommandPatch CommandObserver Command
output thing

Does a non-local exit from the current procedure and returns thing to the caller. Useful for defining short procedures and monitor commands.

Note: You cannot call output from the command center. You can use it only within procedures.

See: show


patchcolor
pc
Turtle CommandPatch Command

Reports the color of a patch.

Example:
if pc = white [fd 20]
;All turtles on top of white patches
;move forward 20 steps.if pc = red [setpc blue];All red patches turn blue.


pc
Patch Command

See: patchcolor


pc-at
Turtle CommandPatch CommandObserver Command
pc-at dx dy

Reports the color of the patch (dx, dy) units away from the caller.

NOTE: The observer behaves as if it were located at (0, 0).


pc-count

See: count-pc


pd
Turtle Command

See: pendown


pen-down?
Turtle Command

Reports true if the turtle's pen is down and false if it is up.


pen-down?-of
Observer Command
pen-down?-of ID-number

Reports true if the given turtle's pen is down and false if it is up.


pendown
pd
Turtle Command

Turtles put down their pens, so that they draw (leaving a trail) when they move. Turtles draw by changing the color of the patches underneath them to their own color. To change the color of the turtle's pen (and the color of the turtle itself), use setc.

Note: When a turtle's pen is down, only forward or back will draw a line.


penup
pu
Turtle Command

Turtles lift up their pens, so that the they don't draw when they move.


pi
Turtle CommandPatch CommandObserver Command

Returns 3.14159


plot
Observer Command
plot y-value

Plots a point at y-value, then increments the x-value of the plot pen by ppinterval.The pen will keep plotting off the end of the current graph when it reaches plot-xmax.

See: ppinterval


plot-pen1
plot-pen2
plot-pen3
plot-pen4
plot-pen5
plot-pen6
pp1
pp2
pp3
pp4
pp5
pp6
Observer Command

Plot-pen1 selects plot pen number 1. Subsequent plotting commands are executed by plot pen 1.

Similarly, the commands plot-pen2 through plot-pen6 select the other plot pens.

Each plotwindow has its own pp1 through pp6.


plot-pencolor
ppc
Observer Command

Reports the color of the current plot-pen.


plot-pendown
ppd
Observer Command

Puts down the current plot-pen, so that it draws connected graphs.


plot-penreset
ppreset
Observer Command

Clears everything this plot pen has drawn and resets its position to (0, 0).


plot-penup
ppu
Observer Command

Lifts up the plot pen, so that it plots points individually (not connected).


plot-point
Observer Command
plot-point x y

Plots a line that connects the current position of the plot pen to the point with coordinates (x, y).

plot-point is useful for creating state-space plots.


plot-xmax

See: plot-xmin


plot-xmin
plot-xmax
plot-ymin
plot-ymax
Observer Command

Reports the minimum and maximum values of the visible axes on the current plot.

These values can be set with the commands setplot-xrange and setplot-yrange.


plot-ymax

See: plot-xmin


plot-ymin

See: plot-xmin


plotwindow1
plotwindow2
plotwindow3
plotwindow4
plotwindow5
plotwindow6
pw1
pw2
pw3
pw4
pw5
pw6
Observer Command

Plotwindow1 selects plotwindow number 1. Subsequent plotting commands are executed in plotwindow 1. Each plotwindow comes with its own 6 plot-pens, pp1 through pp6.

Similarly, the commands plotwindow2 through plotwindow6 select the other plotwindows.


position
Observer Command
position item data

Reports the first position of item in data; if item is not in the data, then it reports false.


pp-plotlist
Observer Command

Reports the entire list of data points plotted by the 'plot' command by the current plotpen (pp) in the current plotwindow (pw).

Example:
show list-max pp-plotlist
;Prints the maximum value of the current pen executing 'plot';commands in the current plotwindow.


pp-plotpointlist
Observer Command

Reports the entire list of data points plotted by the 'plot-point' command by the current plotpen (pp) in the current plotwindow (pw).

Example:
show list-min pp-plotpointlist
;Prints the minimum value of the current pen executing 'plot-point';commands in the current plotwindow.


pp1
pp2
pp3
pp4
pp5
pp6

See: plot-pen1


ppd

See: plot-pendown


ppinterval
Observer Command

Reports the x distance that the plot pen moves after a plot command. You can make the plot pen move less than a pixel or jump many pixels.


ppu

See: plot-penup


ppxcor
Observer Command

Reports the x-coordinate of the plot pen.


ppycor
Observer Command

Reports the y-coordinate of the plot pen.


print
Observer Command
print "thing

Prints thing in the output window followed by a carriage return.

If you want to print a string with special characters (like a space), enclose the string in vertical bars (e.g. print "|Hello|).


project-directory
Observer Command

Reports the directory where the current project is located. If there is no named project, then it reports false.


project-name
Observer Command

Reports the current project file name without the pathname. If there is no named project, then it reports false.


project-pathname
Observer Command

Reports the current project file pathname. If there is no named project, then it reports false.


pset<TURTLE-VARIABLE>-at
Turtle Command
pset<TURTLE-VARIABLE>-at dx dy numeric-expression

The patch sets the value of <TURTLE-VARIABLE> for a turtle (x,y) units away, to expression.

Example:
;Suppose my turtle variable was called "chemical". I could say:
psetchemical-at 1 1 25
;Where the patch sets the chemical variable of the turtle (1,1) units away to 25.


pset<TURTLE-VARIABLE>-of
Turtle Command
pset<TURTLE-VARIABLE>-of ID-number numeric-expression

The patch sets the value of the <TURTLE-VARIABLE> for the turtle with the given ID-number, to expression.

Example:
;Suppose my turtle variable was called "chemical". I could say:
psetchemical-of 3 25
;Where the patch sets the chemical variable of turtle 3, to 25.


pset<VARIABLE>
Observer Command
pset<VARIABLE> numerical-expression

The patch sets the value of <VARIABLE> to numerical-expression.

Example:
;Suppose my observer variable was called "pollution". I could say:
psetpollution 10
;Which means that the patch sets the "pollution" variable to 10.


psetbreed
Patch Command
psetbreed breed-name

Used by the patch to set the breed of all of the turtles on top of it to breed-name.


psetbreed-at
Patch Command
psetbreed-at dx dy breed-name

Used by the patch to set the breed of all turtles in the patch (dx, dy) units away from it to breed-name.


psetbreed-of
Patch Command
psetbreed-of ID-number breed-name

Used by the patch to set the breed of the turtle with the given ID-number to breed-name.


psetshape
Patch Command
psetshape shape

Used by the patch to set the shape of all of the turtles on top of it to shape.

shape can be either a name or a number.


psetshape-at
Patch Command
psetshape-at dx dy shape

Used by the patch to set the shape of all turtles on the patch (dx, dy) away from it to shape.

shape can be either a name or a number.


psetshape-of
Patch Command
psetshape-of ID-number shape

Used by the patch to set the shape of turtle with the given ID-number to shape.

shape can be either a name or a number.


pstamp
Patch Command
pstamp color

Used by a patch to set the color of all turtles on itself to color.

color can be either a name or a number.


pstamp-at
Patch Command
pstamp-at dx dy color

Used by a patch to set the color of all turtles in the patch (dx, dy) units away to color.

color can be either a name or a number.


pu
Turtle Command

See: penup


pw1
pw2
pw3
pw4
pw5
pw6

See: plotwindow1


random
Turtle CommandPatch CommandObserver Command
random number

Reports a random integer uniformly-distributed between 0 and number, including 0 but excluding number.

If the observer calls random and number is a floating-point number, the return value will be floating-point.

Example:
crt (random 500)
;creates between 0 and 499 new turtles


random-exponential
Observer Command
random-exponential number

Reports a random floating-point number exponentially-distributed with mean number.


random-exponential-list
Observer Command
random-exponential-list number1 number2

Reports a list of number2 random numbers, each exponentially-distributed with mean number1.


random-normal
Observer Command
random-normal number1 number2

Reports a random number normally-distributed with mean number1 and standard deviation number2.


random-normal-list
Observer Command
random-normal-list number1 number2 number3

Reports a list of number3 random numbers, each normally-distributed with mean number1 and standard deviation number2.


random-poisson
Observer Command
random-poisson number

Reports a random integer distributed according to the Poisson distribution with mean number.


random-poisson-list
Observer Command
random-poisson-list number1 number2

Reports a list of number2 random integers, each distributed according to the Poisson distribution with mean number1.


random-seed-a
Observer Command

Reports the current value of one of the three seeds used in picking pseudo-random numbers. Seeds a and b are used by turtles and patches, while the observer seed is used by the observer for all random functions except random itself.


random-seed-b

See: random-seed-a


random-seed-observer

See: random-seed-a


random-uniform
Observer Command
random-uniform number

Reports a random number uniformly-distributed within the range 0 <= n < number.

If number is an integer, the number returned will also be an integer. Otherwise it will be a real number.


random-uniform-list
Observer Command
random-uniform-list number1 number2

Reports a list of number2 random numbers, each uniformly-distributed within the range 0 <= n < number. If number is an integer, the number returned will also be an integer. Otherwise, it will be a real number.


readlist
Observer Command
readlist thing

Opens a text window with thing displayed inside, prompting the user for input. Whatever the user types is returned as a list of separate words.


remove
Observer Command
remove item data

Reports a data with all instances of item in the list removed.


remove-duplicates
Observer Command
remove-duplicates data

Reports a data with all duplicate items in the list removed. The first instance of each item remains in place.


repeat
Turtle CommandPatch CommandObserver Command
repeat number [commands]

Runs the list of commands number times.

Example:
pd repeat 36 [fd 1 rt 10]
;Each turtle draws a circle.


reset-timer
Observer Command

Resets the global clock to zero.


resett

See: reset-timer


right
Turtle Command
rt number

Turtles turn right by number degrees.


rotate-left
Turtle CommandPatch CommandObserver Command
number1 rotate-left number2

Reports number1 rotated to the left number2 bits.


rotate-right
Turtle CommandPatch CommandObserver Command
number1 rotate-right number2

Reports number1 rotated to the right number2 bits.

See: shift-left


round
Turtle CommandPatch CommandObserver Command
round number

Reports the integer nearest to number. If the decimal portion of number is exactly .5,rounds to the nearest even integer.

Example:
show round -4.5
;Prints -4 to the command center.
show round 5.5
;Prints 6 to the command center.


rt
Turtle Command

See: right


save-pict
Observer Command
save-pict filename

Saves the current graphics screen to the file filename.


save-project
Observer Command

Saves the current project to the file. Equivalent to command-S or choosing the "Save Project" menu item.


scale-color
Turtle Command
scale-color color variable number1 number2

Sets the color of each turtle to a shade of color proportional to its value of variable.

If number1 is less than number2, then the larger the variable, the lighter the shade of color.

If variable is less than number1, then the darkest shade of color is chosen.

If variable is greater than number2, then the lightest shade of color is chosen.

If number2 is less than number1, the color scaling is inverted.

Example:
scale-color red age 0 50
;Colors each turtle a shade of red
;proportional to its value for the variable age.


scale-pc
scale-patch-color
Patch Command
scale-pc color variable number1 number2

Sets the color of each patch to a shade of color proportional to its value of variable.

If number1 is less than number2, then the larger the variable, the lighter the shade of color.

If variable is less than number1,then the darkest shade of color is chosen.

If variable is greater than number2,then the lightest shade of color is chosen.

If number2 is less than number1, the color scaling is inverted.

Example:
scale-pc green chemical 0 50
;Colors each patch a shade of green proportional to its value for the variable chemical.


screen-edge

See: screen-edge-x


screen-edge-x
screen-edge-y
Turtle CommandPatch CommandObserver Command

The screen-edge reporters give the maximum x-coordinate and maximum y-coordinate (respectively) of the StarLogoT world. If the graphics window is square, screen-edge applies to both x and y.

You can change the size of the StarLogoT world using the Settings... dialog in the Edit menu.

Note: screen-edge is the "half-width" of the StarLogoT world -- the distance from the origin to the edge.
Screen-size is the same as ((2 * screen-edge) + 1).

Example:
crt 100setxy (random screen-edge-x) (random screen-edge-y);distributes 100 turtles randomly in the first quadrant.


screen-edge-y

See: screen-edge-x


screen-size

See: screen-size-x


screen-size-x
Turtle CommandPatch CommandObserver Command

The screen-size reporters give the width and height of the StarLogoT world. If the graphics window is square, screen-size applies to both x and y.

You can change the size of the StarLogoT world using the Settings... dialog in the Edit menu.

Note: screen-edge is the "half-width" of the StarLogoT world.
Screen-size is the same as ((2 * screen-edge) + 1).


screen-size-y

See: screen-size-x


sentence
se
Observer Command
sentence anything1 anything2
se anything1 anything2

Reports a new list composed of elements of anything1 and anything2.

If either of the inputs are data lists, sentence will concatenate the two inputs together to form a new data list. If none of the inputs are data lists, sentence behaves like the list command.


set<ARRAY-VARIABLE>-ref
Turtle CommandPatch CommandObserver Command
set<ARRAY-VARIABLE>-ref index value

Sets the ith(index) value in <ARRAY-VARIABLE> to value.

Example:
setarray-ref 0 random 100 ;; sets the first value
;; in array to random 100.


set<ARRAY-VARIABLE>-ref-at
Turtle CommandPatch CommandObserver Command
set<ARRAY-VARIABLE>-ref-at index x y value

Sets the ith(index) value in <ARRAY-VARIABLE> of the turtle or patch that is (x, y) units away from the caller to value.

NOTE: The observer behaves as if it were located at (0, 0).

Example:
setarray-ref 0 0 1 random 100 ;; sets the first value
;; in array of the turtle directly
;; above this turtle to random 100.


set<ARRAY-VARIABLE>-ref-of
Turtle CommandPatch CommandObserver Command
set<ARRAY-VARIABLE>-ref-of index who value

Sets the ith(index) value in <ARRAY-VARIABLE> of turtle with the turtle id who to value.

Example:
setarray-ref 0 one-of-turtles random 100 ;; sets the first value
;; in array of a random turtle to random 100.


set<SLIDER-VARIABLE>-inc
Observer Command
set<SLIDER-VARIABLE>-inc number

Set the value of the SLIDER-VARIABLE's current increment value. This can also be done in the slider editor box.

Example:
;Suppose my slider variable was called "range". I could say:
setrange-inc 2
;Where the observer sets the increment value of range to 2.


set<SLIDER-VARIABLE>-max
Observer Command
set<SLIDER-VARIABLE>-max number

Observer sets the value of SLIDER-VARIABLE's current max value. This can also be done in the slider editor box.

Example:
;Suppose my slider variable was called "range". I could say:
setrange-max 30
;Where the observer sets the max value of range to 30.


set<SLIDER-VARIABLE>-min
Observer Command
set<SLIDER-VARIABLE>-min number

Observer sets the value of SLIDER-VARIABLE's current min value. This can also be done in the slider editor box.

Example:
;Suppose my slider variable was called "range". I could say:
setrange-min 1
;Where the observer sets the min value of range to 30.


set<TURTLE-VARIABLE>-of
Turtle Command
set<TURTLE-VARIABLE>-of ID-Number number

Sets the TURTLE-VARIABLE of the turtle with the given ID-number to some value.

Example:
;Suppose my turtle variable was called "chemical". I could say:
setchemical-of 61 25
;Which sets the chemical variable of the turtle with an ID-number of 61 to 25


set<VARIABLE>
Turtle CommandPatch CommandObserver Command
set<VARIABLE> numeric-expression

Evaluates numeric-expression and sets VARIABLE to the result.

VARIABLE can be any valid variable identifier for turtles, patches, observers or sliders.

Example:
;set the value of the variable called chemical to zero
setchemical 0


set<VARIABLE>-at
Turtle CommandPatch Command
set<VARIABLE>-at dx dy numeric-expression

Evaluates numeric-expression and assigns its value to VARIABLE for a turtle or patch that is (dx, dy) units away.

NOTE: The observer behaves as if it were located at (0, 0).

Example:
;Suppose my turtle variable was called "chemical". I could say:
setchemical-at 1 1 25
;Which gives a value of 25 to "chemical" variable of the turtle that is (1,1) away from the turtle executing this command.


set<VARIABLE>-color
Observer Command
set<VARIABLE>-color color

Sets the textbox's color to the given color.

Example:
;Suppose my textbox name was "trees". I could say:
settrees-color brown
;Which sets the color of the textbox to brown.


set<VARIABLE>-text
Observer Command
set<VARIABLE>-text string

Sets the text displayed inside the textbox to the given string. Note the quotation marks.

Example:
;Suppose the name of my textbox is "trees". I could say:
settrees-text "hello"
;Which sets the text to the string "hello".


set<VARIABLE>-textcolor
Observer Command
set<VARIABLE>-textcolor color

Sets the color of the text in the textbox named VARIABLE to the given color.

Example:
;Suppose my textbox name was "trees". I could say:
settrees-textcolor green
;Which sets the text within the textbox to the color green.


set-output-filename
Observer Command

Sets the file where the StarLogoT output window is saved (when you execute the export-output command). Set-output-filename does not take any inputs; it pops up a dialog box in which you can write the filename.


set-project-filename
Observer Command
set-project-filename filename

Sets the current project's name to filename.


set-random-seed-a
Observer Command
set-random-seed-[a, b, observer] number

Sets one of the seeds used in picking pseudo-random numbers to number.

Random-seed-a and random-seed-b are used for selecting turtle and patch pseudo-random numbers, while random-seed-observer is used in selecting pseudo-random numbers for the observer (with the exception of the random primitive).


set-random-seed-b

See: set-random-seed-a


set-random-seed-observer

See: set-random-seed-a


setbreed
Turtle Command
setbreed number
setbreed breed-name

Sets the turtle's BREED to number. You can also specify a breed-name, as in:

Example:
crt 500
setbreed red-ants
;creates 500 turtles of breed type 'red-ants'.


setbreed-at
Turtle Command
setbreed-at dx dy number
setbreed-at dx dy breed-name

Used by a turtle to set the breed of all turtles on the patch (dx, dy) away from it to number or breed-name.


setbreed-of
Turtle Command
setbreed-of ID-number number
setbreed-of ID-number breed-name

Used by a turtle to set the breed of the turtle with the given ID-number to number or breed-name.


setc
Turtle Command

See: setcolor


setc-at
Turtle Command
setc-at dx dy color

Used by a turtle to set the color of all turtles in the patch (dx, dy) units away from it to color.


setc-of
Turtle Command
setc-of ID-number color

Sets the color of the turtle with the given ID-number to color.


setcolor
Turtle Command
setcolor color

Sets a turtle's color to color.

Example:
if xcor < 0 [setc red]
;Each turtle left of the center turns red


seth
Turtle Command

See: setheading


seth-of
Turtle Command
seth-of ID-number number

Sets the heading of the turtle with the given ID-number to number.


setheading
seth
Turtle Command
setheading number

Sets the turtle's heading in degrees to number. A heading of 0 is straight up.


sethist-color
Observer Command
sethist-color color

Sets the color of the histogram bars in the current plot window.


sethist-num-bars
Observer Command
sethist-num-bars number

Sets the number of histogram bars in the current plot window.

NOTE: For exact results (a bar graph), make sure that hist-num-bars equals the number of plottable values in your histogram.

If the number of bars in the histogram does not equal the number of plottable values in the histogram, StarlogoT will try to distribute values evenly between the bars. Specifically, StarlogoT will set the width of each bar to the total x-axis range / the number of bars in the histogram. Each bar will then calculate its magnitude by including the value at its left-most point, and excluding the value at its right-most point. For example, a bar that spans from 0 to 2 will include the value at 0 in its magnitude, but exclude the value at 2.

Example:
;If you plan to plot integers from -5 to 5 (inclusive):
sethist-xrange -5 6
sethist-num-bars 11 ; (remember, there's a bar at x = 0, but no bar at x = 6)

;Or, if you plan to plot values from 0 to 1 (inclusive) accurate to 1 decimal point:
sethist-xrange 0 1.1
sethist-num-bars 11


sethist-xrange
Observer Command
sethist-xrange min max

This is an alias for setplot-xrange.

NOTE: Min will be included in the histogram range, but max will not.

Example:
sethist-xrange 0 26
histogram-turtles [speed] ; assume speed is an integer variable
;This creates a histogram of turtles
;with speeds between 0 and 25 (inclusive).

See: setplot-xrange


sethist-yrange
Observer Command
sethist-yrange min max

This is an alias for setplot-yrange.

See: setplot-yrange


setpatchcolor
setpc
Patch Command
setpatchcolor color

Sets patch's color to color.

Example:
setpc green
;Each patch turns green.


setpc
Patch Command

See: setpatchcolor


setpc-at
Patch Command
setpc-at dx dy color

Used by a patch to set the color of the patch (dx, dy) units away from it to color.

Note: While StarLogoT is a parallel language, it is not executing on a parallel computer. Do not use setpc-at to set the patch color to another patch's color. (i.e. setpc-at 4 4 pc). If you want to do this, use a temporary variable.


setpen-name
Observer Command
setpen-name name

Names the current plot pen. Setting a plot's name will cause the plot-legend window to appear when the pen's parent plot-window is active.

Example:
setpen-name "Photons


setplot-pencolor
setppc
Observer Command
setplot-pencolor color
setppc color

Sets the color of the plot pen to color.


setplot-xlabel
setplot-ylabel
Observer Command
setplot-xlabel label
setplot-ylabel label

Labels the axes of the current plot window.

Example:
;sets the label on the x-axis of the current plot window to "Time"
setplot-xlabel "Time


setplot-xrange
setplot-yrange
Observer Command
setplot-xrange min max
setplot-yrange min max

Sets the minimum and maximum values of the visible axes of the current plot.


setplot-ylabel

See: setplot-xlabel


setplot-yrange

See: setplot-xrange


setplotwindow-name
setpw-name
Observer Command
setplotwindow-name title
setpw-name title

Puts the title at the top of the current plotwindow. Note the use of | | to preserve spaces.

Example:
setpw-name "|Population Over Time|


setppc

See: setplot-pencolor


setppinterval
Observer Command
setppinterval number

Tells the plot pen to move a distance of number in the x direction after each plot command.


setpw-name

See: setplotwindow-name


setscreen-size
Observer Command
setscreen-size x-size y-size

Sets the StarLogoT screen-size to x-size and y-size, turning off all forever buttons and recompiling.


setscreen-size-x
Observer Command
setscreen-size-x number

Sets the StarLogoT screen-size-x to number, turning off all forever buttons and recompiling.


setscreen-size-y
Observer Command
setscreen-size-y number

Sets the StarLogoT screen-size-y to number, turning off all forever buttons and recompiling.


setshape
Turtle Command
setshape number
setshape shape-name

Sets the turtle's shape to number or shape-name. Find or make shapes using the toolbar. Note that turtle shapes are only visible if the patch size is greater than 4x4.

Example:
setshape duck-shape
;sets the turtle's shape to "duck-shape".


setshape-at
Turtle Command
setshape-at dx dy number
setshape-at dx dy shape-name

Used by a turtle to set the shape of all turtles on the patch (dx, dy) away from it to number or shape-name.


setshape-of
Turtle Command
setshape-of ID-number number
setshape-of ID-number shape-name

Used by the turtle to set the shape of turtle with the given ID-number to number or shape-name.


setup-movie

See: open-movie


setx-of
Turtle Command
setx-of ID-number xcor

Sets the xcor of the turtle with the given ID-number.


setxcor
setx
Turtle Command
setxcor number

Turtles set their x-coordinate to number.


setxy
Turtle Command
setxy number 1 number2

Turtles set their x-coordinate to number1 and set their y-coordinate to number2.

Example:
setxy 0 0
;All turtles move to
;the center of the screen.


setxy-of
Turtle Command
setxy-of ID-number xcor ycor

Sets the xcor and ycor of the turtle with the given ID-number.

Example:
setxy-of 25 0 0
;Turtle with ID-number of 25 moves to
;the center of the screen.


sety-of
Turtle Command
sety-of ID-number ycor

Sets the ycor of the turtle with the given ID-number.


setycor
sety
Turtle Command
setycor number

Turtles set their y-coordinate to number.


shape
Turtle CommandPatch Command

Reports the shape of the turtle, as a number.


shape-at
Turtle CommandPatch CommandObserver Command
shape-at dx dy

Reports the shape of any turtle in the patch (dx, dy) units away from the caller. Remember, the observer acts as if it were located at (0, 0).

If there are no turtles in that patch, it reports 0.

NOTE: The observer behaves as if it were located at (0, 0).


shape-of
Turtle CommandPatch CommandObserver Command
shape-of ID-number

Reports the shape of the turtle with the given ID-number.


shift-left
Turtle CommandPatch CommandObserver Command
number1 shift-left number2

Reports number1 shifted to the left number2 bits. In other words, number1 multiplied by 2 to the number2th power. Note that shift-left is "infix" -- it comes between its two inputs.

Example:
show 15 shift-left 2
;Prints 60 to the command center.


shift-right
Turtle CommandPatch CommandObserver Command
number1 shift-right number2

Reports number1 shifted to the right number2 bits. In other words, number1 divided by 2 to the number2th power. Note that shift-right is "infix" -- it comes between its two inputs.

Example:
show 15 shift-right 2
;Prints 3.75 to the command center.


show
Observer Command
show thing

Prints thing in the command center, followed by a carriage return.

Example:
show clock 2
;Prints the current value of the global variable "clock" in the command center.
show (3 = 4)
;Evaluates the expression as false and prints 1 in the command center.


showturtle
st
Turtle Command

Turtles make themselves visible.

See: hideturtle


sin
Turtle CommandPatch CommandObserver Command
sin angle

Reports the sine of angle. Assumes angle is given in degrees.


snapshot
Observer Command

Captures a frame in the current movie, when the open-movie command has been executed.


sprout
Patch Command
sprout [ commands ]

Creates a turtle which runs the list of commands. The turtle's heading is 0. To get a turtle to do this, use "hatch".

Note: While executing these commands, the newly hatched turtle will not run forever buttons.

Example:
if ycor = 12 [sprout [setcolor blue fd random 10]]
;Each patch for which ycor = 12
;creates a new turtle that sets its color to blue and
;moves forward a random amount from 0 to 9.


sqrt
Turtle CommandPatch CommandObserver Command
sqrt number

Reports the square root of number.


stamp
Turtle Command
stamp color

Sets the color of the patch under the turtle to the given color.

Example:
crt 1 repeat 30 [stamp yellow fd 3 rt 6]
;A turtle records its arched path. Compare this to "pendown".


stamp-at
Turtle Command
stamp-at dx dy color

Used by a turtle to set the color of the patch (dx, dy) units away from it to color.


standard-deviation
Observer Command
standard-deviation [ data ]

Reports the statistical standard deviation of the numeric elements of a list of data. Ignores non-numeric elements. The standard deviation is the square root of the variance of the list.

Example:
show standard-deviation [1 4 10]
;Prints 4.5826 to the command center.


starlogo-directory
Observer Command

Reports the directory where the StarLogoT application is located.


stop
Turtle CommandPatch CommandObserver Command

Exits immediately from the current procedure.

Note: You cannot call stop from the command center.


stop<BUTTON-NAME>
Turtle CommandPatch CommandObserver Command

Stops the execution of the "forever" button with the specified <BUTTON-NAME>.

Note: You must use the button's name, which is not necessarily the same as the text displayed on the button's face. Remember that a button can display either its name or the instruction it executes.

Note: This command only suspends the button's "forever" loop, thus preventing the button from executing its instruction another time. However, it does not terminate the current execution of the button's instruction. For that, you must use the stop command.

Example:
to go
if (count = 100) [
stopbutton1
stop ; count ends at 100
]
setcount 1 + count
end

to go
setcount 1 + count
if (count = 100) [
stopbutton1 ; count ends at 100
]
end

See: stop


sum-of-<BREED>
Turtle CommandObserver Command
sum-of-<BREED> [numerical-expression]

Reports the total sum of the given expression over all turtles of breed type <BREED>.

Example:
;Suppose the name of my breed was "sheep", and I had declared a sheep-variable called "energy". I could say:
sum-of-sheep [energy]
;Which would report the added sum over all "sheep" for the variable "energy".


sum-of-<BREED>-with
Turtle CommandObserver Command
sum-of-<BREED>-with [condition] [numerical-expression]

Reports the total sum of the given expression over all turtles of breed type <BREED> for whom the given condition is true.

Example:
;Suppose the name of my breed was "sheep", and I had declared sheep-variables called "energy" and "age". I could say:
sum-of-sheep-with [age = 12] [energy]
;Which would report the added sum over all "sheep" of age 12 for the variable "energy".


sum-of-patches
Observer Command
sum-of-patches [numerical-expression]

Reports the total value of the expression over the patches.

Example:
show sum-of-patches [heat * speed]
;Prints the sum over all patches for
;the patch expression heat * speed.


sum-of-turtles
Turtle CommandObserver Command
sum-of-turtles [numerical-expression]

Reports the total value of the expression over all turtles. Make sure this value does not exceed 32,678.


sum-of-turtles-with
Turtle CommandObserver Command
sum-of-turtles-with [condition ] [numerical-expression]

Reports the total value of the given expression when run over the turtles for which the condition is true. If there are no turtles in which the condition is true, this reports 0.


tan
Turtle CommandPatch CommandObserver Command
tan angle

Reports the tangent of angle. Assumes angle is given in degrees.


timer
Observer Command

Prints current value of the global clock since the last reset-timer, in seconds.


towards
Turtle Command
towards xcor ycor

Reports the direction from the turtle towards the point (xcor, ycor).

If the wrapped distance (around the edges of the screen) is shorter than the on-screen distance, towards will report the direction of the wrapped path.


towards-nowrap
Turtle Command
towards-nowrap xcor ycor

Reports the direction from the turtle towards the point (xcor, ycor).

If the wrapped distance (around the edges of the screen) is shorter than the on-screen distance, towards-nowrap will report the direction of the on-screen path.


true
Turtle CommandPatch CommandObserver Command

This is the boolean value of "true". Currently in StarLogoT, true = 0. This may change in future versions or in N-Logo, so it is best to use "true" and false" rather than numerical values.

Example:
;suppose each turtle has a variable called "happy?"
ifelse (happy? = true) [setc green] [setc blue]
;turns happy turtles green and non-happy turtles blue


tset<VARIABLE>
Patch CommandObserver Command
tset<VARIABLE> numerical-expression

If <VARIABLE> is a patch variable, then the turtle sets the <VARIABLE> of the patch underneath it to numerical-expression. If <VARIABLE> is an observer variable, then the turtle sets <VARIABLE> to numerical-expression.

The "t" in "tset" is needed when you want turtles do do something with a patch or observer variable.

Example:
;Suppose my patch variable was called "shade". I could say:
tsetshade 5
;Which means that the turtle sets the patch variable shade underneath it to 5.


tset<VARIABLE>-at
Patch Command
tset<VARIABLE>-at dx dy numerical-expression

Turtle sets the <VARIABLE> of the patch a distance (dx, dy) away from the turtle.

Example:
;Suppose my patch variable was called "shade". I could say:
tsetshade-at 0 1 25;Which means that each turtle sets the patch variable shade on the patch above it to 25.


turtle-at
Turtle Command

See: one-of-turtles-at


turtle-here
Turtle Command

See: one-of-turtles-here


turtles-at
Turtle Command

See: count-turtles-at


turtles-here
Turtle Command

See: count-turtles-here


type
Observer Command
type thing

Prints thing in the output window without a carriage return.

If you want to type a string with special characters (like a space), enclose the string in vertical bars.

Example:
type "|Number of turtles: | type count-turtles
;Prints Number of turtles: 247 in the output window


uphill
Turtle Command
uphill patch-variable

Reports the turtle heading (between 0 and 359 degrees) in the direction of the maximum value of patch-variable, in the eight patches directly surrounding the turtle.

Note that patch-variable must be declared in the 'patches-own' list.

Example:
seth uphill chemical
;Each turtle sets its heading in the direction of the
;patch with the greatest value of the 'chemical' variable,
;over the eight surrounding patches.


uphill4
Turtle Command
uphill4 patch-variable

Reports the turtle heading (between 0 and 359 degrees) in the direction of the maximum value of patch-variable, in the four patches directly above, below, to the left, and to the right of the turtle.

Note that patch-variable must be declared in the 'patches-own' list.

Example:
seth uphill4 chemical
;Each turtle sets its heading in the direction of the
;patch with the greatest value of the 'chemical' variable,
;over the four patches in the cardinal directions.


variance
Observer Command
variance [ data ]

Reports the statistical variance of the numeric elements of the list of data. Ignores non-numeric elements. The variance is the sum of the squared deviation of each element from the mean, divided by the number of elements minus one.

Example:
show variance [1 4 10]
;Prints 21 to the command center.


wait
Turtle CommandObserver Command
wait number

Waits for number seconds.


who
Turtle Command

Reports the ID-number of the turtle.

Example:
if who < 50 [setc blue]
;all turtles whose ID numbers
;are less than 50 turn blue


who-max-of-<BREED>
Turtle CommandObserver Command
who-max-of-<BREED> [numerical-expression]

Reports the ID-number of the turtle of the breed type <BREED> that has the maximum value of the given expression.

Example:
;Suppose the name of my breed was "bluecar", I could say:
who-max-of-bluecar [speed]
;Which would report the ID-number of the "bluecar" that has
;the highest "speed".


who-max-of-<BREED>-with
Turtle CommandObserver Command
who-max-of-<BREED>-with [ condition ] [numerical-expression]

Reports the ID-number of the turtle of the breed type <BREED>,for which the given condition is true, that has the maximum value of the given expression.

Example:
;Suppose the name of my breed was "worker-ants", I could say:
who-max-of-worker-ants-with [(distance-to-nest > 10)] [food]
;Which would report the ID-number of the "worker-ant" more than 10 away from the next,that has the most "food".


who-max-of-turtles
Turtle CommandObserver Command
who-max-of-turtles [numerical-expression]

Reports the ID-number of the turtle with the maximum value of the given expression.

Example:
show who-max-of-turtles [stuff]
;Prints the ID-number of the turtle
;with the maximum value of "stuff".


who-max-of-turtles-with
Turtle CommandObserver Command
who-max-of-turtles-with [ condition ] [numerical-expression]

Reports the ID-number of the turtle with the maximum value of the given expression when run over all turtles for which the condition is true. If there are no turtles for which the condition is true, this reports -1.


who-min-of-<BREED>
Turtle CommandObserver Command
who-min-of-<BREED> [numerical-expression]

Reports the ID-number of the turtle with the breed type <BREED> who has the minimum value of the given expression.


who-min-of-<BREED>-with
Turtle CommandObserver Command
who-min-of-<BREED>-with [ condition ] [numerical-expression]

Reports the ID-number of the turtle with the breed type <BREED>, for which the given condition is true, that has the minimum value of the given expression.


who-min-of-turtles
Turtle CommandObserver Command
who-min-of-turtles [numerical-expression]

Reports the ID-number of the turtle with the minimum value of the given expression.

Example:
show who-min-of-turtles [stuff]
;Prints the ID-number of the turtle
;with the minimum value of "stuff".


who-min-of-turtles-with
Turtle CommandObserver Command
who-min-of-turtles-with [ condition ] [numerical-expression]

Reports the ID-number of the turtle with the minumum value of the given expression when run over all turtles for which the condition is true. If there are no turtles for which the condition is true, this reports -1.


word
Observer Command
word thing1 thing2

Concatenates the two inputs together and returns the result as a symbol.

Example:
word "a "b
;Returns the symbol ab

Example:
load-pict (word project-directory "traffic.pict) test
;Loads the picture "traffic.pict" (which is in the current
;project's directory) into patch variable "test".)


xcor
Turtle CommandPatch Command

Reports the x-coordinate of a turtle or a patch.

Example:
setweight xcor
;Turtles set their weight variable
;equal to their x-coordinate.
setpc xcor
;Each patch sets its color
;equal to its x-coordinate.


xcor-of
Turtle CommandPatch CommandObserver Command
xcor-of ID-number

Reports the x-coordinate of the turtle with the given ID-number.


xor
Turtle CommandPatch CommandObserver Command
boolean1 xor boolean2

Reports the value of boolean1 xor boolean2.


ycor
Turtle CommandPatch Command

Reports the y-coordinate of a patch or a turtle.

Example:
setpc ycor
;Each patch sets its color equal to its y-coordinate.
setweight ycor
;Each turtle sets its weight variable
;equal to its y-coordinate.


ycor-of
Turtle CommandPatch CommandObserver Command
ycor-of ID-number

Reports the y-coordinate of the turtle with the given ID-number


yes-or-no
Observer Command
yes-or-no thing

Opens a dialog, prompting user to click either the "yes" or "no" button. Returns 0 if "yes" is pressed, 1 if "no" is pressed.