Skip to content

Commit

Permalink
+ restrict min genome parameter to replicators
Browse files Browse the repository at this point in the history
+ change feature and parameter name
  • Loading branch information
chrxh committed Dec 19, 2024
1 parent dbf1f2a commit 2fb6946
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 51 deletions.
24 changes: 13 additions & 11 deletions source/EngineGpuKernels/MutationProcessor.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,19 @@ __inline__ __device__ void MutationProcessor::applyRandomMutationsForCell(Simula
__inline__ __device__ void MutationProcessor::checkMutationsForCell(SimulationData& data, Cell* cell)
{
auto& constructor = cell->cellFunctionData.constructor;
auto numNodes = GenomeDecoder::getNumNodesRecursively(constructor.genome, constructor.genomeSize, false, true);
auto numNonSeparatedNodes = GenomeDecoder::getNumNodesRecursively(constructor.genome, constructor.genomeSize, false, false);
auto tooMuchSeparatedParts = numNodes > 2 * numNonSeparatedNodes;
auto tooSmall =
cudaSimulationParameters.features.customizeDeletionMutations && numNonSeparatedNodes < cudaSimulationParameters.cellCopyMutationDeletionMinSize;
if (tooMuchSeparatedParts || tooSmall) {
cell->livingState = LivingState_Dying;
for (int i = 0; i < cell->numConnections; ++i) {
auto const& connectedCell = cell->connections[i].cell;
if (connectedCell->creatureId == cell->creatureId) {
connectedCell->livingState = LivingState_Detaching;
if (GenomeDecoder::containsSelfReplication(constructor)) {
auto numNodes = GenomeDecoder::getNumNodesRecursively(constructor.genome, constructor.genomeSize, false, true);
auto numNonSeparatedNodes = GenomeDecoder::getNumNodesRecursively(constructor.genome, constructor.genomeSize, false, false);
auto tooMuchSeparatedParts = numNodes > 2 * numNonSeparatedNodes;
auto tooSmall =
cudaSimulationParameters.features.advancedCellLifeCycleControl && numNonSeparatedNodes < cudaSimulationParameters.cellMinReplicatorGenomeSize[cell->color];
if (tooMuchSeparatedParts || tooSmall) {
cell->livingState = LivingState_Dying;
for (int i = 0; i < cell->numConnections; ++i) {
auto const& connectedCell = cell->connections[i].cell;
if (connectedCell->creatureId == cell->creatureId) {
connectedCell->livingState = LivingState_Detaching;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/EngineInterface/Features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ bool Features::operator==(Features const& other) const
&& cellColorTransitionRules == other.cellColorTransitionRules && advancedAbsorptionControl == other.advancedAbsorptionControl
&& advancedAttackerControl == other.advancedAttackerControl && cellAgeLimiter == other.cellAgeLimiter && cellGlow == other.cellGlow
&& legacyModes == other.legacyModes && customizeNeuronMutations == other.customizeNeuronMutations
&& customizeDeletionMutations == other.customizeDeletionMutations;
&& advancedCellLifeCycleControl == other.advancedCellLifeCycleControl;
}
2 changes: 1 addition & 1 deletion source/EngineInterface/Features.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ struct Features
bool advancedAttackerControl = false;
bool externalEnergyControl = false;
bool customizeNeuronMutations = false;
bool customizeDeletionMutations = false;
bool advancedCellLifeCycleControl = false;
bool cellColorTransitionRules = false;
bool cellAgeLimiter = false;
bool cellGlow = false;
Expand Down
4 changes: 3 additions & 1 deletion source/EngineInterface/SimulationParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ bool SimulationParameters::operator==(SimulationParameters const& other) const
if (genomeComplexityDepthLevel[i] != other.genomeComplexityDepthLevel[i]) {
return false;
}
if (cellMinReplicatorGenomeSize[i] != other.cellMinReplicatorGenomeSize[i]) {
return false;
}
}
for (int i = 0; i < MAX_COLORS; ++i) {
for (int j = 0; j < MAX_COLORS; ++j) {
Expand Down Expand Up @@ -218,6 +221,5 @@ bool SimulationParameters::operator==(SimulationParameters const& other) const
&& cellCopyMutationNeuronDataReinforcement == other.cellCopyMutationNeuronDataReinforcement
&& cellCopyMutationNeuronDataDamping == other.cellCopyMutationNeuronDataDamping
&& cellCopyMutationNeuronDataOffset == other.cellCopyMutationNeuronDataOffset
&& cellCopyMutationDeletionMinSize == other.cellCopyMutationDeletionMinSize
;
}
6 changes: 3 additions & 3 deletions source/EngineInterface/SimulationParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ struct SimulationParameters
Infinity<int>::value,
Infinity<int>::value};

// advanced cell life cycle control
ColorVector<int> cellMinReplicatorGenomeSize = {0, 0, 0, 0, 0, 0, 0};

bool cellMaxAgeBalancer = false;
int cellMaxAgeBalancerInterval = 10000;
bool cellResetAgeAfterActivation = false;
Expand Down Expand Up @@ -143,9 +146,6 @@ struct SimulationParameters
float cellCopyMutationNeuronDataDamping = 1.05f;
float cellCopyMutationNeuronDataOffset = 0.05f;

// customize deletion mutations setting
int cellCopyMutationDeletionMinSize = 0;

ColorVector<float> cellFunctionInjectorRadius = {3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f};
ColorMatrix<int> cellFunctionInjectorDurationColorMatrix = {
{3, 3, 3, 3, 3, 3, 3},
Expand Down
1 change: 1 addition & 0 deletions source/Gui/AutosaveWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ void AutosaveWindow::processAutomaticSavepoints()
if (minSinceLastAutosave >= _autosaveInterval && _savepointTable.has_value()) {
onCreateSavepoint(_catchPeaks != CatchPeaks_None);
_lastAutosaveTimepoint = std::chrono::steady_clock::now();
_lastPeakTimepoint = std::chrono::steady_clock::now();
}

if (_catchPeaks != CatchPeaks_None) {
Expand Down
39 changes: 20 additions & 19 deletions source/Gui/SimulationParametersBaseWidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,26 @@ void _SimulationParametersBaseWidgets::process()
}
AlienImGui::EndTreeNode();

/**
* Expert settings: Advanced cell life cycle control
*/
if (AlienImGui::BeginTreeNode(AlienImGui::TreeNodeParameters()
.name("Expert settings: Advanced cell life cycle control")
.visible(parameters.features.advancedCellLifeCycleControl)
.blinkWhenActivated(true))) {
AlienImGui::SliderInt(
AlienImGui::SliderIntParameters()
.name("Minimum replicator genome size")
.textWidth(RightColumnWidth)
.colorDependence(true)
.min(0)
.max(1000)
.logarithmic(true)
.defaultValue(origParameters.cellMinReplicatorGenomeSize),
parameters.cellMinReplicatorGenomeSize);
}
AlienImGui::EndTreeNode();

/**
* Expert settings: Cell color transition rules
*/
Expand Down Expand Up @@ -1320,25 +1340,6 @@ void _SimulationParametersBaseWidgets::process()
}
AlienImGui::EndTreeNode();

/**
* Expert settings: Customize deletion mutations
*/
if (AlienImGui::BeginTreeNode(AlienImGui::TreeNodeParameters()
.name("Expert settings: Customize deletion mutations")
.visible(parameters.features.customizeDeletionMutations)
.blinkWhenActivated(true))) {
AlienImGui::SliderInt(
AlienImGui::SliderIntParameters()
.name("Minimum size")
.textWidth(RightColumnWidth)
.min(0)
.max(1000)
.logarithmic(true)
.defaultValue(&origParameters.cellCopyMutationDeletionMinSize),
&parameters.cellCopyMutationDeletionMinSize);
}
AlienImGui::EndTreeNode();

/**
* Expert settings: Customize neuron mutations
*/
Expand Down
6 changes: 3 additions & 3 deletions source/Gui/SimulationParametersMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,9 @@ void SimulationParametersMainWindow::processExpertSettings()
.defaultValue(origFeatures.advancedAttackerControl)
.tooltip("It contains further settings that influence how much energy can be obtained from an attack by attacker cells."),
parameters.features.advancedAttackerControl);
AlienImGui::Checkbox(
AlienImGui::CheckboxParameters().name("Advanced cell life cycle control").textWidth(0).defaultValue(origFeatures.advancedCellLifeCycleControl),
parameters.features.advancedCellLifeCycleControl);
AlienImGui::Checkbox(
AlienImGui::CheckboxParameters()
.name("Cell age limiter")
Expand All @@ -405,9 +408,6 @@ void SimulationParametersMainWindow::processExpertSettings()
.defaultValue(origFeatures.cellGlow)
.tooltip("It enables an additional rendering step that makes the cells glow."),
parameters.features.cellGlow);
AlienImGui::Checkbox(
AlienImGui::CheckboxParameters().name("Customize deletion mutations").textWidth(0).defaultValue(origFeatures.customizeDeletionMutations),
parameters.features.customizeDeletionMutations);
AlienImGui::Checkbox(
AlienImGui::CheckboxParameters()
.name("Customize neuron mutations")
Expand Down
21 changes: 9 additions & 12 deletions source/PersisterInterface/AuxiliaryDataParserService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ namespace
"simulation parameters.cell.death probability",
parserTask);

ParameterParser::encodeDecode(
tree, parameters.cellMinReplicatorGenomeSize, defaultParameters.cellMinReplicatorGenomeSize, "simulation parameters.cell.min replicator genome size", parserTask);

ParameterParser::encodeDecode(
tree,
parameters.cellFunctionConstructorConnectingCellMaxDistance,
Expand Down Expand Up @@ -412,12 +415,6 @@ namespace
defaultParameters.baseValues.cellCopyMutationDeletion,
"simulation parameters.cell.copy mutation.deletion",
parserTask);
ParameterParser::encodeDecode(
tree,
parameters.cellCopyMutationDeletionMinSize,
defaultParameters.cellCopyMutationDeletionMinSize,
"simulation parameters.cell.copy mutation.deletion.min size",
parserTask);
ParameterParser::encodeDecode(
tree,
parameters.baseValues.cellCopyMutationTranslation,
Expand Down Expand Up @@ -1048,6 +1045,12 @@ namespace
defaultParameters.features.advancedAttackerControl,
"simulation parameters.features.additional attacker control",
parserTask);
ParameterParser::encodeDecode(
tree,
parameters.features.advancedCellLifeCycleControl,
defaultParameters.features.advancedCellLifeCycleControl,
"simulation parameters.features.advanced cell life cycle control",
parserTask);
missingFeatures.externalEnergyControl = ParameterParser::encodeDecode(
tree, parameters.features.externalEnergyControl, defaultParameters.features.externalEnergyControl, "simulation parameters.features.external energy", parserTask);
missingFeatures.cellColorTransitionRules = ParameterParser::encodeDecode(
Expand Down Expand Up @@ -1076,12 +1079,6 @@ namespace
defaultParameters.features.customizeNeuronMutations,
"simulation parameters.features.customize neuron mutations",
parserTask);
ParameterParser::encodeDecode(
tree,
parameters.features.customizeDeletionMutations,
defaultParameters.features.customizeDeletionMutations,
"simulation parameters.features.customize deletion mutations",
parserTask);
}

void encodeDecodeSimulationParameters(
Expand Down

0 comments on commit 2fb6946

Please sign in to comment.