Smart breeding. On the way to the desired dragon

in #web35 years ago (edited)

0.jpg

by @savetheales

Disclaimer: This article does not claim to be a deep scientific research. Get in touch with me on Telegram @savetheales if you find some mistakes or inaccuracies. Feel free to contact me ;)

It started with...

Can you imagine getting two amazing dragons with rare arms, spikes, and horns... With coolness 39+... and breeding them to get a handsome child...

and have this

1.png

Just 1 rare body part and nothing else. This is a weak dragon without any future in Ancient Sparta, I believe. And look at it coolness! WHAT!!?!? It looks like genesis dragon! Please don't think that I don't love my child... But.. why..?

With this frustration in mind, I've decided to dig deeper and find out how I can control it. Or predict it.

Intro

As this is an on-chain dapp, the experiments are a little bit expensive. It has become clear that I need some prediction model for the breedings. Easy!

I just need to take genome from both parents, multiply it similar to simple genetics problem and compare my result with that creep :)

Apparently, to get dragon genome as described in the White Paper is not as easy as I think. Yes, I have found the contract. Actually, here it is 0x960f401AED58668ef476eF02B2A2D43B83C261D8.

I found a read-contract method 'getGenome' at Etherscan service. Put dragon ID and... it doesn't work! Alright. I have to go to myetherwallet.com and try to take a chance here.

Yes!!! It works! But wait... it doesn't look like genome in the whitepaper. The contract gives me 4 big numbers and that’s it. What do I need to do with it? How can I convert it? Of course, I can thoroughly examine how contract works by myself but it would take too much time. So I wrote to developers and Holy Chains @maxaleks helped me ;)

He has provided special genome parser. All you need is just put it in Solidity compiler, insert dragon's ID and WHOOOOOHOOOOOOOO. You get a genome!

So, now let’s take a closer look how it works.

Problem Statement:

Calculate the probability of the rare (or epic) genes emergence in the genome of the offspring: the probability of carrying over all rare genes, some rare genes or none of rare genes.

Inputs:

Dragon #415. Rare Voodoo spikes and Laser arms

Dragon #314. Rare Necromantic horns

Expectations:

Awesome dragon with 3 rare parts and 40+ coolness! (spoiler: weak creep with 1 rarely part and ★ 37.44)

Solution:

1. Genes parsing

Copy code from here and paste it in Remix Solidity IDE like this

2.png

! important type pragma solidity ^0.4.25; at the top and choose 0.4.25+commit.59dbf8f1.Emscripten.clang version of compiler.

Start to compile. If it compiles without exceptions go to Run tab.

Choose environment Injected Web3 Main (as default), choose Parser in methods.
Paste the following contract and click on At Address button with 0x2c0e0b651fe43d56ad03ad6672d9d410ea2980cd address.

3.png

You should see Deployed Contracts window.

4.png

Click on this triangle as on the picture to maximize window.

Put the dragon ID (in my case 415) and click on getParsedGenome button.

5.png

WHOOOOOAOOAOOAOOAOOAOAAOAO!!!!!! Dragons geneprint!!!! AWESOME!!!

Copy it and paste to your text editor. I use Google Docs for it.

Get rid of commas and divide into 10 groups of 16 digits. Also, divide every group into 4 genes. I'll show you my example. We take this:

6.png

And convert into this:

7.png

Yes, it is..!!! In my case, every part has two pairs of genes.

The following order of parts I took from the whitepaper.

Dragonereum’s dragons have 10 body parts, each consisting of 4 sets of genes

How to decode set of genes? It's explained in the whitepaper, but let’s do it for my dragon.

I want to take the first gene set of Arms.

1711

  • The first digit means a dragon type. 1 is fire. (the order is 0 - water, 1 - fire, 2 - wind, 3 - earth, 4 - cyber)
  • The second digit is the gene variety. 7 is Laser.
  • The third digit is the gene lvl. It can be more than 9, so a gene set in cool dragons should be with 5 digits.
  • The fourth digit is the type of a gene: 1 - dominant, 0 - recessive.

8.png

0 gene variety is for inbreeding dragons, gene variety of 1 to 4 are regular parts, from 5 to 7 is rare parts, 8 and 9 is epic parts.

OK. Let's see arms gene pairs in full. My lovely dragon has Laser arms dominant gene set, hypnotic arms from a cyber dragon dominant gene set, flaming arm recessive and hypnotic arm recessive. Why do we see exactly Laser arms? Let’s take a look at following rules:

  1. If a pair of genes consists of two dominant genes, the first dominant gene will become
    the active gene for this dragon.
  1. If a pair of genes consists of a dominant and a recessive gene, the dominant gene
    will become the active gene.
  1. If a pair of genes consists of two recessive genes, then the first of the pair will
    become the active gene.

Laser arms are a dominant gene set and it is first in the sequence of genes, so that why it is active.

Alright, after examination of all sets of genes and parsing another dragon geneprint I've got:

9.png

Of course, I'm interested in rare parts, so I'll mark it. What next? Genetics...

2. Interbreeding

How the interbreeding process goes explained here. I'll interbreed arms pairs genes as an example. For other parts I will just give the results.

So, we are interbreeding 415's dragon arms with 314's dragon arms as follows:

1711 4111 1210 4110 x 4211 4210 4210 4210

We need to convert it to WWyy x YYww

We have here fire and cyber genes. I'll decide to code Fire genes set with A if it dominates, with a if it recessive. Cyber dragon genes with E and with e.

This way, 1711 4111 1210 4110 x 4211 4210 4210 4210 is converted to this:

Ae ae x Xx xx.

The second dragon I code with Xx xx to avoid repetition. Anyway we interested just in A active genes set as Laser's arms. Other genes are not rare.

Let's interbreed them by the following rule:

Every pair of genes originates from the combining of genes from both parents. The table below lists all available options. The overall rule is that for each case, one gene is taken from rows and one from columns.

10.png

After interbreeding we have the table with 16 results.

During the breeding process, one of all possible options is chosen, based on random number generation (RNG). For details on RNG for Dragonereum please refer to our whitepaper.

So, a child can take one of 16 genes pairs.

The great result for us is when active child genes set will be A - Laser arms. The rest of the genes are regular. I've highlighted it in green.

11.png

Why I've highlighted them? By the rules mentioned above.

6 out of 16 results are good for us. The probability of this outcome is P1=0.375 around 37.5%. Not bad, ya?! 37.5% chance to inherit Laser's arms!

In the same manner I've calculated the probability of rare Horns P2=0.625 and Spikes P3=0.375

So, we have:

  • P1=0.375
  • P2=0.625
  • P3=0.375

What are our chances?..

Final stage. Probability.

In this section, we'll finally solve the problem statement.

Alright.

Please see below all calculations in one picture :)

12.png

Conclusion

The geneprint of the dragon that I've got is:

13.png

My lovely freak ;)

As you can see it got just rare spikes. All other parts are complete bullshit. There were good chances to get 2 rare genes as active but... Bad luck :)

Actually, with my calculations I've breed dragon with 3 rare parts.

At the Genesis time this genetics is predictable by eye :) but in 3+ generation this problem will become a super important.

Also, you need to check family ties to avoid the penalty for sex with a sister or brother ;)

Moreover, there is a mutation mechanism implemented in the game. And this is a clear random ;)

This process is not as fun as breeding, but results are awesome!

You must try it at least once ;) Later hopefully someone will implement this logic for Dragonereum assist app ;) Maybe me? Who knows... ;)


I'm playing the dapp with 16 Gb Ram, own ETH node, own IPFS node and on Cyb. I decided to access a web3 game with a web3 browser.


If you find my article useful you can donate ETH at this address 0x0eC942c8eF80B5e809b1200B782Fdc63c570506B. This is not necessary, my award is your reading. But if you decide - all ETHs will go to supporting experiments, streams and help apps.

Oh, yeah. I will start streaming :) The first stream I plan to broadcast on Sunday 2018/12/16 on my twitch channel. The announcement will be later :)

See ya, Dragon Masters!


The content hash signed by @savetheales at Dec-11-2018 05:33:55 PM +UTC

Sort:  

I've published a small js project to decode the dragon's gene. If someone is interested, check it out.
https://github.com/BigMurry/dragon-g

Yeah! It really nice!

Thanks for that, I believe devs will bring you some gold for this lib by following program.

Your post was upvoted by the @archdruid gaming curation team in partnership with @curie to support spreading the rewards to great content. Join the Archdruid Gaming Community at https://discord.gg/nAUkxws. Good Game, Well Played!

Thanks for your support !

Congratulations @savetheales! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You received more than 50 upvotes. Your next target is to reach 100 upvotes.

Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word STOP

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @savetheales! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You received more than 100 upvotes. Your next target is to reach 250 upvotes.

Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word STOP

Support SteemitBoard's project! Vote for its witness and get one more award!

Coin Marketplace

STEEM 0.28
TRX 0.12
JST 0.032
BTC 66167.71
ETH 3014.78
USDT 1.00
SBD 3.73