I add different behaviours depending upon how a random number compares with the given odds.

Begin micro-behaviour

DO-WITH-PROBABILITIES

Begin NetLogo code:
substitute-text-area-for odds-of-branch-1 0.2 
substitute-text-area-for odds-of-branch-2 0.3 
substitute-text-area-for odds-of-branch-3 0.0 
substitute-text-area-for odds-of-branch-4 0.0 
substitute-text-area-for odds-of-branch-5 0.0 
substitute-text-area-for odds-of-branch-6 0.0 
substitute-text-area-for odds-of-branch-7 0.0 
substitute-text-area-for odds-of-branch-8 0.0 
substitute-text-area-for odds-of-branch-9 0.0 
substitute-text-area-for comment ; Notes                                                                                
do-with-probabilities 
   [odds-of-branch-1 list-of-micro-behaviours "Behaviours 1" []
    odds-of-branch-2 list-of-micro-behaviours "Behaviours 2" []
    odds-of-branch-3 list-of-micro-behaviours "Behaviours 3" []
    odds-of-branch-4 list-of-micro-behaviours "Behaviours 4" []
    odds-of-branch-5 list-of-micro-behaviours "Behaviours 5" []
    odds-of-branch-6 list-of-micro-behaviours "Behaviours 6" []
    odds-of-branch-7 list-of-micro-behaviours "Behaviours 7" []
    odds-of-branch-8 list-of-micro-behaviours "Behaviours 8" []
    odds-of-branch-9 list-of-micro-behaviours "Behaviours 9" []
    ]
comment
End NetLogo code

Variants

You can edit the box containing the odds. You can add micro-behaviours to either list by clicking on the micro-behaviour and navigating back to this page.

Related Micro-behaviours

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

How this works

This relies upon the do-with-probabilities Modelling4All extension to NetLogo that produces a uniform random number between 0 and 1 and if it is less than or equal to the first odds adds the first list of micro-behaviours otherwise if it is less than or equal to the sum of the first two odds the second list of micro-behaviours is added and so on..

History

DO-WITH-PROBABILITIES was first implemented by Ken Kahn on 21 February 2010.