Skip to content

Commit 8f6cb95

Browse files
committed
merged
2 parents 52c7872 + 3512963 commit 8f6cb95

2 files changed

Lines changed: 58 additions & 6 deletions

File tree

source/sgp_mode/SymbiontImpact.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ double CheckSymbiont(SGPHost host, SGPSymbiont symbiont,
2727
host.ClearReproSyms();
2828
host.SetPoints(0.0);
2929
for (size_t i = 0; i < SYM_CHECK_UPDATES; i++) {
30-
// world.GetUpdate() isn't changing since the whole world isn't being
31-
// updated, so we need to do this resetting manually
32-
if (i % (30 / world.GetConfig()->CYCLES_PER_UPDATE()) == 0)
33-
host.GetCPU().state.used_resources->reset();
3430
host.GetCPU().RunCPUStep(emp::WorldPosition::invalid_id,
3531
world.GetConfig()->CYCLES_PER_UPDATE());
3632
}
@@ -40,8 +36,6 @@ double CheckSymbiont(SGPHost host, SGPSymbiont symbiont,
4036
host.AddSymbiont(&symbiont);
4137
symbiont.SetPoints(0.0);
4238
for (size_t i = 0; i < SYM_CHECK_UPDATES; i++) {
43-
if (i % (30 / world.GetConfig()->CYCLES_PER_UPDATE()) == 0)
44-
host.GetCPU().state.used_resources->reset();
4539
// Instead of randomly ordering the host and symbiont (like in
4640
// Host::Process()), alternate every update. That way it's deterministic and
4741
// we don't need to have access to the emp::Random.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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

Comments
 (0)