Skip to content

Commit

Permalink
Revert "test implementation for PersisterController"
Browse files Browse the repository at this point in the history
This reverts commit 177430c.
  • Loading branch information
chrxh committed Sep 30, 2024
1 parent 177430c commit 6be3b53
Showing 1 changed file with 0 additions and 182 deletions.
182 changes: 0 additions & 182 deletions source/EngineTests/TransmitterTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,185 +288,3 @@ TEST_F(TransmitterTests, distributeToTwoTransmittersWithDifferentColor)
EXPECT_TRUE(actualOtherTransmitterCell2.energy > origOtherTransmitterCell2.energy + NEAR_ZERO);
EXPECT_TRUE(approxCompare(getEnergy(data), getEnergy(actualData)));
}

TEST_F(TransmitterTests, distributeToNotToNotReadyConstructors)
{
_parameters.cellFunctionConstructorCheckCompletenessForSelfReplication = true;
_simController->setSimulationParameters(_parameters);

auto subgenome = GenomeDescription().setCells({CellGenomeDescription()});

auto genome = GenomeDescription().setCells({
CellGenomeDescription().setCellFunction(ConstructorGenomeDescription().setMakeSelfCopy()),
CellGenomeDescription().setCellFunction(TransmitterGenomeDescription()),
CellGenomeDescription().setCellFunction(ConstructorGenomeDescription().setGenome(GenomeDescriptionService::convertDescriptionToBytes(subgenome))),
});

DataDescription data;
data.addCells({
CellDescription()
.setId(1)
.setPos({9.0f, 10.0f})
.setMaxConnections(1)
.setExecutionOrderNumber(0)
.setCellFunction(ConstructorDescription().setNumInheritedGenomeNodes(4).setGenome(GenomeDescriptionService::convertDescriptionToBytes(genome))),
CellDescription()
.setId(2)
.setPos({10.0f, 10.0f})
.setMaxConnections(2)
.setExecutionOrderNumber(1)
.setCellFunction(TransmitterDescription().setMode(EnergyDistributionMode_TransmittersAndConstructors))
.setEnergy(_parameters.cellNormalEnergy[0] * 2),
CellDescription()
.setId(3)
.setPos({11.0f, 10.0f})
.setMaxConnections(1)
.setExecutionOrderNumber(0)
.setCellFunction(ConstructorDescription().setGenome(GenomeDescriptionService::convertDescriptionToBytes(subgenome))),
});
data.addConnection(1, 2);
data.addConnection(2, 3);

_simController->setSimulationData(data);
_simController->calcTimesteps(2);

auto actualData = _simController->getSimulationData();

auto origReplicator = getCell(data, 1);
auto actualReplicator = getCell(actualData, 1);

auto origTransmitter = getCell(data, 2);
auto actualTransmitter = getCell(actualData, 2);

auto origConstructor = getCell(data, 3);
auto actualConstructor = getCell(actualData, 3);

EXPECT_TRUE(actualTransmitter.energy < origTransmitter.energy - NEAR_ZERO);
EXPECT_TRUE(approxCompare(actualReplicator.energy, origReplicator.energy));
EXPECT_TRUE(actualConstructor.energy > origConstructor.energy + NEAR_ZERO);

EXPECT_TRUE(approxCompare(getEnergy(data), getEnergy(actualData)));
}

TEST_F(TransmitterTests, distributeToReadyConstructors)
{
_parameters.cellFunctionConstructorCheckCompletenessForSelfReplication = true;
_simController->setSimulationParameters(_parameters);

auto subgenome = GenomeDescription().setCells({CellGenomeDescription()});

auto genome = GenomeDescription().setCells({
CellGenomeDescription().setCellFunction(ConstructorGenomeDescription().setMakeSelfCopy()),
CellGenomeDescription().setCellFunction(TransmitterGenomeDescription()),
CellGenomeDescription().setCellFunction(ConstructorGenomeDescription().setGenome(GenomeDescriptionService::convertDescriptionToBytes(subgenome))),
});

DataDescription data;
data.addCells({
CellDescription()
.setId(1)
.setPos({9.0f, 10.0f})
.setMaxConnections(1)
.setExecutionOrderNumber(0)
.setCellFunction(ConstructorDescription().setNumInheritedGenomeNodes(4).setGenome(GenomeDescriptionService::convertDescriptionToBytes(genome))),
CellDescription()
.setId(2)
.setPos({10.0f, 10.0f})
.setMaxConnections(2)
.setExecutionOrderNumber(1)
.setCellFunction(TransmitterDescription().setMode(EnergyDistributionMode_TransmittersAndConstructors))
.setEnergy(_parameters.cellNormalEnergy[0] * 2),
CellDescription()
.setId(3)
.setPos({11.0f, 10.0f})
.setMaxConnections(2)
.setExecutionOrderNumber(0)
.setCellFunction(ConstructorDescription().setGenome(GenomeDescriptionService::convertDescriptionToBytes(subgenome))),
CellDescription()
.setId(4)
.setPos({12.0f, 10.0f})
.setMaxConnections(1)
.setExecutionOrderNumber(0),
});
data.addConnection(1, 2);
data.addConnection(2, 3);
data.addConnection(3, 4);

_simController->setSimulationData(data);
_simController->calcTimesteps(2);

auto actualData = _simController->getSimulationData();

auto origReplicator = getCell(data, 1);
auto actualReplicator = getCell(actualData, 1);

auto origTransmitter = getCell(data, 2);
auto actualTransmitter = getCell(actualData, 2);

auto origConstructor = getCell(data, 3);
auto actualConstructor = getCell(actualData, 3);

EXPECT_TRUE(actualTransmitter.energy < origTransmitter.energy - NEAR_ZERO);
EXPECT_TRUE(actualReplicator.energy > origReplicator.energy + NEAR_ZERO);
EXPECT_TRUE(actualConstructor.energy > origConstructor.energy + NEAR_ZERO);

EXPECT_TRUE(approxCompare(getEnergy(data), getEnergy(actualData)));
}

TEST_F(TransmitterTests, distributeFromNotReadyToReadyConstructors)
{
_parameters.cellFunctionConstructorCheckCompletenessForSelfReplication = true;
_simController->setSimulationParameters(_parameters);

auto subgenome = GenomeDescription().setCells({CellGenomeDescription()});

auto genome = GenomeDescription().setCells({
CellGenomeDescription().setCellFunction(ConstructorGenomeDescription().setMakeSelfCopy()),
CellGenomeDescription().setCellFunction(TransmitterGenomeDescription()),
CellGenomeDescription().setCellFunction(ConstructorGenomeDescription().setGenome(GenomeDescriptionService::convertDescriptionToBytes(subgenome))),
});

DataDescription data;
data.addCells({
CellDescription()
.setId(1)
.setPos({9.0f, 10.0f})
.setMaxConnections(1)
.setExecutionOrderNumber(0)
.setEnergy(_parameters.cellNormalEnergy[0] * 2)
.setCellFunction(ConstructorDescription().setNumInheritedGenomeNodes(4).setGenome(GenomeDescriptionService::convertDescriptionToBytes(genome))),
CellDescription()
.setId(2)
.setPos({10.0f, 10.0f})
.setMaxConnections(2),
CellDescription()
.setId(3)
.setPos({11.0f, 10.0f})
.setMaxConnections(2)
.setExecutionOrderNumber(0)
.setCellFunction(ConstructorDescription().setGenome(GenomeDescriptionService::convertDescriptionToBytes(subgenome))),
CellDescription().setId(4).setPos({12.0f, 10.0f}).setMaxConnections(1).setExecutionOrderNumber(0),
});
data.addConnection(1, 2);
data.addConnection(2, 3);

_simController->setSimulationData(data);
_simController->calcTimesteps(7);

auto actualData = _simController->getSimulationData();

auto origReplicator = getCell(data, 1);
auto actualReplicator = getCell(actualData, 1);

auto origOtherCell = getCell(data, 2);
auto actualOtherCell = getCell(actualData, 2);

auto origConstructor = getCell(data, 3);
auto actualConstructor = getCell(actualData, 3);

EXPECT_TRUE(actualReplicator.energy < origReplicator.energy - NEAR_ZERO);
EXPECT_TRUE(approxCompare(actualOtherCell.energy, origOtherCell.energy));
EXPECT_TRUE(actualConstructor.energy > origConstructor.energy + NEAR_ZERO);

EXPECT_TRUE(approxCompare(getEnergy(data), getEnergy(actualData)));
}

0 comments on commit 6be3b53

Please sign in to comment.