NetLogo banner

NetLogo Publications
Contact Us

Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Farsi / Persian


NetLogo Models Library:
Curricular Models/ModelSim/Evolution

(back to the library)

Bacteria Hunt Speeds

[screen shot]

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


This is a natural/artificial selection model that shows the result of two competing forces from natural selection related to the speed of a prey.

Which force dominates the outcome from natural selection depends on the behavior of the predator(s).

One force is that predators that chase prey, tend to catch slower moving prey more often, thereby selecting for removing prey that are slower, leaving behind faster prey to have offspring. This leads to progressively faster prey in the population over time.

Another force is that predators who wait for their prey without moving, tend to catch prey that are moving faster more often, because these prey run into them more frequently than the slow moving prey. In this manner, they thereby select for removing prey that are faster, leaving behind slow prey to have offspring. This leads to progressively slower prey in the population over time.

A player can intentionally cause bacteria to become faster over time, simply by trying to chase after them, clicking (eating) any bacteria that player can catch. And they can unintentionally cause bacteria to become slower over time, simply by waiting for bacteria to come to them and clicking (eating) any bacteria that travel under where that player is situated.


You assume the role of a predator (such as a nematode) amongst a population of single celled bacteria. To begin your pursuit of bacteria as a predator, press SETUP to create a population of bacteria, determined by six times the INITIAL-BACTERIA-PER-VARIATION slider. These bacteria that are created are randomly distributed around the world and assigned a variation (the number of flagella they posses [1 through 6])

When you press GO the bacteria begin to move at speed proportional to the number of flagella they posses. As they move around, try to eat as many bacteria as fast as you can by clicking on them. Alternatively, you may hold the mouse button down and move the predator over the bacteria.

The six different variations in the population are initially equally distributed amongst six sub-populations of the bacteria. With each bacteria you catch, a new bacteria is randomly chosen from the population to produce one offspring. Flagella number is an inherited trait. The offspring that is chosen, therefore, is an exact duplicate of the parent (in its number of flagella as well in its location in the world). The creation of new offspring keeps the overall population of the bacteria constant.

Initially, there are equal numbers of each sub-population of bacteria (e.g. five bacteria with each variation). With each new bacteria you eat, the distribution of the bacteria will tend to change, as shown in the # OF BACTERIA FOR EACH VARIATION histogram. In the histogram, you might see the distribution shift to the left (showing that more bacteria with less flagella are surviving [these are the slower ones]) or to the right (showing that more bacteria with more flagella are surviving [these are the faster ones]). Sometimes all the bacteria with a given variation will be wiped out completely. At this point, no other bacteria of this speed can be created in the population.

Bacteria turn around (to face in the opposite direction) when they detect your mouse cursor (as a predator) in their detection cone (an arc of 120 degrees that has a range of 2 units). They are not able to detect you when your mouse cursor has turned gray (after a couple seconds of inactivity).

Bacteria can detect the predator only in this arc in front of them, and so will not react to the mouse cursor when caught or chased from behind.


INITIAL-BACTERIA-PER-VARIATION is the number of bacteria you start with in each of the six possible variations in flagella number. The overall population of bacteria is determined by multiplying this value by 6.

VISUALIZE-VARIATION helps you apply different visualization cues to see which variation each a bacterium has. These are the options you can set this chooser to:

  • flagella only - shows the different number of flagella that each bacterium has as "wiggling" hair-like appendages on the bacterium.

  • as color - shows 6 distinct colors for the 6 different trait variations (number of flagella) a bacterium might have (red = 6, orange = 5, yellow = 4, green = 3, blue = 2, and violet = 1).

  • flagella and color - shows both of the above at the same time.

  • # flagella as label - shows a number as a label, corresponding to the number of flagella the bacterium has. But the actual flagella themselves are invisible and each bacterium is colored gray.

  • none - each bacteria is colored gray, with no flagella visible, nor any label shown. The bacteria still travel at different speeds based on the number of flagella they have, regardless of whether they are visible or not.

Some of these visualization settings are designed to remove elements that may distract the person running the mode (who is also playing the role of the predator), from unintentionally attending to one visualization cue over another and selecting bacteria based on certain visualization cues (e.g. purposely going after the red ones).

# OF BACTERIA EACH VARIATION is a histogram showing the distribution of bacteria with different number of flagella (which also corresponds to the relative speed of movement).

AVG. # OF FLAGELLA PER BACTERIA is a bivariate graph of the average number of flagella per bacteria in the population over time. This tends to increase when bacteria are chased after by the player mouse and this tends to decrease when

# ALIVE is a monitor showing the total number of bacteria currently in the world.

# CAUGHT is a monitor showing the total number of bacteria caught.


The # OF BACTERIA EACH VARIATION histogram tends to shift to the right (corresponding to an increasing average speed in the population) if you assume the role of chasing easy prey.

The # OF BACTERIA EACH VARIATION histogram tends to shift to the left (corresponding to an decreasing average speed in the population) if you assume the role of waiting for prey come to you. The same effect can also be achieved by moving the predator around the world randomly.


Setup the model up with INITIAL-BACTERIA-PER-VARIATION set to 1. Slow the model down and watch where new bacteria come from when you eat a bacteria. You should see a new bacteria hatch from one of the five remaining and it should be moving at the same speed as its parent.

Setup the model with more initial bacteria. Chase bacteria around trying to catch the bacteria nearest you at any one time by holding the mouse button down and moving the predator around the view after the nearest bacteria.

Setup and run the model again. This time wait in one location for the bacteria to come to you by placing the predator in one location and holding down the mouse button. All bacteria that run into you will be eaten.


A HubNet version of the model with adjustable starting populations of bacteria would help show what happens when two or more competitors assume similar vs. different hunting strategies on the same population at the same time.


Bug Hunters Camouflage Bacteria Food Hunt Previous versions of this model were referred to as Bug Hunt Speeds


This model is part of the Evolution unit of the ModelSim curriculum, sponsored by NSF grant DRL-1020101.

For more information about the project and the curriculum, see the ModelSim project website:

Inspired by EvoDots software:


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 2015 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)