Wip
This commit is contained in:
parent
42c4b88f49
commit
031c1276ac
@ -27,7 +27,7 @@ void DnaManager::init()
|
||||
if (file == NULL)
|
||||
return;
|
||||
|
||||
size_t ret = fread(&randSeed, 1, sizeof(uint128), file);
|
||||
fread(&randSeed, 1, sizeof(uint128), file);
|
||||
fclose(file);
|
||||
}
|
||||
else
|
||||
@ -49,7 +49,7 @@ void DnaManager::deinit()
|
||||
FILE *file = fopen(filename, "wb");
|
||||
if (file == NULL)
|
||||
return;
|
||||
size_t ret = fwrite(&randSeed, 1, sizeof(uint128), file);
|
||||
fwrite(&randSeed, 1, sizeof(uint128), file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
@ -111,11 +111,6 @@ void DnaManager::newGen()
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto &&i : liked)
|
||||
{
|
||||
queued.push_back(i);
|
||||
}
|
||||
|
||||
if (liked.size() == 1)
|
||||
{
|
||||
int front = liked.front();
|
||||
@ -123,12 +118,10 @@ void DnaManager::newGen()
|
||||
for (auto &&i : disliked)
|
||||
{
|
||||
DNA::clone(&vector[front], &vector[i], &randSeed);
|
||||
queued.push_back(i);
|
||||
}
|
||||
|
||||
disliked.clear();
|
||||
liked.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (liked.size() >= 2)
|
||||
@ -149,16 +142,12 @@ void DnaManager::newGen()
|
||||
Dna *c = &vector[i];
|
||||
|
||||
DNA::makeChild(p1p, p2p, c, &randSeed);
|
||||
queued.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (queued.size() == NUM_PER_GEN)
|
||||
for (size_t i = 0; i < NUM_PER_GEN; i++)
|
||||
{
|
||||
for (auto &&i : queued)
|
||||
{
|
||||
DNA::mutate(&vector[i], NUM_OF_MUT, &randSeed);
|
||||
}
|
||||
return;
|
||||
DNA::mutate(&vector[i], NUM_OF_MUT, &randSeed);
|
||||
queued.push_back(i);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user