NetLogo banner

Home
Download
Help
Resources
Extensions
FAQ
NetLogo Publications
Contact Us
Donate

Models:
Library
Community
Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

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

  Donate

NetLogo Models Library:
Code Examples

(back to the library)

Lottery 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?

NetLogo makes it easy to make a random choice where every outcome is equally likely. But what if you want different outcomes to have different chances of being chosen...?

In this example, we show how to run a "lottery" in which we pick a random turtle, and a turtle's chance of winning is proportional to its size.

EXTENDING THE MODEL

In this version of the code, the agentset for the lottery (turtles) and the reporter run by each agent (size) are both hardcoded in the lottery-winner procedure. If those were passed as inputs to the procedure instead, then the same procedure could be used to run different lotteries. This would be possible using reporter tasks. (See the Tasks section of the Programming Guide.)

RELATED MODELS

The Rnd Example model, in the Extensions Examples section of the Code Examples, shows how to achieve similar results using the rnd extension bundled with NetLogo.

(back to the NetLogo Models Library)