...back to flash


gene warfare v.1

Gene Warfare is a simulation of genetics and evolution. It consists of a world populated by a few individuals, which I call "little guys". The little guys can eat each other to score points. Guys with higher scores get to breed more than guys with lower scores, and this simple rule leads to the remarkable fact that over time, the population learns.

Genetics

Each individual has its own genetic code. Ordinarily we think of genes as determining the physical features of an individual, but these genes determine only the behavior of these little guys. Each individual's genetic code is interpreted as a simple computer program, and the individual runs this program continually in order to determine how to steer and move.

You can click a little guy to bring up his Information View.

Little guys are colored according to their genetic makeup. This helps you to see which guys are similar and which ones are not. But don't read too much into this. A blue guy may behave the same as a red guy, whereas two red guys may behave nothing like each other. Color is a loose indicator of the little guy's genetic code.

The Rules

Whenever two individuals touch, one of them kills the other. Whichever of them is more squarely facing the other one at the moment of collision is the winner. The losing individual dies; the winning individual gains points.

Eventually each generation ends. Whenever this happens, the next generation is bred from the winners of the previous generation. Little guys with more points get to breed more often and their genetic code gets passed on to more members of the next generation. Little guys with no points don't get to breed at all.

The generation will end under a few circumstances.

  • Only one individual is left alive.
  • None of the individuals are actually moving anywhere.
  • About 20 seconds have passed since the start of the generation.
  • You click the Retire button.

What happens when the generation ends and no little guys have points? In this case, Armageddon takes place. The race is destroyed and a new race is created, with each individual starting from a totally random genetic code.

What happens when just one little guy has points at the end of a generation? In this case, the Noah Effect comes into play. The lone point scorer is allowed to breed with all the other little guys, but the other little guys are given random genetic codes. In effect, the race now has a single parent and heavy mutation.

Parenting

Whenever a new generation is created, each individual is the result of a mating between two individuals from the previous generation.

Mating two individuals is very simple. Each byte in the offspring's genetic code is randomly chosen either from one parent or the other. There is a 50%/50% chance it will come from one or the other. Believe it or not, this rather haphazard-sounding algorithm is the basis for all genetics.

After the offspring's genetic code is formed, it is mutated. During mutation, random bytes are modified either by swapping them with other bytes, or setting them to random values.

Mutation and Genetic Distance

Mutation is a very important concept. You can set the chance of mutation yourself in the Options panel. If there were no mutations, eventually the race would settle upon a single genetic code and all individuals would be identical to all others. On the other hand, if mutation is rampant, the race loses coherency; individuals have little genetic information in common and the population will not evolve. The amount of mutation you dial in while playing with Gene Warfare will fundamentally affect how quickly the population learns and how creative its strategies become.

In order to help you tune how much mutation to allow, the genetic distances of each generation are displayed. Genetic distance describes how similar individuals within the generation are. If your maximum genetic distance is very low, you've got a stagnant population with not enough diversity. If your minimum genetic distance is too high, you've got an incoherent population where evolution will not occur.

The Program

In version 1 of Gene Warfare, only 5 program instructions are available for the little guys to use. They are:

  • SET - sets the value of an internal register to an arbitrary number.
  • OMOV - moves the contents of an internal register to an output register.
  • IMOV - moves the contents of an input register to an internal register.
  • NEG - negates an internal register.
  • MUL - finds the product of two internal registers.

That's not much of a programming language, but it's enough for them to figure out some pretty nifty things.

The SET, NEG, and MUL instructions are pretty straightforward. The interesting instructions are OMOV and IMOV. OMOV allows a little guy to drive himself around. IMOV allows him to sense the world around him.

Each little guy has two "controls". He has a "steering wheel" and a "gas pedal". What the little guy actually does with these controls is determined by the contents of his output registers (oregs for short). You can see these registers in the little guy's Information View. The OMOV instruction is responsible for putting values into the registers.

Which direction the little guy steers is determined by his oreg[ 0 ] register. The larger this number is, the more the little guy steers to the right. If the number is negative, it means he is steering to the left.

How hard he pushes down on the gas pedal is determined by oreg[ 1 ]. The bigger this number is—whether it's positive or negative—the harder he pushes on the gas.

If a little guy's program is effective at sending values to these registers, he'll move around, and that turns out to be a pretty important strategy for doing well in the world the little guys live in.

The little guys also have some very limited senses about the world around them. These senses are passed into them via their input registers (iregs). The IMOV instruction is responsible for retrieving values from these registers into the program for further processing.

The ireg[ 0 ] register tells the little guy how far away he is from the nearest other little guy. As you watch generations evolve, you'll notice that some little guys like to slow down as they get close to other little guys; others like to speed up.

The ireg[ 1 ] register tells the little guy whether the nearest other little guy is to the right or to the left, and how much so.

Using IMOV effectively is a pretty advanced skill, and it may take quite a few generations before your little guys learn to sense their world and tune their movements to respond to it.

Rewarding and Pruning

You can view an individual's program and registers by clicking on him. The same Information View also allows you to Reward or Prune the individual.

Rewarding the individual gives him 100 points per click. This works even if he's already dead. So if you see an individual who is behaving in neat ways, reward him to ensure his genes get passed on to the next generation.

Pruning the individual both kills him and strips him of all points. This guarantees his genes will have no part in the next generation.