|
| 1 | +#include "../../sgp_mode/GenomeLibrary.h" |
| 2 | +#include "../../sgp_mode/CPU.h" |
| 3 | +#include "../../sgp_mode/SGPHost.h" |
| 4 | +#include "../../sgp_mode/SGPHost.cc" |
| 5 | +#include "../../sgp_mode/SGPWorld.h" |
| 6 | +#include "../../sgp_mode/SGPWorldSetup.cc" |
| 7 | +#include "../../sgp_mode/SGPDataNodes.h" |
| 8 | + |
| 9 | +#include "../../catch/catch.hpp" |
| 10 | + |
| 11 | +TEST_CASE("Organisms, without mutation can only do NOT operations", "[sgp]") { |
| 12 | + |
| 13 | + emp::Random random(1); |
| 14 | + SymConfigSGP config; |
| 15 | + config.SEED(2); |
| 16 | + config.ORGANISM_TYPE(HEALTH); |
| 17 | + config.STRESS_TYPE(PARASITE); |
| 18 | + config.MUTATION_RATE(0.0); |
| 19 | + config.MUTATION_SIZE(0.000); |
| 20 | + SGPWorld world(random, &config, LogicTasks); |
| 21 | + |
| 22 | + // Mock Organism to check reproduction |
| 23 | + class TestOrg : public Organism { |
| 24 | + public: |
| 25 | + bool IsHost() override { return true; } |
| 26 | + void AddPoints(double p) override {} |
| 27 | + double GetPoints() override { return 0; } |
| 28 | + }; |
| 29 | + |
| 30 | + TestOrg organism; |
| 31 | + |
| 32 | + // NOT builder |
| 33 | + ProgramBuilder builder; |
| 34 | + (builder.AddNot)(); |
| 35 | + CPU cpu(&organism, &world, builder.Build(100)); |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + cpu.RunCPUStep(0, 100); |
| 40 | + |
| 41 | + //The result of a AND bitwise operations when one of the inputs, in binary, is all ones will be the other input |
| 42 | + long all_ones_binary = 4294967295; |
| 43 | + cpu.state.input_buf.push(all_ones_binary); |
| 44 | + cpu.RunCPUStep(0, 100); |
| 45 | + world.Update(); |
| 46 | + |
| 47 | + //Checks both that NOT is being done and no other operations are being done |
| 48 | + for (auto data : world.GetTaskSet()) { |
| 49 | + |
| 50 | + if(data.task.name != "NOT"){ |
| 51 | + |
| 52 | + REQUIRE(data.n_succeeds_host == 0); |
| 53 | + } |
| 54 | + else{ |
| 55 | + REQUIRE(data.n_succeeds_host > 0); |
| 56 | + } |
| 57 | + } |
| 58 | +} |
0 commit comments