Immune System - sekelsta/horse-colors GitHub Wiki

The immune system is unique in that it is more dependent on genetic diversity than anything else, so that inbreeding is directly bad for the immune system. This is based on the importance of diversity in biological immune systems.

The mod tracks inbreeding with genes, as you would expect. There's some big linked areas meant to represent the MHC and some miscellaneous ones meant to represent things like the immunoglobulins involved in immune system recombination. For all of these genes being heterozygous is treated as being better than being homozygous.

In the case of making antibodies by recombination, it's basically taking a bunch of pieces from different genes and seeing how many ways they can be combined, so obviously you can make more unique types of antibodies when genes are heterozygous. More unique types is good because then that's more potentially dangerous things you can bind to. To learn more, read about V(D)J recombination on Wikipedia.

Meanwhile the MHC is a complex of genes involved in making molecules that grab something random from inside the cell, chop it up so if it was dangerous before hopefully it isn't now, and wave it around while asking the T cells "hey what do you think of this?" Then if the killer T cells don't like it, they trigger cell death. Immune systems are pretty complicated and hard to understand well, but many of the MHC genes have thousands of known alleles in humans, so diversity here is clearly important. The variability may matter so that if some virus happens to avoid getting presented by one individual's MHC molecules, if the whole population has the same alleles as that individual the virus will then be able to spread almost freely and do a lot of damage, whereas if no one else has the same alleles the virus doesn't get any major advantage. To be practical, heterozygosity is a proxy for that. As for the ridiculously large number of alleles, in response rather than having each of those individual alleles there are a large number of loci for each gene. (This is kind of abstracted away as the specifics don't matter.) That way we end up with 18446744073709551616 different combinations of alleles for all the MHC genes together, which can recombine in the proper way.

Now, for how much all this contributes to health. Like the vanilla horse, 15 half-hearts of health is a given no matter what the genetics are. Then before the immune system update up to 16 health could come from genes, split evenly between the four susbsets of health. Three of them haven't changed, the other now depends on zygosity and has gone from being worth 0-4 half-hearts to being worth 0-5 half-hearts. However, the maximum reliably attainable is 3.5-4. It keeps track of not alleles but smaller loci where there are only two options, so even in a perfectly randomized horse half should be homozygous in expectation. So the half that you get by not inbreeding is worth 4 points of health, and the other half that you could only get by luck is worth 1 point. If you want you can think of the second half as being other loci that are part of the same gene, so the alleles are already different between the two copies and there isn't as much gain to be had by making them different in more places.