Change generate newDna

This commit is contained in:
Nikola Petrov 2025-01-02 22:52:40 +01:00
parent 8066ba5103
commit 91f7966224
2 changed files with 8 additions and 22 deletions

View File

@ -18,13 +18,6 @@ struct uint128
uint32_t d;
};
struct Moon
{
float x;
float y;
float size;
};
struct Branch
{
uint8_t colorR;
@ -50,14 +43,14 @@ struct Branch
struct Dna
{
uint128 mountenSeed;
uint128 starSeed;
uint128 branchSeed;
uint8_t moonX;
uint8_t moonY;
uint8_t moonSize;
uint8_t colorSet;
uint128 mountenSeed;
uint128 starSeed;
uint128 branchSeed;
Branch branches[MAX_DEPTH];
};

View File

@ -1,4 +1,5 @@
#include <cmath>
#include <cstddef>
#include "values/Dna.hpp"
#include "values/mrand.hpp"
@ -7,11 +8,6 @@
void newDna(Dna &dna)
{
dna.moonX = mrand::getValue(0, 254);
dna.moonY = mrand::getValue(0, 254);
dna.moonSize = mrand::getValue(0, 254);
dna.colorSet = mrand::getValue(0, 254);
dna.mountenSeed.a = mrand::getInt();
dna.mountenSeed.b = mrand::getInt();
dna.mountenSeed.c = mrand::getInt();
@ -27,13 +23,10 @@ void newDna(Dna &dna)
dna.branchSeed.c = mrand::getInt();
dna.branchSeed.d = mrand::getInt();
for (size_t i = 0; i < MAX_DEPTH; i++)
uint8_t *array = (uint8_t *)&dna;
for (size_t i = offsetof(Dna, moonX); i < sizeof(Dna); i++)
{
uint8_t *array = (uint8_t *)&dna.branches[i];
for (size_t i = 0; i < sizeof(Branch); i++)
{
array[i] = mrand::getValue(0, 254);
}
array[i] = mrand::getValue(0, 254);
}
return;