Skip to main content

RosalindTestLab

RosalindTestLab

INTERNAL TOOL Used to test RosalindDNA library.

breedDNASimple

function breedDNASimple(uint256[] parents, uint8[] genes, uint256 randomSeed) public pure returns (uint256)

Breeds multiple parents DNA, returning a new combined

NameTypeDescription
parentsuint256[]N different parent DNAs
genesuint8[]start indicies of each gene. First index should ALWAYS be 0. Using [0, 128] splits the DNA into two genes of equal length
randomSeeduint256random value to use for gene splicing

breedDNAWithMutations

function breedDNAWithMutations(uint256[] parents, uint8[] genes, uint256 randomSeed, uint256[] mutationRates) public pure returns (uint256 childDNA)

Breeds multiple parents DNA, returning a new combined DNA Allows for random mutations to occur, producing random bits instead.

NameTypeDescription
parentsuint256[]N different parent DNAs
genesuint8[]start indicies of each gene. First index should ALWAYS be 0. Using [0, 128] splits the DNA into two genes of equal length
randomSeeduint256random value to use for gene splicing
mutationRatesuint256[]probability that a random gene is picked vs. mutated. A higher mutation rate means a higher probability of having a random gene. The mutation rate m is a probability of m/(2^256-1) or in other words the probability that geneRandomnessSeed <= m. We therefore assign a mutated gene at the following rates according to m: 0 = 000... => 0% 2^254-1 = 001... => 25% 2^255-1 = 011... => 50% 2^255 + 2^254 -1 => 75% 2^256-1 = 111... => 100% Always mutate Calculated probability as a function: 1/2^(256-m)
NameTypeDescription
childDNAuint256combined child DNA with mutations occuring.

generateMutations

function generateMutations(uint256 dna, uint8[] genes, uint256 randomSeed, uint256[] mutationRates) public pure returns (uint256 mutatedDNA)

Mutates encoded DNA

NameTypeDescription
dnauint256existing DNA to mutate
genesuint8[]start indicies of each gene. First index should ALWAYS be 0. Using [0, 128] splits the DNA into two genes of equal length
randomSeeduint256random value to use for gene splicing
mutationRatesuint256[]probability that a random gene is picked vs. mutated. A higher mutation rate means a higher probability of having a random gene. The mutation rate m is a probability of m/(2^256-1) or in other words the probability that geneRandomnessSeed <= m. We therefore assign a mutated gene at the following rates according to m: 0 = 000... => 0% 2^254-1 = 001... => 25% 2^255-1 = 011... => 50% 2^255 + 2^254 -1 => 75% 2^256-1 = 111... => 100% Always mutate Calculated probability as a function: 1/2^(256-m)
NameTypeDescription
mutatedDNAuint256combined child DNA with mutations occuring.

getGenCount

function getGenCount(uint256 child) public pure returns (uint256)

Gets the generation for a specimen

NameTypeDescription
childuint256child dna to read specimen age

setGenCount

function setGenCount(uint256 child, uint256[] parents) public pure returns (uint256)

Sets an offsprings generation (increases max parent +1)

NameTypeDescription
childuint256child dna
parentsuint256[]array of parent dna