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:
- There are male and female creatures. Males are blue, females are red.
- When a male and female collide, the female becomes pregnant.
- 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.
- After gestating, the pregnant female gives birth to a single offspring.
- The traits of the offspring are inherited from the traits of the parent.
- 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.
- I also added a death from old age mechanic, so more breeding would eventually resume.
- 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.
- 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.