From 44053629a38459c5913b9788e0458021c555c75a Mon Sep 17 00:00:00 2001
From: Christian Heinemann
Date: Sat, 8 Oct 2022 10:28:29 +0200
Subject: [PATCH 01/15] first implementation of NeuralNetProcessor added
---
source/EngineGpuKernels/CMakeLists.txt | 2 +-
source/EngineGpuKernels/Cell.cuh | 4 +-
.../CommunicationProcessor.cuh | 20 ------
.../EngineGpuKernels/NeuralNetProcessor.cuh | 72 +++++++++++++++++++
source/EngineGpuKernels/SensorProcessor.cuh | 4 +-
source/EngineGpuKernels/TokenProcessor.cuh | 5 +-
source/EngineInterface/Enums.h | 40 +++--------
source/EngineInterface/SymbolMap.cpp | 24 +------
source/Gui/InspectorWindow.cpp | 10 +--
source/Gui/InspectorWindow.h | 2 +-
source/Gui/SimulationView.cpp | 2 +-
11 files changed, 96 insertions(+), 89 deletions(-)
delete mode 100644 source/EngineGpuKernels/CommunicationProcessor.cuh
create mode 100644 source/EngineGpuKernels/NeuralNetProcessor.cuh
diff --git a/source/EngineGpuKernels/CMakeLists.txt b/source/EngineGpuKernels/CMakeLists.txt
index f58073353..b613b5671 100644
--- a/source/EngineGpuKernels/CMakeLists.txt
+++ b/source/EngineGpuKernels/CMakeLists.txt
@@ -9,7 +9,6 @@ add_library(alien_engine_gpu_kernels_lib
CellFunctionData.cuh
CellProcessor.cuh
ClusterProcessor.cuh
- CommunicationProcessor.cuh
ConstantMemory.cu
ConstantMemory.cuh
ConstructionProcessor.cuh
@@ -53,6 +52,7 @@ add_library(alien_engine_gpu_kernels_lib
MonitorKernels.cu
MonitorKernels.cuh
MuscleProcessor.cuh
+ NeuralNetProcessor.cuh
Operations.cuh
Particle.cuh
ParticleProcessor.cuh
diff --git a/source/EngineGpuKernels/Cell.cuh b/source/EngineGpuKernels/Cell.cuh
index e882d1a17..fb8b02456 100644
--- a/source/EngineGpuKernels/Cell.cuh
+++ b/source/EngineGpuKernels/Cell.cuh
@@ -51,7 +51,7 @@ struct Cell
int age;
//editing data
- int selected; //0 = no, 1 = selected, 2 = indirectly selected
+ int selected; //0 = no, 1 = selected, 2 = cluster selected
//temporary data
int locked; //0 = unlocked, 1 = locked
@@ -98,7 +98,7 @@ struct Cell
__inline__ __device__ Enums::CellFunction getCellFunctionType() const
{
- return static_cast(cellFunctionType) % Enums::CellFunction_Count;
+ return calcMod (cellFunctionType, Enums::CellFunction_Count);
}
__inline__ __device__ void initMemorySizes()
diff --git a/source/EngineGpuKernels/CommunicationProcessor.cuh b/source/EngineGpuKernels/CommunicationProcessor.cuh
deleted file mode 100644
index 441768dbb..000000000
--- a/source/EngineGpuKernels/CommunicationProcessor.cuh
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-
-#include "SimulationData.cuh"
-#include "QuantityConverter.cuh"
-
-class CommunicationProcessor
-{
-public:
- __inline__ __device__ static void process(Token* token, SimulationData& data);
-
-};
-
-/************************************************************************/
-/* Implementation */
-/************************************************************************/
-
-__inline__ __device__ void CommunicationProcessor::process(Token* token, SimulationData& data)
-{
- //#TODO
-}
\ No newline at end of file
diff --git a/source/EngineGpuKernels/NeuralNetProcessor.cuh b/source/EngineGpuKernels/NeuralNetProcessor.cuh
new file mode 100644
index 000000000..75fa4f036
--- /dev/null
+++ b/source/EngineGpuKernels/NeuralNetProcessor.cuh
@@ -0,0 +1,72 @@
+#pragma once
+
+#include "SimulationData.cuh"
+#include "QuantityConverter.cuh"
+
+class NeuralNetProcessor
+{
+public:
+ __inline__ __device__ static void process(Token* token, SimulationData& data);
+
+private:
+ __inline__ __device__ static float getWeight(Cell* cell, int index1, int index2);
+ __inline__ __device__ static float getInput(Token* token, int index);
+ __inline__ __device__ static void setOutput(Token* token, int index, float value);
+ __inline__ __device__ static float sigmoid(float z);
+};
+
+/************************************************************************/
+/* Implementation */
+/************************************************************************/
+
+__inline__ __device__ void NeuralNetProcessor::process(Token* token, SimulationData& data)
+{
+ auto cell = token->cell;
+ auto partition = calcPartition(8, threadIdx.x, blockDim.x);
+
+ __shared__ float input[8];
+ for (int i = partition.startIndex; i <= partition.endIndex; ++i) {
+ input[i] = getInput(token, i);
+ }
+ __syncthreads();
+
+ for (int i = partition.startIndex; i <= partition.endIndex; ++i) {
+ float netInput = 0;
+ for (int j = 0; j < 8; ++j) {
+ netInput += getWeight(cell, i, j) * input[j];
+ }
+ setOutput(token, i, sigmoid(netInput));
+ }
+ __syncthreads();
+}
+__inline__ __device__ float NeuralNetProcessor::getWeight(Cell* cell, int index1, int index2)
+{
+ auto flatIndex = index1 + index2 * 8;
+ auto data = static_cast(cell->staticData[flatIndex / 2]);
+ int weigthInt = (flatIndex % 2) == 0 ? data & 0xf : (data >> 4) & 0xf;
+ return static_cast(weigthInt) / 16 - 0.5f;
+}
+
+__inline__ __device__ float NeuralNetProcessor::getInput(Token* token, int index)
+{
+ int address = Enums::NeuralNet_InOut + index * 2;
+ auto byte1 = static_cast(static_cast(token->memory[address]));
+ auto byte2 = static_cast(static_cast(token->memory[address + 1]));
+ return static_cast((byte1 << 8) + byte2) / 65536;
+}
+
+__inline__ __device__ void NeuralNetProcessor::setOutput(Token* token, int index, float value)
+{
+ auto scaledValue = static_cast(value * 65536);
+ auto byte1 = scaledValue >> 8;
+ auto byte2 = scaledValue & 0xff;
+
+ int address = Enums::NeuralNet_InOut + index * 2;
+ token->memory[address] = static_cast(byte1);
+ token->memory[address + 1] = static_cast(byte2);
+}
+
+__inline__ __device__ float NeuralNetProcessor::sigmoid(float z)
+{
+ return 1.0f / (1.0f + __expf(-z));
+}
diff --git a/source/EngineGpuKernels/SensorProcessor.cuh b/source/EngineGpuKernels/SensorProcessor.cuh
index 11ee4153d..8ea050fba 100644
--- a/source/EngineGpuKernels/SensorProcessor.cuh
+++ b/source/EngineGpuKernels/SensorProcessor.cuh
@@ -90,7 +90,7 @@ __device__ __inline__ void SensorProcessor::searchVicinity(Token* token, Simulat
if (threadIdx.x == 0) {
if (result != 0xffffffff) {
token->memory[Enums::Sensor_Output] = Enums::SensorOut_ClusterFound;
- token->memory[Enums::Sensor_OutMass] = static_cast((result >> 8) & 0xff);
+ token->memory[Enums::Sensor_OutDensity] = static_cast((result >> 8) & 0xff);
auto radiusInt = static_cast(radius);
if (radiusInt > 255) {
radiusInt = 255;
@@ -154,7 +154,7 @@ __device__ __inline__ void SensorProcessor::searchByAngle(Token* token, Simulati
if (threadIdx.x == 0) {
if (result != 0xffffffff) {
token->memory[Enums::Sensor_Output] = Enums::SensorOut_ClusterFound;
- token->memory[Enums::Sensor_OutMass] = static_cast(result & 0xff);
+ token->memory[Enums::Sensor_OutDensity] = static_cast(result & 0xff);
auto distance = static_cast((result >> 8) & 0xff);
if (distance > 255) {
distance = 255;
diff --git a/source/EngineGpuKernels/TokenProcessor.cuh b/source/EngineGpuKernels/TokenProcessor.cuh
index 0340570f9..e9910c2df 100644
--- a/source/EngineGpuKernels/TokenProcessor.cuh
+++ b/source/EngineGpuKernels/TokenProcessor.cuh
@@ -12,7 +12,7 @@
#include "ConstructionProcessor.cuh"
#include "ScannerProcessor.cuh"
#include "DigestionProcessor.cuh"
-#include "CommunicationProcessor.cuh"
+#include "NeuralNetProcessor.cuh"
#include "MuscleProcessor.cuh"
#include "SensorProcessor.cuh"
@@ -182,9 +182,6 @@ TokenProcessor::executeModifyingCellFunctions(SimulationData& data, SimulationRe
if (Enums::CellFunction_Constructor == cellFunctionType) {
ConstructionProcessor::process(token, data, result);
}
- if (Enums::CellFunction_Communication == cellFunctionType) {
- CommunicationProcessor::process(token, data);
- }
if (Enums::CellFunction_Muscle == cellFunctionType) {
MuscleProcessor::process(token, data, result);
}
diff --git a/source/EngineInterface/Enums.h b/source/EngineInterface/Enums.h
index 2af7366bf..98886fa2b 100644
--- a/source/EngineInterface/Enums.h
+++ b/source/EngineInterface/Enums.h
@@ -12,7 +12,7 @@ namespace Enums
enum CellFunction_
{
CellFunction_Computation,
- CellFunction_Communication,
+ CellFunction_NeuralNet,
CellFunction_Scanner,
CellFunction_Digestion,
CellFunction_Constructor,
@@ -41,36 +41,6 @@ namespace Enums
EnergyGuidanceIn_Count
};
- using Communicator = int;
- enum Communicator_
- {
- Communicator_Input = 26,
- Communicator_InChannel = 27,
- Communicator_InMessage = 28,
- Communicator_InAngle = 29,
- Communicator_InDistance = 30,
- Communicator_OutSentNumMessage = 31,
- Communicator_OutReceivedNewMessage = 32,
- Communicator_OutReceivedMessage = 33,
- Communicator_OutReceivedAngle = 34,
- Communicator_OutReceivedDistance = 35,
- };
- using CommunicatorIn = int;
- enum CommunicatorIn_
- {
- CommunicatorIn_DoNothing,
- CommunicatorIn_SetListeningChannel,
- CommunicatorIn_SendMessage,
- CommunicatorIn_ReceiveMessage,
- CommunicatorIn_Count
- };
- using CommunicatorOutReceivedNewMessage = int;
- enum CommunicatorOutReceivedNewMessage_
- {
- CommunicatorOutReceivedNewMessage_No,
- CommunicatorOutReceivedNewMessage_Yes
- };
-
using ComputationOperation = int;
enum ComputationOperation_
{
@@ -152,6 +122,12 @@ namespace Enums
ConstrInUniformDist_Count
};
+ using NeuralNet = int;
+ enum NeuralNet_
+ {
+ NeuralNet_InOut = 110,
+ };
+
using Scanner = int;
enum Scanner_
{
@@ -182,7 +158,7 @@ namespace Enums
Sensor_InMinDensity = 22,
Sensor_InMaxDensity = 23,
Sensor_InColor = 8,
- Sensor_OutMass = 24,
+ Sensor_OutDensity = 24,
Sensor_OutDistance = 25
};
using SensorIn = int;
diff --git a/source/EngineInterface/SymbolMap.cpp b/source/EngineInterface/SymbolMap.cpp
index 47cbdabab..282e8da13 100644
--- a/source/EngineInterface/SymbolMap.cpp
+++ b/source/EngineInterface/SymbolMap.cpp
@@ -57,7 +57,7 @@ SymbolMap SymbolMapHelper::getDefaultSymbolMap()
result.emplace("CONSTR_IN_CELL_COLOR", "[" + std::to_string(Enums::Constr_InCellColor) + "]");
result.emplace("CONSTR_IN_CELL_FUNCTION", "[" + std::to_string(Enums::Constr_InCellFunction) + "]");
result.emplace("CONSTR_IN_CELL_FUNCTION::COMPUTATION", std::to_string(Enums::CellFunction_Computation));
- result.emplace("CONSTR_IN_CELL_FUNCTION::COMMUNICATION", std::to_string(Enums::CellFunction_Communication));
+ result.emplace("CONSTR_IN_CELL_FUNCTION::NEURALNET", std::to_string(Enums::CellFunction_NeuralNet));
result.emplace("CONSTR_IN_CELL_FUNCTION::SCANNER", std::to_string(Enums::CellFunction_Scanner));
result.emplace("CONSTR_IN_CELL_FUNCTION::DIGESTION", std::to_string(Enums::CellFunction_Digestion));
result.emplace("CONSTR_IN_CELL_FUNCTION::CONSTR", std::to_string(Enums::CellFunction_Constructor));
@@ -78,7 +78,7 @@ SymbolMap SymbolMapHelper::getDefaultSymbolMap()
result.emplace("SCANNER_OUT_CELL_COLOR", "[" + std::to_string(Enums::Scanner_OutCellColor) + "]");
result.emplace("SCANNER_OUT_CELL_FUNCTION", "[" + std::to_string(Enums::Scanner_OutCellFunction) + "]");
result.emplace("SCANNER_OUT_CELL_FUNCTION::COMPUTATION", std::to_string(Enums::CellFunction_Computation));
- result.emplace("SCANNER_OUT_CELL_FUNCTION::COMMUNICATION", std::to_string(Enums::CellFunction_Communication));
+ result.emplace("SCANNER_OUT_CELL_FUNCTION::NEURALNET", std::to_string(Enums::CellFunction_NeuralNet));
result.emplace("SCANNER_OUT_CELL_FUNCTION::SCANNER", std::to_string(Enums::CellFunction_Scanner));
result.emplace("SCANNER_OUT_CELL_FUNCTION::DIGESTION", std::to_string(Enums::CellFunction_Digestion));
result.emplace("SCANNER_OUT_CELL_FUNCTION::CONSTR", std::to_string(Enums::CellFunction_Constructor));
@@ -105,27 +105,9 @@ SymbolMap SymbolMapHelper::getDefaultSymbolMap()
result.emplace("SENSOR_IN_MIN_DENSITY", "[" + std::to_string(Enums::Sensor_InMinDensity) + "]");
result.emplace("SENSOR_IN_MAX_DENSITY", "[" + std::to_string(Enums::Sensor_InMaxDensity) + "]");
result.emplace("SENSOR_IN_COLOR", "[" + std::to_string(Enums::Sensor_InColor) + "]");
- result.emplace("SENSOR_OUT_MASS", "[" + std::to_string(Enums::Sensor_OutMass) + "]");
+ result.emplace("SENSOR_OUT_DENSITY", "[" + std::to_string(Enums::Sensor_OutDensity) + "]");
result.emplace("SENSOR_OUT_DISTANCE", "[" + std::to_string(Enums::Sensor_OutDistance) + "]");
- //communicator
- result.emplace("COMMUNICATOR_IN", "[" + std::to_string(Enums::Communicator_Input) + "]");
- result.emplace("COMMUNICATOR_IN::DO_NOTHING", std::to_string(Enums::CommunicatorIn_DoNothing));
- result.emplace("COMMUNICATOR_IN::SET_LISTENING_CHANNEL", std::to_string(Enums::CommunicatorIn_SetListeningChannel));
- result.emplace("COMMUNICATOR_IN::SEND_MESSAGE", std::to_string(Enums::CommunicatorIn_SendMessage));
- result.emplace("COMMUNICATOR_IN::RECEIVE_MESSAGE", std::to_string(Enums::CommunicatorIn_ReceiveMessage));
- result.emplace("COMMUNICATOR_IN_CHANNEL", "[" + std::to_string(Enums::Communicator_InChannel) + "]");
- result.emplace("COMMUNICATOR_IN_MESSAGE", "[" + std::to_string(Enums::Communicator_InMessage) + "]");
- result.emplace("COMMUNICATOR_IN_ANGLE", "[" + std::to_string(Enums::Communicator_InAngle) + "]");
- result.emplace("COMMUNICATOR_IN_DISTANCE", "[" + std::to_string(Enums::Communicator_InDistance) + "]");
- result.emplace("COMMUNICATOR_OUT_SENT_NUM_MESSAGE", "[" + std::to_string(Enums::Communicator_OutSentNumMessage) + "]");
- result.emplace("COMMUNICATOR_OUT_RECEIVED_NEW_MESSAGE", "[" + std::to_string(Enums::Communicator_OutReceivedNewMessage) + "]");
- result.emplace("COMMUNICATOR_OUT_RECEIVED_NEW_MESSAGE::NO", std::to_string(Enums::CommunicatorOutReceivedNewMessage_No));
- result.emplace("COMMUNICATOR_OUT_RECEIVED_NEW_MESSAGE::YES", std::to_string(Enums::CommunicatorOutReceivedNewMessage_Yes));
- result.emplace("COMMUNICATOR_OUT_RECEIVED_MESSAGE", "[" + std::to_string(Enums::Communicator_OutReceivedMessage) + "]");
- result.emplace("COMMUNICATOR_OUT_RECEIVED_ANGLE", "[" + std::to_string(Enums::Communicator_OutReceivedAngle) + "]");
- result.emplace("COMMUNICATOR_OUT_RECEIVED_DISTANCE", "[" + std::to_string(Enums::Communicator_OutReceivedDistance) + "]");
-
//muscle
result.emplace("MUSCLE_IN", "[" + std::to_string(Enums::Muscle_Input) + "]");
result.emplace("MUSCLE_IN::DO_NOTHING", std::to_string(Enums::MuscleIn_DoNothing));
diff --git a/source/Gui/InspectorWindow.cpp b/source/Gui/InspectorWindow.cpp
index 16fea0f54..2524ebb0b 100644
--- a/source/Gui/InspectorWindow.cpp
+++ b/source/Gui/InspectorWindow.cpp
@@ -24,7 +24,7 @@ namespace
auto const MaxCellContentTextWidth = 120.0f;
auto const MaxParticleContentTextWidth = 80.0f;
auto const CellFunctions =
- std::vector{"Computation"s, "Communication"s, "Scanner"s, "Digestion"s, "Construction"s, "Sensor"s, "Muscle"s};
+ std::vector{"Computation"s, "Neural Net"s, "Scanner"s, "Digestion"s, "Construction"s, "Sensor"s, "Muscle"s};
}
_InspectorWindow::_InspectorWindow(
@@ -345,8 +345,8 @@ void _InspectorWindow::showCellInOutChannelTab(CellDescription& cell)
if (cell.cellFeature.getType() == Enums::CellFunction_Scanner) {
showScannerTableContent();
}
- if (cell.cellFeature.getType() == Enums::CellFunction_Communication) {
- showCommunicationTableContent();
+ if (cell.cellFeature.getType() == Enums::CellFunction_NeuralNet) {
+ showNeuralNetTableContent();
}
if (cell.cellFeature.getType() == Enums::CellFunction_Digestion) {
showDigestionTableContent();
@@ -619,7 +619,7 @@ void _InspectorWindow::showScannerTableContent()
AlienImGui::Text("Output:\ninternal data of scanned cell\n(e.g. cell code and cell memory");
}
-void _InspectorWindow::showCommunicationTableContent()
+void _InspectorWindow::showNeuralNetTableContent()
{
ImGui::TableSetColumnIndex(1);
AlienImGui::Text("Not yet implemented");
@@ -881,7 +881,7 @@ void _InspectorWindow::showSensorTableContent()
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
- AlienImGui::Text(formatHex(Enums::Sensor_OutMass));
+ AlienImGui::Text(formatHex(Enums::Sensor_OutDensity));
ImGui::TableSetColumnIndex(1);
AlienImGui::Text("Output: detected mass concentration");
diff --git a/source/Gui/InspectorWindow.h b/source/Gui/InspectorWindow.h
index 6d7831270..036f3da6b 100644
--- a/source/Gui/InspectorWindow.h
+++ b/source/Gui/InspectorWindow.h
@@ -43,7 +43,7 @@ class _InspectorWindow
void processParticle(ParticleDescription particle);
void showScannerTableContent();
- void showCommunicationTableContent();
+ void showNeuralNetTableContent();
void showDigestionTableContent();
void showConstructionTableContent();
void showMuscleTableContent();
diff --git a/source/Gui/SimulationView.cpp b/source/Gui/SimulationView.cpp
index 9e5890ccf..8280c3c4c 100644
--- a/source/Gui/SimulationView.cpp
+++ b/source/Gui/SimulationView.cpp
@@ -21,7 +21,7 @@ namespace
std::unordered_map cellFunctionToStringMap = {
{Enums::CellFunction_Computation, "Computation"},
- {Enums::CellFunction_Communication, "Communication"},
+ {Enums::CellFunction_NeuralNet, "Neural Net"},
{Enums::CellFunction_Scanner, "Scanner"},
{Enums::CellFunction_Digestion, "Digestion"},
{Enums::CellFunction_Constructor, "Construction"},
From 19c25f3dd4bb7b6af16dd309153c91e176993311 Mon Sep 17 00:00:00 2001
From: Christian Heinemann
Date: Sat, 8 Oct 2022 11:06:22 +0200
Subject: [PATCH 02/15] simulation data structured
---
source/EngineGpuKernels/Operations.cuh | 5 +++++
source/EngineGpuKernels/SimulationData.cuh | 10 ++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/source/EngineGpuKernels/Operations.cuh b/source/EngineGpuKernels/Operations.cuh
index 01d3ba63a..b44832761 100644
--- a/source/EngineGpuKernels/Operations.cuh
+++ b/source/EngineGpuKernels/Operations.cuh
@@ -59,3 +59,8 @@ struct SensorOperation
{
Token* token;
};
+
+struct NeuralNetOperation
+{
+ Token* token;
+};
diff --git a/source/EngineGpuKernels/SimulationData.cuh b/source/EngineGpuKernels/SimulationData.cuh
index ac65e6550..5b8a7254c 100644
--- a/source/EngineGpuKernels/SimulationData.cuh
+++ b/source/EngineGpuKernels/SimulationData.cuh
@@ -13,19 +13,25 @@
struct SimulationData
{
+ //maps
int2 worldSize;
-
CellMap cellMap;
ParticleMap particleMap;
- CellFunctionData cellFunctionData;
+ //objects
Entities entities;
Entities entitiesForCleanup;
+ //additional data for cell functions
RawMemory processMemory;
+ CellFunctionData cellFunctionData;
+
+ //scheduled operations
TempArray structuralOperations;
TempArray sensorOperations;
+ TempArray neuralNetOperations;
+ //number generators
CudaNumberGenerator numberGen1;
CudaNumberGenerator numberGen2; //second random number generator used in combination with the first generator for evaluating very low probabilities
From 02a14b12bc60c1c53dff3cc228de268d009809cb Mon Sep 17 00:00:00 2001
From: Christian Heinemann
Date: Sat, 8 Oct 2022 19:40:28 +0200
Subject: [PATCH 03/15] precision of mutation rate in gui widget increased +
settings of dark forest adapted
---
.../demos/Dark Forest.settings.json | 385 +++++++++++++-----
resources/autosave.settings.json | 385 +++++++++++++-----
source/Gui/SimulationParametersWindow.cpp | 8 +-
3 files changed, 590 insertions(+), 188 deletions(-)
diff --git a/examples/simulations/demos/Dark Forest.settings.json b/examples/simulations/demos/Dark Forest.settings.json
index 0814b16cb..b658400b6 100644
--- a/examples/simulations/demos/Dark Forest.settings.json
+++ b/examples/simulations/demos/Dark Forest.settings.json
@@ -1,156 +1,357 @@
{
"general": {
- "time step": "15574",
+ "time step": "0",
"world size": {
"x": "2500",
"y": "1500"
}
},
"simulation parameters": {
- "time step size": "1.000000",
- "friction": "0.001000",
- "rigidity": "0.000000",
+ "time step size": "1.00000000",
+ "friction": "0.00100000",
+ "rigidity": "0.00000000",
"cell": {
- "binding force": "1.000000",
- "max velocity": "2.000000",
- "max binding distance": "2.600000",
- "repulsion strength": "0.080000",
- "mutation rate": "0.000000",
- "min distance": "0.200000",
- "max distance": "1.300000",
- "max force": "0.367000",
- "max force decay probability": "0.200000",
+ "binding force": "1.00000000",
+ "max velocity": "2.00000000",
+ "max binding distance": "2.59999990",
+ "repulsion strength": "0.08000000",
+ "mutation rate": "0.00000040",
+ "min distance": "0.20000000",
+ "max distance": "1.29999995",
+ "max force": "0.36700001",
+ "max force decay probability": "0.20000000",
"max bonds": "6",
"max token": "3",
"max token branch number": "6",
- "min energy": "50.000000",
- "transformation probability": "0.200000",
- "fusion velocity": "0.206000",
- "max binding energy": "500000.000000",
+ "min energy": "50.00000000",
+ "transformation probability": "0.20000000",
+ "fusion velocity": "0.20600000",
+ "max binding energy": "500000.00000000",
+ "color transition rules": {
+ "duration[0]": "0",
+ "target color[0]": "0",
+ "duration[1]": "0",
+ "target color[1]": "1",
+ "duration[2]": "0",
+ "target color[2]": "2",
+ "duration[3]": "0",
+ "target color[3]": "3",
+ "duration[4]": "0",
+ "target color[4]": "4",
+ "duration[5]": "0",
+ "target color[5]": "5",
+ "duration[6]": "0",
+ "target color[6]": "6"
+ },
"function": {
"min invocations": "40000",
- "invocations decay probability": "0.000000",
+ "invocations decay probability": "0.00000000",
"computer": {
"max instructions": "15",
"memory size": "8"
},
"weapon": {
- "strength": "0.100000",
- "energy cost": "0.159000",
- "geometry deviation exponent": "0.000000",
- "target color mismatch penalty": "0.375000",
- "color penalty": "0.000000",
- "connections mismatch penalty": "0.330000",
- "token penalty": "0.000000"
+ "strength": "0.10000000",
+ "energy cost": "0.15899999",
+ "geometry deviation exponent": "0.00000000",
+ "target color mismatch penalty": "0.37500000",
+ "food chain color matrix[0, 0]": "1.00000000",
+ "food chain color matrix[0, 1]": "1.00000000",
+ "food chain color matrix[0, 2]": "1.00000000",
+ "food chain color matrix[0, 3]": "1.00000000",
+ "food chain color matrix[0, 4]": "1.00000000",
+ "food chain color matrix[0, 5]": "1.00000000",
+ "food chain color matrix[0, 6]": "1.00000000",
+ "food chain color matrix[1, 0]": "1.00000000",
+ "food chain color matrix[1, 1]": "1.00000000",
+ "food chain color matrix[1, 2]": "1.00000000",
+ "food chain color matrix[1, 3]": "1.00000000",
+ "food chain color matrix[1, 4]": "1.00000000",
+ "food chain color matrix[1, 5]": "1.00000000",
+ "food chain color matrix[1, 6]": "1.00000000",
+ "food chain color matrix[2, 0]": "1.00000000",
+ "food chain color matrix[2, 1]": "1.00000000",
+ "food chain color matrix[2, 2]": "1.00000000",
+ "food chain color matrix[2, 3]": "1.00000000",
+ "food chain color matrix[2, 4]": "1.00000000",
+ "food chain color matrix[2, 5]": "1.00000000",
+ "food chain color matrix[2, 6]": "1.00000000",
+ "food chain color matrix[3, 0]": "1.00000000",
+ "food chain color matrix[3, 1]": "1.00000000",
+ "food chain color matrix[3, 2]": "1.00000000",
+ "food chain color matrix[3, 3]": "1.00000000",
+ "food chain color matrix[3, 4]": "1.00000000",
+ "food chain color matrix[3, 5]": "1.00000000",
+ "food chain color matrix[3, 6]": "1.00000000",
+ "food chain color matrix[4, 0]": "1.00000000",
+ "food chain color matrix[4, 1]": "1.00000000",
+ "food chain color matrix[4, 2]": "1.00000000",
+ "food chain color matrix[4, 3]": "1.00000000",
+ "food chain color matrix[4, 4]": "1.00000000",
+ "food chain color matrix[4, 5]": "1.00000000",
+ "food chain color matrix[4, 6]": "1.00000000",
+ "food chain color matrix[5, 0]": "1.00000000",
+ "food chain color matrix[5, 1]": "1.00000000",
+ "food chain color matrix[5, 2]": "1.00000000",
+ "food chain color matrix[5, 3]": "1.00000000",
+ "food chain color matrix[5, 4]": "1.00000000",
+ "food chain color matrix[5, 5]": "1.00000000",
+ "food chain color matrix[5, 6]": "1.00000000",
+ "food chain color matrix[6, 0]": "1.00000000",
+ "food chain color matrix[6, 1]": "1.00000000",
+ "food chain color matrix[6, 2]": "1.00000000",
+ "food chain color matrix[6, 3]": "1.00000000",
+ "food chain color matrix[6, 4]": "1.00000000",
+ "food chain color matrix[6, 5]": "1.00000000",
+ "food chain color matrix[6, 6]": "1.00000000",
+ "connections mismatch penalty": "0.33000001",
+ "token penalty": "0.00000000"
},
"constructor": {
"offspring": {
- "cell energy": "100.000000",
- "cell distance": "1.600000",
- "token energy": "60.000000",
- "token suppress memory copy": "0.002000"
+ "cell energy": "100.00000000",
+ "cell distance": "1.60000002",
+ "token energy": "60.00000000",
+ "token suppress memory copy": "0.00200000",
+ "inherit color": "false"
}
},
"sensor": {
- "range": "220.000000"
+ "range": "220.00000000"
},
"communicator": {
- "range": "250.000000"
+ "range": "250.00000000"
}
}
},
"token": {
- "mutation rate": "0.000000",
+ "mutation rate": "0.00004200",
"memory size": "256",
- "min energy": "3.000000"
+ "min energy": "3.00000000"
},
"radiation": {
- "exponent": "1.000000",
- "factor": "0.000050",
- "probability": "0.030000",
- "velocity multiplier": "1.000000",
- "velocity perturbation": "0.500000"
+ "exponent": "1.00000000",
+ "factor": "0.00005000",
+ "probability": "0.03000000",
+ "velocity multiplier": "1.00000000",
+ "velocity perturbation": "0.50000000"
},
"spots": {
"num spots": "0",
"0": {
"color": "0",
"pos": {
- "x": "0.000000",
- "y": "0.000000"
+ "x": "0.00000000",
+ "y": "0.00000000"
},
"shape": "circular",
- "core width": "100.000000",
- "core height": "200.000000",
- "core radius": "100.000000",
- "fadeout radius": "100.000000",
- "friction": "0.001000",
- "rigidity": "0.000000",
+ "core width": "100.00000000",
+ "core height": "200.00000000",
+ "core radius": "100.00000000",
+ "fadeout radius": "100.00000000",
+ "friction": "0.00100000",
+ "rigidity": "0.00000000",
"radiation": {
- "factor": "0.000200"
+ "factor": "0.00020000"
},
"cell": {
- "max force": "0.800000",
- "min energy": "50.000000",
- "binding force": "1.000000",
- "fusion velocity": "0.400000",
- "max binding energy": "500000.000000",
- "mutation rate": "0.000000",
+ "max force": "0.80000001",
+ "min energy": "50.00000000",
+ "binding force": "1.00000000",
+ "fusion velocity": "0.40000001",
+ "max binding energy": "500000.00000000",
+ "mutation rate": "0.00000000",
+ "color transition rules": {
+ "duration[0]": "0",
+ "target color[0]": "0",
+ "duration[1]": "0",
+ "target color[1]": "1",
+ "duration[2]": "0",
+ "target color[2]": "2",
+ "duration[3]": "0",
+ "target color[3]": "3",
+ "duration[4]": "0",
+ "target color[4]": "4",
+ "duration[5]": "0",
+ "target color[5]": "5",
+ "duration[6]": "0",
+ "target color[6]": "6"
+ },
"function": {
"min invocations": "40000",
- "invocations decay probability": "0.000000",
+ "invocations decay probability": "0.00000000",
"weapon": {
- "energy cost": "0.200000",
- "target color mismatch penalty": "0.000000",
- "color penalty": "0.000000",
- "geometry deviation exponent": "0.000000",
- "connections mismatch penalty": "0.330000",
- "token penalty": "0.000000"
+ "energy cost": "0.20000000",
+ "target color mismatch penalty": "0.00000000",
+ "geometry deviation exponent": "0.00000000",
+ "connections mismatch penalty": "0.33000001",
+ "token penalty": "0.00000000"
}
}
},
"token": {
- "mutation rate": "0.000000"
+ "mutation rate": "0.00000000"
+ },
+ "function": {
+ "weapon": {
+ "color matrix[0, 0]": "1.00000000",
+ "color matrix[0, 1]": "1.00000000",
+ "color matrix[0, 2]": "1.00000000",
+ "color matrix[0, 3]": "1.00000000",
+ "color matrix[0, 4]": "1.00000000",
+ "color matrix[0, 5]": "1.00000000",
+ "color matrix[0, 6]": "1.00000000",
+ "color matrix[1, 0]": "1.00000000",
+ "color matrix[1, 1]": "1.00000000",
+ "color matrix[1, 2]": "1.00000000",
+ "color matrix[1, 3]": "1.00000000",
+ "color matrix[1, 4]": "1.00000000",
+ "color matrix[1, 5]": "1.00000000",
+ "color matrix[1, 6]": "1.00000000",
+ "color matrix[2, 0]": "1.00000000",
+ "color matrix[2, 1]": "1.00000000",
+ "color matrix[2, 2]": "1.00000000",
+ "color matrix[2, 3]": "1.00000000",
+ "color matrix[2, 4]": "1.00000000",
+ "color matrix[2, 5]": "1.00000000",
+ "color matrix[2, 6]": "1.00000000",
+ "color matrix[3, 0]": "1.00000000",
+ "color matrix[3, 1]": "1.00000000",
+ "color matrix[3, 2]": "1.00000000",
+ "color matrix[3, 3]": "1.00000000",
+ "color matrix[3, 4]": "1.00000000",
+ "color matrix[3, 5]": "1.00000000",
+ "color matrix[3, 6]": "1.00000000",
+ "color matrix[4, 0]": "1.00000000",
+ "color matrix[4, 1]": "1.00000000",
+ "color matrix[4, 2]": "1.00000000",
+ "color matrix[4, 3]": "1.00000000",
+ "color matrix[4, 4]": "1.00000000",
+ "color matrix[4, 5]": "1.00000000",
+ "color matrix[4, 6]": "1.00000000",
+ "color matrix[5, 0]": "1.00000000",
+ "color matrix[5, 1]": "1.00000000",
+ "color matrix[5, 2]": "1.00000000",
+ "color matrix[5, 3]": "1.00000000",
+ "color matrix[5, 4]": "1.00000000",
+ "color matrix[5, 5]": "1.00000000",
+ "color matrix[5, 6]": "1.00000000",
+ "color matrix[6, 0]": "1.00000000",
+ "color matrix[6, 1]": "1.00000000",
+ "color matrix[6, 2]": "1.00000000",
+ "color matrix[6, 3]": "1.00000000",
+ "color matrix[6, 4]": "1.00000000",
+ "color matrix[6, 5]": "1.00000000",
+ "color matrix[6, 6]": "1.00000000"
+ }
}
},
"1": {
"color": "0",
"pos": {
- "x": "0.000000",
- "y": "0.000000"
+ "x": "0.00000000",
+ "y": "0.00000000"
},
"shape": "circular",
- "core width": "100.000000",
- "core height": "200.000000",
- "core radius": "100.000000",
- "fadeout radius": "100.000000",
- "friction": "0.001000",
- "rigidity": "0.000000",
+ "core width": "100.00000000",
+ "core height": "200.00000000",
+ "core radius": "100.00000000",
+ "fadeout radius": "100.00000000",
+ "friction": "0.00100000",
+ "rigidity": "0.00000000",
"radiation": {
- "factor": "0.000200"
+ "factor": "0.00020000"
},
"cell": {
- "max force": "0.800000",
- "min energy": "50.000000",
- "binding force": "1.000000",
- "fusion velocity": "0.400000",
- "max binding energy": "500000.000000",
- "mutation rate": "0.000000",
+ "max force": "0.80000001",
+ "min energy": "50.00000000",
+ "binding force": "1.00000000",
+ "fusion velocity": "0.40000001",
+ "max binding energy": "500000.00000000",
+ "mutation rate": "0.00000000",
+ "color transition rules": {
+ "duration[0]": "0",
+ "target color[0]": "0",
+ "duration[1]": "0",
+ "target color[1]": "1",
+ "duration[2]": "0",
+ "target color[2]": "2",
+ "duration[3]": "0",
+ "target color[3]": "3",
+ "duration[4]": "0",
+ "target color[4]": "4",
+ "duration[5]": "0",
+ "target color[5]": "5",
+ "duration[6]": "0",
+ "target color[6]": "6"
+ },
"function": {
"min invocations": "40000",
- "invocations decay probability": "0.000000",
+ "invocations decay probability": "0.00000000",
"weapon": {
- "energy cost": "0.200000",
- "target color mismatch penalty": "0.000000",
- "color penalty": "0.000000",
- "geometry deviation exponent": "0.000000",
- "connections mismatch penalty": "0.330000",
- "token penalty": "0.000000"
+ "energy cost": "0.20000000",
+ "target color mismatch penalty": "0.00000000",
+ "geometry deviation exponent": "0.00000000",
+ "connections mismatch penalty": "0.33000001",
+ "token penalty": "0.00000000"
}
}
},
"token": {
- "mutation rate": "0.000000"
+ "mutation rate": "0.00000000"
+ },
+ "function": {
+ "weapon": {
+ "color matrix[0, 0]": "1.00000000",
+ "color matrix[0, 1]": "1.00000000",
+ "color matrix[0, 2]": "1.00000000",
+ "color matrix[0, 3]": "1.00000000",
+ "color matrix[0, 4]": "1.00000000",
+ "color matrix[0, 5]": "1.00000000",
+ "color matrix[0, 6]": "1.00000000",
+ "color matrix[1, 0]": "1.00000000",
+ "color matrix[1, 1]": "1.00000000",
+ "color matrix[1, 2]": "1.00000000",
+ "color matrix[1, 3]": "1.00000000",
+ "color matrix[1, 4]": "1.00000000",
+ "color matrix[1, 5]": "1.00000000",
+ "color matrix[1, 6]": "1.00000000",
+ "color matrix[2, 0]": "1.00000000",
+ "color matrix[2, 1]": "1.00000000",
+ "color matrix[2, 2]": "1.00000000",
+ "color matrix[2, 3]": "1.00000000",
+ "color matrix[2, 4]": "1.00000000",
+ "color matrix[2, 5]": "1.00000000",
+ "color matrix[2, 6]": "1.00000000",
+ "color matrix[3, 0]": "1.00000000",
+ "color matrix[3, 1]": "1.00000000",
+ "color matrix[3, 2]": "1.00000000",
+ "color matrix[3, 3]": "1.00000000",
+ "color matrix[3, 4]": "1.00000000",
+ "color matrix[3, 5]": "1.00000000",
+ "color matrix[3, 6]": "1.00000000",
+ "color matrix[4, 0]": "1.00000000",
+ "color matrix[4, 1]": "1.00000000",
+ "color matrix[4, 2]": "1.00000000",
+ "color matrix[4, 3]": "1.00000000",
+ "color matrix[4, 4]": "1.00000000",
+ "color matrix[4, 5]": "1.00000000",
+ "color matrix[4, 6]": "1.00000000",
+ "color matrix[5, 0]": "1.00000000",
+ "color matrix[5, 1]": "1.00000000",
+ "color matrix[5, 2]": "1.00000000",
+ "color matrix[5, 3]": "1.00000000",
+ "color matrix[5, 4]": "1.00000000",
+ "color matrix[5, 5]": "1.00000000",
+ "color matrix[5, 6]": "1.00000000",
+ "color matrix[6, 0]": "1.00000000",
+ "color matrix[6, 1]": "1.00000000",
+ "color matrix[6, 2]": "1.00000000",
+ "color matrix[6, 3]": "1.00000000",
+ "color matrix[6, 4]": "1.00000000",
+ "color matrix[6, 5]": "1.00000000",
+ "color matrix[6, 6]": "1.00000000"
+ }
}
}
}
@@ -160,19 +361,19 @@
"num centers": "1",
"center0": {
"pos": {
- "x": "700.000000",
- "y": "500.000000"
+ "x": "700.00000000",
+ "y": "500.00000000"
},
- "radius": "200.000000",
- "strength": "0.010000"
+ "radius": "200.00000000",
+ "strength": "0.01000000"
},
"center1": {
"pos": {
- "x": "0.000000",
- "y": "0.000000"
+ "x": "0.00000000",
+ "y": "0.00000000"
},
- "radius": "200.000000",
- "strength": "0.010000"
+ "radius": "200.00000000",
+ "strength": "0.01000000"
}
}
}
diff --git a/resources/autosave.settings.json b/resources/autosave.settings.json
index 0814b16cb..b658400b6 100644
--- a/resources/autosave.settings.json
+++ b/resources/autosave.settings.json
@@ -1,156 +1,357 @@
{
"general": {
- "time step": "15574",
+ "time step": "0",
"world size": {
"x": "2500",
"y": "1500"
}
},
"simulation parameters": {
- "time step size": "1.000000",
- "friction": "0.001000",
- "rigidity": "0.000000",
+ "time step size": "1.00000000",
+ "friction": "0.00100000",
+ "rigidity": "0.00000000",
"cell": {
- "binding force": "1.000000",
- "max velocity": "2.000000",
- "max binding distance": "2.600000",
- "repulsion strength": "0.080000",
- "mutation rate": "0.000000",
- "min distance": "0.200000",
- "max distance": "1.300000",
- "max force": "0.367000",
- "max force decay probability": "0.200000",
+ "binding force": "1.00000000",
+ "max velocity": "2.00000000",
+ "max binding distance": "2.59999990",
+ "repulsion strength": "0.08000000",
+ "mutation rate": "0.00000040",
+ "min distance": "0.20000000",
+ "max distance": "1.29999995",
+ "max force": "0.36700001",
+ "max force decay probability": "0.20000000",
"max bonds": "6",
"max token": "3",
"max token branch number": "6",
- "min energy": "50.000000",
- "transformation probability": "0.200000",
- "fusion velocity": "0.206000",
- "max binding energy": "500000.000000",
+ "min energy": "50.00000000",
+ "transformation probability": "0.20000000",
+ "fusion velocity": "0.20600000",
+ "max binding energy": "500000.00000000",
+ "color transition rules": {
+ "duration[0]": "0",
+ "target color[0]": "0",
+ "duration[1]": "0",
+ "target color[1]": "1",
+ "duration[2]": "0",
+ "target color[2]": "2",
+ "duration[3]": "0",
+ "target color[3]": "3",
+ "duration[4]": "0",
+ "target color[4]": "4",
+ "duration[5]": "0",
+ "target color[5]": "5",
+ "duration[6]": "0",
+ "target color[6]": "6"
+ },
"function": {
"min invocations": "40000",
- "invocations decay probability": "0.000000",
+ "invocations decay probability": "0.00000000",
"computer": {
"max instructions": "15",
"memory size": "8"
},
"weapon": {
- "strength": "0.100000",
- "energy cost": "0.159000",
- "geometry deviation exponent": "0.000000",
- "target color mismatch penalty": "0.375000",
- "color penalty": "0.000000",
- "connections mismatch penalty": "0.330000",
- "token penalty": "0.000000"
+ "strength": "0.10000000",
+ "energy cost": "0.15899999",
+ "geometry deviation exponent": "0.00000000",
+ "target color mismatch penalty": "0.37500000",
+ "food chain color matrix[0, 0]": "1.00000000",
+ "food chain color matrix[0, 1]": "1.00000000",
+ "food chain color matrix[0, 2]": "1.00000000",
+ "food chain color matrix[0, 3]": "1.00000000",
+ "food chain color matrix[0, 4]": "1.00000000",
+ "food chain color matrix[0, 5]": "1.00000000",
+ "food chain color matrix[0, 6]": "1.00000000",
+ "food chain color matrix[1, 0]": "1.00000000",
+ "food chain color matrix[1, 1]": "1.00000000",
+ "food chain color matrix[1, 2]": "1.00000000",
+ "food chain color matrix[1, 3]": "1.00000000",
+ "food chain color matrix[1, 4]": "1.00000000",
+ "food chain color matrix[1, 5]": "1.00000000",
+ "food chain color matrix[1, 6]": "1.00000000",
+ "food chain color matrix[2, 0]": "1.00000000",
+ "food chain color matrix[2, 1]": "1.00000000",
+ "food chain color matrix[2, 2]": "1.00000000",
+ "food chain color matrix[2, 3]": "1.00000000",
+ "food chain color matrix[2, 4]": "1.00000000",
+ "food chain color matrix[2, 5]": "1.00000000",
+ "food chain color matrix[2, 6]": "1.00000000",
+ "food chain color matrix[3, 0]": "1.00000000",
+ "food chain color matrix[3, 1]": "1.00000000",
+ "food chain color matrix[3, 2]": "1.00000000",
+ "food chain color matrix[3, 3]": "1.00000000",
+ "food chain color matrix[3, 4]": "1.00000000",
+ "food chain color matrix[3, 5]": "1.00000000",
+ "food chain color matrix[3, 6]": "1.00000000",
+ "food chain color matrix[4, 0]": "1.00000000",
+ "food chain color matrix[4, 1]": "1.00000000",
+ "food chain color matrix[4, 2]": "1.00000000",
+ "food chain color matrix[4, 3]": "1.00000000",
+ "food chain color matrix[4, 4]": "1.00000000",
+ "food chain color matrix[4, 5]": "1.00000000",
+ "food chain color matrix[4, 6]": "1.00000000",
+ "food chain color matrix[5, 0]": "1.00000000",
+ "food chain color matrix[5, 1]": "1.00000000",
+ "food chain color matrix[5, 2]": "1.00000000",
+ "food chain color matrix[5, 3]": "1.00000000",
+ "food chain color matrix[5, 4]": "1.00000000",
+ "food chain color matrix[5, 5]": "1.00000000",
+ "food chain color matrix[5, 6]": "1.00000000",
+ "food chain color matrix[6, 0]": "1.00000000",
+ "food chain color matrix[6, 1]": "1.00000000",
+ "food chain color matrix[6, 2]": "1.00000000",
+ "food chain color matrix[6, 3]": "1.00000000",
+ "food chain color matrix[6, 4]": "1.00000000",
+ "food chain color matrix[6, 5]": "1.00000000",
+ "food chain color matrix[6, 6]": "1.00000000",
+ "connections mismatch penalty": "0.33000001",
+ "token penalty": "0.00000000"
},
"constructor": {
"offspring": {
- "cell energy": "100.000000",
- "cell distance": "1.600000",
- "token energy": "60.000000",
- "token suppress memory copy": "0.002000"
+ "cell energy": "100.00000000",
+ "cell distance": "1.60000002",
+ "token energy": "60.00000000",
+ "token suppress memory copy": "0.00200000",
+ "inherit color": "false"
}
},
"sensor": {
- "range": "220.000000"
+ "range": "220.00000000"
},
"communicator": {
- "range": "250.000000"
+ "range": "250.00000000"
}
}
},
"token": {
- "mutation rate": "0.000000",
+ "mutation rate": "0.00004200",
"memory size": "256",
- "min energy": "3.000000"
+ "min energy": "3.00000000"
},
"radiation": {
- "exponent": "1.000000",
- "factor": "0.000050",
- "probability": "0.030000",
- "velocity multiplier": "1.000000",
- "velocity perturbation": "0.500000"
+ "exponent": "1.00000000",
+ "factor": "0.00005000",
+ "probability": "0.03000000",
+ "velocity multiplier": "1.00000000",
+ "velocity perturbation": "0.50000000"
},
"spots": {
"num spots": "0",
"0": {
"color": "0",
"pos": {
- "x": "0.000000",
- "y": "0.000000"
+ "x": "0.00000000",
+ "y": "0.00000000"
},
"shape": "circular",
- "core width": "100.000000",
- "core height": "200.000000",
- "core radius": "100.000000",
- "fadeout radius": "100.000000",
- "friction": "0.001000",
- "rigidity": "0.000000",
+ "core width": "100.00000000",
+ "core height": "200.00000000",
+ "core radius": "100.00000000",
+ "fadeout radius": "100.00000000",
+ "friction": "0.00100000",
+ "rigidity": "0.00000000",
"radiation": {
- "factor": "0.000200"
+ "factor": "0.00020000"
},
"cell": {
- "max force": "0.800000",
- "min energy": "50.000000",
- "binding force": "1.000000",
- "fusion velocity": "0.400000",
- "max binding energy": "500000.000000",
- "mutation rate": "0.000000",
+ "max force": "0.80000001",
+ "min energy": "50.00000000",
+ "binding force": "1.00000000",
+ "fusion velocity": "0.40000001",
+ "max binding energy": "500000.00000000",
+ "mutation rate": "0.00000000",
+ "color transition rules": {
+ "duration[0]": "0",
+ "target color[0]": "0",
+ "duration[1]": "0",
+ "target color[1]": "1",
+ "duration[2]": "0",
+ "target color[2]": "2",
+ "duration[3]": "0",
+ "target color[3]": "3",
+ "duration[4]": "0",
+ "target color[4]": "4",
+ "duration[5]": "0",
+ "target color[5]": "5",
+ "duration[6]": "0",
+ "target color[6]": "6"
+ },
"function": {
"min invocations": "40000",
- "invocations decay probability": "0.000000",
+ "invocations decay probability": "0.00000000",
"weapon": {
- "energy cost": "0.200000",
- "target color mismatch penalty": "0.000000",
- "color penalty": "0.000000",
- "geometry deviation exponent": "0.000000",
- "connections mismatch penalty": "0.330000",
- "token penalty": "0.000000"
+ "energy cost": "0.20000000",
+ "target color mismatch penalty": "0.00000000",
+ "geometry deviation exponent": "0.00000000",
+ "connections mismatch penalty": "0.33000001",
+ "token penalty": "0.00000000"
}
}
},
"token": {
- "mutation rate": "0.000000"
+ "mutation rate": "0.00000000"
+ },
+ "function": {
+ "weapon": {
+ "color matrix[0, 0]": "1.00000000",
+ "color matrix[0, 1]": "1.00000000",
+ "color matrix[0, 2]": "1.00000000",
+ "color matrix[0, 3]": "1.00000000",
+ "color matrix[0, 4]": "1.00000000",
+ "color matrix[0, 5]": "1.00000000",
+ "color matrix[0, 6]": "1.00000000",
+ "color matrix[1, 0]": "1.00000000",
+ "color matrix[1, 1]": "1.00000000",
+ "color matrix[1, 2]": "1.00000000",
+ "color matrix[1, 3]": "1.00000000",
+ "color matrix[1, 4]": "1.00000000",
+ "color matrix[1, 5]": "1.00000000",
+ "color matrix[1, 6]": "1.00000000",
+ "color matrix[2, 0]": "1.00000000",
+ "color matrix[2, 1]": "1.00000000",
+ "color matrix[2, 2]": "1.00000000",
+ "color matrix[2, 3]": "1.00000000",
+ "color matrix[2, 4]": "1.00000000",
+ "color matrix[2, 5]": "1.00000000",
+ "color matrix[2, 6]": "1.00000000",
+ "color matrix[3, 0]": "1.00000000",
+ "color matrix[3, 1]": "1.00000000",
+ "color matrix[3, 2]": "1.00000000",
+ "color matrix[3, 3]": "1.00000000",
+ "color matrix[3, 4]": "1.00000000",
+ "color matrix[3, 5]": "1.00000000",
+ "color matrix[3, 6]": "1.00000000",
+ "color matrix[4, 0]": "1.00000000",
+ "color matrix[4, 1]": "1.00000000",
+ "color matrix[4, 2]": "1.00000000",
+ "color matrix[4, 3]": "1.00000000",
+ "color matrix[4, 4]": "1.00000000",
+ "color matrix[4, 5]": "1.00000000",
+ "color matrix[4, 6]": "1.00000000",
+ "color matrix[5, 0]": "1.00000000",
+ "color matrix[5, 1]": "1.00000000",
+ "color matrix[5, 2]": "1.00000000",
+ "color matrix[5, 3]": "1.00000000",
+ "color matrix[5, 4]": "1.00000000",
+ "color matrix[5, 5]": "1.00000000",
+ "color matrix[5, 6]": "1.00000000",
+ "color matrix[6, 0]": "1.00000000",
+ "color matrix[6, 1]": "1.00000000",
+ "color matrix[6, 2]": "1.00000000",
+ "color matrix[6, 3]": "1.00000000",
+ "color matrix[6, 4]": "1.00000000",
+ "color matrix[6, 5]": "1.00000000",
+ "color matrix[6, 6]": "1.00000000"
+ }
}
},
"1": {
"color": "0",
"pos": {
- "x": "0.000000",
- "y": "0.000000"
+ "x": "0.00000000",
+ "y": "0.00000000"
},
"shape": "circular",
- "core width": "100.000000",
- "core height": "200.000000",
- "core radius": "100.000000",
- "fadeout radius": "100.000000",
- "friction": "0.001000",
- "rigidity": "0.000000",
+ "core width": "100.00000000",
+ "core height": "200.00000000",
+ "core radius": "100.00000000",
+ "fadeout radius": "100.00000000",
+ "friction": "0.00100000",
+ "rigidity": "0.00000000",
"radiation": {
- "factor": "0.000200"
+ "factor": "0.00020000"
},
"cell": {
- "max force": "0.800000",
- "min energy": "50.000000",
- "binding force": "1.000000",
- "fusion velocity": "0.400000",
- "max binding energy": "500000.000000",
- "mutation rate": "0.000000",
+ "max force": "0.80000001",
+ "min energy": "50.00000000",
+ "binding force": "1.00000000",
+ "fusion velocity": "0.40000001",
+ "max binding energy": "500000.00000000",
+ "mutation rate": "0.00000000",
+ "color transition rules": {
+ "duration[0]": "0",
+ "target color[0]": "0",
+ "duration[1]": "0",
+ "target color[1]": "1",
+ "duration[2]": "0",
+ "target color[2]": "2",
+ "duration[3]": "0",
+ "target color[3]": "3",
+ "duration[4]": "0",
+ "target color[4]": "4",
+ "duration[5]": "0",
+ "target color[5]": "5",
+ "duration[6]": "0",
+ "target color[6]": "6"
+ },
"function": {
"min invocations": "40000",
- "invocations decay probability": "0.000000",
+ "invocations decay probability": "0.00000000",
"weapon": {
- "energy cost": "0.200000",
- "target color mismatch penalty": "0.000000",
- "color penalty": "0.000000",
- "geometry deviation exponent": "0.000000",
- "connections mismatch penalty": "0.330000",
- "token penalty": "0.000000"
+ "energy cost": "0.20000000",
+ "target color mismatch penalty": "0.00000000",
+ "geometry deviation exponent": "0.00000000",
+ "connections mismatch penalty": "0.33000001",
+ "token penalty": "0.00000000"
}
}
},
"token": {
- "mutation rate": "0.000000"
+ "mutation rate": "0.00000000"
+ },
+ "function": {
+ "weapon": {
+ "color matrix[0, 0]": "1.00000000",
+ "color matrix[0, 1]": "1.00000000",
+ "color matrix[0, 2]": "1.00000000",
+ "color matrix[0, 3]": "1.00000000",
+ "color matrix[0, 4]": "1.00000000",
+ "color matrix[0, 5]": "1.00000000",
+ "color matrix[0, 6]": "1.00000000",
+ "color matrix[1, 0]": "1.00000000",
+ "color matrix[1, 1]": "1.00000000",
+ "color matrix[1, 2]": "1.00000000",
+ "color matrix[1, 3]": "1.00000000",
+ "color matrix[1, 4]": "1.00000000",
+ "color matrix[1, 5]": "1.00000000",
+ "color matrix[1, 6]": "1.00000000",
+ "color matrix[2, 0]": "1.00000000",
+ "color matrix[2, 1]": "1.00000000",
+ "color matrix[2, 2]": "1.00000000",
+ "color matrix[2, 3]": "1.00000000",
+ "color matrix[2, 4]": "1.00000000",
+ "color matrix[2, 5]": "1.00000000",
+ "color matrix[2, 6]": "1.00000000",
+ "color matrix[3, 0]": "1.00000000",
+ "color matrix[3, 1]": "1.00000000",
+ "color matrix[3, 2]": "1.00000000",
+ "color matrix[3, 3]": "1.00000000",
+ "color matrix[3, 4]": "1.00000000",
+ "color matrix[3, 5]": "1.00000000",
+ "color matrix[3, 6]": "1.00000000",
+ "color matrix[4, 0]": "1.00000000",
+ "color matrix[4, 1]": "1.00000000",
+ "color matrix[4, 2]": "1.00000000",
+ "color matrix[4, 3]": "1.00000000",
+ "color matrix[4, 4]": "1.00000000",
+ "color matrix[4, 5]": "1.00000000",
+ "color matrix[4, 6]": "1.00000000",
+ "color matrix[5, 0]": "1.00000000",
+ "color matrix[5, 1]": "1.00000000",
+ "color matrix[5, 2]": "1.00000000",
+ "color matrix[5, 3]": "1.00000000",
+ "color matrix[5, 4]": "1.00000000",
+ "color matrix[5, 5]": "1.00000000",
+ "color matrix[5, 6]": "1.00000000",
+ "color matrix[6, 0]": "1.00000000",
+ "color matrix[6, 1]": "1.00000000",
+ "color matrix[6, 2]": "1.00000000",
+ "color matrix[6, 3]": "1.00000000",
+ "color matrix[6, 4]": "1.00000000",
+ "color matrix[6, 5]": "1.00000000",
+ "color matrix[6, 6]": "1.00000000"
+ }
}
}
}
@@ -160,19 +361,19 @@
"num centers": "1",
"center0": {
"pos": {
- "x": "700.000000",
- "y": "500.000000"
+ "x": "700.00000000",
+ "y": "500.00000000"
},
- "radius": "200.000000",
- "strength": "0.010000"
+ "radius": "200.00000000",
+ "strength": "0.01000000"
},
"center1": {
"pos": {
- "x": "0.000000",
- "y": "0.000000"
+ "x": "0.00000000",
+ "y": "0.00000000"
},
- "radius": "200.000000",
- "strength": "0.010000"
+ "radius": "200.00000000",
+ "strength": "0.01000000"
}
}
}
diff --git a/source/Gui/SimulationParametersWindow.cpp b/source/Gui/SimulationParametersWindow.cpp
index fad2dee4a..4f2c1d0a1 100644
--- a/source/Gui/SimulationParametersWindow.cpp
+++ b/source/Gui/SimulationParametersWindow.cpp
@@ -357,7 +357,7 @@ void _SimulationParametersWindow::processBase(
.min(0)
.max(0.001f)
.logarithmic(true)
- .format("%.7f")
+ .format("%.8f")
.defaultValue(origSimParameters.spotValues.cellMutationRate)
.tooltip(std::string("Probability that a byte or property of a cell is changed per time step.")),
simParameters.spotValues.cellMutationRate);
@@ -368,7 +368,7 @@ void _SimulationParametersWindow::processBase(
.min(0)
.max(0.1f)
.logarithmic(true)
- .format("%.5f")
+ .format("%.6f")
.defaultValue(origSimParameters.spotValues.tokenMutationRate)
.tooltip(std::string("Probability that a memory byte of a token is changed per time step.")),
simParameters.spotValues.tokenMutationRate);
@@ -701,7 +701,7 @@ void _SimulationParametersWindow::processSpot(SimulationParametersSpot& spot, Si
.min(0)
.max(0.001f)
.logarithmic(true)
- .format("%.7f")
+ .format("%.8f")
.defaultValue(origSpot.values.cellMutationRate),
spot.values.cellMutationRate);
AlienImGui::SliderFloat(
@@ -711,7 +711,7 @@ void _SimulationParametersWindow::processSpot(SimulationParametersSpot& spot, Si
.min(0)
.max(0.1f)
.logarithmic(true)
- .format("%.5f")
+ .format("%.6f")
.defaultValue(origSpot.values.tokenMutationRate),
spot.values.tokenMutationRate);
From d72a869049987cbfda15d305b809c37981605964 Mon Sep 17 00:00:00 2001
From: Christian Heinemann
Date: Sat, 29 Oct 2022 22:52:48 +0200
Subject: [PATCH 04/15] Update README.md
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index 4c602e5a2..868d49305 100644
--- a/README.md
+++ b/README.md
@@ -94,6 +94,8 @@ Contributions to the project are very welcome. The most convenient way is to com
A short architectural overview of the source code can be found in the [documentation](https://alien-project.gitbook.io/docs/under-the-hood).
+**IMPORTANT:** The current development is taking place on the branch `version4`.
+
# Dependency list
- [CUDA Toolkit](https://developer.nvidia.com/cuda-toolkit)
- [Dear ImGui](https://github.com/ocornut/imgui)
From ecd0c4e0466add82a3cad0b61463b18a1242dc6b Mon Sep 17 00:00:00 2001
From: Christian Heinemann
Date: Mon, 14 Nov 2022 19:01:17 +0100
Subject: [PATCH 05/15] Update README.md
---
README.md | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 868d49305..782e0d71e 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,9 @@ The development is driven by the desire to better understand the conditions for
An important goal is to make the simulator user-friendly through a modern user interface, visually appealing rendering and a playful approach.
+**IMPORTANT:** The current development is taking place on the branch `version4`.
+
+
# Main features
### Physics and graphics engine
- Particles for simulating soft body mechanics, heat dissipation, bondings, damages, phase transitions, etc.
@@ -94,8 +97,6 @@ Contributions to the project are very welcome. The most convenient way is to com
A short architectural overview of the source code can be found in the [documentation](https://alien-project.gitbook.io/docs/under-the-hood).
-**IMPORTANT:** The current development is taking place on the branch `version4`.
-
# Dependency list
- [CUDA Toolkit](https://developer.nvidia.com/cuda-toolkit)
- [Dear ImGui](https://github.com/ocornut/imgui)
From 5262e32765cdc207bfcd94522bb773a4b4abd994 Mon Sep 17 00:00:00 2001
From: David Guerizec
Date: Mon, 2 Jan 2023 21:07:35 +0100
Subject: [PATCH 06/15] Added # comments in code, and symbols decompilation in
comments.
---
.../CellComputationCompiler.cpp | 147 +++++++++++++++---
source/EngineTests/CellComputationTests.cpp | 65 ++++++++
2 files changed, 188 insertions(+), 24 deletions(-)
diff --git a/source/EngineInterface/CellComputationCompiler.cpp b/source/EngineInterface/CellComputationCompiler.cpp
index f23677c33..9f5ee9fc3 100644
--- a/source/EngineInterface/CellComputationCompiler.cpp
+++ b/source/EngineInterface/CellComputationCompiler.cpp
@@ -18,7 +18,9 @@ namespace
LOOKING_FOR_SEPARATOR,
LOOKING_FOR_COMPARATOR,
LOOKING_FOR_OP2_START,
- LOOKING_FOR_OP2_END
+ LOOKING_FOR_OP2_END,
+ LOOKING_FOR_COMMENT,
+ LOOKING_FOR_COMMENT_END,
};
struct InstructionUncoded
@@ -62,12 +64,15 @@ namespace
if (std::isalpha(currentSymbol)) {
state = CompilerState::LOOKING_FOR_INSTR_END;
instruction.name = currentSymbol;
+ } else if (currentSymbol == '#') {
+ instruction.name = currentSymbol;
+ state = CompilerState::LOOKING_FOR_COMMENT_END;
}
} break;
case CompilerState::LOOKING_FOR_INSTR_END: {
if (!std::isalpha(currentSymbol)) {
if (instruction.name == "else" || instruction.name == "endif")
- instruction.readingFinished = true;
+ state = CompilerState::LOOKING_FOR_COMMENT;
else
state = CompilerState::LOOKING_FOR_OP1_START;
} else {
@@ -133,13 +138,27 @@ namespace
case CompilerState::LOOKING_FOR_OP2_END: {
if (!isNameChar(currentSymbol) && (currentSymbol != '-') && (currentSymbol != '_') && (currentSymbol != '[')
&& (currentSymbol != ']') && (currentSymbol != '(') && (currentSymbol != ')'))
- instruction.readingFinished = true;
+ state = CompilerState::LOOKING_FOR_COMMENT;
else {
instruction.operand2 += currentSymbol;
if ((bytePos + 1) == codeSize)
instruction.readingFinished = true;
}
} break;
+ case CompilerState::LOOKING_FOR_COMMENT: {
+ if (currentSymbol == '\n' || (bytePos + 1) == codeSize)
+ instruction.readingFinished = true;
+ else if (currentSymbol == '#')
+ state = CompilerState::LOOKING_FOR_COMMENT_END;
+ else if (currentSymbol != ' ' && currentSymbol != '\t') {
+ instruction.readingFinished = true;
+ return false;
+ }
+ } break;
+ case CompilerState::LOOKING_FOR_COMMENT_END: {
+ if (currentSymbol == '\n' || (bytePos + 1) == codeSize)
+ instruction.readingFinished = true;
+ } break;
}
if ((currentSymbol == '\n') || ((bytePos + 1) == codeSize)) {
if (!instruction.name.empty()) {
@@ -221,7 +240,9 @@ namespace
instructionCoded.operation = Enums::ComputationOperation_Else;
else if (instructionUncoded.name == "endif")
instructionCoded.operation = Enums::ComputationOperation_Endif;
- else {
+ else if (instructionUncoded.name == "#") {
+ return true;
+ } else {
return false;
}
@@ -324,7 +345,8 @@ CompilationResult CellComputationCompiler::compileSourceCode(std::string const&
result.lineOfFirstError = linePos;
return result;
}
- writeInstruction(result.compilation, instructionCoded);
+ if(instructionUncoded.name != "#")
+ writeInstruction(result.compilation, instructionCoded);
state = CompilerState::LOOKING_FOR_INSTR_START;
instructionUncoded = InstructionUncoded();
}
@@ -347,6 +369,13 @@ namespace
stream << "0x" << std::hex << static_cast(value);
return stream.str();
}
+ template
+ std::string toDecString(T value)
+ {
+ std::stringstream stream;
+ stream << std::dec << static_cast(value);
+ return stream.str();
+ }
}
std::string CellComputationCompiler::decompileSourceCode(
@@ -354,8 +383,13 @@ std::string CellComputationCompiler::decompileSourceCode(
SymbolMap const& symbols,
SimulationParameters const& parameters)
{
+ SymbolMap revsymbols;
+ for (auto const& symbol : symbols) {
+ revsymbols[symbol.second] = symbol.first;
+ }
std::string text;
- std::string textOp1, textOp2;
+ std::string textOp1, textOp2, comment1, comment2;
+ size_t lineStart, opEnd;
int nestingLevel = 0;
auto dataSize = (data.size() / 3) * 3;
auto isNullInstruction = [&data](int address) {
@@ -369,7 +403,19 @@ std::string CellComputationCompiler::decompileSourceCode(
}
}
+ auto commentAlign = [&]() {
+ auto lineSize = text.size() - lineStart;
+ std::string spaces = " ";
+ spaces = spaces.substr(0, 8 - lineSize % 4);
+ return spaces;
+ };
+
+ auto getOp = [&]() {
+ return text.substr(lineStart, opEnd - lineStart + 1);
+ };
+
for (int instructionPointer = 0; instructionPointer < dataSize;) {
+ lineStart = text.size();
//decode instruction data
CellInstruction instruction;
@@ -414,42 +460,95 @@ std::string CellComputationCompiler::decompileSourceCode(
text += "endif";
}
+ opEnd = text.size();
+
//write operands
- if (instruction.opType1 == Enums::ComputationOpType_Mem)
+ if (instruction.opType1 == Enums::ComputationOpType_Mem) {
+ comment1 = "[" + toDecString(convertToAddress(instruction.operand1, parameters.tokenMemorySize)) + "]";
+ if (revsymbols.find(comment1) != revsymbols.end())
+ comment1 = revsymbols[comment1];
textOp1 = "[" + toHexString(convertToAddress(instruction.operand1, parameters.tokenMemorySize)) + "]";
- if (instruction.opType1 == Enums::ComputationOpType_MemMem)
+ }
+ if (instruction.opType1 == Enums::ComputationOpType_MemMem) {
+ comment1 = "[[" + toDecString(convertToAddress(instruction.operand1, parameters.tokenMemorySize)) + "]]";
+ if (revsymbols.find(comment1) != revsymbols.end())
+ comment1 = revsymbols[comment1];
textOp1 = "[[" + toHexString(convertToAddress(instruction.operand1, parameters.tokenMemorySize)) + "]]";
- if (instruction.opType1 == Enums::ComputationOpType_Cmem)
+ }
+ if (instruction.opType1 == Enums::ComputationOpType_Cmem) {
+ comment1 = "("
+ + toDecString(convertToAddress(instruction.operand1, parameters.cellFunctionComputerCellMemorySize))
+ + ")";
+ if (revsymbols.find(comment1) != revsymbols.end())
+ comment1 = revsymbols[comment1];
textOp1 = "("
- + toHexString(convertToAddress(instruction.operand1, parameters.cellFunctionComputerCellMemorySize))
- + ")";
- if (instruction.opType2 == Enums::ComputationOpType_Mem)
+ + toHexString(convertToAddress(instruction.operand1, parameters.cellFunctionComputerCellMemorySize))
+ + ")";
+ }
+ if (instruction.opType2 == Enums::ComputationOpType_Mem) {
+ comment2 = "[" + toDecString(convertToAddress(instruction.operand2, parameters.tokenMemorySize)) + "]";
+ if (revsymbols.find(comment2) != revsymbols.end())
+ comment2 = revsymbols[comment2];
textOp2 = "[" + toHexString(convertToAddress(instruction.operand2, parameters.tokenMemorySize)) + "]";
- if (instruction.opType2 == Enums::ComputationOpType_MemMem)
+ }
+ if (instruction.opType2 == Enums::ComputationOpType_MemMem) {
+ comment2 = "[[" + toDecString(convertToAddress(instruction.operand2, parameters.tokenMemorySize)) + "]]";
+ if (revsymbols.find(comment2) != revsymbols.end())
+ comment2 = revsymbols[comment2];
textOp2 = "[[" + toHexString(convertToAddress(instruction.operand2, parameters.tokenMemorySize)) + "]]";
- if (instruction.opType2 == Enums::ComputationOpType_Cmem)
+ }
+ if (instruction.opType2 == Enums::ComputationOpType_Cmem) {
+ comment2 = "("
+ + toDecString(convertToAddress(instruction.operand2, parameters.cellFunctionComputerCellMemorySize))
+ + ")";
+ if (revsymbols.find(comment2) != revsymbols.end())
+ comment2 = revsymbols[comment2];
textOp2 = "("
- + toHexString(convertToAddress(instruction.operand2, parameters.cellFunctionComputerCellMemorySize))
- + ")";
- if (instruction.opType2 == Enums::ComputationOpType_Constant)
+ + toHexString(convertToAddress(instruction.operand2, parameters.cellFunctionComputerCellMemorySize))
+ + ")";
+ }
+ if (instruction.opType2 == Enums::ComputationOpType_Constant) {
+ // try to be smart about constants
+ auto number = toDecString(convertToAddress(instruction.operand2, parameters.tokenMemorySize));
+ comment2 = number;
+ for (auto &it : symbols) {
+ auto pos = it.first.find(':');
+ if (it.first.substr(0,pos) == comment1.substr(0,pos) && it.second == number) {
+ comment2 = it.first;
+ break;
+ }
+ }
textOp2 = toHexString(convertToAddress(instruction.operand2, parameters.tokenMemorySize));
-
+ }
//write separation/comparator
if (instruction.operation <= Enums::ComputationOperation_And) {
text += " " + textOp1 + ", " + textOp2;
+ text += commentAlign() + "# " + getOp() + comment1 + ", " + comment2;
}
- if (instruction.operation == Enums::ComputationOperation_Ifg)
+ if (instruction.operation == Enums::ComputationOperation_Ifg) {
text += " " + textOp1 + " > " + textOp2;
- if (instruction.operation == Enums::ComputationOperation_Ifge)
+ text += commentAlign() + "# " + getOp() + comment1 + " > " + comment2;
+ }
+ if (instruction.operation == Enums::ComputationOperation_Ifge) {
text += " " + textOp1 + " >= " + textOp2;
- if (instruction.operation == Enums::ComputationOperation_Ife)
+ text += commentAlign() + "# " + getOp() + comment1 + " >= " + comment2;
+ }
+ if (instruction.operation == Enums::ComputationOperation_Ife) {
text += " " + textOp1 + " = " + textOp2;
- if (instruction.operation == Enums::ComputationOperation_Ifne)
+ text += commentAlign() + "# " + getOp() + comment1 + " = " + comment2;
+ }
+ if (instruction.operation == Enums::ComputationOperation_Ifne) {
text += " " + textOp1 + " != " + textOp2;
- if (instruction.operation == Enums::ComputationOperation_Ifle)
+ text += commentAlign() + "# " + getOp() + comment1 + " != " + comment2;
+ }
+ if (instruction.operation == Enums::ComputationOperation_Ifle) {
text += " " + textOp1 + " <= " + textOp2;
- if (instruction.operation == Enums::ComputationOperation_Ifl)
+ text += commentAlign() + "# " + getOp() + comment1 + " <= " + comment2;
+ }
+ if (instruction.operation == Enums::ComputationOperation_Ifl) {
text += " " + textOp1 + " < " + textOp2;
+ text += commentAlign() + "# " + getOp() + comment1 + " < " + comment2;
+ }
if (instructionPointer < dataSize)
text += "\n";
}
diff --git a/source/EngineTests/CellComputationTests.cpp b/source/EngineTests/CellComputationTests.cpp
index f42ac43a9..59d12316b 100644
--- a/source/EngineTests/CellComputationTests.cpp
+++ b/source/EngineTests/CellComputationTests.cpp
@@ -40,6 +40,10 @@ std::string CellComputationTests::runSimpleCellComputer(std::string const& progr
CompilationResult compiledProgram = CellComputationCompiler::compileSourceCode(program, symbols, parameters);
+ if(!compiledProgram.compilationOk) {
+ return "";
+ }
+
DataDescription origData
= DescriptionHelper::createRect(DescriptionHelper::CreateRectParameters().width(2).height(1));
auto& origFirstCell = origData.cells.at(0);
@@ -426,3 +430,64 @@ TEST_F(CellComputationTests, divisionByZero)
auto data = runSimpleCellComputer(program);
EXPECT_EQ(0, data.at(1));
}
+
+TEST_F(CellComputationTests, singleLineComment)
+{
+ std::string program = " # this is ignored\n";
+ auto data = runSimpleCellComputer(program);
+ EXPECT_EQ(0, data.at(1));
+}
+
+TEST_F(CellComputationTests, lineComment)
+{
+ std::string program = "mov [1], 55\n"
+ "# this is ignored\n"
+ "sub [1], 13\n";
+ auto data = runSimpleCellComputer(program);
+ EXPECT_EQ(42, data.at(1));
+}
+
+TEST_F(CellComputationTests, opComments)
+{
+ std::string program = "mov [1], 55 # this is ignored\n"
+ "add [1], -13\n";
+ auto data = runSimpleCellComputer(program);
+ EXPECT_EQ(42, data.at(1));
+}
+
+TEST_F(CellComputationTests, ifelseendifComments)
+{
+ std::string program = "mov [1], 55\n"
+ "if [1] < 3 # if comment\n"
+ "div [1], 1\n"
+ "else # else comment\n"
+ "div [1], 1\n"
+ "endif # endif comment\n";
+ auto data = runSimpleCellComputer(program);
+ EXPECT_EQ(55, data.at(1));
+}
+
+TEST_F(CellComputationTests, allComments)
+{
+ std::string program = "# first line comment\n"
+ "mov [1], 2 # mov comment\n"
+ "# empty line comment\n"
+ "if [1] < 3 # if comment\n"
+ "mov [2], 1 # mov comment\n"
+ "else # else comment\n"
+ " # space line comment\n"
+ "mov [2],2 # mov comment\n"
+ "endif # endif comment\n"
+ " # last line comment";
+ auto data = runSimpleCellComputer(program);
+ EXPECT_EQ(1, data.at(2));
+}
+
+TEST_F(CellComputationTests, compileError)
+{
+ std::string program = "mov [1], 55 this triggers an error\n"
+ "add [1], -13\n";
+ auto data = runSimpleCellComputer(program);
+ EXPECT_EQ(0, data.size());
+}
+
From 0621455d7cacfb8c9bd712cd86057ee7e584da16 Mon Sep 17 00:00:00 2001
From: Christian Heinemann
Date: Wed, 4 Jan 2023 17:47:38 +0100
Subject: [PATCH 07/15] Update ubuntu-ci.yml
---
.github/workflows/ubuntu-ci.yml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.github/workflows/ubuntu-ci.yml b/.github/workflows/ubuntu-ci.yml
index fe0bbdd89..a42c270e4 100644
--- a/.github/workflows/ubuntu-ci.yml
+++ b/.github/workflows/ubuntu-ci.yml
@@ -27,6 +27,9 @@ jobs:
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libgl1-mesa-dev libglu-dev
+ sudo apt install gcc-10 g++-10
+ export CC=/usr/bin/gcc-10
+ export CXX=/usr/bin/g++-10
- uses: Jimver/cuda-toolkit@v0.2.5
id: cuda-toolkit
From be3191f92371ce45083091a098e9bc397a3a6978 Mon Sep 17 00:00:00 2001
From: Christian Heinemann
Date: Wed, 4 Jan 2023 18:08:28 +0100
Subject: [PATCH 08/15] Update ubuntu-ci.yml
---
.github/workflows/ubuntu-ci.yml | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/ubuntu-ci.yml b/.github/workflows/ubuntu-ci.yml
index a42c270e4..35c4d5399 100644
--- a/.github/workflows/ubuntu-ci.yml
+++ b/.github/workflows/ubuntu-ci.yml
@@ -27,14 +27,20 @@ jobs:
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libgl1-mesa-dev libglu-dev
- sudo apt install gcc-10 g++-10
- export CC=/usr/bin/gcc-10
- export CXX=/usr/bin/g++-10
- uses: Jimver/cuda-toolkit@v0.2.5
id: cuda-toolkit
with:
cuda: '11.5.1'
+
+ - name: Install Packages, part 2
+ run: |
+ sudo apt install gcc-10 g++-10
+ export CC=/usr/bin/gcc-10
+ export CXX=/usr/bin/g++-10
+ export CUDA_ROOT=/usr/local/cuda
+ ln -s /usr/bin/gcc-10 $CUDA_ROOT/bin/gcc
+ ln -s /usr/bin/g++-10 $CUDA_ROOT/bin/g++
- name: Run vcpkg
uses: lukka/run-vcpkg@v6
From b08b9cbf7ab94bb21814300004968247cfe11f66 Mon Sep 17 00:00:00 2001
From: Christian Heinemann
Date: Wed, 4 Jan 2023 18:12:24 +0100
Subject: [PATCH 09/15] Update ubuntu-ci.yml
---
.github/workflows/ubuntu-ci.yml | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/.github/workflows/ubuntu-ci.yml b/.github/workflows/ubuntu-ci.yml
index 35c4d5399..24d6b2990 100644
--- a/.github/workflows/ubuntu-ci.yml
+++ b/.github/workflows/ubuntu-ci.yml
@@ -31,17 +31,8 @@ jobs:
- uses: Jimver/cuda-toolkit@v0.2.5
id: cuda-toolkit
with:
- cuda: '11.5.1'
+ cuda: '11.6.2'
- - name: Install Packages, part 2
- run: |
- sudo apt install gcc-10 g++-10
- export CC=/usr/bin/gcc-10
- export CXX=/usr/bin/g++-10
- export CUDA_ROOT=/usr/local/cuda
- ln -s /usr/bin/gcc-10 $CUDA_ROOT/bin/gcc
- ln -s /usr/bin/g++-10 $CUDA_ROOT/bin/g++
-
- name: Run vcpkg
uses: lukka/run-vcpkg@v6
with:
From 86b8a66fecd5f669d6fe677643ad9af56d1acc13 Mon Sep 17 00:00:00 2001
From: Christian Heinemann
Date: Wed, 4 Jan 2023 18:14:09 +0100
Subject: [PATCH 10/15] Update ubuntu-ci.yml
---
.github/workflows/ubuntu-ci.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/ubuntu-ci.yml b/.github/workflows/ubuntu-ci.yml
index 24d6b2990..df393204a 100644
--- a/.github/workflows/ubuntu-ci.yml
+++ b/.github/workflows/ubuntu-ci.yml
@@ -31,7 +31,7 @@ jobs:
- uses: Jimver/cuda-toolkit@v0.2.5
id: cuda-toolkit
with:
- cuda: '11.6.2'
+ cuda: '11.6.1'
- name: Run vcpkg
uses: lukka/run-vcpkg@v6
From 11f376c41a67b4cd1ef38d30cd99005406943e64 Mon Sep 17 00:00:00 2001
From: Christian Heinemann
Date: Wed, 4 Jan 2023 18:15:56 +0100
Subject: [PATCH 11/15] Update ubuntu-ci.yml
---
.github/workflows/ubuntu-ci.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/ubuntu-ci.yml b/.github/workflows/ubuntu-ci.yml
index df393204a..736a2244a 100644
--- a/.github/workflows/ubuntu-ci.yml
+++ b/.github/workflows/ubuntu-ci.yml
@@ -31,7 +31,7 @@ jobs:
- uses: Jimver/cuda-toolkit@v0.2.5
id: cuda-toolkit
with:
- cuda: '11.6.1'
+ cuda: '11.7.0'
- name: Run vcpkg
uses: lukka/run-vcpkg@v6
From 515eb2d5fe5b0806dd1950f1b3e4122eeef2913a Mon Sep 17 00:00:00 2001
From: Christian Heinemann
Date: Wed, 4 Jan 2023 18:16:30 +0100
Subject: [PATCH 12/15] Update ubuntu-ci.yml
---
.github/workflows/ubuntu-ci.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/ubuntu-ci.yml b/.github/workflows/ubuntu-ci.yml
index 736a2244a..64c59060e 100644
--- a/.github/workflows/ubuntu-ci.yml
+++ b/.github/workflows/ubuntu-ci.yml
@@ -28,7 +28,7 @@ jobs:
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libgl1-mesa-dev libglu-dev
- - uses: Jimver/cuda-toolkit@v0.2.5
+ - uses: Jimver/cuda-toolkit@v0.2.8
id: cuda-toolkit
with:
cuda: '11.7.0'
From c426e1013f3af9419bb5c0c738a2eddf771e185e Mon Sep 17 00:00:00 2001
From: Christian Heinemann
Date: Fri, 6 Jan 2023 22:27:21 +0100
Subject: [PATCH 13/15] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 782e0d71e..ce8fb5c44 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@ The development is driven by the desire to better understand the conditions for
An important goal is to make the simulator user-friendly through a modern user interface, visually appealing rendering and a playful approach.
-**IMPORTANT:** The current development is taking place on the branch `version4`.
+**IMPORTANT:** The current development is taking place on the branch [version4](https://github.com/chrxh/alien/tree/version4).
# Main features
From 0616c7baac81867de5208eebf5f3d1cf5fade30f Mon Sep 17 00:00:00 2001
From: Christian Heinemann
Date: Fri, 3 Feb 2023 18:05:16 +0100
Subject: [PATCH 14/15] update RELEASE-NOTES.md and fix compile error
---
RELEASE-NOTES.md | 5 +++++
source/Base/Resources.h | 2 +-
source/EngineInterface/Serializer.cpp | 2 +-
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 4e09ca9e8..650a6d368 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -1,5 +1,10 @@
# Release notes
+## [3.3.1] - 2023-02-03
+### Added
+- allow comments starting with # in cell code
+- decompiled cell code shows matching symbols in comments
+
## [3.3.0] - 2022-10-05
### Added
- extended color semantic for cells: food chain color matrix and cell color transition rules
diff --git a/source/Base/Resources.h b/source/Base/Resources.h
index e5817a1f0..931df42fb 100644
--- a/source/Base/Resources.h
+++ b/source/Base/Resources.h
@@ -2,7 +2,7 @@
namespace Const
{
- std::string const ProgramVersion = "3.3.0";
+ std::string const ProgramVersion = "3.3.1";
std::string const BasePath = "resources/";
diff --git a/source/EngineInterface/Serializer.cpp b/source/EngineInterface/Serializer.cpp
index 0a765b52f..f365a5c6b 100644
--- a/source/EngineInterface/Serializer.cpp
+++ b/source/EngineInterface/Serializer.cpp
@@ -553,7 +553,7 @@ namespace
boost::split(versionParts, s, boost::is_any_of("."));
try {
for (auto const& versionPart : versionParts) {
- std::stoi(versionPart);
+ static_cast(std::stoi(versionPart));
}
} catch (...) {
return false;
From 51723b1b011a75c42f57e2f58e3c8b21fb4e9756 Mon Sep 17 00:00:00 2001
From: Christian Heinemann
Date: Fri, 3 Feb 2023 18:29:48 +0100
Subject: [PATCH 15/15] simple version check
---
source/EngineInterface/Serializer.cpp | 10 +++++++++-
source/Gui/BrowserWindow.cpp | 5 ++++-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/source/EngineInterface/Serializer.cpp b/source/EngineInterface/Serializer.cpp
index f365a5c6b..c7ca5dea5 100644
--- a/source/EngineInterface/Serializer.cpp
+++ b/source/EngineInterface/Serializer.cpp
@@ -551,14 +551,21 @@ namespace
{
std::vector versionParts;
boost::split(versionParts, s, boost::is_any_of("."));
+ if (versionParts.size() < 3) {
+ return false;
+ }
try {
for (auto const& versionPart : versionParts) {
static_cast(std::stoi(versionPart));
}
+ //simple check: will be improved in future
+ if (std::stoi(versionParts.front()) > 3) {
+ return false;
+ }
} catch (...) {
return false;
}
- return versionParts.size() == 3;
+ return true;
}
struct VersionParts
{
@@ -583,6 +590,7 @@ void Serializer::deserializeDataDescription(ClusteredDataDescription& data, std:
throw std::runtime_error("No version detected.");
}
auto versionParts = getVersionParts(version);
+
if (versionParts.major <= 3 && versionParts.minor <= 2) {
DEPRECATED_ClusteredDataDescription_3_2 oldData;
archive(oldData);
diff --git a/source/Gui/BrowserWindow.cpp b/source/Gui/BrowserWindow.cpp
index 3e75bd73b..ec07ab826 100644
--- a/source/Gui/BrowserWindow.cpp
+++ b/source/Gui/BrowserWindow.cpp
@@ -349,7 +349,10 @@ void _BrowserWindow::onOpenSimulation(std::string const& id)
}
DeserializedSimulation deserializedSim;
- Serializer::deserializeSimulationFromStrings(deserializedSim, content, settings, symbolMap);
+ if (!Serializer::deserializeSimulationFromStrings(deserializedSim, content, settings, symbolMap)) {
+ MessageDialog::getInstance().show("Error", "Failed to load simulation. Your program version may not match.");
+ return;
+ }
_simController->closeSimulation();
_statisticsWindow->reset();