Name: ______

Activity Title: “Relating Geometric Figures to Writing Code in NetLogo”

Pre-Assessment:

  1. What are some of the properties of a square?
  1. What are some of the properties of a circle?
  1. What is an interior angle? An exterior angle? What is the sum of the interior and exterior angles?

Goals:

  1. Gain an introductory knowledge of NetLogo and its programming concepts
  2. Draw a square in the program
  3. Draw an equilateral triangle in the program
  4. Draw a circle in the program

Procedure:

  1. Open the program “NetLogo 5.0.4 ”
  2. The black space is the “world” and is made up of what we call patches
  3. The left side is for creating buttons and other inputs
  4. The bottom is the Command Center
  1. Let’s create an item you can move around the world
  2. In the Command Center type the following then press enter

create-turtles 2

  1. This made 2 arrow shapes at the center of the screen. We call them turtles.
  2. The number means how many we wanted to create.
  1. Let’s make all of them move, type:

ask turtles [forward 4](Notice the plural when we want them all to move)

  1. 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)

  1. Make turtle 0 keep moving till it runs off the world. What happened?
  1. Let’s make our turtles turn
  2. To make one turtle turn, type:

ask turtle 0 [right 30](This turns the turtle 30 degrees to the right)

  1. To make all turtles turn, type:

ask turtles [left 50](This turns each turtle 50 degrees to the left)

  1. What are three ways to code a right 375 degree turn?
  1. We can also change aspects of our turtles
  2. To change color, type:

ask turtle 0 [set color blue](This turns the color to blue. Try some other colors)

  1. 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”]

  1. To change size, type:

ask turtle 0 [set size 10]

  1. To change location, type:

ask turtle 0 [set xcor 0 set ycor 0](This moves back to the center of the world)

  1. To remove everything from the world, type:

clear-all

  1. The second goal is to DRAW a square with side length of 10 on our background
  2. Create 1 new turtle (it should be at the center of the world), type:

create-turtles 1

  1. The sides of the square are 10 so let’s have the turtle move forward 10 steps, type:

ask turtle 0 [forward 10]

  1. The turtle then needs to turn 90 degrees right or left, type:

ask turtle 0 [right 90]

  1. We want 4 sides, so we repeat this process 3 more times
  1. It appeared to move in the shape of a square, but we wanted to DRAW a square
  2. To make the turtle leave a trail as it moves type:

ask turtle 0 [pendown]

  1. Repeat steps b-d to actually draw the square.
  1. The third goal is to draw an equilateral triangle
  2. What properties do we know about the sides in an equilateral triangle?
  1. What properties do we know about the angles of an equilateral triangle?
  1. Using a similar code process, draw an equilateral triangle.
  2. To erase the pen marks type:

clear-drawing

  1. The sides should be 10 steps, the angle needs to be 180 – interior angle
  2. What code did you type to draw an equilateral triangle?
  1. The fourth goal is to draw a circle
  2. How many 30° exterior turns would we need to make a circle?
  1. 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)

  1. Is that a good representation of a circle? How can we make it better?
  1. What is the code for a very good representation of a circle?

On your own:

  1. Draw a running track. It should have two straight edges with a semi-circle connecting both sides

What is the code?

  1. Draw a figure 8

What is the code?

Post-Assessment

  1. What code would I type of I wanted to create 10 turtles, each shaped like a tree with a size of 5?
  1. Next to each line of code write what you think will happen in NetLogo

  1. Enter each line of code into NetLogo.
  1. 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