Skip to main content

7.4) Setup


The next natural thing to do is to program the setup procedure, where all entities and state variables are created and initialised. Our guide of course is the Initialisation part of the ODD description.

Back in the Procedures tab, let us again start by writing a “skeleton”:

to setup
   ca
   ask patches
   [
   ]
   reset-ticks
end

Click the Check button again to make sure the syntax of this code is correct. There is already some code in this setup procedure: ca to delete everything, which is almost always first in the setup procedure, and reset-ticks, which is almost always last. The ask patches statement will be needed to initialise the patches by giving them all a value for each of their state variable. The code to do so will go within the brackets of this statement.