Libraries‎ > ‎Library‎ > ‎Interact with others‎ > ‎

Interactions

BehaviourComposer: ignore everything before this.

Begin micro-behaviour

Begin description:

Interact with anyone who meets the specified conditions.

End description

Interact with another

Begin NetLogo code:

substitute-text-area-for set-of-agents other all-individuals
substitute-text-area-for other-agent one-of target-agents
let target-agents set-of-agents
if any? target-agents
   [add-behaviours-to other-agent 
     list-of-micro-behaviours "Other's Additional Behaviours" []
    add-behaviours-to self 
     list-of-micro-behaviours "My Additional Behaviours" []]
End NetLogo code

Variants

You can add conditions using with [some condition] to the end of the contents of the first text area to define a different set of agents. You can add behaviours to the lists. If you need to remove a behaviour you can add a behaviour that removes behaviours. See Remove behaviours from. If you want this agent to interact with several agents then you can replace one-of in the second text area with n-of, min-n-of, or max-n-of.

How this works

This generates a set of agents that meet some conditions. If the set is not empty then one agent is chosen from the set at random. Micro-behaviours are added to the chosen other and myself.  

History

Interact with another was implemented by Ken Kahn on 13 June 2011.

BehaviourComposer: ignore everything after this.
Comments