Farsi / Persian
NetLogo Models Library:
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.
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.)
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.