The CryptoKitties Genome Project: On Dominance, Inheritance and Mutation
Since this post where I posted the key to understanding the Cryptokitties genes as 5-bit blocks and mapping those back to the cattribute traits, the community took this understanding and mapped it back to the work on deciphering the code itself, and finally we can see exactly how the breeding algorithm works and understand the exact probabilities of breeding specific offspring.
- CryptoKittyDex – this was the starting point for understanding the genome and the team there continues to update the tool with the latest findings.
- CryptoKitties mixGenes Function by Sean Soria — Sean translated the Ethereum bytecode responsible for the breeding algorithm into pseudocode that made it easier to clearly see how it is working.
- CryptoKitties GeneScience algorithm by Alex Hegyi — Alex took the research further and pinpointed the cause of mutations.
- Offspring Trait Probability Calculator by AppXMatthew (on Discord) — Matt used his understanding of the algorithm to calculate exact probabilities of offspring inheriting or mutating traits from their parents.
- The Discord community — a lot of these ideas were hashed out with the community on Discord in the #gene-discussion channel.
How the genome works
Each Cryptokitty has a genome which can be looked up as a long integer on the Ethereum smart contract. By converting this number into a 240-bit binary string and dividing that into 5-bit segments, we get the genes that represent individual traits. CryptoKittyDex has converted this into Kai-notation which is the Base58 representation of the integer value of each 5-bit segment.
So– 01110 =14 = f in Kai-notation
For the most part, you don’t need to worry about that. You can use the Kai-notation directly from CryptoKittyDex.
Mapping genes to cattribute traits
The genome represents 12 groups of 4 genes. Each group of 4 genes maps to a given cattribute trait.
So far, 9 of those 12 traits have been seen to have an influence on the appearance of the kitty. 3 have not yet been expressed as cattributes.
Dominant & recessive traits
Within each group of 4 genes, there are 3 recessive genes and 1 dominant gene which will be reflected as a cattribute for that trait, represented in the appearance of that kitty.
Breeding & direct inheritance
When breeding 2 kitties (a matron & a sire) the offspring will receive genes from either parent.
Let’s look at an example of breeding two kitties and the pattern trait.
- Kitty #449663 & Kitty #447522 breed to produce an offspring, Kitty #449777
- Kitty #449663 has a dominant totesbasic (g) cattribute, meaning there is no pattern displayed. The 1st recessive is luckystripe (a), 2nd recessive is spock (d) & 3rd is calicool (9).
- Kitty #447522 has a dominant luckystripe cattribute, displaying the striped pattern. 1st recessive is amur (b), 2nd & 3rd are spock (d).
- The child inherits the luckystripe gene as the dominant gene and the 3rd recessive from #447522. It inherits the 1st recessive as a gene swap from #449663. The 2nd recessive came from either parent.
Offspring might receive a direct inheritance from either parents — meaning the nth-gene from parent A or parent B becomes the nth-gene in the offspring. There is a pseudo-random chance that instead of choosing the nth-gene the offspring will receive adjacent genes n+1,n+2…,n-1,n-2… (always within the same trait). As you move further away, there is a lesser probability. So a small chance of receiving the gene from n+1, and even smaller chance of receiving the gene from n+2.
Genes can be grouped into pairs when listing them in ascending order. So in binary the first pairs are: (00000,00001),(00010,00011),(00100,00101)… or in kai-notation, Base58: (1,2),(3,4),(5,6) …
There is a very small pseudo-random chance that when these pairs align in the parents, the offspring will receive a mutation which is a bitwise rotation of the second pair.
- Binary– (00000,00001) mutates 00001 into 10000
- Base58– (1,2) mutates 2 into h
Here we can see that the eye color genes pumpkin (h/10000) and limegreen (i/10001) have mutated into babypuke (q/11000)
Gen0 and new gene mutations
New genes first occur in Generation 0 kitties. These are the kitties released by the CryptoKitties developers every 15 minutes.
New genes generated by Gen0 kitties only occur in what can be considered Tier 1 in the sequence of genes, representing 00000–01111 (1-g). These are genes that cannot be mutated into via a bitwise rotation. The next tier consists of all the genes which can be obtained from Tier 1 mutations, and so on:
- Tier 1–00000–01111 (1-g)
- Tier 2–10000–10111 (h-p)
- Tier 3–11000–11011 (q-t)
- Tier 4–11100, 11101 (u,v)
- Tier 5–11110 (w)
It’s impossible for a mutation to reach the value 11111 (x) so either genes cannot attain this value, or this is reserved for the developers to use as easter-eggs.
Domain map of all genes
Given what we know, it’s possible to map all of the potential traits and mutations as I’ve done in the above spreadsheet.
You can see how once sequential gene pairs appear, the breeding community quickly generates the mutations through the different tiers.
- When the icy (4) appeared as a secondary color trait (color_2) it was quickly bred with a peach (3) to produce flamingo (i)
- Soon after, someone bred a flamingo (i) with a daffodil (h) to produce seafoam (q)
- Now the progression is stalled until color_2 (6) is released in a Gen0 kitty, which can be bred with granitegrey (5) to produce color_2 (j) which can be bred with bloodred (k) to produce color_2 (r) — which finally, can be bred with seafoam (q) to produce the next tier mutation, color_2 (u)
Here is a quick sketch of the relative odds of getting a specific gene from the parents
- 75% — either dominant gene from parent A or B
- 18.75% (75/4) — chance of getting either 1st recessive from A or B
- 4.69% (75/4²) — chance of getting either 2nd recessive from A or B
- 0.02% (1/4³) — chance of getting either 3rd recessive from A or B
- 14.06% — chance of getting a mutation given A & B contain the right gene pairs in the dominant position. (Up to 25% if both parents contain the same genes in all their recessive slots)
So if you were after a specific gene from a specific parent, you’d need to divide that by 2 — so it’s a 9.38% chance you’d get a 1st recessive from parent A.
For a clear explanation on how to calculate probabilities, see:
- CryptoKitties 411: Mutations by Jodiferous
My CryptoKitties donation address
If you’ve benefitted from this work at all, please consider sending a few of your spare kitties to the following address: