Skip to content

Commit

Permalink
+ accumulation of sensor target data fixed
Browse files Browse the repository at this point in the history
+ cell function usage flag for constructor changed
+ evaluating externalEnergyControl feature flag
  • Loading branch information
chrxh committed Sep 23, 2024
1 parent e27d12f commit 557850a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
18 changes: 9 additions & 9 deletions source/EngineGpuKernels/CellFunctionProcessor.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ __inline__ __device__ Activity CellFunctionProcessor::calcInputActivity(Cell* ce
return result;
}

int numSensorActivities = 0;
for (int i = 0, j = cell->numConnections; i < j; ++i) {
auto connectedCell = cell->connections[i].cell;
if (connectedCell->outputBlocked || connectedCell->livingState != LivingState_Ready ) {
Expand All @@ -145,18 +146,17 @@ __inline__ __device__ Activity CellFunctionProcessor::calcInputActivity(Cell* ce
result.channels[i] = max(-10.0f, min(10.0f, result.channels[i])); //truncate value to avoid overflow
}
if (connectedCell->activity.origin == ActivityOrigin_Sensor) {
if (result.origin != ActivityOrigin_Sensor) {
result.origin = ActivityOrigin_Sensor;
result.targetX = connectedCell->activity.targetX;
result.targetY = connectedCell->activity.targetY;
} else {
result.origin = ActivityOrigin_Unknown;
result.targetX = 0;
result.targetY = 0;
}
result.origin = ActivityOrigin_Sensor;
result.targetX += connectedCell->activity.targetX;
result.targetY += connectedCell->activity.targetY;
++numSensorActivities;
}
}
}
if (numSensorActivities > 0) {
result.targetX /= numSensorActivities;
result.targetY /= numSensorActivities;
}
return result;
}

Expand Down
7 changes: 3 additions & 4 deletions source/EngineGpuKernels/ConstructorProcessor.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,7 @@ __inline__ __device__ void ConstructorProcessor::processCell(SimulationData& dat
if (isConstructionTriggered(data, cell, activity)) {
if (tryConstructCell(data, statistics, cell, constructionData)) {
cellBuilt = true;
if (!constructionData.containsSelfReplication) {
cell->cellFunctionUsed = CellFunctionUsed_Yes;
}
cell->cellFunctionUsed = CellFunctionUsed_Yes;
}
}

Expand Down Expand Up @@ -764,7 +762,8 @@ __inline__ __device__ bool ConstructorProcessor::checkAndReduceHostEnergy(Simula
}
}

auto externalEnergyConditionalInflowFactor = cudaSimulationParameters.externalEnergyConditionalInflowFactor[hostCell->color];
auto externalEnergyConditionalInflowFactor =
cudaSimulationParameters.features.externalEnergyControl ? cudaSimulationParameters.externalEnergyConditionalInflowFactor[hostCell->color] : 0.0f;
//if (isSelfReplicator(hostCell)) {
// externalEnergyConditionalInflowFactor = 0;
//}
Expand Down
2 changes: 1 addition & 1 deletion source/EngineGpuKernels/ParticleProcessor.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ __inline__ __device__ void ParticleProcessor::radiate(SimulationData& data, floa

data.cellMap.correctPosition(pos);

auto externalEnergyBackflowFactor = cudaSimulationParameters.externalEnergyBackflowFactor[color];
auto externalEnergyBackflowFactor = cudaSimulationParameters.features.externalEnergyControl ? cudaSimulationParameters.externalEnergyBackflowFactor[color] : 0.0f;
auto particleEnergy =
energy * (1.0f - externalEnergyBackflowFactor);
if (particleEnergy > NEAR_ZERO) {
Expand Down
4 changes: 2 additions & 2 deletions source/Gui/StatisticsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,9 @@ void _StatisticsWindow::processTimelineStatistics()

ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
processPlot(row++, &DataPointCollection::deviationGenomeComplexity, 2);
processPlot(row++, &DataPointCollection::varianceGenomeComplexity, 2);
ImGui::TableSetColumnIndex(1);
AlienImGui::Text("Genome complexity\ndeviation");
AlienImGui::Text("Genome complexity\nvariance");

ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
Expand Down

0 comments on commit 557850a

Please sign in to comment.