Ok, so I've been rewriting the DNA system. I've made it a bit more realistic, but not overly so. My first attempt was as realistic as I could make it, but I found it just didn't really work as well as I'd hoped, so I've pulled back the complexity a lot to make something a bit more playable.
The DNA system is a bit too complex for me to want to try to describe here. :)/> I've also used random names in my code that don't really line up with real life terms, because.. well, I'm not very good at biology!
I guess in simple terms it's like this:
A DNA is split into various genomes. Each genome describes a particular trait of the mob. For example, "head type", "body type", "offspring", "drop items", "drop count".etc..
Each genome has 40 genes. A gene is just an integer and a boolean. The integer refers to a particular trait (pig head, chicken head, 2 drops, 3 drops, wool, silk, whatever), and the boolean defines whether that gene is active or not.
So, a typical DNA (so far) looks a bit like this:
dt[2:1,3:0,3:0,2:0,2:1,2:1,3:0,2:1,3:1,3:1,2:0,3:1,3:0,2:0,2:1,3:1,3:1,2:1,3:1,2:1,2:1,2:1,3:0,3:0,3:1,2:0,3:1,3:0,2:1,3:1,3:0,2:1,2:0,3:1,2:0,2:0,3:1,3:1,2:1,3:1]
da[1:0,2:1,2:0,2:0,2:1,1:1,1:1,2:1,1:0,2:1,1:0,2:0,1:1,2:0,2:1,1:1,2:0,2:0,1:1,2:0,1:0,1:0,1:1,2:0,2:0,2:0,2:1,1:1,2:0,2:1,2:1,2:0,1:1,2:1,2:0,2:0,2:0,2:0,1:0,1:0]
tt[33:0,33:0,33:0,33:1,33:0,33:0,33:1,33:1,33:1,33:0,33:0,33:1,33:0,33:1,33:1,33:1,33:1,33:0,33:1,33:1,33:0,33:1,33:0,33:0,33:0,33:0,33:0,33:0,33:1,33:1,33:0,33:1,33:1,33:0,33:0,33:0,33:1,33:0,33:1,33:1]
c[2:0,2:1,2:0,2:1,2:1,2:0,2:0,2:1,2:0,2:1,2:0,2:0,2:0,2:1,2:0,2:0,2:1,2:1,2:0,2:1,2:1,2:0,2:0,2:1,2:1,2:0,2:1,2:0,2:0,2:1,2:1,2:1,2:1,2:0,2:0,2:1,2:0,2:1,2:1,2:0]
ht[33:1,33:1,33:0,33:0,33:1,33:1,33:1,33:0,33:1,33:0,33:1,33:1,33:1,33:1,33:0,33:0,33:0,33:1,33:1,33:0,33:1,33:0,33:1,33:0,33:1,33:1,33:0,33:1,33:1,33:1,33:1,33:0,33:0,33:1,33:0,33:0,33:0,33:0,33:1,33:1]
a[0:0,0:0,0:1,0:1,0:0,0:1,0:0,0:0,0:1,0:1,0:1,0:0,0:1,0:1,0:0,0:0,0:0,0:0,0:0,0:0,0:1,0:1,0:1,0:0,0:0,0:1,0:0,0:1,0:1,0:0,0:0,0:0,0:1,0:0,0:1,0:0,0:0,0:0,0:1,0:0]
at[33:1,33:0,33:0,33:1,33:0,33:1,33:0,33:0,33:0,33:0,33:1,33:0,33:0,33:1,33:0,33:1,33:1,33:0,33:0,33:0,33:0,33:0,33:0,33:0,33:0,33:1,33:0,33:0,33:1,33:1,33:1,33:0,33:0,33:0,33:1,33:1,33:1,33:0,33:1,33:1]
o[1:0,1:0,1:1,1:0,1:1,1:0,1:0,1:0,1:1,1:1,1:1,1:1,1:1,1:1,1:1,1:0,1:1,1:1,1:1,1:1,1:0,1:0,1:1,1:1,1:1,1:1,1:1,1:1,1:0,1:0,1:0,1:0,1:1,1:0,1:1,1:0,1:0,1:1,1:0,1:0]
lt[33:1,33:1,33:1,33:0,33:0,33:1,33:1,33:1,33:1,33:1,33:0,33:0,33:0,33:1,33:0,33:1,33:1,33:1,33:0,33:0,33:0,33:0,33:0,33:0,33:1,33:0,33:0,33:0,33:1,33:0,33:0,33:0,33:1,33:0,33:0,33:1,33:0,33:0,33:1,33:0]
wt[33:1,33:0,33:1,33:1,33:0,33:1,33:1,33:1,33:1,33:0,33:0,33:1,33:1,33:1,33:1,33:0,33:0,33:0,33:1,33:1,33:1,33:0,33:1,33:1,33:0,33:0,33:0,33:0,33:1,33:0,33:0,33:0,33:0,33:1,33:1,33:0,33:1,33:0,33:1,33:0]
bt[33:0,33:0,33:0,33:1,33:0,33:0,33:1,33:0,33:1,33:0,33:0,33:0,33:0,33:0,33:0,33:0,33:1,33:1,33:0,33:0,33:1,33:0,33:1,33:0,33:0,33:0,33:0,33:1,33:0,33:0,33:1,33:1,33:0,33:0,33:1,33:0,33:0,33:0,33:1,33:0]
In this one, the "dt" genome describes the drop types, where "2" refers to feathers and "3" refers to raw chicken. This is a pure chicken DNA.
If you splice two DNAs from two different mobs, it'll run through each genome on both the mobs and randomly copy the values of the genes into a new genome. It also copies the values of a gene independently, so:
Lets take the very start of the first line:
dt[2:1…
Lets pretend our other DNA is
dt[4:1..
there's a 50/50 chance of it being either a 2 or a 4, and a 100% chance of this gene being active in the new DNA.
You could have a situation where inactive genes become active:
dt[2:0…
dt[1:1…
the result could be:
dt[2:1…
Different traits of the animal depend on the active genes within the DNA. For example, for drops it'll use weighted randomness on any active gene in that genome. For color, it might use an average of all active traits. To decide which models to use for different parts of the bodies i'm using er.. weighted weights pow(1.7)!
As for DNA Fragments (which are extracted from organic material), if you splice a DNA fragment with a DNA, it'll copy a single gene from the fragment into your DNA (from a random genome). You currently have no control which gene gets copied across.
I might eventually make some advanced (expensive) tools, possibly CC peripherals too, to give players a bit more control over their dna.