Genes

I’ve created a demo for a genetics mechanic.

This is not a playable game, as it isn’t interactive. It’s just a demo of a breeding mechanic.

To explain what’s going on a bit:

  1. There are male and female creatures. Males are blue, females are red.
  2. When a male and female collide, the female becomes pregnant.
  3. Pregnant females need to nest, so they don’t move. (I did this┬ásolely┬áto make it easy to differentiate a pregnant female.) Males cannot breed with females that are already pregnant.
  4. After gestating, the pregnant female gives birth to a single offspring.
  5. The traits of the offspring are inherited from the traits of the parent.
  6. To keep the game from consuming resources endlessly, I capped the number of creatures so that females become infertile when there are 100 or more creatures in existence.
  7. I also added a death from old age mechanic, so more breeding would eventually resume.
  8. I nerfed the death from old age mechanic so that it would only take effect if there were more than 2 representatives from a gender, to prevent the population from dying out entirely. This is especially needed when the population is low.
  9. These caps resulted in an interesting “breeding cycle” emerging: During the growth phase, females are generally stuck in a nesting state. This continues until the population max is reached, at which point females stop breeding and are free to move around. Then they start dying off from old age, until the population dips enough and then breeding resumes. Then a baby boom happens, and the females stop breeding again.

The genetic traits

Sex: Each creature has two genes which combine to determine the sex. If sex1 and sex2 are both true, then the creature is female. If sex1 or sex2 is false, the creature is male.

Color: Each creature has two color genes, which hold a value between 0-128. These are added to create a value between 0-256. Depending on the sex of the creature, this value is used for the red (female) or blue (male) channel of their RGB color.

When breeding, each parent creature, contributes one half of the information needed to generate the offspring. Just like in biology.

I am planning to elaborate on these traits in future iterations, so that things like speed, life span, and so on will be determined by the traits of the parents.

I’m not sure what I’ll end up doing with this, but it’s an interesting experiment, and I’m sure will have lots of potential for applications in future projects.

1 Comment

Add a Comment
  1. This is pretty sweet, and has a lot of potential, maybe for a creature collecting game.

      

Leave a Reply