Name: ______
Activity Title: “Relating Geometric Figures to Writing Code in NetLogo”
Pre-Assessment:
- What are some of the properties of a square?
- What are some of the properties of a circle?
- What is an interior angle? An exterior angle? What is the sum of the interior and exterior angles?
Goals:
- Gain an introductory knowledge of NetLogo and its programming concepts
- Draw a square in the program
- Draw an equilateral triangle in the program
- Draw a circle in the program
Procedure:
- Open the program “NetLogo 5.0.4 ”
- The black space is the “world” and is made up of what we call patches
- The left side is for creating buttons and other inputs
- The bottom is the Command Center
- Let’s create an item you can move around the world
- In the Command Center type the following then press enter
create-turtles 2
- This made 2 arrow shapes at the center of the screen. We call them turtles.
- The number means how many we wanted to create.
- Let’s make all of them move, type:
ask turtles [forward 4](Notice the plural when we want them all to move)
- Let’s make one of them move, type:
ask turtle 0 [forward 3] (The first created turtle is turtle 0, the second is turtle 1)
- Make turtle 0 keep moving till it runs off the world. What happened?
- Let’s make our turtles turn
- To make one turtle turn, type:
ask turtle 0 [right 30](This turns the turtle 30 degrees to the right)
- To make all turtles turn, type:
ask turtles [left 50](This turns each turtle 50 degrees to the left)
- What are three ways to code a right 375 degree turn?
- We can also change aspects of our turtles
- To change color, type:
ask turtle 0 [set color blue](This turns the color to blue. Try some other colors)
- To change shape, type:
ask turtle 0 [set shape “person”](A shape editor is available in the tools menu)
ask turtle 0 [set shape “truck”]
- To change size, type:
ask turtle 0 [set size 10]
- To change location, type:
ask turtle 0 [set xcor 0 set ycor 0](This moves back to the center of the world)
- To remove everything from the world, type:
clear-all
- The second goal is to DRAW a square with side length of 10 on our background
- Create 1 new turtle (it should be at the center of the world), type:
create-turtles 1
- The sides of the square are 10 so let’s have the turtle move forward 10 steps, type:
ask turtle 0 [forward 10]
- The turtle then needs to turn 90 degrees right or left, type:
ask turtle 0 [right 90]
- We want 4 sides, so we repeat this process 3 more times
- It appeared to move in the shape of a square, but we wanted to DRAW a square
- To make the turtle leave a trail as it moves type:
ask turtle 0 [pendown]
- Repeat steps b-d to actually draw the square.
- The third goal is to draw an equilateral triangle
- What properties do we know about the sides in an equilateral triangle?
- What properties do we know about the angles of an equilateral triangle?
- Using a similar code process, draw an equilateral triangle.
- To erase the pen marks type:
clear-drawing
- The sides should be 10 steps, the angle needs to be 180 – interior angle
- What code did you type to draw an equilateral triangle?
- The fourth goal is to draw a circle
- How many 30° exterior turns would we need to make a circle?
- Type this code to make that circle (moving forward 4 steps then turning)
repeat 12 [ask turtle 0 [forward 4 right 30]]
(The “repeat #” command makes your turtle do that same command that # of times)
- Is that a good representation of a circle? How can we make it better?
- What is the code for a very good representation of a circle?
On your own:
- Draw a running track. It should have two straight edges with a semi-circle connecting both sides
What is the code?
- Draw a figure 8
What is the code?
Post-Assessment
- What code would I type of I wanted to create 10 turtles, each shaped like a tree with a size of 5?
- Next to each line of code write what you think will happen in NetLogo
- Enter each line of code into NetLogo.
- What is the code to create 100 sheep randomly located on a green field?
Reference(s): http://ccl.northwestern.edu/netlogo/index.shtml
http://cs.appstate.edu/ret/
http://ccl.northwestern.edu/netlogo/docs/dictionary.html