NetLogo banner

NetLogo Publications
Contact Us

Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Farsi / Persian


NetLogo User Community Models

(back to the NetLogo User Community Models)

[screen shot]

If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".(The run link is disabled for this model because it was made in a version prior to NetLogo 6.0, which NetLogo Web requires.)


This model is a simple illustration of bacteria growth in the body, and how white bloods and antibiotics can be used to fight the infection. It is aimed as a basic educational model, giving an abstracted visual representation of the scenario.

A general bacterium reproduces by cell division. The cells grow to a fixed size then, reproduce through binary fission, and creates two identical clone daughter cells, doubling in quantity over a given time step.


Bacteria are set to double in size every time step.

The white bloods work to eliminate the bacteria by randomly moving around the area and killing the bacteria on touch.

Antibiotics can be introduced into the model at any time which will kill half of the bacteria over the specified time step. In order to keep the bacteria under control, the antibiotic interval must be as frequent as or more often than the bacterial reproduction rate.


Setup – Clears the screen and creates and a simulation with the specified parameters (eg initial bacteria, initial white blood cells, etc)

Go – Runs the simulation

Bacteria Cells – Displays the total number of bacteria cells alive

Total Cells – A graph showing the total number of bacteria cells and white blood cells alive. Bacteria are drawn in red; white blood cells are drawn in grey.

InitialWhiteBloodCells – Sets the initial quantity of white blood cells in the system. 0 - 10

InitialBacteria – Sets the initial value of bacteria in the system. 0 - 100

BacteriaReproductionRate – Sets the time step for bacteria reproduction (i.e. how often are new bacteria reproduced).

IntroduceAntibiotic – Sets whether or not to introduce antibiotics to the system. When starting the simulation this should be set to off and be turned on later in the simulation (i.e. when a sufficient quantity of bacteria exist)

AntibioticInterval – Sets the time step for antibiotic effect. This can be viewed as how often the antibiotics are taken.


Running the simulation with the same initial values does not always produce the same results. Sometimes the white blood cells will be able to locate and engulf/kill all the bacteria fast enough, other times they will not. The ability/inability of the white blood cells to kill bacteria could lead to an infection which can resurge when the quantity of bacteria is low. This can demonstrate the rise and fall of a person’s well being during an infection.

If the bacterium becomes too much for the white bloods cells to manage, antibiotics can be introduced. Depending on when the antibiotics are introduced, the simulation will either be able to control the bacteria, or over run model. The key to antibiotics is to introduce them at the right time and take them at the right frequency.


Play around with the sliders to set the initial starting values of the parameters in the simulation. How does the quantity of white blood cells related to the bacteria growth and how does the reproduction rate of the bacteria affect the simulation?

Turn the IntroduceAntibiotics switch to on mid way through the simulation to model a patient being prescribed antibiotic treatment. Once introducing antibiotics, turn off the switch before all (or most) the bacteria have been killed. This demonstrates the importance of finishing a course of antibiotics


The operation of white blood cells is a lot more complicated than represented in the model. The quantity of white blood cells within a person’s body depends very much on their immune system and their overall health. Additionally, if specific area is infected, white blood cells from the circulation to help to fight the infection. A more realistic simulation would have a fluctuating quantity of white blood cells proportional to the bacterial infection, which represents both the body dealing with the infection, and the life cycle of white blood cells.

The affect of antibiotics have also been greatly simplified in the system and do not technically operate by killing exactly half of the bacteria when ingested. Additionally many bacteria have been came resistant to many of the common antibiotics (or if antibiotics are taken haphazardly, become resistant during the infection). If a prolonged exposure to antibiotics produced a resistance in the bacteria, how would this affect the simulation?


This model was created by Paul Hanson as part of his Game Artificial Intelligence coursework at Glasgow Caledonian University

Porth, C.M. and Matfin, G. (2009). Pathophysiology: Concepts of Altered Health States (8th edition). Lippincott, Williams and Wilkins. Philadelphia

Bannister, B., Gillespie, S. and Jones, J. (2006). Infection: Microbiology and Management. Blackwell Publishing Ltd. Oxford

(back to the NetLogo User Community Models)