Basic Logo Commands

In the NetLogo Command Center at the bottom of the window, you will see that you can switch between observer, turtles, patches & links by clicking on observer. The first commands you need to learn are either observer commands - to setup your environment or turtle commands - to move your turtles.

Observer commands

ca - clear all
crt number - creates the number of turtles specified

Turtle commands

fd number - moves the turtle(s) forward the number of steps specified
bk number - moves the turtle(s) backward the number of steps specified
pd - puts the pen down, so when the turtle(s) move, they will leave a mark
pu - puts the pen up
rt number - turns the turtle(s) rt the number of degrees specified
lt number - turns the turtle(s) lt the number of degreed specified
repeat number [ ] - repeats the commands in the brackets the number of times specified

Create a square

To create a square
With the command center set to observer>, type:
crt 1

Change the command center to turtles> and then type:
fd 10
rt 90
fd 10
rt 90
fd 10
rt 90
fd 10
rt 90

There's a more efficient way to create the square using the repeat command. Can you figure it out? Try creating multiple turtles and use the repeat command to create patterns.

Here's an example of using the repeat command:
repeat 10 [fd 4 rt 34 bk 1 lt 180 fd 7 lt 66 bk 3]

If you get an error, check your syntax. Just like there are rules of language that dictate how the various parts of a sentence go together, programming languages also have rules for how a set of instructions can be put together. If you miss a bracket or forget to tell the program how many spaces to move forward, then you will receive a syntax error.

Next Lesson

Turtle shapes