140 likes | 372 Views
Exploring Netlogo. Beth Fulton. April 2012. Essential Components. Patches (environment) Turtles (agents) breeds (different kinds) Links Observers Built-in tools, features to help (keep manual handy ) variables: color , location observer’s = globals routines (primitives)
E N D
Exploring Netlogo Beth Fulton April 2012
Essential Components • Patches (environment) • Turtles (agents) • breeds (different kinds) • Links • Observers • Built-in tools, features to help (keep manual handy) • variables: color, location • observer’s = globals • routines (primitives) • commands (act); reporters (calculate statistic & report)
Description of model Coding window Netlogo GUI GUI (controls) Specific queries (Advanced)
Netlogo GUI Speed Turn off map updates for super speedy run ALWAYS press first (initialisation) Start (Stop) Set parameters
Netlogo GUI Aggregate time series plot Aggregate indicator (statistic)
turtle = agent Coding Key Points Check code syntax Globals & attributes Setup Go Routines called by Go
turtle = agent Coding Key Points primitive ;; Comment
Coding hints • Use Netlogo dictionary: (icon for relevancy) • turtle • link • observer • patch • Each block of code has a context (kind of agent that can execute it) • e.g. can’t use patch primitives in turtle context • button related routine = observer context • change context ask XXX [XXX context]
Coding hints let local variable set (first time) by the entity creating it (only works within the procedure or [ ] where the local variable is defined set to set value of existing variable of get the value of a variable belonging to another entity one-of for single case of if want list from agentset ask get another entity to change the value of its variable
Globals Needed For • For global variables (define world) • Fixed parameters used by all (so only enter once) • Interface sliders, switches etc refer to globals • Any parameter to be changed in batch runs • Use carefully as run the risk of in appropriate sets • For agent level variables use patches-own turtles-own links-own
When all else fails export-world writes ALL variable values to one file import-world reads in ALL variable values (“hot start” model) • Can also export plot contents etc • file is more refined way of getting specific output
Psuedo code trips Netlogo C to end [ ] varvar + abc ; ifelsething_to_test [ do xyz ] ;; true case [do ijk ] ;; false case void () { return } { } var = var + abc; OR var += abc; // OR /* */ if (thing_to_test) { do xyz; // true case } else { do ijk; // false case } Spaces important !!
Thank you • CMAR Beth FultonSenior Research Scientist t +61 3 6232 5018 ebeth.fulton@csiro.au wwww.cmar.csiro.au