Skip to main content

7.11) Setup Agents


Now we need to create some agents or, to use NetLogo terminology, turtles. We do this by using the create-turtles primitive (abbreviated crt). To create 5 thousand turtles, we use crt 5000 [ ]. As the turtle represents a house owner we might want to give him the shape of a square and distribute it to a random empty patch. For the latter we use the move-to primitive which moves the turtle to a specified definition, and the reporter [not any? turtles-here] which reports true if the random selected patch is empty. We do need to initialise the available roof-size and PV-output (patch variables we can use now were we are place on one). PV-output is simple set false at the beginning and the roof-size is randomly assigned between 10-40 m2.

Enter this code in the setup procedure, after the ask patches statement:

crt 5000 [
    set shape "square"
    set color black
    move-to one-of patches with [not any? turtles-here]
    set roof-size 10 + random 40
    set PV-output 0
]

Click the Check button to check syntax, then press the setup button on the Interface, check in the agent monitor the variables of the turtles. With this, we are almost good to go for our first model. We just need some early PV adopters with their solar panels.