MCPcopy Create free account
hub / github.com/chrxh/alien / compareNeuronDataMutation

Method compareNeuronDataMutation

source/EngineTests/MutationTests.cpp:210–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

208 }
209
210 bool compareNeuronDataMutation(std::vector<uint8_t> const& expected, std::vector<uint8_t> const& actual)
211 {
212 if (expected.size() != actual.size()) {
213 return false;
214 }
215 auto expectedGenome = GenomeDescriptionService::get().convertBytesToDescription(expected);
216 auto actualGenome = GenomeDescriptionService::get().convertBytesToDescription(actual);
217 if (expectedGenome.header != actualGenome.header) {
218 return false;
219 }
220 if (expectedGenome.cells.size() != actualGenome.cells.size()) {
221 return false;
222 }
223
224 for (auto const& [expectedCell, actualCell] : boost::combine(expectedGenome.cells, actualGenome.cells)) {
225 if (expectedCell.getCellFunctionType() != actualCell.getCellFunctionType()) {
226 return false;
227 }
228 if (expectedCell.getCellFunctionType() != CellFunction_Neuron && expectedCell.getCellFunctionType() != CellFunction_Constructor
229 && expectedCell.getCellFunctionType() != CellFunction_Injector && expectedCell != actualCell) {
230 return false;
231 }
232 if (expectedCell.color != actualCell.color) {
233 return false;
234 }
235 if (expectedCell.getCellFunctionType() == CellFunction_Constructor) {
236 auto expectedConstructor = std::get<ConstructorGenomeDescription>(*expectedCell.cellFunction);
237 auto actualConstructor = std::get<ConstructorGenomeDescription>(*actualCell.cellFunction);
238 if (expectedConstructor.isMakeGenomeCopy() != actualConstructor.isMakeGenomeCopy()) {
239 return false;
240 }
241 if (!expectedConstructor.isMakeGenomeCopy()) {
242 if (!compareNeuronDataMutation(expectedConstructor.getGenomeData(), actualConstructor.getGenomeData())) {
243 return false;
244 }
245 }
246 }
247 if (expectedCell.getCellFunctionType() == CellFunction_Injector) {
248 auto expectedInjector = std::get<InjectorGenomeDescription>(*expectedCell.cellFunction);
249 auto actualInjector = std::get<InjectorGenomeDescription>(*actualCell.cellFunction);
250 if (expectedInjector.isMakeGenomeCopy() != actualInjector.isMakeGenomeCopy()) {
251 return false;
252 }
253 if (!expectedInjector.isMakeGenomeCopy()) {
254 if (!compareNeuronDataMutation(expectedInjector.getGenomeData(), actualInjector.getGenomeData())) {
255 return false;
256 }
257 }
258 }
259
260 }
261 return true;
262 }
263
264 bool compareGeometryMutation(std::vector<uint8_t> const& expected, std::vector<uint8_t> const& actual)
265 {

Callers

nothing calls this directly

Calls 5

sizeMethod · 0.80
getCellFunctionTypeMethod · 0.45
isMakeGenomeCopyMethod · 0.45
getGenomeDataMethod · 0.45

Tested by

no test coverage detected