The set of NetLogo commands and reporters has been extended by the Behaviour Composer. Those that are not solely for internal use are listed here and can be used in your micro-behaviours. This document is intended as a reference resource while the programming guide describes Behaviour Composer programming in detail. Schedulingdo-everydo-every interval [ actions ] performs actions now and every interval time units (actions can be any NetLogo commands). do-every-dynamicdo-every-dynamic [interval-reporter] [ actions ] performs actions now and repeats them after an interval computed by running the  interval-reporter  (actions can be any NetLogo commands).Âdo-at-setupdo-at-setup [ actions ] performs actions when the simulation is initialised (actions can be any NetLogo commands). do-after-setupdo-after-setup [ action ] performs actions just after the simulation is initialised (actions can be any NetLogo commands). do-afterdo-after interval [ actions ] performs actions after interval time units (actions can be any NetLogo commands; interval any positive number). do-at-timedo-at-time time [ actions ] performs actions when the clock has reached time (actions can be any NetLogo commands and time can be any number). do-nowdo-now [ actions ] performs actions immediately (actions can be any NetLogo commands). whenwhen [ condition ] [ actions ] performs actions one time as soon as condition holds (actions can be any NetLogo commands; condition any NetLogo reporter that returns true or false). wheneverwhenever [ condition ] [ actions ] performs actions every time condition is true (actions can be any NetLogo commands; condition any NetLogo reporter that returns true or false). do-if-elsedo-if-else [ condition ] [ micro-behaviourt1 micro-behaviourt2 … micro-behaviourtn ] [ micro-behaviourf1 micro-behaviourf2 … micro-behaviourfn ] adds micro-behaviourt1 micro-behaviourt2 … micro-behaviourtn if condition reports true otherwise it adds micro-behaviourf1 micro-behaviourf2 … micro-behaviourfn.do-for-ndo-for-n n agents [ actions ]This is useful when you want a subset of agents to perform some action. Selects n of the agents and runs actions for each agent. If n is a non-integer the remainder is used as the odds of selecting an additional agent. If there are fewer than n agents then all agents run the actions. While the actions are run the code can refer to the agent that is running do-for-n using the-other. select-n is a reporter that returns n agents and also treats fractions probabilistically. A typical example is from RANDOM_ENCOUNTER: do-every 1 [do-if my-state = "infected" [do-for-n the-encounter-rate all-individuals with [my-state != "dead"] [add-behaviour POSSIBLE-INFECTION]]] It selects the-encounter-rate of those not dead and adds the POSSIBLE-INFECTION micro-behaviour. do-repeatedlydo-repeatedly n [ actions ] performs actions n times (if n is a non-integer then the actions may be performed an additional time where the odds are the fractional part of n). When n is an integer this is identical to the NetLogo repeat reporter. do-with-probabilitydo-with-probability odds [ actions ] performs actions with probability odds. do-with-probabilitiesdo-with-probabilities odds1 [ behaviour1 ]  odds2 [ behaviour2  ] …  oddsn [ behaviourn  ] performs behaviouri  with probability of oddsi. If oddsi that together with the oddsj where j < i adds up to more than 1.0 then only the portion of oddsi  that adds up to 1.0 is used. add-behaviouradd-behaviour micro-behaviour adds the micro-behaviour to the current agent (the prototype running the micro-behaviour that is executing the add-behaviour command). add-behavioursadd-behaviours [ micro-behaviour1 micro-behaviour2 … micro-behaviourn ] adds the micro-behaviours  to the current agent  (the prototype running the micro-behaviour that is executing the add-behaviours command). add-behaviour-to agentadd-behaviour-to agent micro-behaviour adds the micro-behaviour to the agent. add-behaviours-toadd-behaviours-to agent [ micro-behaviour1 micro-behaviour2 … micro-behaviourn ] adds the micro-behaviours to the agent. add-link-behaviouradd-link-behaviour micro-behaviour when-to-add when asked of a link or set of links adds the micro-behaviour to the links at time when-to-add. when-to-add can be time so that it is added immediately. add-link-behavioursadd-link-behaviours [ micro-behaviour1 micro-behaviour2 … micro-behaviourn ] when-to-add when asked of a link or set of links adds the micro-behaviours to the links at time when-to-add. when-to-add can be time so that they are added immediately. add-link-behaviour-afteradd-link-behaviour micro-behaviour delay  when asked of a link or set of link adds the micro-behaviour to the links after delay.add-link-behaviours-afteradd-link-behaviours-after [ micro-behaviour1 micro-behaviour2 … micro-behaviourn ] delay when asked of a link or set of links adds the micro-behaviours to the links after delay.Âremove-behaviours-fromremove-behaviours-from agent-or-agent-set [ micro-behaviour1 micro-behaviour2 … micro-behaviourn ] removes the micro-behaviours from agent-or-agent-set . If  a micro-behaviour of agent-or-agent-set and one of the micro-behaviouri are copies of the same micro-behaviour then it is removed from agent-or-agent-set. remove-all-behavioursremove-all-behaviours removes all behaviours from the agent running it. remove-all-behaviours-fromremove-all-behaviours-from agent-or-agent-set removes all behaviours from agent-or-agent-set. Selecting agentsselect-nselect-n n agents returns n random members of agents. If n is a non-integer the remainder is used as the odds of selecting an additional agent. If there are fewer than n agents then all agents is returned. If n is an integer that is equal to or larger than the number of agents then this is identical to the NetLogo n-of reporter. can-pick-onecan-pick-one agents if agents is not empty reports true and the-other will return the agent chosen. anyany prototype name reports true if there are any (non-hidden) agents other than the caller created as copies of the prototype named prototype name and the-other will return the agent chosen. anyone-who-isanyone-who-is [ conditions ] [ actions ] runs actions for any agent that satisfies conditions and the-other will return the agent chosen (actions can be any NetLogo commands; condition any NetLogo reporter that returns true or false). all-who-areall-who-are [ conditions ] [ actions ] runs actions for all agents that satisfy conditions and the-other can be used. the-otherthe-other can be used in NetLogo code in the Behaviour Composer to refer to an agent defined by the most recent execution of one of the above extensions. An example of its use is in EAT-WHEN-HUNGRY. A simplified version is when [can-pick-one all-individuals with [distance-to-me < 5]] [add-behaviour-to the-other DIE] When there is at least one individual whose distance to the agent running this code fragment is less than 5 units then the behaviour DIE is added to the the-other, can-pick-one sets the-other when it randomly choses one of the agents from all-individuals with [distance-to-me < 5]. all-individualsall-individuals reports all agents that are not invisible. Same as NetLogo all-of-kindall-of-kind "prototype name" reports all instances of the prototype with that name. Same as NetLogo: any-of-kindany-of-kind "prototype name" reports one random instance of the prototype with that name. Same as NetLogo: all-othersall-others reports all agents that are not invisible other than the agent calling this. Random numbersrandom-integer-betweenrandom-integer-between [number1 number2 ] for whole numbers or integers between number1 and number2. random-number-betweenrandom-number-between [number1 number2 ] creates a random number between number1 and number2 (including all rational numbers e.g. fractions of whole numbers represented by double floating numbers). MovementThe BehaviourComposer supports three movement attributes: my-x , my-y , and my-heading . If the corresponding NetLogo variables xcor, ycor, and heading are not updated (which many NetLogo primitives do such as forward , face , right , ...) then they are set to the values of the attributes. Note that as with all attributes, one can use my-next-x, my-next-y, and my-next-heading to distinguish between the value the attribute should have when the current cycle ends and the value it currently has. The advantage of using go-forward and turn-right is that they work together with any other code that deals with my-x , my-y , and my-heading such that they don't depend upon the order of events. go-forwardgo-forward is similar to NetLogo's jump except it relies upon my-x, my-y, and my-heading. turn-rightturn-right angle sets my-next-heading to my-heading+angle. This is similar to how NetLogo's right affects heading. Because it sets my-next-heading my-heading is not updated until the end of the cycle. turn-leftturn-left angle decrements sets my-next-heading to my-heading-angle . This is similar to how NetLogo's left affects heading. Because it sets my-next-heading my-heading is not updated until the end of the cycle. move-horizontally-or-vertically-towards-another move-horizontally-or-vertically-towards-another agent speed moves speed units towards agent by moving either horizontally or vertically. The odds of whether it moves horizontally or vertically is proportional to the horizontal and vertical distance to the other. random-unoccupied-locationrandom-unoccupied-location min-xcor max-xcor min-ycor max-ycor reports a location (a list of the x and y coordinates) that does not contain an agent and is in the region specified by min-xcor, max-xcor, min-ycor, and max-ycor. heading-towards-anotherheading-towards-another another reports the heading towards another if another is an agent or patch. This is similar to NetLogo's towards except that it returns my-heading if another is at the same location as the agent or another is neither a patch nor an agent. canonical-headingcanonical-heading angle reports an angle between 0 and 360 degrees that is equivalent to angle. Miscellaneouscreate-agentscreate-agents number-of-agents prototype-name [additional behaviours] creates number-of-agents using all the behaviours of the  prototype-name and any additional behaviours. create-objects is the older name of this command.  After calling create-agents the local variable just-created-agents contains the set agents just created. This is implemented by generating NetLogo code that relies upon sprout. create-agents-from-datacreate-agents-from-data   prototype-name list-of-attribute-names data [additional behaviours] creates (length of data) / (length of  list-of-attribute-names ) agents using the data and all the behaviours of the  prototype-name and any additional behaviours. This is implemented by generating NetLogo code that relies upon sprout. ask-every-patchask-every-patch [ actions ] performs actions for every patch of the environment. Note that unlike ask patches in NetLogo this can be run from the "turtle context". within-rangewithin-range x minimum-value maximum-value reports x if it is between minimum-value and maximum-value. Otherwise it returns minimum-value if x is less than minimum-value and maximum-value  if x is greater than maximum-value. layout-gridlayout-grid agent-set-or-list lower-left-x lower-left-y width height lays the members of agent-set-or-list out in a grid that is width by height with its lower left corner at lower-left-x, lower-left-y. layout-rectangular-prismlayout-rectangular-prism agent-set-or-list lower-left-x lower-left-y lower-left-z width height depth lays the members of agent-set-or-list out in a rectangular prism that is width by height by depth with its lower left corner at lower-left-x, lower-left-y, lower-left-z. add-copies add-copies [n behaviours] creates n exact copies of the agent running this and then adds the behaviours to each of the newly created agents. add-copies-of-anotheradd-copies-of-another [n another-agent behaviours] creates n exact copies of another-agent and then adds the behaviours to each of the newly created agents. log-log-histogramSimilar to NetLogo's histogram command.  log-log-histogram [data increment] computes the frequency of data points in the interval [ m+n* increment,  m+(n+1)* increment) where m is the minimum value in data and n is any non-negative integer. If the frequency is not zero it  plots the natural logarithm of the frequency and the logarithm of the average of the interval.power-law-randompower-law-random [power maximum-value] returns a random non-negative integer less than or equal to maximum-value. The distribution of the random numbers follows a power law with power as the exponent. power-law-listpower-law-list  [n power maximum-value] returns a list of n values returned by power-law-random. secondthirdfourth |
Guides‎ > ‎