NetLogo banner

NetLogo Publications
Contact Us

Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Farsi / Persian


NetLogo Models Library:
Sample Models/Social Science/Economics

(back to the library)

Fruit Wars

[screen shot]

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


The Fruit Wars model is intended to demonstrate how non-zero-sum economic environments can encourage cooperation and discourage violence. The foragers wander the map looking for fruit bushes. When they arrive at a fruit bush they gain energy through foraging until the fruit bush is exhausted of resources. These animals reproduce and pass on their characteristics to their offspring after gathering a certain amount of energy. They also make decisions based on heritable parameters about how to interact with other foraging animals. The foragers can choose to cooperate, threaten, fight or flee under different circumcstances.

In the model, foragers can either cooperate or fight based on heritable aggression attributes. The COLLABORATION-BONUS parameter in the model controls how beneficial cooperation is in terms of foraging and so one should expect to see the evolutionary equilbrium of the system move toward foragers with less violent tendencies when the model is run with higher COLLABORATION-BONUS settings.


Foragers in the model have 240-bit binary genomes:

  • The sum of the first 120 bits determines the strength, speed and intelligence of the foragers. These three stats can have any values between 0 and 60, but their sum must always be 60.

  • The sum of bits 120 to 180 determine the forager's reactive-aggression, which determines the tendency to threaten when arriving at a bush and the tendency to threaten new arrivals when already at a bush. The sum of bits 180 to 240 determine the forager's proactive-aggression, which determines the tendency to fight back when threatened.

Each Tick in the Model:

For each Forager:

  • If no bushes are very nearby or my status is fleeing, move randomly based on the speed attribute. Consume 1 energy.

  • If there is a bush nearby, move toward it a distance based on the speed attribute. Consume 1 energy.

  • If I am very close to a bush, do the arrival procedure.

  • If my status is foraging, gain some energy and take that energy away from the bush. If the bush runs out of energy, make it die, and remove the foraging status from all other foragers at that bush.

  • If my energy is above 200, reproduce, lose 100 energy.

  • If out of energy or older than the max-age parameter, die.

The arrival procedure:

  • If there are no other foragers at the fruit bush, set status to foraging.

  • If there are other foragers at the bush, the arriving forager chooses to threaten or collaborate probabalistically based on its reactive-aggression value.

  • If my choice is threaten, other foragers at the bush choose to flee or fight back according to their proactive-aggression parameter.

    • If any fight back, the arriving forager wins with a probability based on the difference of the arriving forager's strength and the aggregate strength of all the other foragers choosing to fight back. If the arriving forager wins all of the foragers choosing to fight back die, otherwise the arriving forager dies.

    • If all the other foragers flee, the arriving forager sets its status to foraging.

  • If the arriving forager chooses to collaborate and there is one other present forager, that forager chooses to either allow the arriving forager to join or to threaten causing the arriving forager to flee.

    • If there is only one forager present and it doesn't threaten, or there are multiple foragers present, the status of the arriving forager is set to foraging.


Each forager has a binary genome which encodes the values of its parameters. When the foragers reproduce (asexually), the genome is passed on to the offspring and each position in the genome has a rate-of-mutation chance to flip values.


  1. Set the parameters as desired.

  2. Click SETUP.

  3. Click GO.

Setup Parameters:

  • INITIAL-FRUIT-BUSHES - The number of fruit bushes at the start.

  • INITIAL-FORAGERS - The number of foragers at the start.

Visualization Parameters:

  • SHOW-ENERGY? - displays the current energy of each individual forager in the view if enabled.

  • VISUALIZATION - scales the color of the agent depending on the selection based on the value of that parameter with lighter colors representing a higher value.

Runtime Parameters:

  • BUSH-GROWTH-CHANCE - The chance for a new fruit bush to grow at each turn.

  • TICKS-TO-FLEE - When a forager flees, this is the number of ticks it must move randomly before it can seek a new fruit bush.

  • RATE-OF-MUTATION - The probability that an individual bit will flip during the passage of bit genome from parent to offspring.

  • COLLABORATION-BONUS - A factor used to determine the collaborative rate of foraging. Higher collaboration bonus means higher foraging rates for multiple foragers at a single bush.

  • MAX-AGE - The maximum number of ticks an individual forager can live.


Observe the behavior of the foraging animals as they move around the map. Do you notice any of them fleeing from the fruit bushes? Do you notice many fatalities due to violent encounters (marked in the view by a red X?) How large of population can be sustained by the environment?

The model also has many graphs to observe:

  • A histogram of different forager attributes at each tick.

  • A standard line graph of the forager attributes at each tick.

  • A graph of the ratio of homicides to other deaths.

  • A graph of the average foraging rate per tick.


Try the different VISUALIZATION modes and observe the changes in the agent population at different model speeds and parameter settings. What sorts of patterns emerge?

Try adjusting the COLLABORATION-BONUS parameter. Oberve the behaviors and graphs discussed in the previous section. How do they vary with the COLLABORATION-BONUS parameter? How long does it generally take the model to reach a somewhat stable state, if ever?


Extend the model such that foragers can fight, but not necessarily die. Also, add a mechanic so that if a forager is defeated in a fight, the victorious forager can take all or most of its resources. Additionally, one might incorporate some mechanism such that the foragers' likelihood to fight is determined by some function of their hunger.


This model makes extensive use of [mutable] ( NetLogo lists to implement bit genomes for agent evolution. It also uses custom turtle shapes designed in the Turtle Shapes Editor.


  • Altriusm

  • Cooperation

  • Braess' Paradox


If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the model itself:

Please cite the NetLogo software as:


Copyright 2019 Uri Wilensky.


This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at

(back to the NetLogo Models Library)