Visions Of Chaos Genetic Bugs Tutorial

Genetic Bugs is a simple simulation to show Darwinian principals of evolution and survival of the fittest.

The World

The world the bugs live within contains the bugs themselves (represented as white circles), food (represented by green pixels) and obstacles (represtented by blue areas).

Genetic Bugs

Genetics Of The Bugs

Each of the bugs' movement is controlled by an artificial DNA made up of a sequence of 8 numbers.

When the bugs are initially randomly created each of their 8 genes are given a random value between 1 and 50. For example, one of the bugs may be given a sequence 10 3 49 26 18 9 23 35 to make up its genes.

Every time the bug moves this is the sequence of calculations that determine its direction;

1. The gene values are added up. For the above sequence this results in 10+3+49+26+18+9+23+35=173.

2. A random number is chosen between 1 and the total value. For this example the random value chosen is 66.

3. The gene sequence is added up in sequence until it does not go over the random value. 66 would fall within the range of the third gene (between the range of 61 (10+3+49) and 87 (10+3+49+26)).

4. Each of the 8 genes represent a direction to move. First gene is north, second is north-east, third is east, etc. So because 66 hit the 3rd gene the bug moves east.

In this virtual world bugs that tend to move in small circles die out from lack of food. Bugs that move in more straight lines eat more food and have a better chance of survival.

Eating and Energy

If a moving bug lands on a food particle, it eats the food and its energy level increases. If there is no food at the location its energy level decreases.

Bugs that lose too much energy will die and are removed from the world.


When a bug's energy reaches a specified amount it will give birth to a child bug. The child bug takes on the same gene sequence as the parent bug, but with slight changes. These changes are like evolutionary mutations.

As the child bugs live in the world they may do better than the parent bug. The best surviving bugs eat more food, gain more energy and give rise to more child bugs and pass on their genes.

Other Settings

There are many settings to tweak that customise the world and the simulation of the bugs.

Initial bug population - The number of bugs to start the simulation with. Each of them get a random gene sequence.

Initial bug energy - The amount of energy each bug gets when first generated or when given birth to.

Initial food density - How much of the world has food particles.

Energy per food particle - How much energy a bug gains when it eats a food particle.

New food per cycle - How many new food particles are added to the world each step of the simulation.

Wraparound world - If checked the right edge wraps around to the left edge and the bottom edge wraps around to the top edge. If unchecked the edges of the world are surrounded by walls or obstacles and bugs cannot travel beyond the edges..

Show statistics - Displays a statistics window during simulations that shows stats on births, deaths and other simulation related data.

Obstacles - When checked the world will have obstacles introduced that the bugs cannot go through. This means their gene sequences need to learn or adapt to not run into the obstacles as much so they keep moving and eating. There are a variety of obstacle types included to choose from.

Genes modified at birth - How many of the 8 genes are changed for a child bug compared to the parent bug.

Amount each gene is affected - Amount added or subtracted to modified genes.

Energy level for birth - The amount of energy a bug needs to reach before it gives birth to a child bug.

Bug display style - Alternate ways other than circles to show the bugs as.

Color settings - Allows customised colors for the display.