NetLogo banner

Home
Download
Help
Resources
Extensions
FAQ
NetLogo Publications
Contact Us
Donate

Models:
Library
Community
Modeling Commons

Beginners Interactive NetLogo Dictionary

User Manuals:
Web
Printable
Chinese
Czech
Farsi / Persian
Japanese
Spanish

  Donate

NetLogo Models Library:
Code Examples

(back to the library)

Partners Example

[screen shot]

If you download the NetLogo application, this model is included. You can also Try running it in NetLogo Web

WHAT IS IT?

This code example shows how agents can "partner up" with each other. Each turtle will pair up with another turtle. Each turtle in a pair are aware of this partnership, preventing mismatched partners and multiple partners.

In this example, the turtles needs to be on the same patch to form a partnership, but you can easily change it to be turtles within a given radius (by using in-radius), or using no spatial requirements at all.

Pairing turtles is used by many models that require single turtle interactions. One example is models that require turtles to reproduce with another turtle. Another example is the GasLab models where molecules are forced to only interact with one other molecule at time, which simplifies the code by preventing a three (or more)-way collision.

HOW IT WORKS

Turtles with no partner are gray; partnered turtles are red. Unpartnered move randomly about the View until they land on a patch with another unpartnered turtle. When this happens, the two turtles form a partnership and stop moving.

RELATED MODELS

Grouping Turtles Example shows how to form groups that contain more than two turtles.

(back to the NetLogo Models Library)