ABM Basics 3 & 2 (2) Flashcards
(33 cards)
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
Write the procedure that checks if a given patch is an intersection patch and, if so, changes its colour to pink.
to check_intersection
ask patches
[
if category = “intersection”
[
set pcolor colour_intersection
]
]
end
What are the elements in an ABM?
Elements in an ABM:
Agents - turtles
Environment - patches/terrain
Actions and interactions
What does the environment do?
Environment defines the grid which the agents can go to
What is a primitive command?
Primitive commands describe an action for the programme to do (i.e., ask turtles [set color yellow])
What is a primitive reporter?
Primitive reporters carry out operations and report the result (i.e., report patches with [pcolor = green])
What is a variable?
Variables are used to label information that we want the prpgram to store.
What is a primitive variable?
Primitive variables in NetLogo are variables that are already named and stored in a NetLogo model (i.e., colour of a turtle - color; colour of a patch - pcolor)
Write the code when you want the color of the patches to be set in the value of green
ask patches [set pcolor green]
How could we assign random colours to the sheep?
We could use set to assign or change the value of a variable. Colors in NetLogo range from 0 to 140
ask sheep [ set color random 141 ]
Why 141? The random command is 141 because you want to include all colours in the shade provided