Chapter 2: Getting Started with NetLogo
- NetLogo is a tool used to implement ABMs. It comes equipped with built-in models, tutorials, and a user manual, all of which help us explore the possibilities of the software. Knowing how to navigate the NetLogo interface is extremely important, and you can use its built-in models and guides to help with that.
2.2 A Quick Tour of NetLogo
- Using the wolf-sheep population model, it is easy to see how the different parameters are set up and manipulated in a model, and what the outcomes are when they are changed.
- The animated output of the models is created by code, and there are examples of how to write it in NetLogo.
- There are four types of agent in NetLogo: mobile agents (or turtles), patches, links, and the observer. The variables and commands for each are stored in the User Manual.
- Primitives are extremely important; they are built-in commands that tell agents what to do. They can be commands and reporters.
- Code is "in context"; each piece of code can only be executed by a specified type (or types) of agent.
2.3 A Demonstration Program: Mushroom Hunt
- Programs start with setup and go: setup initializes the world, and go runs the actions to be performed in the model.
- Using the syntax checker often helps to write code quickly
- The ask primitive is the most important and powerful primitive in NetLogo: it makes selected agents perform a block of actions.
- You almost always have to use the clear-all command at the beginning of the setup procedure to make sure everything initializes correctly.
- Instead of "hardwriting" important variables, make them parameters that can be changed
- To keep the go procedure easy to understand, it is short and simple, only calling other procedures from different parts of the code
- Agent Monitors are tools to see and change the variables of an agent.
- From the Command Center, you can send commands to the observer or to all patches, turtles, or links.
- The tick primitive keeps track of how many times our go statement runs.
2.4 Summary and Conclusions
- Learning the basics is important, but you have to keep using the User Manual all the time to work successfully with NetLogo.
- Working with other people is super helpful, for beginners and experienced programmers and scientists.
For me, the biggest struggle will be what the end of this chapter talked about - not thinking that code in NetLogo should be the same as code in Python. The differences in style are already driving me crazy.