At the forefront of Artificial Intelligence
  Home Articles Reviews Interviews JDK Glossary Features Discussion Search
Home » Articles » Artificial Life » Bio-Inspired Computing

Modelling Bacterium using the JDK

Simulation 0-250 iterations Several years ago back in university, I was set some very interesting coursework. It involved taking a simulation package called BEAST, and writing code to evolve several elements of a complicated mathematical model to coerce simulated bacteria into exhibiting fractal behaviour.

The coursework continued to fascinate me years later, so I decided that as part of my drive to resurrect my work on Generation5, I'd use the Generation5 JDK to try to simulate this behaviour myself.

Important Note: I had to update portions of the JDK to implement this, so you will not be able to develop against the current version of the JDK. To use it, you may download the JAR file currently in use on Generation5.

The Model

The model I devised was a gross simplification of the one BEAST implements - firstly, because I didn't have access to the BEAST code anymore, secondly, I like simple models and finally, I wanted to implement the bacteria as a cellular automata.

The model took into account several things:

  • Energy
  • Surrounding nutrient
  • Attrantant
  • Repellent
  • Swarming
  • Basic attractant/repellent diffusion
Even with just these elements, the bacteria showed the behaviour I was after. Below you can see two images of the bacteria after 250 and 500 iterations of the world. Click the picture to see a quick animation of 2000 lifecycles.

The World

Our world is very simple - there are three main components to it. The nutrient, the attractant and the repellent - food levels varying between 0 and 100, attractant/repellent varying between 0 and 255.

Nutrient

Nutrient is added to the world using a 2-dimensional Gaussian distribution so that the bacterium have a gradient to work up (food plentiful in the centre of the world, more scare as you move further out). A 2D Gaussian plot is show to the below.

Bacterium

Each bacterium has an energy level and a heading (direction it is moving in). Each bacterium has the following rules and influences applied to it:
  • For each iteration of the world, energy must be used to survive.
  • Absorb some nutrient, if available.
  • If the bacterium has enough energy to reproduce, add another bacterium to the world.
  • If the bacterium doesn't have enough energy to move, stop here.
  • Otherwise, have a look at the world around for attractant, repellent and nutrient.
  • Next, take a look at surrounding bacteria and their headings (swarming).
  • If there is a swarm and there is sufficient nutrient, secrete some attractant. If there is little or no nutrient, secrete repellent.
  • Select a new heading by using the weighted averages of the nearest attractant, repellent, nutrient and average heading of the swarm.

Implementation

The bacteria was implemented using CellularAutomataLayered, with the nutrient modelled at the world level and the attractant/repellent modelled separately within the derived class. Rendering the world was also overridden to provide the screenshots above. A separate array called trail tracks any time a bacterium moves across a portion of the world, with the render function displaying trail using a gradient. This allows you to see how the trails evolve for all bacteria over time.


Click here to run the demonstration applet.
Bacteria: 500, 1000, 1500 and 2000 iterations

The main crux of the code is contained within BacteriaCA::doStep. The method is pretty lengthy and highly iterative and, as always with my code, optimized for educational ease-of-understanding, rather than speed! The only thing I did do to make the code more efficient, was move any local or temporary variables out of loops. Nevertheless, all code has been heavily commented, so hopefully you'll be able to understand it.

Future Development

I am hoping to expand the code to be evolvable (literally, implement the JDK's Evolvable interface), allowing for experimentation around different fitness functions to evolve certain behaviour. This would involve:

  • Expanding the code to allow for parent/child tracking
  • Distance travelled
  • Having an uneven population of bacteria, with differing thresholds.

References

[1] Gordon, David. beast. Available online at: http://david.gordon.name/ai_a-life.php.

[2] Ben-Jacob, Eshel. Bacterial linguistic communication and social intelligence. Available online at http://star.tau.ac.il/~eshel/bacterial_linguistic.html.

Submitted: 19/03/2007

Article content copyright © James Matthews, 2007.
 Article Toolbar
Print
BibTeX entry

Search

Latest News
- Generation5 10-year Anniversary (03/09/2008)
- New Generation5 Design! (09/04/2007)
- Happy New Year 2007 (02/01/2007)
- Where has Generation5 Gone?! (04/11/2005)
- NeuroEvolving Robotic Operatives (NERO) (25/06/2005)

What's New?
- Back-propagation using the Generation5 JDK (07/04/2008)
- Hough Transforms (02/01/2008)
- Kohonen-based Image Analysis using the Generation5 JDK (11/12/2007)
- Modelling Bacterium using the JDK (19/03/2007)
- Modelling Bacterium using the JDK (19/03/2007)


All content copyright © 1998-2007, Generation5 unless otherwise noted.
- Privacy Policy - Legal - Terms of Use -