public static byte[] BuildImmigrant(byte[] reef, BigInteger consensusData, BigInteger randomStep) { byte[] newFish = new byte[0]; BigInteger endOfDnaInfluence = GetIndexOfDna() + SizeOfRandomDnaInfluence(); // First 4 properties are random: Vegan-Carnivorous, Size, BellyType, BackType for (int i = (int)GetIndexOfDna(); i < endOfDnaInfluence; i++) { BigInteger bigStepPlusI = randomStep + i; BigInteger randomNumber = BlockchainHelper.Random(consensusData, bigStepPlusI); byte[] randomByteValue = randomNumber.AsByteArray(); newFish = newFish.Concat(randomByteValue); } BigInteger blockHeight = Blockchain.GetHeight(); newFish = newFish.Concat(reef.Range((int)endOfDnaInfluence, (int)SizeOfReefDnaInfluence())); newFish = newFish.Concat(blockHeight.AsByteArray()); // 4 bytes byte[] quantityOfFeeds = new byte[] { 0 }; newFish = newFish.Concat(quantityOfFeeds); // how many times ate BigInteger remainingSize = GetSize() - newFish.Length; for (int i = 0; i < remainingSize; i++) { newFish = newFish.Concat(new byte[] { 0 }); } return(newFish); }
public static byte[] BuildFromParents(BigInteger consensusData, BigInteger randomStep, byte[] father, byte[] mother) { byte[] newFish = new byte[0]; BigInteger endOfDna = GetIndexOfDna() + GetSizeOfDna(); for (int i = (int)GetIndexOfDna(); i < endOfDna; i++) { // Mix DNA BigInteger aRandom = BlockchainHelper.Random(consensusData, randomStep); randomStep = randomStep + 1; if (aRandom % 2 > 0) { newFish = newFish.Concat(father.Range(i, 1)); } else { newFish = newFish.Concat(mother.Range(i, 1)); } } BigInteger blockHeight = Blockchain.GetHeight(); newFish = newFish.Concat(blockHeight.AsByteArray()); // 4 bytes byte[] quantityOfFeeds = new byte[] { 0 }; newFish = newFish.Concat(quantityOfFeeds); // how many times ate BigInteger remainingSize = GetSize() - newFish.Length; for (int i = 0; i < remainingSize; i++) { newFish = newFish.Concat(new byte[] { 0 }); } return(newFish); }