StarLogo Vocabulary: Beginner


= used for the observer,
= used for turtles,
= used for patches



Commands to: Move Turtles,Clear & Setup, Color,Create Turtles
Other Commands

_____________________________________________________________
_____________________________________________________________

Commands to Move the Turtles

_____________________________________________________________
bk
number
(backward)

Moves turtles backward by number steps.
_____________________________________________________________
fd
number
(forward)

Moves turtles forward by number steps.
_____________________________________________________________
jump
number

Moves turtles forward by number units in one "big step" (in one unit of time).

This command is useful for synchronizing turtle movements. The command fd 15 takes
15 times longer to execute than fd 1, but jump 15 executes in the same time
as jump 1 or fd 1.
_____________________________________________________________
heading

heading-of ID-number

heading reports the heading of the turtle. Heading 0 is due north, 90
is east, and so on. heading-of reports the heading of the turtle with the given ID-number.
_____________________________________________________________
home

Moves the turtle to the middle of the screen, at coordinates (0, 0).
_____________________________________________________________
lt
number

Turns turtles left by number degrees.
_____________________________________________________________
rt
number

Turns turtles right by number degrees.
_____________________________________________________________
distance
x-coordinate y-coordinate
distance-nowrap x-coordinate y-coordinate

Reports the distance to the point (x-coordinate, y-coordinate)
With distance, turtles and patches use the "wrapped distance" (around the edges of the
screen) if that distance is shorter than the "onscreen distance." With distance-nowrap,
turtles and patches always use the onscreen distance.

Example:
if (distance 0 0) > 10 [setc green]
(All turtles more than 10 units from the center of the screen turn green.)
seth number turtles, patches
(set heading)
Sets the heading of turtles to number. Heading 0 is due north, 90 is east, and so on.
_____________________________________________________________
setx
number

Sets the x-coordinate of turtles to number.
_____________________________________________________________
setxy
number1 number2

Sets the x-coordinate of turtles to number1 and the y-coordinate of turtles to
number2.

Example:
setxy 0 0
(All turtles move to the center of the screen.)
_____________________________________________________________
sety
number

Sets the y-coordinate of turtles to number.
_____________________________________________________________
towards
x-coordinate y-coordinate
towards-nowrap x-coordinate y-coordinate

Reports the direction from the turtle towards the point (x-coordinate, y-coordinate).

If the "wrapped distance" (around the edges of the screen) is shorter than the "onscreen
distance," towards will report the direction of the wrapped path, while
towards-nowrap will report the direction of the onscreen path.
_____________________________________________________________
turtle-at
x-offset y-offset

Reports the ID-number of another turtle in the patch that is x-offset away in the
x-direction and y-offset away in the y-direction. If there are several turtles in
the patch, an arbitrary (other) turtle is picked.

If used by a patch, and there are no turtles in the indicated patch, reports -1. If used by
a turtle, and there are no other turtles in the indicated patch, reports -1.
_____________________________________________________________
turtle-here

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

If used by a patch, and there are no turtles in the patch, reports -1. If used by a turtle,
and there are no other turtles in the patch, reports -1.
_____________________________________________________________
turtles-at
x-offset y-offset

Reports the number of turtles in the patch that is x-offset away in the x-direction
and y-offset away in the y-direction.
_____________________________________________________________
turtles-here

Reports the number of turtles in the patch.
_____________________________________________________________
turtle-total

Reports the total number of turtles.
_____________________________________________________________
who

Reports the ID-number of the turtle.

Example:
if who < 50 [setc blue] (Makes 50 of the turtles blue.)
_____________________________________________________________
xcor

xcor-of ID-number

xcor reports the x-coordinate of a turtle or a patch.

xcor-of reports the x-coordinate of the turtle with the given ID-number.

Example:
sety xcor
(Sets turtlesı y-coordinate to equal x-coordinate, so that all turtles move to the line y=x.)
_____________________________________________________________
ycor

ycor-of ID-number

ycor reports the y-coordinate of a turtle or a patch.

ycor-of reports the y-coordinate of the turtle with the given ID-number.

Example:
setpc ycor (Displays the StarLogo color table as horizontal bands.)
_____________________________________________________________
_____________________________________________________________

Clearing & Setup Commands

_____________________________________________________________
ca

(clear all)

Kills all turtles, sets the color of all patches to black, and clears the Plot Window.
_____________________________________________________________
cc

(clear commands)

Deletes all text in the command center.
_____________________________________________________________
cg

(clear graphics)

Sets the color of all patches to black.
_____________________________________________________________
screen-edge

Reports the maximum x-coordinate (and maximum y-coordinate). This is the "half width"
of the StarLogo world. (The full width is actually (2 * screen-edge) + 1.)
_____________________________________________________________
screen-size

Reports the width (or height) of the StarLogo world. (In the current version, the StarLogo
world is always a square, so the width and height are always the same.) You can change the
size by changing the starlogo.patch file (see section 1.4).
_____________________________________________________________
show
thing

Prints thing in the command center.
_____________________________________________________________
_____________________________________________________________

Color Commands

_____________________________________________________________
color
color-of ID-number
color-at dx dy

color reports the color of a turtle.

If used by a patch, color reports the color of the turtle on the patch. If there are
several turtles on the patch, it arbitrarily chooses one of them. If there are no turtles
on the patch, it reports the patchıs color.

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

color-at reports the color of a turtle in the patch (dx, dy) units away. If
there are several turtles on the patch, it arbitrarily chooses one. If there are no turtles
on the patch, it reports the patchıs color.

Example:
if color = white [fd 20]
(Moves all white turtles forward 20 steps.)
_____________________________________________________________
pc

(patch color)
pc-at dx dy

pc reports the color number of a patch.

pc-at reports the color of the patch (dx, dy) units away.

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.)
_____________________________________________________________
pd

(pen down)

Puts down the turtle's pen, so that the turtle draws (leaves a trail) when it moves.
The turtle draws by changing the color of the patches underneath it to its own color.
To change the color of the turtleıs pen (and the color of the turtle itself), use setc.
_____________________________________________________________
pu

(pen up)

Lifts up the turtle's pen, so that the turtle doesn't draw when it moves. To put down
the turtle's pen, use pd (for pen down).
_____________________________________________________________
setc
color
setc-of ID-number color
setc-at dx dy color

setc sets turtle's color to the given color. See section 3 for discussion
of StarLogo colors.

setc-of sets the color of the turtle with the given ID-number.

setc-at is used by a turtle to set the color of turtles in the patch (dx, dy)
units away.

Example:
setc red
(Each turtle turns red.)
_____________________________________________________________
setpc
color
setpc-at dx dy color

setpc sets patch's color to the given color. See section 3 for discussion
of StarLogo colors.

setpc-at is used by a patch to set the color of the patch (dx, dy) units away.

Example:
setpc green
(Each patch turns green.)
_____________________________________________________________
stamp
color
stamp-at dx dy color

stamp sets the color of the patch under the turtle to the given color.
See section 3 for discussion of StarLogo colors.

stamp-at is used by a turtle to set the color of the patch (dx, dy) units away.
_____________________________________________________________
_____________________________________________________________

Commands to Create Turtles

_____________________________________________________________
crt
number
(create turtles)

Creates number new turtles. New turtles start at position (0, 0).
[Explain initial color and headings.]
_____________________________________________________________
hatch
procedure-list

Each turtle creates a new turtle, identical to itself, and tells the new turtle to
execute procedure-list.

Example:
hatch [lt 45] hatch [rt 45]
(Each turtle creates two new turtles, one angled to the left, one angled to the right.)
_____________________________________________________________
alive?
alive?-of ID-number

alive? reports true if the turtle is alive. alive?-of reports true if turtle with the
given ID-number is alive.
_____________________________________________________________
die

Tells turtles to die.

Example:
if pc = red [die]
(All turtles on red patches die.)
_____________________________________________________________
_____________________________________________________________

Other Useful Commands

_____________________________________________________________
if
predicate procedure-list

If predicate evaluates to true, then execute procedure-list.

Example:
if xcor > 0 [setc blue]
(Turtles on the right half of the screen turn blue.)
_____________________________________________________________
ifelse
predicate proc-list1 proc-list2

If predicate evaluates to true, then execute proc-list1. If
predicate evaluates to false, then execute proc-list2.

Predicate may have different values for different objects, so some objects may
execute consequent-procedure while others execute alternate-procedure.

Example:
ifelse xcor > 0 [setpc blue] [setpc red]
(The left half of the screen turns red and the right half turns blue.)
_____________________________________________________________
repeat
number procedure-list

Executes procedure-list number times.

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