ABM Basics 3 & 2 (2) Flashcards
Which loop structure in Netlogo should you use if you want a set of commands to run a specific number of times?
Repeat loop structure
Which loop structure should you use in Netlogo to run commands for each element in a list or agent-set?
Foreach
How can we use the while command to create a list of 5 random numbers between 0 and 100?
let the_list []
while [ length the_list < 5 ]
[
set the_list lput (random 101)
the_list
]
What is the main purpose of a .nls file in Netlogo?
To make the main file easier to read. This organises your code and it’s better for testing/structure
How do you import a .nls file into your main Netlogo code?
__includes [“filename.nls”]
Where should the .nls file be located in relation to the main .nlogo file?
Must be in the same directory
What is the primary delimiter used to separate data in a .csv file?
Comma (,)
Which extension must be added at the top your code to use .csv functionalities in NetLogo?
‘extensions [csv]’
With the CSV extension in Netlogo, which command is used to convert a row of data from a .csv file into a list?
csv: from-row
How would you load data from a .csv file named boroughs.csv into a list called borough_data using the Netlogo ‘csv’ extension?
let borough_data csv: from-file “boroughs.csv”
What is the purpose of setting the coordinates of the bottom-left corner of the supermarket to (0,0)?
To establish the origin of the coordinate system
How is the colour of each patch determined in the supermarket layout?
Assigned automatically based on keywords in a CSV file
Where should the CRAVED vectors be stored for each patch?
In a patch attribute called CRAVED
Explain the purpose of the set_colour_patches procedure in terrain .nls
It assigns global variables for the colours of each type of patch available.
By using global vars, we can easily adjust the colours in one central location rather than changing the colour in each individual patch’s code
What is the purpose of the add_products procedure in relation to CRAVED attributes?
Created to assign CRAVED values to each shelves patch, showing how likely items on those shelves are to be stolen.
This procedure reads CRAVED values from the .csv file and assigns them as a list of numbers to the CRAVED attribute of each patch