NetLogo Lesson Plan 1
Shodor > SUCCEED > Curriculum > Apprentices > NetLogo Lesson Plan 1

NetLogo 1



Lesson Abstract

This lesson plan provides an introduction into scientific modeling, using Netlogo.

One will gain a basic understanding of NetLogo, and will be introduced to agent behaviors and emergent properties.

Standards Addressed



  • Define agent modeling.
  • Explore a working model to help sudents see how agent modeling is used.
  • Modify an existing model to see how different pieces affect the functionality of the model.
  • Build a simple model piece-by-piece using a pseudo-code approach which involves writing behaviors in comments before using code.

Key Terms


Prerequisite Knowledge

Basic familiarity with computers (user interfaces). No programming experience required for students.

Good coding organization will be an advantage.

Teacher Preparation

Should be comfortable with basic NetLogo commands/coding(such as ca, crt, etc). For teachers who have not used NetLogo before, it would be a good idea to build a few models before teaching this class. Also the models library in Netlogo is a good resource to parse through and familiarize oneself with the code.


Required MaterialsMediaEquipment

  • Whiteboard and markers.
  • 1 computer for each pair of students.
  • Notebooks and pens for each student.

  • NetLogo must be on each computer to be used for the class.

  • Computer and a projector for the instructor.


No physical safety issues.

But Netlogo might use excessive virtual memory, depending on computer, causing the program, and the rest of the computer, to run slow.

Presentation Outline


5 minutes

What is a Scientific Model?

  • Representation of a natural occurrence utilizing prior knowledge

Examples of scientific models (ask for ideas):

  • Weather models
  • Virtual Product testing (car crashes etc)
  • Environmental models (wildfire spread, etc)
  • Traffic Models

What can we use a scientific model for?

  • Testing Hypotheses
  • Analysis of Scenarios
  • Drawing Conclusions to certain problems
  • Investigating happennings that are difficult to observe in real life

Agent Modeling

  • Individual behaviors -> Emergent properties
  • "Agents" have particular behavior
  • The resulting system has observable properties.


15 minutes

Open Rabbit-Grass-Weeds Model

Introduce students to NetLogo interface

  • Tabs: Interface, Information, Procedure
  • Buttons: ("forever" versus "one-time")
  • Sliders: Initial and dynamic values
  • Switches
  • Monitors
  • Plots

Elements of the model

  • Turtles = agents
  • Patches = background (actually a kind of agent that can't move...)

Run the model and make observations

  • Individual behaviors?
    • Eat grass
    • Reproduce
    • Move
    • Die (as a result of starving)
  • Emergent properties?
    • More grass -> More rabbits
    • More rabbits -> Less grass
    • Less grass -> Less rabbits
    • Less rabbits -> More grass
    • It's a cycle! (Point out graph)
  • What does it mean?
    • Predator / Prey (or herbivore / vegetation) levels fluctuate in a cycle (could show hare/lynx graph online)
  • What factors produce more rabbits?
    • Lower Birth Threshold (more fluctuation)
    • Higher Grass Energy
    • Higher Grass-Grow-Rate

Make changes to the model

  • What happens when we hit the "setup" button?
  • Go to the procedures tab and find "to setup"
    • Each procedure is a set of instructions telling the computer how to do something
  • Introduce commenting - it's like turning code off (putting ;; before a line of code to turn it off, or putting it at the end of the line to still execute the command but also put in a note about the code)
  • Comment out or change different lines of code and observe changes (do only one comment at a time)
    • set color white (change color)
    • setxy random-xcor random-ycor (random positions)
    • set-default-shape of the rabbits to "cow" (change shape)
    • Tools->Shapes Editor for shape names

Computational Modeling

30 minutes

Introduce a color changing model (5 min)

  • When two turtles meet, one of them will become the color of the other. Eventually, all the turtles will be the same color. This represents the spread of a fad or, in a more scientific approach, genetic traits leading to evolution.
  • What will a turtle have to do?
    • Be created
    • Move
    • Change colors
    • Know if another turtle is nearby, and how to respond
  • Write the steps in your notebook
  • Write kids' ideas on the board

Build the model we worked on (20 min)

  • What procedures do we need?
  • Write these steps as comments first, then fill in the commands.
    • setup
      • Clear all
      • Create 100 turtles
      • Position turtles (remember what happened in the rabbit model?)
  • go
    • Move turtles
    • Change turtle color
  • move
    • Rotate turtles
    • Move forward one step
  • Change-color
    • Any turtles around me?
    • Set my color to the color of one of my neighbors

Follow Up

Could have a longer class or a second class where the students build on their original model and add more behaviors.

Diffused background:

ask patches [

set pcolor sky + random 30 - 14


diffuse pcolor 1

Alternate Outline

If there are no student computers, the class can make observations and give input to sample models that the teacher displays on the projector.

Other interesting models to explore:

  • Wolves and Sheep
  • Flocking