Search code examples
procedurenetlogo

Netlogo To randomly select one of 3 procedures


How do I randomly select one of 3 procedures?

Please see below:

to move
   ifelse random-float 100 < 70 
   [move-forward]
   [move-left move-right move-back] ;; To randomly select one of these 3 procedures to execute.
end

Thank you. I am quite unfamiliar with the syntax.


Solution

  • NetLogo 6:

    run one-of (list [-> move-left]
                     [-> move-right]
                     [-> move-back])
    

    NetLogo 5:

    run one-of (list task move-left
                     task move-right
                     task move-back)