Conditionally adds a list of micro-behaviours.

Begin micro-behaviour

DO-IF-ELSE

Begin NetLogo code:
substitute-text-area-for columns: 68 rows: 5 condition true                                                
substitute-text-area-for columns: 80 rows: 5 comment ; Notes                                                                                      
do-if-else (condition)
  [add-behaviours 
       list-of-micro-behaviours "Behaviours to add if true" []]
  [add-behaviours 
       list-of-micro-behaviours "Behaviours to add if false" []]
comment
End NetLogo code

Related Micro-behaviours

DO-IF-ELSE differs from DO-IF in that it has actions to perform when condition is false. WHEN runs only once when the condition is true while WHENEVER runs every time the condition is true. DO-IF-ELSE runs if the condition is true now.

ADD-BEHAVIOURS -- Adds behaviours

ADD-BEHAVIOURS-TO -- Adds behaviours immediately to a specified agent or set of agents

ADD-BEHAVIOURS-TO-LINKS -- Adds micro-behaviours to links (rather than agents)

REMOVE-BEHAVIOURS -- Removes behaviours

REMOVE-BEHAVIOURS-FROM -- Removes specified behaviours from an agent or set of agents

REMOVE-ALL-BEHAVIOURS -- Remove all behaviours

REMOVE-ALL-BEHAVIOURS-FROM -- Removes all behaviours from an agent or set of agents

DO-WITH-PROBABILITY -- Adds behaviours probabilistically

DO-WITH-PROBABILITIES  -- Choose which set of behaviours to add probabilistically

REPEATEDLY-DO-BEHAVIOURS -- Adds behaviours repeatedly

DO-AFTER -- Delays the addition of a list of micro-behaviours

DO-AFTER-SETUP -- Delays the addition of a list of micro-behaviours until setup has completed

DO-AT-TIME -- Schedules the addition of a list of micro-behaviours

DO-IF -- Runs actions if condition is true

DO-IF-ELSE -- Runs one set of actions if condition is true and another set if condition is false

WHEN -- Adds and removes micro-behaviours the first time that conditions are true

WHENEVER -- Adds and removes micro-behaviours every time conditions are true

Variants

You can edit the condition field to any expression that can evaluate to true. You can add micro-behaviours to either list of behaviours.

How this works

This relies upon the Behaviour Composer scheduling extensions to NetLogo to run the list of micro-behaviours if condition is true.

History

DO-IF-ELSE was implemented by Ken Kahn on 1 February 2010.