Search This Blog

Happy little genes

 [Originally written October 6 2020]

While at this point I’ve more or less given up on figuring out the formula for exact RGB values produced by color rotations and swaps, I do want to dive a little deeper into the genetics side of it. What if you have more (or fewer) bleed genes? What about regular pigment genes?

In my previous exploration of color rotations, I found that the three bleed genes produce the final rotation output by means of the formula Floor((((0.5 * Gene1) + (Gene2) + (2 * Gene3)) / 4) + 16) = Actual Value.

I tried deleting the third gene and did some more experimentation.

Visual
Gene 1210170128180255
Gene 2180220255235255
Actual174184191194223

Using the same formula structure I concluded that this is calculated as Floor(((Gene1 + (2 * Gene3)) / 4) + 32) = Actual Value.

Based on the relationship between the formulas, I would then expect that a single rotation gene would be calculated as Floor(((2 * Gene) / 4) + 64) = Actual Value. Indeed, when I created a creature with only one pigment bleed gene set to rotation 200, I got a creature with a total rotation value of 164 out of it. 

Extrapolating from this, would adding a gene result in the formula Floor((((0.25 * Gene1) + (0.5 * Gene2) + (Gene3) + (2 * Gene4)) / 4) + 8) = Actual Value? I created a Norn with a fourth gene placed before the normal three, in the configuration 255/128/128/128. As expected, the reported rotation was 135. I think I’ve cracked the entire formula!

Floor(((Sum((4/(2^(n+1-i)))*GENEi))/4)+(128/(2^n))) = reported rotation for n bleed genes

Do normal pigment genes work the same way? For each of the three colors, a creature has four genes. One of these is labeled “at birth” for each color but the rest (except for red) also switch on at birth; perhaps during development they intended these to turn on at different stages of life. Red is a bit of an oddball, because three of the genes for this color switch on at birth… but the fourth is tied to gender and turns on at adolescence. Why only red? That’s a question only the creators could answer. All I can do is figure out how the numbers are calculated. I decided to leave red alone for the time being and created some Norns with various edits to their blue genes, and swiftly concluded that this is far less complicated than bleed genes – the game simply averages the values.

So… what about those genes that switch on later? Do they replace values, or do they simply get added into the mix? I created some creatures to test both bleeds and regular pigments. One had rotation genes set to 255/255/128 for embryo genes and 255/128/255 for adolescence genes. As a baby, her rotation value is 175. If the genes get replaced, the adolescent value would be 207, but if they get added in, it would be 213. I also created two creatures with their embryo red genes set to 20/100/150 and their adolescence gene set to 255 – one male, one female. I created both because if the genes got replaced, the order could matter. Their childhood red value was set to 90; if the gene got added in, it would become 131; if the gene replaced one other, it would be 168, 141, or 125 depending on which gene it replaced. And of course it would be 255 if it replaced all of them. Indeed, the bleed creature came out at 207, while the pigment creatures came out at 255, meaning that once a new coloration gene kicks in, it replaces the ones from previous life stages.

No comments:

Post a Comment