Skip to content

Commit

Permalink
completeness check compares connected genome nodes and number of actu…
Browse files Browse the repository at this point in the history
…al connected cells
  • Loading branch information
chrxh committed Dec 14, 2023
1 parent 578bfb9 commit fc63edc
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 18 deletions.
2 changes: 1 addition & 1 deletion source/Base/Resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Const
{
std::string const ProgramVersion = "4.5.0";
std::string const ProgramVersion = "4.5.1";
std::string const DiscordLink = "https://discord.gg/7bjyZdXXQ2";

std::string const BasePath = "resources/";
Expand Down
18 changes: 7 additions & 11 deletions source/EngineGpuKernels/ConstructorProcessor.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ __inline__ __device__ void ConstructorProcessor::completenessCheck(SimulationDat
constructor.isComplete = true;
return;
}

auto numConnectedGenomeNodes = GenomeDecoder::getNumNodesRecursively(constructor.genome, constructor.genomeSize, true, false);

auto constexpr ContainerSize = 256;
Cell* temp[ContainerSize * 2];
HashSet<Cell*, HashFunctor<Cell*>> visitedCells(ContainerSize * 2, temp);
Expand All @@ -110,7 +113,7 @@ __inline__ __device__ void ConstructorProcessor::completenessCheck(SimulationDat
auto connectionIndex = 0;
Cell* lastCells[ContainerSize];
int lastIndices[ContainerSize];

int scannedCells = 1;
do {
auto goBack = false;
if (connectionIndex < currentCell->numConnections) {
Expand All @@ -120,14 +123,7 @@ __inline__ __device__ void ConstructorProcessor::completenessCheck(SimulationDat
if (nextCell->creatureId != cell->creatureId) {
goBack = true;
} else {
if (nextCell->cellFunction == CellFunction_Constructor && !GenomeDecoder::hasEmptyGenome(nextCell->cellFunctionData.constructor)
&& !nextCell->cellFunctionData.constructor.isConstructionBuilt
&& !GenomeDecoder::containsSectionSelfReplication(
nextCell->cellFunctionData.constructor.genome + Const::GenomeHeaderSize,
nextCell->cellFunctionData.constructor.genomeSize - Const::GenomeHeaderSize)) {
constructor.isComplete = false;
return;
}
++scannedCells;
lastCells[depth] = currentCell;
lastIndices[depth] = connectionIndex;
currentCell = nextCell;
Expand All @@ -153,7 +149,7 @@ __inline__ __device__ void ConstructorProcessor::completenessCheck(SimulationDat
}
} while (true);

constructor.isComplete = true;
constructor.isComplete = scannedCells == numConnectedGenomeNodes;
}

__inline__ __device__ void ConstructorProcessor::processCell(SimulationData& data, SimulationStatistics& statistics, Cell* cell)
Expand Down Expand Up @@ -365,7 +361,7 @@ ConstructorProcessor::startNewConstruction(SimulationData& data, SimulationStati

if (GenomeDecoder::containsSelfReplication(constructor)) {
constructor.offspringCreatureId = 1 + data.numberGen1.random(65535);
hostCell->genomeNumNodes = GenomeDecoder::getNumNodesRecursively(constructor.genome, toInt(constructor.genomeSize), true, true);
hostCell->genomeNumNodes = GenomeDecoder::getNumNodesRecursively(constructor.genome, toInt(constructor.genomeSize), true, false);
} else {
constructor.offspringCreatureId = hostCell->creatureId;
}
Expand Down
2 changes: 1 addition & 1 deletion source/EngineGpuKernels/GenomeDecoder.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ __inline__ __device__ void GenomeDecoder::setNextConstructionAngle2(uint8_t* gen

__inline__ __device__ void GenomeDecoder::setNextConstructorSeparation(uint8_t* genome, int nodeAddress, bool separation)
{
genome[nodeAddress + Const::CellBasicBytes + Const::ConstructorFixedBytes + 3 + Const::ConstructorSeparation] = convertBoolToByte(separation);
genome[nodeAddress + Const::CellBasicBytes + Const::ConstructorFixedBytes + 3 + Const::GenomeHeaderSeparationPos] = convertBoolToByte(separation);
}

__inline__ __device__ int GenomeDecoder::getNextSubGenomeSize(uint8_t* genome, int genomeSize, int nodeAddress)
Expand Down
4 changes: 2 additions & 2 deletions source/EngineGpuKernels/MutationProcessor.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ __inline__ __device__ void MutationProcessor::cellFunctionMutation(SimulationDat
GenomeDecoder::setNextCellFunctionType(targetGenome, nodeAddress, newCellFunction);
GenomeDecoder::setRandomCellFunctionData(data, targetGenome, nodeAddress + Const::CellBasicBytes, newCellFunction, makeSelfCopy, Const::GenomeHeaderSize);
if (newCellFunction == CellFunction_Constructor && !makeSelfCopy) {
GenomeDecoder::setNextConstructorSeparation(targetGenome, nodeAddress, false); //currently no subgenome with separation property wished
GenomeDecoder::setNextConstructorSeparation(targetGenome, nodeAddress, false); //currently no sub-genome with separation property wished
}

for (int i = nodeAddress + Const::CellBasicBytes + origCellFunctionSize; i < genomeSize; ++i) {
Expand Down Expand Up @@ -449,7 +449,7 @@ __inline__ __device__ void MutationProcessor::insertMutation(SimulationData& dat
GenomeDecoder::setNextCellColor(targetGenome, nodeAddress, newColor);
GenomeDecoder::setRandomCellFunctionData(data, targetGenome, nodeAddress + Const::CellBasicBytes, newCellFunction, makeSelfCopy, Const::GenomeHeaderSize);
if (newCellFunction == CellFunction_Constructor && !makeSelfCopy) {
GenomeDecoder::setNextConstructorSeparation(targetGenome, nodeAddress, false); //currently no subgenome with separation property wished
GenomeDecoder::setNextConstructorSeparation(targetGenome, nodeAddress, false); //currently no sub-genome with separation property wished
}

for (int i = nodeAddress; i < genomeSize; ++i) {
Expand Down
2 changes: 0 additions & 2 deletions source/EngineInterface/GenomeConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ namespace Const
auto constexpr ConstructorConstructionAngle1Pos = 3;
auto constexpr ConstructorConstructionAngle2Pos = 4;

auto constexpr ConstructorSeparation = 2;

auto constexpr CellBasicBytes = 8;
auto constexpr NeuronBytes = 64 + 8 + 8;
auto constexpr TransmitterBytes = 1;
Expand Down
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "alien",
"version": "4.5.0",
"version": "4.5.1",
"dependencies": [
{
"name": "glew",
Expand Down

0 comments on commit fc63edc

Please sign in to comment.