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