Skip to content

Commit

Permalink
+ sensors remember last match
Browse files Browse the repository at this point in the history
+ tooltips for sensor and muscles corrected
  • Loading branch information
chrxh committed Sep 1, 2023
1 parent a98fa1b commit aadf282
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 9 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";
std::string const ProgramVersion = "4.0.1";

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

Expand Down
5 changes: 5 additions & 0 deletions source/EngineGpuKernels/Cell.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ struct SensorFunction
float minDensity;
int color;
int targetedCreatureId;

//temp
float memoryChannel1;
float memoryChannel2;
float memoryChannel3;
};

struct NerveFunction
Expand Down
4 changes: 4 additions & 0 deletions source/EngineGpuKernels/ConstructorProcessor.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,10 @@ ConstructorProcessor::constructCellIntern(
result->cellFunctionData.sensor.angle = GenomeDecoder::readAngle(constructor);
result->cellFunctionData.sensor.minDensity = (GenomeDecoder::readFloat(constructor) + 1.0f) / 2;
result->cellFunctionData.sensor.color = GenomeDecoder::readByte(constructor) % MAX_COLORS;
result->cellFunctionData.sensor.memoryChannel1 = 0;
result->cellFunctionData.sensor.memoryChannel2 = 0;
result->cellFunctionData.sensor.memoryChannel3 = 0;

} break;
case CellFunction_Nerve: {
result->cellFunctionData.nerve.pulseMode = GenomeDecoder::readByte(constructor);
Expand Down
6 changes: 6 additions & 0 deletions source/EngineGpuKernels/ObjectFactory.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ __inline__ __device__ void ObjectFactory::changeCellFromTO(DataTO const& dataTO,
cell->cellFunctionData.sensor.minDensity = cellTO.cellFunctionData.sensor.minDensity;
cell->cellFunctionData.sensor.color = cellTO.cellFunctionData.sensor.color;
cell->cellFunctionData.sensor.targetedCreatureId = cellTO.cellFunctionData.sensor.targetedCreatureId;
cell->cellFunctionData.sensor.memoryChannel1 = 0;
cell->cellFunctionData.sensor.memoryChannel2 = 0;
cell->cellFunctionData.sensor.memoryChannel3 = 0;
} break;
case CellFunction_Nerve: {
cell->cellFunctionData.nerve.pulseMode = cellTO.cellFunctionData.nerve.pulseMode;
Expand Down Expand Up @@ -299,6 +302,9 @@ __inline__ __device__ Cell* ObjectFactory::createRandomCell(float energy, float2
cell->cellFunctionData.sensor.minDensity = _data->numberGen1.random(1.0f);
cell->cellFunctionData.sensor.color = _data->numberGen1.random(MAX_COLORS - 1);
cell->cellFunctionData.sensor.targetedCreatureId = 0;
cell->cellFunctionData.sensor.memoryChannel1 = 0;
cell->cellFunctionData.sensor.memoryChannel2 = 0;
cell->cellFunctionData.sensor.memoryChannel3 = 0;
} break;
case CellFunction_Nerve: {
} break;
Expand Down
6 changes: 6 additions & 0 deletions source/EngineGpuKernels/SensorProcessor.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,19 @@ SensorProcessor::searchNeighborhood(SimulationData& data, SimulationStatistics&
activity.channels[1] = static_cast<float>((lookupResult >> 40) & 0xff) / 256; //density
activity.channels[2] = static_cast<float>(lookupResult >> 48) / 256; //distance
activity.channels[3] = convertDataToAngle(static_cast<int8_t>((lookupResult >> 32) & 0xff)) / 360.0f; //angle: between -0.5 and 0.5
cell->cellFunctionData.sensor.memoryChannel1 = activity.channels[1];
cell->cellFunctionData.sensor.memoryChannel2 = activity.channels[2];
cell->cellFunctionData.sensor.memoryChannel3 = activity.channels[3];
auto targetCreatureId = lookupResult & 0xffffffff;
if (targetCreatureId != 0xffffffff) {
cell->cellFunctionData.sensor.targetedCreatureId = toInt(targetCreatureId);
}
statistics.incNumSensorMatches(cell->color);
} else {
activity.channels[0] = 0; //nothing found
activity.channels[1] = cell->cellFunctionData.sensor.memoryChannel1;
activity.channels[2] = cell->cellFunctionData.sensor.memoryChannel2;
activity.channels[3] = cell->cellFunctionData.sensor.memoryChannel3;
}
}
__syncthreads();
Expand Down
2 changes: 1 addition & 1 deletion source/Gui/SimulationParametersWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ void _SimulationParametersWindow::processBase(
.textWidth(RightColumnWidth)
.colorDependence(true)
.min(0.1f)
.max(3.0f)
.max(4.0f)
.defaultValue(origSimParameters.cellFunctionInjectorRadius)
.tooltip("The maximum distance over which an injector cell can infect another cell."),
simParameters.cellFunctionInjectorRadius);
Expand Down
18 changes: 11 additions & 7 deletions source/Gui/Tooltips.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ namespace Const
std::string const SensorTooltip =
"Sensor cells scan their environment for concentrations of cells of a certain color and provide distance and angle to the "
"closest match.\n\n" ICON_FA_CHEVRON_RIGHT " Input channel #0: abs(value) > threshold activates sensor\n\n" ICON_FA_CHEVRON_RIGHT " Output channel #0: "
"0 (no match) or 1 (match)\n\n" ICON_FA_CHEVRON_RIGHT " Output channel #1: density of the match\n\n" ICON_FA_CHEVRON_RIGHT " Output channel #2: distance "
"of the match\n\n" ICON_FA_CHEVRON_RIGHT " Output channel #3: angle of the match";
"0 (no match) or 1 (match)\n\n" ICON_FA_CHEVRON_RIGHT " Output channel #1: density of the last match\n\n" ICON_FA_CHEVRON_RIGHT " Output channel #2: distance "
"of the last match\n\n" ICON_FA_CHEVRON_RIGHT " Output channel #3: angle of the last match";

std::string const NerveTooltip =
"By default, a nerve cell forwards activity states by receiving activity as input from connected cells (and summing it if "
Expand All @@ -55,7 +55,9 @@ namespace Const
"Muscle cells can perform different movements and deformations based on input and configuration.\n\n" ICON_FA_CHEVRON_RIGHT " Input channel "
"#0: The strength of the movement, bending or expansion/contraction. A negative sign corresponds to the opposite "
"action.\n\n" ICON_FA_CHEVRON_RIGHT " Input channel #1: This channel is solely utilized for acceleration due to bending. If the sign of channel #1 "
"differs from the sign of channel #0, no acceleration will be obtained during the bending process.";
"differs from the sign of channel #0, no acceleration will be obtained during the bending process.\n\n " ICON_FA_CHEVRON_RIGHT
" Input channel #3: This channel is used for muscles in movement mode. It allows to determine the relative angle of the movement. A value of -0.5 "
"correspond to -180 deg and +0.5 to +180 deg.";

std::string const DefenderTooltip =
"A defender cell does not need to be activated. Its presence reduces the strength of an enemy attack involving attacker "
Expand Down Expand Up @@ -315,9 +317,9 @@ namespace Const
"constructor next cell, e.g. no energy, required connection check failed, completeness check failed), 1 (next cell construction "
"successful)\n\n" ICON_FA_CHEVRON_RIGHT " Sensor: 0 (no match) or 1 (match)\n\n" ICON_FA_CHEVRON_RIGHT " Attacker: a value which is proportional to the gained "
"energy\n\n" ICON_FA_CHEVRON_RIGHT " Injector: 0 (no cells found) or 1 (injection in process or completed)",
"The following cell functions write their output to channel #1:\n\n" ICON_FA_CHEVRON_RIGHT " Neuron\n\n" ICON_FA_CHEVRON_RIGHT " Sensor: density of the match",
"The following cell functions write their output to channel #2:\n\n" ICON_FA_CHEVRON_RIGHT " Neuron\n\n" ICON_FA_CHEVRON_RIGHT " Sensor: distance of the match",
"The following cell functions write their output to channel #3:\n\n" ICON_FA_CHEVRON_RIGHT " Neuron\n\n" ICON_FA_CHEVRON_RIGHT " Sensor: angle of the match",
"The following cell functions write their output to channel #1:\n\n" ICON_FA_CHEVRON_RIGHT " Neuron\n\n" ICON_FA_CHEVRON_RIGHT " Sensor: density of the last match",
"The following cell functions write their output to channel #2:\n\n" ICON_FA_CHEVRON_RIGHT " Neuron\n\n" ICON_FA_CHEVRON_RIGHT " Sensor: distance of the last match",
"The following cell functions write their output to channel #3:\n\n" ICON_FA_CHEVRON_RIGHT " Neuron\n\n" ICON_FA_CHEVRON_RIGHT " Sensor: angle of the last match",
"The following cell functions write their output to channel #4:\n\n" ICON_FA_CHEVRON_RIGHT " Neuron",
"The following cell functions write their output to channel #5:\n\n" ICON_FA_CHEVRON_RIGHT " Neuron",
"The following cell functions write their output to channel #6:\n\n" ICON_FA_CHEVRON_RIGHT " Neuron",
Expand All @@ -334,7 +336,9 @@ namespace Const
"solely utilized for acceleration due to bending. If the sign of channel #1 differs from the sign of channel #0, no acceleration will be obtained "
"during the bending process.",
"The following cell functions obtain their input from channel #2:\n\n" ICON_FA_CHEVRON_RIGHT " Neuron",
"The following cell functions obtain their input from channel #3:\n\n" ICON_FA_CHEVRON_RIGHT " Neuron",
"The following cell functions obtain their input from channel #3:\n\n" ICON_FA_CHEVRON_RIGHT " Neuron\n\n" ICON_FA_CHEVRON_RIGHT
" Muscle: This channel is used for muscles in movement mode. It allows to determine the relative angle of the movement. A value of -0.5 correspond to "
"-180 deg and +0.5 to +180 deg.",
"The following cell functions obtain their input from channel #4:\n\n" ICON_FA_CHEVRON_RIGHT " Neuron",
"The following cell functions obtain their input from channel #5:\n\n" ICON_FA_CHEVRON_RIGHT " Neuron",
"The following cell functions obtain their input from channel #6:\n\n" ICON_FA_CHEVRON_RIGHT " Neuron",
Expand Down

0 comments on commit aadf282

Please sign in to comment.