Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2] 3

Author Topic: Creature color genetics experimentation  (Read 10187 times)

DeKaFu

  • Bay Watcher
    • View Profile
Re: Creature color genetics experimentation
« Reply #15 on: June 13, 2016, 11:44:13 am »

Nice science!

To save you some work, the Appearance Tweaks mod in my signature has gender-specific coloring for the wings of fairies and pixies.  You'll have to remove the vermin tags from them to get them in the arena, but they conveniently have overlapping color choices for the males and females.  This will help determine if there is really one set of genes or two.

Thanks for the offered help, but I've actually already made my own creature and finished several hours of testing on them. I should be able to post what I found later today. I'm glad someone's interested, though!

Your science certainly adds convenience to livestock breeding. Would I be correct to assume that there isn't anything barring parent-child relationships either?

I set up a quick side-test for this by letting a pair breed and then killing off the father and all but three male offspring. I let the boys grow up, and then left the game running for about four hours. They haven't bred in all that time, which suggests to me that Parent-Child relationships might not work. Obviously it's not 100% proof (all three boys could be asexual?) but that's what I'm seeing. I'll probably leave it going for a few more hours and update if anything happens. (Edit: The mother died of old age without breeding.)
« Last Edit: June 13, 2016, 07:32:24 pm by DeKaFu »
Logged

DeKaFu

  • Bay Watcher
    • View Profile
Re: Creature color genetics experimentation
« Reply #16 on: June 13, 2016, 07:33:06 pm »

Okay, I finished investigating what happens to DF genetics when colors are defined separately for males and females. Incoming wall of SCIENCE. Don't say I didn't warn you.
Also, just to reiterate, the conditions this post covers will never come up in an un-modded game. For how genetics function in vanilla creatures, look back at the first post.

GOAL

In DF, it's possible to define different sets of potential colors for males versus females. For example, male peacocks are always born blue and female peacocks are always born brown. Because no vanilla creatures with this arrangement have more than one potential color per sex, nobody knows how this affects the system of inheritance. I wanted to find out if it works differently than normal genetics, and how it accounts for the possibility of colors that show up in one gender but not the other.

EXPERIMENTAL SETUP

To start off, here is the slightly modified version of my test creature that is used for these tests:


The only difference between this one and the first is that instead of all the possible colors being defined under [CASTE:ALL], they are defined under [CASTE:MALE] and [CASTE:FEMALE].
I decided to establish a baseline by leaving the color and dominance options identical between the two sexes. By doing it this way, there's a chance the behavior will exactly match what we saw before. If it doesn't, there's obviously a different system in place.

Apart from that, I did breeding experiments in the arena like I described before.

RESULTS

The results of my first two breeding experiments were… interesting.  The colors of the offspring  seemed to be following the normal dominance and inheritance rules, but the ratios were all screwed up.
For example: on a cross where I would have expected the stripes to be 50% red, 25% sky-blue, and 25% purple, I was instead getting 10% red, 50% sky-blue and 40% purple. Not very informative, but pretty weird.

Then on the third cross experiment, I got this:
Code: [Select]
Pair #3
M/F | Fur Stripes Eyes
--------------------------------------------------------------
Father M white black black
Mother F ivory red black
--------------------------------------------------------------
Pups:

#1 F ivory sky-blue black
#2 F ivory red black
#3 M white black black
#4 M cream black black
#5 F ivory red black
#6 M white black black
#7 M white black black
#8 M cream black black
#9 F ivory sky-blue black
#10 M cream black black

...Yeah, there's a problem here. Look at the stripes. We have 2 reds, 2 sky blues and 6 blacks.
The dad is black-striped, and black is the most recessive color, which means dad has to be carrying two black stripe genes (BB). That means the red and sky-blue stripes both have to come from mom (RS). But then… for any of the babies to have black stripes, they would also need to be carrying two black genes (BB). They got one from dad… but mom doesn't have any to give. So what's going on?

Then I noticed a pattern. If you sort the offspring by gender...

Code: [Select]
Pair #3 sorted by gender
M/F | Fur Stripes Eyes
--------------------------------------------------------------
Father M white black black
Mother F ivory red black
--------------------------------------------------------------
Pups:
#1 F ivory sky-blue black
#2 F ivory red black
#5 F ivory red black
#9 F ivory sky-blue black

#3 M white black black
#4 M cream black black
#6 M white black black
#7 M white black black
#8 M cream black black
#10 M cream black black

...Suddenly the system it's using becomes obvious.

It looks like when colors are defined separately for each gender, babies receive the genes only from the parents of the same sex. The males only receive genes from the father, and the females only received genes from the mother, with absolutely no crossover.

-------------------------------------------

Now, I could have easily left it here, but this raised another nitpicky question I wanted to answer:
What system is the game using to decide what genes the single-parent passes on?

Because the babies only recieve genes from one parent, there's basically two main options here:

Option 1: The game looks at the parent's genes, duplicates them, and then runs the usual mating algorithm on those. Basically, it treats it like the parent breeding with itself.
   Example: Father is carrying red and black stripe genes (RB). For a male offspring, the game simulates breeding an RB with an RB. (possible outcomes: RR, RB, BR, BB)

Option 2: The game looks at the parent's genes, picks one at random, doubles it and passes it to the offspring.
   Example: Father is carrying red and black stripe genes (RB). The game flips a coin, chooses one, and sends two copies to the child. (Possible outcomes: RR, BB)

This actually kind of matters for breeding, because if that uses the latter system, there are no more "hidden genes" after the first generation. So from the second generation onwards, red-striped males could only ever have red-stripes sons, etc.

I ended up testing this in two different ways:

TEST 1

Quickest way to test this was with our old friend, Punnet square ratios!

Take a parent with two different color genes.
- If the game uses the "breed-with-self" system, you'd expect to see the dominant gene color option from the parent showing up 75% of the time, and the recessive color 25% of the time, due to the recessive gene being "hidden" 50% of the time.  (from the above example, RR = red, RB = red, BR = red, BB = black)
- Alternatively, if it uses the "pick-one-and-double" system, you'd expect to see them both show up equally (50% dominant / 50% recessive) because no hidden genes are present.

To test this I just did a simple breeding experiment with the litter size cranked up to 40. Recorded all the appearances of the babies, and did some math.

Results:
The litter conveniently had 20 girls and 20 boys. After tallying everything up, I found that in this litter, dominant colors showed up 41% of the time and recessive ones 59% of the time.
Then I did some Chi-squared bullshit to statistically confirm what was already pretty obvious: 41% is nowhere near 75%, so we can pretty confidently reject the "breed-with-self" model based on this data set.

This means we can throw out one model, but that doesn't necessarily prove the other one is correct. Luckily, there's another way to test it.

TEST 2
....Here's where that second-generation testing comes in.

The idea behind this one is really simple: If the "pick-one-and-double" model is true, every child born past the second generation will be a perfect clone of its same-sex parent. Again, because there's no more hidden genes in the population. All it would take would be a single child looking different from their parent to disprove the entire thing, so this test should be pretty definitive!

So here I just did a series of second-generation breeding tests like I described in my last big post, with the litter size set to 20 for a larger sample size.

Results:

I had three tests that failed because one of the starting pairs refused to breed (::)) but finally got some results:

Second-Generation Cross #1

Father: ivory fur, black stripes, golden yellow eyes
Mother: ivory fur, red stripes, black eyes

Offspring:
9 males with ivory fur, black stripes, golden yellow eyes
11 females with ivory fur, red stripes, black eyes

Second-Generation Cross #2

Father: white fur, purple stripes, golden yellow eyes
Mother: cream fur, purple stripes, black eyes

Offspring:
14 males with white fur, purple stripes, golden yellow eyes
6 females with cream fur, purple stripes, black eyes


...Yeah, I think I'm ready to call it. Option 2 wins.

--------------------
CONCLUSIONS

Well, that was a huge amount of work for something very few people will ever care about, but that's okay!

To summarize what I found:

If a creature is modded so that the color options for their hair/skin/tissues/etc. are defined separately for each gender, the game does not use the normal genetics system for inheritance. Instead, offspring receive all of their genes from the parents that is the same sex they are, and no genes from the opposite parent. Daughters inherit genes only from their mothers, and sons inherit genes only from their fathers. As a side effect of how the system apparently handles this, all breeding done from the second generation onwards will produce only perfect clones of their parents, meaning a huge amount of genetic diversity is inevitably lost.

Differences or similarities in the color list between males and females don't matter because they are essentially two completely separate gene pools.

I guess this way of dealing with it makes the most sense, given all the potential weirdness with DF's caste system, but it's still a bit disappointing. It means that it's impossible to add even a single gender-specific color without sort-of-breaking the entire genetics system.

But at least now we know.
Logged

Salmeuk

  • Bay Watcher
    • View Profile
Re: Creature color genetics experimentation
« Reply #17 on: June 13, 2016, 08:39:55 pm »

Hey, this was really cool to read through! And no science goes un-appreciated on these forums, however trivial (I would argue that this science is actually pretty important for people who like to mod animals or raise large herds).

If only we could give you a badge or something. . .
Logged

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: Creature color genetics experimentation
« Reply #18 on: June 13, 2016, 11:51:58 pm »

Fascinating and interesting read, even if I don't understand attribute inheritance I can see this being rather useful for having second+ generation castes suited for specific tasks (perhaps the first generation creates random variance and every generation thereafter will always repeat those attribute combinations?)

In other management games, innovation and technology is obtained through building libraries and spending points on a tech tree. In Dwarf Fortress, you demonstrate excellently that overseers' libraries are not done for a single fortress in a single world, but for the game itself - we do not choose "research wheelbarrow" from the UI, we choose it by finding wheelbarrow options and then learning and watching how they work and what they do.

(Although the in-game libraries are still really cool, we can't exactly store schematics in them now can we?)

Dirst

  • Bay Watcher
  • [EASILY_DISTRA
    • View Profile
Re: Creature color genetics experimentation
« Reply #19 on: June 14, 2016, 11:00:44 am »

Great work DeKaFu!  I think I'll have to harmonize the wing colors across genders in Appearance Tweaks.
Logged
Just got back, updating:
(0.42 & 0.43) The Earth Strikes Back! v2.15 - Pay attention...  It's a mine!  It's-a not yours!
(0.42 & 0.43) Appearance Tweaks v1.03 - Tease those hippies about their pointy ears.
(0.42 & 0.43) Accessibility Utility v1.04 - Console tools to navigate the map

slink

  • Bay Watcher
  • Crazy Cat Dwarf
    • View Profile
    • Slink's Burrow Online
Re: Creature color genetics experimentation
« Reply #20 on: June 14, 2016, 01:01:11 pm »

Thank you, DeKaFu!  This was a masterly work of science.  I really enjoyed reading it.
Logged
There is only one cat, and all cats are that cat.
Almost losing is sometimes fun.

infrequentLurker

  • Bay Watcher
    • View Profile
Re: Creature color genetics experimentation
« Reply #21 on: June 15, 2016, 11:36:32 am »

A cool read, thank you 8^)

A question possibly stemming from inexperience, though: you've shown what happens when there is a full gender split for characteristics, but can you mix gender characteristics and general characteristics?  For instance, if caste: male can only have golden yellow eyes, and all other features defined under caste: all?  What happens in your last experimental setup if you replace either caste: male or caste: female with caste: all?  Will the genetics work out more normally?  Depending on the results of that, what happens when you add caste: all as a third copy of the caste male/female color list to the existing setup?
« Last Edit: June 15, 2016, 11:48:35 am by infrequentLurker »
Logged
Bugs from Normal Games: "The game stutters for six seconds before crashing."
Bugs from Broken Games: "The lighting is weird and the characters have no faces."
Bugs from Dwarf Fortress: "The horses outnumber us. I have seen settlements with a thousand horses to a man. I have seen them in the deepest caverns. They are everywhere. Liberate te ex equus."

DeKaFu

  • Bay Watcher
    • View Profile
Re: Creature color genetics experimentation
« Reply #22 on: June 15, 2016, 01:51:19 pm »

A question possibly stemming from inexperience, though: you've shown what happens when there is a full gender split for characteristics, but can you mix gender characteristics and general characteristics?  For instance, if caste: male can only have golden yellow eyes, and all other features defined under caste: all?  What happens in your last experimental setup if you replace either caste: male or caste: female with caste: all?  Will the genetics work out more normally?  Depending on the results of that, what happens when you add caste: all as a third copy of the caste male/female color list to the existing setup?

That's... actually an excellent question.

I hadn't tested it because I assumed that defining the same part twice, once in [CASTE:ALL] and once in [CASTE:MALE], would result in the game treating it as two different parts (e.g.: "His fur is white. His stripes are purple. His eyes are black. His eyes are golden yellow.").

A quick edit and ten-second test shows that I was wrong and this is NOT the case. Eyes still only show up once. This is a good example of the danger of assuming anything without testing. ;)

Back to the arena I go!
Logged

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Creature color genetics experimentation
« Reply #23 on: June 15, 2016, 02:09:35 pm »

My assumption was that later tags override earlier instances of the same tag, so defining eye color first for all and then for the appropriate gender would result in the gender one taking effect (and (re)defining the same tag multiple times would have the same effect as removing all but the last instances), but I haven't tested it.
Logged

DeKaFu

  • Bay Watcher
    • View Profile
Re: Creature color genetics experimentation
« Reply #24 on: June 17, 2016, 09:07:02 pm »

All right, I think I'm finished with this one. It's a pretty niche case that would never show up in vanilla, but it was worth investigating for anyone interested in modding colors/genders. This one got more complicated and I'm not sure how well I've explained it, so proceed at your own risk.

GOAL

I've already established how DF handles color inheritance under normal circumstances (where color is defined at the species level under [CASTE:ALL]) and under circumstances where color inheritance is split by gender (when defined under [CASTE:MALE] and [CASTE:FEMALE] separately).

Based on the suggestion by infrequentLurker a few posts up, I wanted to investigate what happens when these two systems are used in combination. In other words, what happens when color options are defined as normal at the species level, but also defined again at the gender level for one of the two sexes?

The main reason I want to check this out is that depending on how it's handled, it could provide a way to mod in gender-specific colors without completely breaking the inheritance system (which happens when you split genetics by gender completely).

EXPERIMENTAL SETUP

Once again, I needed to modify my test creature:


Breaking down the changes:

Eye color is defined under [CASTE:ALL] as normal, but also defined a second time under [CASTE:MALE]. I also added a male-only eye color: Emerald, which is dominant to black and recessive to golden yellow. The main purpose of this one was just to determine which of the two potential color definitions (ALL or MALE) the game actually uses to decide appearance.
Stripe color is defined under [CASTE:ALL] as normal, and defined a second time under [CASTE:FEMALE] with no changes. This is the main attribute I planned to look at in my crossbreeding tests.
Fur color is only defined under [CASTE:ALL] as normal and isn't really used in this test. I already knew based on other tests that it would follow vanilla genetics rules, so we can safely ignore it. :P

All my tests on this one were first-generation breeding experiments in the arena.

RESULTS

Before getting to the meat of it, I had one super-quick test: Place a bunch of males in the arena, and see if any of them have emerald-colored eyes.

If so: the genes defined in [CASTE:MALE] override the genes defined in [CASTE:ALL] when deciding the creature's actual appearance. (as predicted by PatrikLundell above)
If not: the genes defined in [CASTE:ALL] override the genes in [CASTE:MALE] instead.

Since they only have one eye color show up in their description, these are the only options.

The results were that emerald-eyed males showed up in-game so we know the gender-specific colors take precedence in the creature's in-game description. Good to know!
This doesn't tell us anything about the actual genetics though, so on to the breeding tests.

--------------------------------

Before looking at the results, it's important to establish some theories to look out for. I came up with three main possibilities:

Option 1: "Vanilla" genetics. The "realistic" inheritance system I established in my first post, with genes being passed from both parents to all offspring.

Option 2: "Gender-locked" genetics. This is the modified system I discovered in my last post: males only passing genes to male offspring and females only passing genes to female offspring.

Option 3: "Mixed" or "Masked" genetics. This one's a bit more complicated, but possibly the most likely. Under this model, the normal vanilla genetics system is still in place and working normally. Both parents are part of a single gene pool, and offspring receive half their genes from each parent. However, the gender-locked model for the gender with the extra color definition (female in our case) is also still in place. The females essentially have a second, different set of genes using the colors defined in [CASTE:FEMALE] that make up an entirely different gene pool than their genes defined in [CASTE:ALL]. And because, as we established, [CASTE:FEMALE] genes override [CASTE:ALL] genes when the game is writing the description, their appearance would be based only on their [CASTE:FEMALE] genes. This is why I call this one "Masked" genetics: the females are carrying two different sets of genes, but one is entirely "masked" by the other.

I'm not sure I explained that clearly, so here's a shitty chart to try to visualize it:
Code: [Select]
Parents
-------

Father --------- Mother
[CASTE:FEMALE] genes:            |      CC
[CASTE:ALL] genes: AA    |     (BB)


       Offspring
       ---------

    Males Females
[CASTE:FEMALE] genes:      CC
[CASTE:ALL] genes: AB (AB)

(Genes in brackets are never seen in the creature description)

...Phew. With that out of the way, let's look at some actual data!
 
My first two litters didn't have enough genetic variation to rule out any of the models, and my third pair refused to breed, but my fourth litter finally gave me some interesting results.

Code: [Select]
Pair #4
M/F | Fur Stripes Eyes
--------------------------------------------------------------
Father M white red emerald
Mother F cream red black
--------------------------------------------------------------
Pups:
#1 F cream sky-blue black
#3 F cream sky-blue black
#4 F cream sky-blue black
#6 F cream sky-blue black
#7 F white sky-blue black
#10 F cream red black

#2 M cream sky-blue emerald
#5 M white red emerald
#8 M white purple emerald
#9 M white purple black
(Sorted by gender to make things clearer.)

Okay, let's pick this apart.

The first thing we can do is throw out Option 2, the "Gender-locked" model based on the stripes. The male offspring would have had to receive genes only from their father, and it would be impossible for him to be carrying three different stripe colors at once. Easy.

Next, let's look at Option 1, the "Vanilla" model. Here's the dominance hierarchy for stripe color again for reference:

Stripes: RED > SKY BLUE > PURPLE > BLACK

We know for sure that both parents are carrying one dominant red gene each. But what about their recessive genes? Well, in order to get purple-striped offspring in this model, both parents would have to be carrying purple as their second gene (so: RP and RP. RP and RB {black} would also work.). However, half the litter has sky-blue stripes, which could only appear if one of the parents was carrying a sky-blue gene instead (RS). Since these are mutually exclusive possibilities, there's no way to have gotten this litter with the vanilla model.  We can throw this one out too.

Finally, Option 3, the "Mixed" model...
If this model is true, we'd expect the stripes on the female offspring to fit the Gender-locked model. While we can't be positive, it's certainly possible: these results match what we would see if the mother's visible genes were red and sky-blue (RS).

The other bit of evidence here is the same thing that made us throw out the vanilla model: the purple-striped male offspring. While there is no way we could see these colors based on the parents' visible traits, we could see them if the mother had a second pair of "masked" genes. Specifically, if the father was carrying red and purple (RP) and the mother was carrying a masked sky-blue and purple (SP), we would expect to see red (RP, RS), sky-blue (SP) and purple (PP) offspring. In other words, Option 3 can explain our data!

-------------------------------------------------

I'm pretty convinced by those results, but I decided to run one more test with a large sample size to definitively show the existence of "masked" genes in this scenario.

I set the litter size to 40, and specifically selected the individuals for my breeding pair: a male with black stripes, and a female with purple stripes. The logic here is that I know the male has two copies of the most recessive color (BB), so any stripe-colors besides black that show up in the offspring can only come from the female. Also, because the female has purple stripes, she could normally only be carrying purple or black genes (PP or PB). As a result, any red or sky-blue stripes in the offspring could only come from the second, masked set of genes.

My results are in a huge spreadsheet, so I will just summarize:


Father: black stripes
Mother: purple stripes

Offspring:
16 females: 7 purple-striped, 9 black-striped
24 males: 16 sky-blue-striped, 8 purple-striped


...And there it is. The male offspring have sky-blue stripes that can only have come from "masked" genes in the mother. These results match the model perfectly, and we can figure out exactly what genes they're carrying:
Male: Black / Black
Female: Purple / Black (visible, from [CASTE:FEMALE]) and Sky blue / Purple (masked, from [CASTE:ALL])

That's enough evidence for me to stand by this model.

CONCLUSIONS

So, instead of this scenario bringing us closer to the "realistic" genetics of the vanilla DF model, it breaks everything further and turns it into an overly complicated mess. :P

To summarize:
If a creature is modded to have the color options for their hair/skin/tissue/etc. defined both at the creature level (in [CASTE:ALL]) and at the gender caste level (in [CASTE:MALE] or [CASTE:FEMALE]), the game treats them as two different gene pools operating simultaniously under different rules. The creature-level one will use the normal, vanilla model were both parents contribute genes to the offspring, while the gender-level one follows the gender-restricted model where genes are only passed from male parents to male offspring, etc.

The in-game descriptions will always prioritize the gender-level genes over the creature-level ones, which leads to the creature-level genes being "masked" and invisible in individuals with both types defined. However, these "masked" genes are still stored by the game and can be can be passed down to offspring.

...To try to put it more simply, here's what you would see in the game:
After the first generation, the critters of the modded gender (let's say female) would only have daughters that looked exactly like them. At the same time, their sons would have completely unpredictable genetics because they're inheriting "masked" genes from their mother which are impossible to predict based on how she looks. It would be a complete nightmare if you were trying to selectively breed anything, and the distribution of colors in your population would look pretty weird and unnatural.

It's still pretty interesting though, and explains a bit about how DF handles castes and genetics. Hopefully this'll be useful to at least one modder out there. :P
Logged

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Creature color genetics experimentation
« Reply #25 on: June 18, 2016, 02:20:05 am »

A nice piece of !!science!!!
Logged

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: Creature color genetics experimentation
« Reply #26 on: June 18, 2016, 04:18:00 am »

I guess this would allow for more realistic birds with sexual dimorphism - still having the advantages of mixing while maintaining camouflage, though they female or male birds would all look the same externally.

Derro

  • Bay Watcher
  • Imprisoned Lunatic
    • View Profile
Re: Creature color genetics experimentation
« Reply #27 on: June 19, 2016, 09:28:41 am »

Interesting. Now all we need are predators with a preference for certain colors and DF evolution (deffolution?) can begin!
Logged

taptap

  • Bay Watcher
    • View Profile
Re: Creature color genetics experimentation
« Reply #28 on: June 20, 2016, 12:11:39 pm »

Congratulations for one of the few genetics threads that actually explores the genetics in the game.

infrequentLurker

  • Bay Watcher
    • View Profile
Re: Creature color genetics experimentation
« Reply #29 on: June 20, 2016, 12:58:34 pm »

This could open some interesting possibilities through creative use.  For example, if you wanted color variety in peacock tail feathers and drab grey in peahen tail feathers, you would want to define your tail feather color variety uner caste:all, then put drab grey feathers in caste: female.  That way you still have second generation variety in your peacock tail feathers, while your peahens are all drab grey.

So long as you only want variety in one gender, you can define the attributes for that gender under caste:all, then put the single overwriting attribute under the other gender's caste.
Logged
Bugs from Normal Games: "The game stutters for six seconds before crashing."
Bugs from Broken Games: "The lighting is weird and the characters have no faces."
Bugs from Dwarf Fortress: "The horses outnumber us. I have seen settlements with a thousand horses to a man. I have seen them in the deepest caverns. They are everywhere. Liberate te ex equus."
Pages: 1 [2] 3