With NetLogo open and the Interface
tab selected, try out the following in
the Command Center
:
This is how you make a turtle:
create-turtles 1
We are going to ask our turtles to draw underneath them as they move.
ask turtles [ pendown ]
Now let's ask the turtle to move forward 5 steps
and then turn right 60
degrees. I hope you guys remember your shapes. It's especially useful if you
remember how big the angles of the shape are.
ask turtles [ forward 5 ]
ask turtles [ right 60 ]
We can combine the 2 instructions to one line as follows.
ask turtles [ forward 5 right 60 ]
Alright, why don't we tell this turtle to repeat this 3 more times?
ask turtles [repeat 3 [forward 5 right 60 ]]
It looks like we almost have a shape. What shape does this look like? Why don't we complete the shape? What instructions do we need to give to complete the shape?
Note: if you make a mistake by giving the wrong instruction to the turtle, you can reset and start again by running: clear-all
We can also tell the turtle to move backwards and to the left. ask turtles [ left 60 ] ask turtles [ back 4 ]
Okay, now let's clean up that mess we drew. This time we will create 2 turtles. clear-all create-turtles 2
Do you notice where the 2 turtles are? They are right on top of each other. Why don't we ask them to move?
ask turtles [ pendown ]
ask turtles [ forward 5 ]
ask turtles [ right 180 ]
But what if we don't want them on top of each other? Okay, let's try this again:
clear-all
create-turtles 2 [setxy random-xcor random-ycor ]
Where are the turtles? Try running that command again.
clear-all
create-turtles 2 [setxy random-xcor random-ycor ]
Okay, now we made our turtles, let's tell them to move exactly like before.
ask turtles [ pendown ]
ask turtles [ forward 5 ]
ask turtles [ right 60 ]
ask turtles repeat 5 [ forward 5 right 60 ]
We can even keep telling the turtles to repeat. Something like:
clear-all
create-turtles 1
ask turtles [ pendown ]
ask turtles [ repeat 6 [repeat 6 [ forward 5 right 60] right 60 ] ]
- What kind of shape did you make?
- Now on to some exercises. Can you make: