Skip to content

Commit

Permalink
+ introduce cellFunctionAttackerGenomeSizeBonus
Browse files Browse the repository at this point in the history
  • Loading branch information
chrxh committed Jul 1, 2023
1 parent 952169f commit ca59cb9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 14 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.0.0.beta.17";
std::string const ProgramVersion = "4.0.0.beta.18";

std::string const BasePath = "resources/";

Expand Down
7 changes: 4 additions & 3 deletions source/EngineGpuKernels/AttackerProcessor.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ __device__ __inline__ void AttackerProcessor::processCell(SimulationData& data,
if (energyToTransfer < 0) {
return;
}
//if (otherCell->genomeSize > cell->genomeSize) {
// return;
//}
if (otherCell->genomeSize > cell->genomeSize) {
auto genomeSizeBonus = cudaSimulationParameters.cellFunctionAttackerGenomeSizeBonus[cell->color];
energyToTransfer /= (1.0f + genomeSizeBonus) * static_cast<int>(otherCell->genomeSize - cell->genomeSize);
}

auto velocityPenalty = Math::length(cell->vel) * 20 * cudaSimulationParameters.cellFunctionAttackerVelocityPenalty[cell->color] + 1.0f;
energyToTransfer /= velocityPenalty;
Expand Down
6 changes: 6 additions & 0 deletions source/EngineInterface/AuxiliaryDataParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,12 @@ namespace
defaultParameters.baseValues.cellFunctionAttackerConnectionsMismatchPenalty,
"simulation parameters.cell.function.attacker.connections mismatch penalty",
parserTask);
encodeDecodeProperty(
tree,
parameters.cellFunctionAttackerGenomeSizeBonus,
defaultParameters.cellFunctionAttackerGenomeSizeBonus,
"simulation parameters.cell.function.attacker.genome size bonus",
parserTask);

encodeDecodeProperty(
tree,
Expand Down
4 changes: 4 additions & 0 deletions source/EngineInterface/SimulationParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ struct SimulationParameters
ColorVector<float> cellFunctionAttackerEnergyDistributionValue = {10.0f, 10.0f, 10.0f, 10.0f, 10.0f, 10.0f, 10.0f};
ColorVector<float> cellFunctionAttackerColorInhomogeneityFactor = {1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f};
ColorVector<float> cellFunctionAttackerVelocityPenalty = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
ColorVector<float> cellFunctionAttackerGenomeSizeBonus = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
float cellFunctionAttackerActivityThreshold = 0.1f;

ColorVector<float> cellFunctionDefenderAgainstAttackerStrength = {1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f};
Expand Down Expand Up @@ -133,6 +134,9 @@ struct SimulationParameters
}

for (int i = 0; i < MAX_COLORS; ++i) {
if (cellFunctionAttackerGenomeSizeBonus[i] != other.cellFunctionAttackerGenomeSizeBonus[i]) {
return false;
}
if (cellFunctionConstructorPumpEnergyFactor[i] != other.cellFunctionConstructorPumpEnergyFactor[i]) {
return false;
}
Expand Down
31 changes: 21 additions & 10 deletions source/Gui/SimulationParametersWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,27 @@ void _SimulationParametersWindow::processBase(
.max(0.1f)
.defaultValue(origSimParameters.cellFunctionAttackerStrength),
simParameters.cellFunctionAttackerStrength);
AlienImGui::SliderFloat(
AlienImGui::SliderFloatParameters()
.name("Attack radius")
.textWidth(RightColumnWidth)
.colorDependence(true)
.min(0)
.max(2.5f)
.defaultValue(origSimParameters.cellFunctionAttackerRadius)
.tooltip("The maximum distance over which an attacker cell can attack another cell."),
simParameters.cellFunctionAttackerRadius);
AlienImGui::SliderFloat(
AlienImGui::SliderFloatParameters()
.name("Genome size bonus")
.textWidth(RightColumnWidth)
.colorDependence(true)
.min(0)
.max(20.0f)
.infinity(true)
.defaultValue(origSimParameters.cellFunctionAttackerGenomeSizeBonus)
.tooltip("The larger this parameter is, the less energy can be gained by attacking creatures with larger genomes."),
simParameters.cellFunctionAttackerGenomeSizeBonus);
AlienImGui::SliderFloat(
AlienImGui::SliderFloatParameters()
.name("Velocity penalty")
Expand Down Expand Up @@ -812,16 +833,6 @@ void _SimulationParametersWindow::processBase(
.defaultValue(origSimParameters.baseValues.cellFunctionAttackerConnectionsMismatchPenalty)
.tooltip("The larger this parameter is, the more difficult it is to attack cells that contain more connections."),
simParameters.baseValues.cellFunctionAttackerConnectionsMismatchPenalty);
AlienImGui::SliderFloat(
AlienImGui::SliderFloatParameters()
.name("Attack radius")
.textWidth(RightColumnWidth)
.colorDependence(true)
.min(0)
.max(2.5f)
.defaultValue(origSimParameters.cellFunctionAttackerRadius)
.tooltip("The maximum distance over which an attacker cell can attack another cell."),
simParameters.cellFunctionAttackerRadius);
AlienImGui::SliderFloat(
AlienImGui::SliderFloatParameters()
.name("Energy distribution radius")
Expand Down

0 comments on commit ca59cb9

Please sign in to comment.