Deep Dive: Hero Genetics

The Hero’s Hold — Special Edition #2

MrZipper
11 min readJan 5, 2022
The Hero’s Hold — A DeFi Kingdoms Hero Report

Introduction

Well met, adventurer — welcome to a special edition of The Hero’s Hold! Today we’re taking a deep dive on hero genetics with full details on where genes come from, how they’re transferred between heroes, and when and how they mutate.

The details and numbers in this article have been confirmed to me by Hubert Cumberdale, DeFi Kingdoms’ lead game designer.

Let’s dig in!

Welcome to The Hero’s Hold, adventurer!

Update (Feb. 9): I’ve posted a spreadsheet that allows you to calculate gene matching for class and ability. You can access it here.

Hero DNA & Genetic Traits

Since first popularized by CryptoKitties in 2017, NFTs produced by genetic algorithms have been all the rage, and more recently gamified by the Axies of Axie Infinity.

Like these other projects, the Heroes of DeFi Kingdoms also have their own DNA, which directly affects their in-game stats and appearance, and is passed on to summoned heroes. Since all heroes originate from Generation 0 Heroes, these heroes provide the master DNA sequences for all heroes in the game, present and future. (Note: This is why it is necessary to mint new Gen0s in order to create new classes and new gene sets in Crystalvale, for example.)

Every hero has 24 different genetic traits that define its abilities and visual appearance. These are divided into two separate DNA strings: one with 12 different “stat” traits that impact how your hero functions and another with 12 “visual” traits that impact its appearance (see Appendix B for a full list of these genetic traits).

Among the stat traits are ones we are very familiar with: Class, SubClass, Profession, and Stat Boosts, while others like Element (e.g. ice/fire/light), Active and Passive 1 & 2, and “StatsUnknown 1 & 2” will likely be used in combat or are simply placeholders for future content expansions.

Visual traits include all aspects of a hero’s appearance: gender and background (e.g. city/forest/desert), hair style and color, skin color, eye color, and other unique traits like horns, wings, and tails. There are also two placeholder traits (“VisualUnknown 1 & 2”) for appearance as well. For the time being, all of these visual traits are entirely cosmetic, though Hubert has hinted that some of them could play a role in the future.

Two items may seem to be missing from this list: a hero’s rarity and whether it is shiny. As it happens, Rarity and Shiny are not genetic in this sense, although they are nevertheless influenced by a hero’s summoners/parents.

Dominant and Recessive Genes

Anyone who has summoned a Warrior with a Knight only to get an Archer or a Priest knows that for every genetic trait, a hero has a set of four genes. Like humans, these genes can be both dominant and recessive. (Note: Gen0s were randomly seeded with their own sets of dominant and recessive genes.)

The dominant gene is the one that is displayed on the hero card itself and directly impacts the hero — its Class, SubClass, Profession (green), StatBoosts (green & blue), or any of its visual traits. The recessive genes do not have any direct effect on the hero — they only matter when summoning.

As Hubert has explained to us, every hero trait (Class, SubClass, Profession, etc.) has one dominant (D) gene and three recessive (R1, R2, & R3) genes. These genes are not mutually exclusive — it’s possible for all four class genes, for example, to be completely different, entirely the same, or any combination. A hero whose genes are entirely the same might be considered a “pure class” hero, like this Gen0:

Sandy Rageshout (#603) is a pure Archer

(Reminder: Class and SubClass are not related in any way. They are completely independent traits with their own dominant and recessive genes, and are rolled separately.

It’s also common to refer to a hero with the same Class and SubClass dominant gene as “pure,” but this is a bit misleading since SubClass has no impact on primary class as noted above. Instead, “pure” should refer to dominant and recessive genes that are aligned.)

Each of these genes has a chance (in decreasing likelihood) to be passed along to a child hero.

Summoning & Gene Transference

So, what happens when you want to summon a new hero? This is where all those dominant and recessive genes finally come into play. Selecting the genes for the newly summoned hero takes places through a series of three steps, which occur independently for all 24 genetic traits:

  1. Summoner Gene Selection
  2. Potential Mutation
  3. Final Gene Selection

Summoner Gene Selection

To begin, each summoner’s gene set (D, R1, R2, & R3) undergoes a series of rolls to determine in what order those genes are potentially passed on, which I will be referring to as the parent’s selected genes.

These rolls start with the R3 gene, which has a 25% chance to swap with R2. Then R2 (regardless of the outcome of the previous roll) rolls to swap with R1 at 25%. Then R1 rolls to swap with D at 25%. Each parent’s genes are then passed on in this new order — this is the selected gene set.

Hubert explains gene selection

Based on these rolls, the chances that each parent’s genes are swapped to the selected D position are:

  • D: 75%
  • R1: 18.75%
  • R2: 4.6875%
  • R3: 1.5625%

And if you chart this out for all of the gene swapping options, we can see all of the following chances:

Notably, this means that while an R3 gene from a parent hero has a small chance to emerge as a new D, the parent’s dominant gene can only be passed on as D or R1.

Potential Mutation

Once the order of selected genes from each parent has been determined, next, there is a check to see if it is possible for the two newly selected D genes to mutate and result in a gene from a higher tier. That is to say, if the two parent genes newly selected to the D position are Pirate and Monk, or Sage and Dragoon, for example.

Class tier mutation tree (Credit: Albus)

If these genes are compatible for mutation, there is a roll to see if they will mutate at the following chances:

  • Basic → Advanced: 25%
  • Advanced → Elite: 25%
  • Elite → Exalted: 12.5%
  • Exalted → ???: 12.5%

For practical purposes where none of the recessive genes align with the dominant, this means that two parent heroes with mutative dominant genes will do so at 14.0625% of the time for Basic and Advanced classes (75% * 75% * 25%), and 7.03125% for Elite and Exalted classes (75% * 75% * 12.5%). But in practice, Basic classes are likely to see slightly higher numbers on these, due to the increased likelihood that the selected R1-R3s may be the same as the selected D for these heroes. Overall, these numbers align closely with what I saw in my previous article on Advanced+ Hero Summoning.

For genetic traits in which mutations do not occur (e.g. Profession, StatBoosts, etc.), this step is ignored.

Final Gene Selection

Compared to the previous two steps, this last one is very simple.

If the newly selected D genes from Step 2 rolled to mutate, that new mutation becomes the new child hero’s D gene. If not, there is a 50/50 roll between the parents’ selected D genes for which to pass on.

Then, the 50/50 rolls continue for the recessive genes, between the two selected R1s → child R1; selected R2s → child R2; and selected R3s → child R3.

This means that barring potential mutations and duplicate genes, you can take the percentage values from Step 1, add them together as necessary, and divide them by two in order to get the likelihood that a given parent gene will become the dominant in a future child hero.

Takeaways

The most important takeaway here, of course, is that we can now calculate with perfect accuracy the potential genetic combinations for any summoned hero based on its parents’ genes.

A number of community tools already exist for this, including my own HeroBot in the official DFK Discord. (Go to the #bot-commands channel and use /genes to see all of a hero’s genes, and /match to see the likelihood of a new hero’s dominant genes based on any two parent heroes.) Until now, however, these tools were based on our best reverse-engineered approximations of the math behind summoning. Now we know the details.

But I’d like to offer a couple of other thoughts as well:

  1. If you’re looking to maximize potential mutations, you’ll want to look for a pair of heroes with aligned D and R1 genes (e.g. D - Archer / R1 - Archer and D - Thief / R1 - Thief). This combination will get you two heroes with a 93.75% chance each of passing along that D/R1 gene. With the 25% chance of mutation (for Basic/Advanced classes), that raises the mutation chance from ~14% (for D alone) to just shy of 22%. Adding an aligned R2 & R3 will also help, but with a smaller overall impact and much harder to find.
  2. Mutations can only occur among the selected dominant genes from each parent hero. It is not possible for a gene to mutate directly into a recessive position. That means that even if a Wizard and Priest gene are both selected in the R1 positions, for example, the new hero cannot end up with a new Summoner gene in any position (unless there was also a Dominant mutation or a Summoner gene already in the mix).
  3. Recessive genes are harder to align than I think many of us anticipated, and don’t automatically inherit from parents’ D genes. It’s been a common understanding, for example, that if a hero inherits one parent’s D gene, its R1 will likely be the other parent’s D gene. Similarly, we’ve thought that if a mutation does take place, the original genes will likely end up as recessives in the new hero. As it turns out, neither of these things are true. The former will only happen if one of the genes swaps position. The latter will not happen at all unless there are duplicate genes.

In the end, what we find is a complex system of hero genetics that support both a high degree of variation, and also a variety of strategies to optimize hero summoning to meet our different goals. And as the game develops and we begin to look toward combat, there will be even more to work with, and new strategies to develop.

Yes, it’s complex, but that’s one of the things that makes DeFi Kingdoms great.

Thanks for reading.

Many thanks to AvgJoe40 and MikeC for helping me wrap my head around the math in Appendix A, and to Samichpunch for proofreading.

Appendices

Appendix A: Calculating a Future Hero’s Dominant Genes

Calculating a future hero’s potential dominant genes (like HeroBot or many of the other community tools do) involves following the steps listed above, outlined in detail below:

  1. Take each parent hero’s gene set (D-R3) and assign each gene a percentage based on the table listed above (D: .75; R1: .1875; R2: .046875; R3: .015625). If there are duplicate genes within a parent’s gene set, add those percentages.
Take these numbers and add the two percentages for Knight, which is repeated in Parent1

2. If there are mutable genes between the two parents’ gene sets (e.g. Parent 1 has a Monk gene and Parent 2 has a Pirate gene), multiply the percentages of the two genes together, and then multiply the product by .25 for Basic & Advanced classes, or .125 for Elite classes.

3. This is the chance of getting that particular mutation from those two genes. Take this number and subtract it from the percentage of each parent’s mutable gene.

4. Repeat this process for all mutable gene combinations between the two parent genes. Note: If the two parents have both combinations for a mutation (e.g. P1: Monk / P2: Pirate and P1: Pirate / P2: Monk), do this process separately, and then add the two products from the mutations together.

5. Set the mutation percentages from Steps 2 and 4 aside — these are complete. Then take every parent gene and divide the percentage by two (use the new percentages from Step 3 as applicable).

6. Add up the percentages for any duplicate genes between the two parents. That’s it! You now have a list of the new hero’s potential dominant genes!

You can find a spreadsheet that does these calculations for you here.

Appendix B: List of Genetic Traits

The following traits are listed here as they appear in the API. I’ve added some clarifications as necessary.

Stat Traits

  • MainClass
  • SubClass
  • Profession
  • StatBoost1 (green)
  • StatBoost2 (blue)
  • Element
  • Active1
  • active2
  • Passive1
  • Passive2
  • StatsUnknown1
  • StatsUnknown2

Visual Traits

  • Gender
  • Background
  • HairStyle
  • HairColor
  • SkinColor
  • EyeColor
  • HeadAppendage
  • AppendageColor (for Head Appendage, presumably)
  • BackAppendage
  • BackAppendageColor
  • VisualUnknown1
  • VisualUnknown2

That’s it for today! Thanks for reading, and please subscribe and stick around for future editions of The Hero’s Hold. If you like what you’re reading here, I’m happy to accept tips at: 0xf543311360d1072873D627B06ffe85587e8fc41a.

Questions, comments, suggestions? Send them to me at MrZipper#7564 on Discord or @MrZipper7 on Twitter.

Previous Issues

Quick Links

The Ruler’s Keep or the Hero’s Hold?

--

--