Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
chrxh committed Jan 6, 2024
2 parents d117b07 + c44ea85 commit 8123d24
Show file tree
Hide file tree
Showing 14 changed files with 167 additions and 57 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Further information and artwork:
An Nvidia graphics card with compute capability 6.0 or higher is needed. Please check [https://en.wikipedia.org/wiki/CUDA#GPUs_supported](https://en.wikipedia.org/wiki/CUDA#GPUs_supported).

# 💽 Installer
Installer for Windows: [alien-installer.msi](https://alien-project.org/media/files/alien-installer.msi) (Updated: 2024-01-04)
Installer for Windows: [alien-installer.msi](https://alien-project.org/media/files/alien-installer.msi) (Updated: 2024-01-06)

In the case that the program crashes for an unknown reason, please refer to the troubleshooting section in [alien-project.org/downloads.html](https://alien-project.org/downloads.html).

Expand Down
12 changes: 10 additions & 2 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Release notes

## [4.7.2] - 2024-01-06
### Added
- engine, gui/simulation parameters: splitting of energy particles above a certain minimum energy
- engine: force fields also affect energy particles

### Fixed
- gui/browser: beginning and ending whitespaces of folder names are ignored for automatic grouping

## [4.7.1] - 2024-01-05
### Added
- gui/browser: shared symbol in private workspace in front of items to indicate if it is public
Expand All @@ -20,11 +28,11 @@
- gui/browser: cache for speeding up downloading simulations
- gui/upload dialog: validation of user input to allowed characters
- gui/upload dialog: upload simulation or genome to folder
- gui/simulation parameters, model: individual cell color mutation
- engine, gui/simulation parameters: individual cell color mutation

### Changed
- gui/browser: layout (in particular, new widget for selecting workspace)
- model: restrict the fusion of energy particles to certain energies
- engine: restrict the fusion of energy particles to certain energies

## [4.6.0] - 2023-12-29
### Added
Expand Down
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.7.1";
std::string const ProgramVersion = "4.7.2";
std::string const DiscordLink = "https://discord.gg/7bjyZdXXQ2";

std::string const BasePath = "resources/";
Expand Down
2 changes: 1 addition & 1 deletion source/EngineGpuKernels/CellProcessor.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ __inline__ __device__ void CellProcessor::applyForces(SimulationData& data)
continue;
}

cell->vel +=cell->shared1;
cell->vel += cell->shared1;
if (Math::length(cell->vel) > cudaSimulationParameters.cellMaxVelocity) {
cell->vel = Math::normalized(cell->vel) * cudaSimulationParameters.cellMaxVelocity;
}
Expand Down
47 changes: 33 additions & 14 deletions source/EngineGpuKernels/FlowFieldKernels.cu
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,43 @@ namespace

__global__ void cudaApplyFlowFieldSettings(SimulationData data)
{
auto& cells = data.objects.cellPointers;
auto partition = calcAllThreadsPartition(cells.getNumEntries());

float2 accelerations[MAX_SPOTS];
for (int index = partition.startIndex; index <= partition.endIndex; ++index) {
auto& cell = cells.at(index);
if (cell->barrier) {
continue;
{
auto& cells = data.objects.cellPointers;
auto partition = calcAllThreadsPartition(cells.getNumEntries());

for (int index = partition.startIndex; index <= partition.endIndex; ++index) {
auto& cell = cells.at(index);
if (cell->barrier) {
continue;
}
int numFlowFields = 0;
for (int i = 0; i < cudaSimulationParameters.numSpots; ++i) {

if (cudaSimulationParameters.spots[i].flowType != FlowType_None) {
accelerations[numFlowFields] = calcAcceleration(data.cellMap, cell->pos, i);
++numFlowFields;
}
}
auto resultingAcceleration = SpotCalculator::calcResultingFlowField(data.cellMap, cell->pos, float2{0, 0}, accelerations);
cell->shared1 += resultingAcceleration;
}
int numFlowFields = 0;
for (int i = 0; i < cudaSimulationParameters.numSpots; ++i) {
}
{
auto& particles = data.objects.particlePointers;
auto partition = calcAllThreadsPartition(particles.getNumEntries());
for (int index = partition.startIndex; index <= partition.endIndex; ++index) {
auto& particle = particles.at(index);
int numFlowFields = 0;
for (int i = 0; i < cudaSimulationParameters.numSpots; ++i) {

if (cudaSimulationParameters.spots[i].flowType != FlowType_None) {
accelerations[numFlowFields] = calcAcceleration(data.cellMap, cell->pos, i);
++numFlowFields;
if (cudaSimulationParameters.spots[i].flowType != FlowType_None) {
accelerations[numFlowFields] = calcAcceleration(data.cellMap, particle->absPos, i);
++numFlowFields;
}
}
auto resultingAcceleration = SpotCalculator::calcResultingFlowField(data.cellMap, particle->absPos, float2{0, 0}, accelerations);
particle->vel += resultingAcceleration;
}
auto resultingAcceleration = SpotCalculator::calcResultingFlowField(data.cellMap, cell->pos, float2{0, 0}, accelerations);
cell->shared1 += resultingAcceleration;
}
}
6 changes: 6 additions & 0 deletions source/EngineGpuKernels/Math.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ __inline__ __device__ __host__ bool operator==(int2 const& p, int2 const& q)
return p.x == q.x && p.y == q.y;
}

__inline__ __device__ __host__ void operator*=(float2& p, float const& q)
{
p.x *= q;
p.y *= q;
}

__inline__ __device__ __host__ void operator+=(float2& p, float2 const& q)
{
p.x += q.x;
Expand Down
58 changes: 44 additions & 14 deletions source/EngineGpuKernels/ParticleProcessor.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public:
__inline__ __device__ static void updateMap(SimulationData& data);
__inline__ __device__ static void movement(SimulationData& data);
__inline__ __device__ static void collision(SimulationData& data);
__inline__ __device__ static void splitting(SimulationData& data);
__inline__ __device__ static void transformation(SimulationData& data);
__inline__ __device__ static void radiate(SimulationData& data, float2 pos, float2 vel, int color, float energy); //return needed energy

Expand All @@ -29,16 +30,15 @@ private:

__inline__ __device__ void ParticleProcessor::updateMap(SimulationData& data)
{
auto partition = calcPartition(data.objects.particlePointers.getNumEntries(), blockIdx.x, gridDim.x);
auto partition = calcPartition(data.objects.particlePointers.getNumOrigEntries(), blockIdx.x, gridDim.x);

Particle** particlePointers = &data.objects.particlePointers.at(partition.startIndex);
data.particleMap.set_block(partition.numElements(), particlePointers);
}

__inline__ __device__ void ParticleProcessor::movement(SimulationData& data)
{
auto partition = calcPartition(
data.objects.particlePointers.getNumEntries(), threadIdx.x + blockIdx.x * blockDim.x, blockDim.x * gridDim.x);
auto partition = calcAllThreadsPartition(data.objects.particlePointers.getNumOrigEntries());

for (int particleIndex = partition.startIndex; particleIndex <= partition.endIndex; ++particleIndex) {
auto& particle = data.objects.particlePointers.at(particleIndex);
Expand All @@ -49,8 +49,7 @@ __inline__ __device__ void ParticleProcessor::movement(SimulationData& data)

__inline__ __device__ void ParticleProcessor::collision(SimulationData& data)
{
auto partition = calcPartition(
data.objects.particlePointers.getNumEntries(), threadIdx.x + blockIdx.x * blockDim.x, blockDim.x * gridDim.x);
auto partition = calcAllThreadsPartition(data.objects.particlePointers.getNumOrigEntries());

for (int particleIndex = partition.startIndex; particleIndex <= partition.endIndex; ++particleIndex) {
auto& particle = data.objects.particlePointers.at(particleIndex);
Expand All @@ -63,15 +62,12 @@ __inline__ __device__ void ParticleProcessor::collision(SimulationData& data)
if (lock.tryLock()) {

if (particle->energy > NEAR_ZERO && otherParticle->energy > NEAR_ZERO) {
if (cudaSimulationParameters.particleTransformationAllowed
|| particle->energy + otherParticle->energy < MaxFusionEnergy) {
auto factor1 = particle->energy / (particle->energy + otherParticle->energy);
otherParticle->vel = particle->vel * factor1 + otherParticle->vel * (1.0f - factor1);
otherParticle->energy += particle->energy;
otherParticle->lastAbsorbedCell = nullptr;
particle->energy = 0;
particle = nullptr;
}
auto factor1 = particle->energy / (particle->energy + otherParticle->energy);
otherParticle->vel = particle->vel * factor1 + otherParticle->vel * (1.0f - factor1);
otherParticle->energy += particle->energy;
otherParticle->lastAbsorbedCell = nullptr;
particle->energy = 0;
particle = nullptr;
}

lock.releaseLock();
Expand Down Expand Up @@ -132,6 +128,40 @@ __inline__ __device__ void ParticleProcessor::collision(SimulationData& data)
}
}

__inline__ __device__ void ParticleProcessor::splitting(SimulationData& data)
{
auto partition = calcAllThreadsPartition(data.objects.particlePointers.getNumOrigEntries());

for (int particleIndex = partition.startIndex; particleIndex <= partition.endIndex; ++particleIndex) {
auto& particle = data.objects.particlePointers.at(particleIndex);
if (particle == nullptr) {
continue;
}
if (data.numberGen1.random() >= 0.01f) {
continue;
}

if (particle->energy > cudaSimulationParameters.particleSplitEnergy[particle->color]) {
particle->energy *= 0.5f;
auto velPerturbation = Math::unitVectorOfAngle(data.numberGen1.random() * 360);

float2 otherPos = particle->absPos + velPerturbation / 5;
data.particleMap.correctPosition(otherPos);

particle->absPos -= velPerturbation / 5;
data.particleMap.correctPosition(particle->absPos);

velPerturbation *= cudaSimulationParameters.radiationVelocityPerturbation / (particle->energy + 1.0f);
float2 otherVel = particle->vel + velPerturbation;

particle->vel -= velPerturbation;
ObjectFactory factory;
factory.init(&data);
factory.createParticle(particle->energy, otherPos, otherVel, particle->color);
}
}
}

__inline__ __device__ void ParticleProcessor::transformation(SimulationData& data)
{
if (!cudaSimulationParameters.particleTransformationAllowed) {
Expand Down
2 changes: 2 additions & 0 deletions source/EngineGpuKernels/SimulationKernels.cu
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ __global__ void cudaNextTimestep_physics_verletPositionUpdate(SimulationData dat
{
CellProcessor::verletPositionUpdate(data);
CellProcessor::checkConnections(data);

ParticleProcessor::splitting(data);
}

__global__ void cudaNextTimestep_physics_calcConnectionForces(SimulationData data, bool considerAngles)
Expand Down
2 changes: 2 additions & 0 deletions source/EngineInterface/AuxiliaryDataParserService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@ namespace
defaultParameters.particleTransformationMaxGenomeSize,
"simulation parameters.particle.transformation.max genome size",
parserTask);
encodeDecodeProperty(
tree, parameters.particleSplitEnergy, defaultParameters.particleSplitEnergy, "simulation parameters.particle.split energy", parserTask);

encodeDecodeProperty(
tree,
Expand Down
11 changes: 11 additions & 0 deletions source/EngineInterface/SimulationParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ struct SimulationParameters
bool particleTransformationAllowed = false;
bool particleTransformationRandomCellFunction = false;
int particleTransformationMaxGenomeSize = 300;
ColorVector<float> particleSplitEnergy = {
Infinity<float>::value,
Infinity<float>::value,
Infinity<float>::value,
Infinity<float>::value,
Infinity<float>::value,
Infinity<float>::value,
Infinity<float>::value};

ColorVector<float> cellFunctionConstructorOffspringDistance = {2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f};
ColorVector<float> cellFunctionConstructorConnectingCellMaxDistance = {1.8f, 1.8f, 1.8f, 1.8f, 1.8f, 1.8f, 1.8f};
Expand Down Expand Up @@ -174,6 +182,9 @@ struct SimulationParameters
}

for (int i = 0; i < MAX_COLORS; ++i) {
if (particleSplitEnergy[i] != other.particleSplitEnergy[i]) {
return false;
}
if (cellFunctionAttackerSensorDetectionFactor[i] != other.cellFunctionAttackerSensorDetectionFactor[i]) {
return false;
}
Expand Down
6 changes: 4 additions & 2 deletions source/Gui/CreatorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ void _CreatorWindow::processIntern()
if (_mode != CreationMode_CreateParticle & _mode != CreationMode_CreateCell) {
AlienImGui::Checkbox(AlienImGui::CheckboxParameters().name("Sticky").textWidth(RightColumnWidth).tooltip(Const::CreatorStickyTooltip), _makeSticky);
}
AlienImGui::Checkbox(
AlienImGui::CheckboxParameters().name("Indestructible").textWidth(RightColumnWidth).tooltip(Const::CellIndestructibleTooltip), _barrier);
if (_mode != CreationMode_CreateParticle) {
AlienImGui::Checkbox(
AlienImGui::CheckboxParameters().name("Indestructible").textWidth(RightColumnWidth).tooltip(Const::CellIndestructibleTooltip), _barrier);
}
}
ImGui::EndChild();

Expand Down
17 changes: 16 additions & 1 deletion source/Gui/SimulationParametersWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,12 +530,26 @@ void _SimulationParametersWindow::processBase(
.colorDependence(true)
.infinity(true)
.min(0)
.max(100000)
.max(100000.0f)
.logarithmic(true)
.format("%.1f")
.defaultValue(origSimParameters.highRadiationMinCellEnergy)
.tooltip("The minimum energy of a cell can be defined here, from which it emits energy particles."),
simParameters.highRadiationMinCellEnergy);
AlienImGui::SliderFloat(
AlienImGui::SliderFloatParameters()
.name("Minimum split energy")
.textWidth(RightColumnWidth)
.colorDependence(true)
.infinity(true)
.min(1.0f)
.max(10000.0f)
.logarithmic(true)
.format("%.0f")
.defaultValue(origSimParameters.particleSplitEnergy)
.tooltip("The minimum energy of an energy particle after which it can split into two particles, whereby it receives a small momentum. The "
"splitting does not occur immediately, but only after a certain time."),
simParameters.particleSplitEnergy);
AlienImGui::Checkbox(
AlienImGui::CheckboxParameters()
.name("Energy to cell transformation")
Expand Down Expand Up @@ -1924,6 +1938,7 @@ void _SimulationParametersWindow::validationAndCorrection(SimulationParameters&
parameters.cellFunctionConstructorExternalEnergySupplyRate[i] =
std::max(0.0f, std::min(1.0f, parameters.cellFunctionConstructorExternalEnergySupplyRate[i]));
parameters.baseValues.cellMinEnergy[i] = std::min(parameters.baseValues.cellMinEnergy[i], parameters.cellNormalEnergy[i] * 0.95f);
parameters.particleSplitEnergy[i] = std::max(0.0f, parameters.particleSplitEnergy[i]);
}
parameters.baseValues.cellMaxBindingEnergy = std::max(10.0f, parameters.baseValues.cellMaxBindingEnergy);
parameters.timestepSize = std::max(0.0f, parameters.timestepSize);
Expand Down
Loading

0 comments on commit 8123d24

Please sign in to comment.