NetLogo banner

 Home
 Download
 Help
 Resources
 Extensions
 FAQ
 NetLogo Publications
 Contact Us
 Donate

 Models:
 Library
 Community
 Modeling Commons

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

  Donate

NetLogo Models Library:
Code Examples

(back to the library)

Breed Procedures 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 shows how to use the run command to give different breeds different definitions of the "same" procedure.

THINGS TO NOTICE

You could accomplish the same thing with code like this:

  ifelse breed = dogs
  [ dogs-speak ]
  [ ifelse breed = cats
    [ cats-speak ]
    [ cows-speak ] ]

but such code is tedious to write and runs slower.

NETLOGO FEATURES

The run command is fast when you use it over and over again on the same strings, so using this technique won't hurt the performance of your model.

(back to the NetLogo Models Library)