From 5224f7520ab7f61e23fdaab86a304b27c444d8b6 Mon Sep 17 00:00:00 2001 From: LaurenC267 Date: Fri, 10 Jul 2026 09:32:31 -0500 Subject: [PATCH 1/9] Changed so that the 'season' starts on the opposite one --- source/sgp_mode/SGPWorldSetup.cc | 27 ++++++++------- .../functional_tests/SenseTask_Tasks.test.cc | 34 ++++++++++--------- .../TempChangingEnvironments.test.cc | 16 ++++----- 3 files changed, 40 insertions(+), 37 deletions(-) diff --git a/source/sgp_mode/SGPWorldSetup.cc b/source/sgp_mode/SGPWorldSetup.cc index d6897522..03456e87 100644 --- a/source/sgp_mode/SGPWorldSetup.cc +++ b/source/sgp_mode/SGPWorldSetup.cc @@ -121,7 +121,6 @@ void SGPWorld::SetupChangingEnvironment() { andn_task_id = task_env.GetTaskSet().GetID("and_not"); } - size_t orn_task_id = task_env.GetTaskSet().GetSize(); if (task_env.GetTaskSet().HasTask("OR_NOT")) { orn_task_id = task_env.GetTaskSet().GetID("OR_NOT"); @@ -157,34 +156,36 @@ void SGPWorld::SetupChangingEnvironment() { } // update 0 will flip not-and-or to rewarded and nand-andn-orn to punished - GetTaskEnv().GetHostTaskReq(not_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(not_task_id).task_value; - GetTaskEnv().GetSymTaskReq(not_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(not_task_id).task_value; + GetTaskEnv().GetHostTaskReq(nand_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(nand_task_id).task_value; + GetTaskEnv().GetSymTaskReq(nand_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(nand_task_id).task_value; - GetTaskEnv().GetHostTaskReq(and_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(and_task_id).task_value; - GetTaskEnv().GetSymTaskReq(and_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(and_task_id).task_value; + GetTaskEnv().GetHostTaskReq(andn_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(andn_task_id).task_value; + GetTaskEnv().GetSymTaskReq(andn_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(andn_task_id).task_value; - GetTaskEnv().GetHostTaskReq(or_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(or_task_id).task_value; - GetTaskEnv().GetSymTaskReq(or_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(or_task_id).task_value; + GetTaskEnv().GetHostTaskReq(orn_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(orn_task_id).task_value; + GetTaskEnv().GetSymTaskReq(orn_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(orn_task_id).task_value; begin_update_sig.AddAction( [this, nand_task_id, andn_task_id, orn_task_id, not_task_id, and_task_id, or_task_id]() { if (GetUpdate() % sgp_config.TEMP_CHANGING_ENVIRONMENT_INTERVAL() == 0) { - GetTaskEnv().GetHostTaskReq(nand_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(nand_task_id).task_value; - GetTaskEnv().GetHostTaskReq(andn_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(andn_task_id).task_value; - GetTaskEnv().GetHostTaskReq(orn_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(orn_task_id).task_value; GetTaskEnv().GetHostTaskReq(not_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(not_task_id).task_value; GetTaskEnv().GetHostTaskReq(and_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(and_task_id).task_value; GetTaskEnv().GetHostTaskReq(or_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(or_task_id).task_value; + GetTaskEnv().GetHostTaskReq(nand_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(nand_task_id).task_value; + GetTaskEnv().GetHostTaskReq(andn_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(andn_task_id).task_value; + GetTaskEnv().GetHostTaskReq(orn_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(orn_task_id).task_value; + + GetTaskEnv().GetSymTaskReq(not_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(not_task_id).task_value; + GetTaskEnv().GetSymTaskReq(and_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(and_task_id).task_value; + GetTaskEnv().GetSymTaskReq(or_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(or_task_id).task_value; GetTaskEnv().GetSymTaskReq(nand_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(nand_task_id).task_value; GetTaskEnv().GetSymTaskReq(andn_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(andn_task_id).task_value; GetTaskEnv().GetSymTaskReq(orn_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(orn_task_id).task_value; - GetTaskEnv().GetSymTaskReq(not_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(not_task_id).task_value; - GetTaskEnv().GetSymTaskReq(and_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(and_task_id).task_value; - GetTaskEnv().GetSymTaskReq(or_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(or_task_id).task_value; + } } ); diff --git a/source/test/sgp_mode_test/functional_tests/SenseTask_Tasks.test.cc b/source/test/sgp_mode_test/functional_tests/SenseTask_Tasks.test.cc index fda179b5..cd9053ad 100644 --- a/source/test/sgp_mode_test/functional_tests/SenseTask_Tasks.test.cc +++ b/source/test/sgp_mode_test/functional_tests/SenseTask_Tasks.test.cc @@ -14,7 +14,7 @@ using sgp_host_t = sgpmode::SGPHost; using sgp_sym_t = sgpmode::SGPSymbiont; using tag_t = typename hw_spec_t::tag_t; -TEST_CASE("Test host SenseTask instruction after a rewarded task", "[sgp]"){ +TEST_CASE("Test host SenseTask instruction after a rewarded task", "[sgp] [LC]"){ sgpmode::SymConfigSGP config; config.CYCLES_PER_UPDATE(0); config.SEED(61); @@ -50,8 +50,8 @@ TEST_CASE("Test host SenseTask instruction after a rewarded task", "[sgp]"){ host_hw.SetProgram(host_program); world.AssignNewEnvIO(host_hw.GetCPUState()); - // NOT is currently rewarded. - REQUIRE(world.GetTaskEnv().GetHostTaskReq(not_task_id).task_value > 0); + // NOT is currently not rewarded. + REQUIRE(world.GetTaskEnv().GetHostTaskReq(not_task_id).task_value < 0); // Initial register values host_hw.SetRegisters({3, 2, 5}); @@ -59,13 +59,13 @@ TEST_CASE("Test host SenseTask instruction after a rewarded task", "[sgp]"){ // Run host program host_hw.RunCPUStep(4); - THEN("SenseTask puts a 1 into register 1"){ - REQUIRE(host_hw.GetRegister(1) == 1); + THEN("SenseTask puts a 0 into register 1"){ + REQUIRE(host_hw.GetRegister(1) == 0);//what should these values be } } } -TEST_CASE("Test host SenseTask instruction after a punished task", "[sgp]"){ +TEST_CASE("Test host SenseTask instruction after a punished task", "[sgp] [LC]"){ sgpmode::SymConfigSGP config; config.CYCLES_PER_UPDATE(0); config.SEED(61); @@ -101,8 +101,10 @@ TEST_CASE("Test host SenseTask instruction after a punished task", "[sgp]"){ host_hw.SetProgram(host_program); world.AssignNewEnvIO(host_hw.GetCPUState()); - // NAND is currently punished. - REQUIRE(world.GetTaskEnv().GetHostTaskReq(nand_task_id).task_value < 0); + // NAND is not currently punished. + REQUIRE(world.GetTaskEnv().GetHostTaskReq(nand_task_id).task_value > 0); + + // Initial register values host_hw.SetRegisters({7, 12, 9}); @@ -110,8 +112,8 @@ TEST_CASE("Test host SenseTask instruction after a punished task", "[sgp]"){ // Run host program host_hw.RunCPUStep(5); - THEN("SenseTask puts a 0 into register 1"){ - REQUIRE(host_hw.GetRegister(1) == 0); + THEN("SenseTask puts a 1 into register 1"){ + REQUIRE(host_hw.GetRegister(1) == 1); } } } @@ -150,7 +152,7 @@ TEST_CASE("Test symbiont SenseTask instruction after a rewarded task", "[sgp]"){ world.AssignNewEnvIO(sym_hw.GetCPUState()); // NOT is currently rewarded. - REQUIRE(world.GetTaskEnv().GetHostTaskReq(not_task_id).task_value > 0); + REQUIRE(world.GetTaskEnv().GetHostTaskReq(not_task_id).task_value < 0); // Initial register values sym_hw.SetRegisters({3, 2, 5}); @@ -158,8 +160,8 @@ TEST_CASE("Test symbiont SenseTask instruction after a rewarded task", "[sgp]"){ // Run symbiont program sym_hw.RunCPUStep(4); - THEN("SenseTask puts a 1 into register 1"){ - REQUIRE(sym_hw.GetRegister(1) == 1); + THEN("SenseTask puts a 0 into register 1"){ + REQUIRE(sym_hw.GetRegister(1) == 0); } } } @@ -199,7 +201,7 @@ TEST_CASE("Test symbiont SenseTask instruction after a punished task", "[sgp]"){ world.AssignNewEnvIO(sym_hw.GetCPUState()); // NAND is currently punished. - REQUIRE(world.GetTaskEnv().GetHostTaskReq(nand_task_id).task_value < 0); + REQUIRE(world.GetTaskEnv().GetHostTaskReq(nand_task_id).task_value > 0); // Initial register values sym_hw.SetRegisters({7, 12, 9}); @@ -207,8 +209,8 @@ TEST_CASE("Test symbiont SenseTask instruction after a punished task", "[sgp]"){ // run symbiont program sym_hw.RunCPUStep(5); - THEN("SenseTask puts a 0 into register 1"){ - REQUIRE(sym_hw.GetRegister(1) == 0); + THEN("SenseTask puts a 1 into register 1"){ + REQUIRE(sym_hw.GetRegister(1) == 1); } } } diff --git a/source/test/sgp_mode_test/functional_tests/TempChangingEnvironments.test.cc b/source/test/sgp_mode_test/functional_tests/TempChangingEnvironments.test.cc index 0930312a..10020a69 100644 --- a/source/test/sgp_mode_test/functional_tests/TempChangingEnvironments.test.cc +++ b/source/test/sgp_mode_test/functional_tests/TempChangingEnvironments.test.cc @@ -172,18 +172,18 @@ TEST_CASE("Hosts start with a punished task in a temporally changing environment world.Update(); size_t host_orn_count = world.GetHostTaskSuccesses().at(or_not_task_id); - THEN("The host initially loses points for completing its task") { + THEN("The host initially gains points for completing its task") { REQUIRE(host_orn_count == 1); - REQUIRE(host_orn_only->GetPoints() == -5); + REQUIRE(host_orn_only->GetPoints() == 5); } // event update world.Update(); host_orn_count += world.GetHostTaskSuccesses().at(or_not_task_id); - THEN("After the environment changes, the host gains points for completing its task") { + THEN("After the environment changes, the host loses points for completing its task") { REQUIRE(host_orn_count == 3); - REQUIRE(host_orn_only->GetPoints() == 5); + REQUIRE(host_orn_only->GetPoints() == -5); } } } @@ -230,18 +230,18 @@ TEST_CASE("Symbionts start with a punished task in a temporally changing environ world.Update(); size_t sym_nand_count = world.GetSymTaskSuccesses().at(nand_task_id); - THEN("The symbiont initially loses points for completing its task") { + THEN("The symbiont initially gains points for completing its task") { REQUIRE(sym_nand_count == 1); - REQUIRE(symbiont_nand_only->GetPoints() == -5); + REQUIRE(symbiont_nand_only->GetPoints() == 5); } // event update world.Update(); sym_nand_count += world.GetSymTaskSuccesses().at(nand_task_id); - THEN("After the environment changes, the symbiont gains points for completing its tasks") { + THEN("After the environment changes, the symbiont loses points for completing its tasks") { REQUIRE(sym_nand_count == 3); - REQUIRE(symbiont_nand_only->GetPoints() == 5); + REQUIRE(symbiont_nand_only->GetPoints() == -5); } } } From 2c92d81292797e43a1491c10a5e0eaa10616248f Mon Sep 17 00:00:00 2001 From: LaurenC267 Date: Fri, 10 Jul 2026 09:35:41 -0500 Subject: [PATCH 2/9] got rid of my name teehee --- .../sgp_mode_test/functional_tests/SenseTask_Tasks.test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/test/sgp_mode_test/functional_tests/SenseTask_Tasks.test.cc b/source/test/sgp_mode_test/functional_tests/SenseTask_Tasks.test.cc index cd9053ad..ee5980b9 100644 --- a/source/test/sgp_mode_test/functional_tests/SenseTask_Tasks.test.cc +++ b/source/test/sgp_mode_test/functional_tests/SenseTask_Tasks.test.cc @@ -14,7 +14,7 @@ using sgp_host_t = sgpmode::SGPHost; using sgp_sym_t = sgpmode::SGPSymbiont; using tag_t = typename hw_spec_t::tag_t; -TEST_CASE("Test host SenseTask instruction after a rewarded task", "[sgp] [LC]"){ +TEST_CASE("Test host SenseTask instruction after a rewarded task", "[sgp]"){ sgpmode::SymConfigSGP config; config.CYCLES_PER_UPDATE(0); config.SEED(61); @@ -65,7 +65,7 @@ TEST_CASE("Test host SenseTask instruction after a rewarded task", "[sgp] [LC]") } } -TEST_CASE("Test host SenseTask instruction after a punished task", "[sgp] [LC]"){ +TEST_CASE("Test host SenseTask instruction after a punished task", "[sgp]"){ sgpmode::SymConfigSGP config; config.CYCLES_PER_UPDATE(0); config.SEED(61); From 86fe2dcad3bf1621427abd652bcf69ff7374f0d4 Mon Sep 17 00:00:00 2001 From: LaurenC267 Date: Fri, 10 Jul 2026 13:43:48 -0500 Subject: [PATCH 3/9] fixed documentation --- source/sgp_mode/SGPWorldSetup.cc | 17 ++++++++--------- .../functional_tests/SenseTask_Tasks.test.cc | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/source/sgp_mode/SGPWorldSetup.cc b/source/sgp_mode/SGPWorldSetup.cc index 03456e87..17a035c3 100644 --- a/source/sgp_mode/SGPWorldSetup.cc +++ b/source/sgp_mode/SGPWorldSetup.cc @@ -129,7 +129,6 @@ void SGPWorld::SetupChangingEnvironment() { orn_task_id = task_env.GetTaskSet().GetID("or_not"); } - // grab task ids for NOT, AND, OR size_t not_task_id = task_env.GetTaskSet().GetSize(); if (task_env.GetTaskSet().HasTask("NOT")) { @@ -155,7 +154,7 @@ void SGPWorld::SetupChangingEnvironment() { or_task_id = task_env.GetTaskSet().GetID("or"); } - // update 0 will flip not-and-or to rewarded and nand-andn-orn to punished + // update 0 will flip nand-andn-orn to rewarded and not-and-or to punished GetTaskEnv().GetHostTaskReq(nand_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(nand_task_id).task_value; GetTaskEnv().GetSymTaskReq(nand_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(nand_task_id).task_value; @@ -169,22 +168,22 @@ void SGPWorld::SetupChangingEnvironment() { [this, nand_task_id, andn_task_id, orn_task_id, not_task_id, and_task_id, or_task_id]() { if (GetUpdate() % sgp_config.TEMP_CHANGING_ENVIRONMENT_INTERVAL() == 0) { - GetTaskEnv().GetHostTaskReq(not_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(not_task_id).task_value; - GetTaskEnv().GetHostTaskReq(and_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(and_task_id).task_value; - GetTaskEnv().GetHostTaskReq(or_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(or_task_id).task_value; - GetTaskEnv().GetHostTaskReq(nand_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(nand_task_id).task_value; GetTaskEnv().GetHostTaskReq(andn_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(andn_task_id).task_value; GetTaskEnv().GetHostTaskReq(orn_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(orn_task_id).task_value; - GetTaskEnv().GetSymTaskReq(not_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(not_task_id).task_value; - GetTaskEnv().GetSymTaskReq(and_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(and_task_id).task_value; - GetTaskEnv().GetSymTaskReq(or_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(or_task_id).task_value; + GetTaskEnv().GetHostTaskReq(not_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(not_task_id).task_value; + GetTaskEnv().GetHostTaskReq(and_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(and_task_id).task_value; + GetTaskEnv().GetHostTaskReq(or_task_id).task_value = -1 * GetTaskEnv().GetHostTaskReq(or_task_id).task_value; GetTaskEnv().GetSymTaskReq(nand_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(nand_task_id).task_value; GetTaskEnv().GetSymTaskReq(andn_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(andn_task_id).task_value; GetTaskEnv().GetSymTaskReq(orn_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(orn_task_id).task_value; + GetTaskEnv().GetSymTaskReq(not_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(not_task_id).task_value; + GetTaskEnv().GetSymTaskReq(and_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(and_task_id).task_value; + GetTaskEnv().GetSymTaskReq(or_task_id).task_value = -1 * GetTaskEnv().GetSymTaskReq(or_task_id).task_value; + } } diff --git a/source/test/sgp_mode_test/functional_tests/SenseTask_Tasks.test.cc b/source/test/sgp_mode_test/functional_tests/SenseTask_Tasks.test.cc index ee5980b9..83c9c058 100644 --- a/source/test/sgp_mode_test/functional_tests/SenseTask_Tasks.test.cc +++ b/source/test/sgp_mode_test/functional_tests/SenseTask_Tasks.test.cc @@ -60,7 +60,7 @@ TEST_CASE("Test host SenseTask instruction after a rewarded task", "[sgp]"){ host_hw.RunCPUStep(4); THEN("SenseTask puts a 0 into register 1"){ - REQUIRE(host_hw.GetRegister(1) == 0);//what should these values be + REQUIRE(host_hw.GetRegister(1) == 0); } } } From f54a1b1e4ef1774721b55d4078a899422923f663 Mon Sep 17 00:00:00 2001 From: LaurenC267 Date: Wed, 15 Jul 2026 11:57:50 -0500 Subject: [PATCH 4/9] no negative --- source/sgp_mode/SGPHost.h | 9 +++++++++ source/sgp_mode/SGPSymbiont.h | 14 +++++++++---- .../sgp_mode_test/unit_tests/SGPHost.test.cc | 20 +++++++++++++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/source/sgp_mode/SGPHost.h b/source/sgp_mode/SGPHost.h index a18ae924..f6a16ec2 100644 --- a/source/sgp_mode/SGPHost.h +++ b/source/sgp_mode/SGPHost.h @@ -179,9 +179,18 @@ class SGPHost : public Host { void DecPoints(double amt) { points -= amt; + + if (points < 0){ + points = 0; + } } void AddPoints(double amt) { points += amt; + if (points < 0){ + points = 0; + } + + } size_t matching_syms_to_interact_with = 0; diff --git a/source/sgp_mode/SGPSymbiont.h b/source/sgp_mode/SGPSymbiont.h index 4ad1bdcf..16ae0327 100644 --- a/source/sgp_mode/SGPSymbiont.h +++ b/source/sgp_mode/SGPSymbiont.h @@ -190,12 +190,18 @@ class SGPSymbiont : public Symbiont { } - void AddPoints(double _in) { - points += _in; - } - void DecPoints(double amt) { points -= amt; + + if (points < 0){ + points = 0; + } + } + void AddPoints(double amt) { + points += amt; + if (points < 0){ + points = 0; + } } /** diff --git a/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc b/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc index 94cbec5f..f12227b7 100644 --- a/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc +++ b/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc @@ -251,4 +251,24 @@ TEST_CASE("ProcessOutputBuffer", "[sgp][sgp-unit]"){ } } } +} + +TEST_CASE("debt", "[sgp][sgp-unit] [LC]"){ + GIVEN("A zero point value"){ + emp::Random random(31); + sgpmode::SymConfigSGP config; + config.TASK_ENV_CFG_PATH("source/test/sgp_mode_test/hardware-test-env.json"); + world_t world(random, &config); + auto& prog_builder = world.GetProgramBuilder(); + emp::Ptr host = emp::NewPtr(&random, &world, &config, prog_builder.CreateNotProgram(100)); + + WHEN("points are added to make total points negative"){ + //call function that should reset points + host->AddPoints(-100); + + THEN("point value should be set to zero"){ + REQUIRE(host->GetPoints() == 0); + } + } + } } \ No newline at end of file From e23ea47bee47157282921d2a03b7e60fe6aed0b4 Mon Sep 17 00:00:00 2001 From: LaurenC267 Date: Wed, 15 Jul 2026 13:09:55 -0500 Subject: [PATCH 5/9] no more generational debt --- source/sgp_mode/SGPHost.h | 2 ++ source/sgp_mode/SGPSymbiont.h | 2 ++ .../TempChangingEnvironments.test.cc | 4 ++-- .../sgp_mode_test/unit_tests/SGPHost.test.cc | 20 +------------------ 4 files changed, 7 insertions(+), 21 deletions(-) diff --git a/source/sgp_mode/SGPHost.h b/source/sgp_mode/SGPHost.h index c52f716a..902b54a0 100644 --- a/source/sgp_mode/SGPHost.h +++ b/source/sgp_mode/SGPHost.h @@ -183,8 +183,10 @@ class SGPHost : public Host { points = 0; } } + void AddPoints(double amt) { points += amt; + if (points < 0){ points = 0; } diff --git a/source/sgp_mode/SGPSymbiont.h b/source/sgp_mode/SGPSymbiont.h index ae2dfd71..18668c34 100644 --- a/source/sgp_mode/SGPSymbiont.h +++ b/source/sgp_mode/SGPSymbiont.h @@ -197,8 +197,10 @@ class SGPSymbiont : public Symbiont { points = 0; } } + void AddPoints(double amt) { points += amt; + if (points < 0){ points = 0; } diff --git a/source/test/sgp_mode_test/functional_tests/TempChangingEnvironments.test.cc b/source/test/sgp_mode_test/functional_tests/TempChangingEnvironments.test.cc index 6f02bb3b..6bbf8fb4 100644 --- a/source/test/sgp_mode_test/functional_tests/TempChangingEnvironments.test.cc +++ b/source/test/sgp_mode_test/functional_tests/TempChangingEnvironments.test.cc @@ -185,7 +185,7 @@ TEST_CASE("Hosts start with a punished task in a temporally changing environment THEN("After the environment changes, the host loses points for completing its task") { REQUIRE(host_orn_count == 3); - REQUIRE(host_orn_only->GetPoints() == -5); + REQUIRE(host_orn_only->GetPoints() == 0); } } } @@ -242,7 +242,7 @@ TEST_CASE("Symbionts start with a punished task in a temporally changing environ THEN("After the environment changes, the symbiont loses points for completing its tasks") { REQUIRE(sym_nand_count == 3); - REQUIRE(symbiont_nand_only->GetPoints() == -5); + REQUIRE(symbiont_nand_only->GetPoints() == 0); } } } diff --git a/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc b/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc index 6247fb9f..45b1257b 100644 --- a/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc +++ b/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc @@ -282,24 +282,6 @@ TEST_CASE("ProcessOutputBuffer", "[sgp][sgp-unit]") { } } } +} -TEST_CASE("debt", "[sgp][sgp-unit] [LC]"){ - GIVEN("A zero point value"){ - emp::Random random(31); - sgpmode::SymConfigSGP config; - config.TASK_ENV_CFG_PATH("source/test/sgp_mode_test/hardware-test-env.json"); - world_t world(random, &config); - auto& prog_builder = world.GetProgramBuilder(); - emp::Ptr host = emp::NewPtr(&random, &world, &config, prog_builder.CreateNotProgram(100)); - - WHEN("points are added to make total points negative"){ - //call function that should reset points - host->AddPoints(-100); - - THEN("point value should be set to zero"){ - REQUIRE(host->GetPoints() == 0); - } - } - } -} \ No newline at end of file From b1f3ed03391b4a0d2321f5ae15f791de1612ba00 Mon Sep 17 00:00:00 2001 From: LaurenC267 Date: Wed, 15 Jul 2026 13:17:51 -0500 Subject: [PATCH 6/9] test for checking that hosts not going into debt --- .../sgp_mode_test/unit_tests/SGPHost.test.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc b/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc index 45b1257b..cdf4d70c 100644 --- a/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc +++ b/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc @@ -285,3 +285,22 @@ TEST_CASE("ProcessOutputBuffer", "[sgp][sgp-unit]") { } +TEST_CASE("debt", "[sgp][sgp-unit]"){ + GIVEN("A zero point value"){ + emp::Random random(31); + sgpmode::SymConfigSGP config; + config.TASK_ENV_CFG_PATH("source/test/sgp_mode_test/hardware-test-env.json"); + world_t world(random, &config); + auto& prog_builder = world.GetProgramBuilder(); + emp::Ptr host = emp::NewPtr(&random, &world, &config, prog_builder.CreateNotProgram(100)); + + WHEN("points are added to make total points negative"){ + //call function that should reset points + host->AddPoints(-100); + + THEN("point value should be set to zero"){ + REQUIRE(host->GetPoints() == 0); + } + } + } +} \ No newline at end of file From 15cf4acbc65f5ad73f41f7cbf698ec1977ad87a8 Mon Sep 17 00:00:00 2001 From: LaurenC267 Date: Wed, 15 Jul 2026 13:19:12 -0500 Subject: [PATCH 7/9] documentation fix --- source/test/sgp_mode_test/unit_tests/SGPHost.test.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc b/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc index cdf4d70c..9d6736bd 100644 --- a/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc +++ b/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc @@ -295,9 +295,7 @@ TEST_CASE("debt", "[sgp][sgp-unit]"){ emp::Ptr host = emp::NewPtr(&random, &world, &config, prog_builder.CreateNotProgram(100)); WHEN("points are added to make total points negative"){ - //call function that should reset points - host->AddPoints(-100); - + host->AddPoints(-100); THEN("point value should be set to zero"){ REQUIRE(host->GetPoints() == 0); } From 6e4cc9ea85eebc88b88f12122a7c2dfbba4550b4 Mon Sep 17 00:00:00 2001 From: LaurenC267 Date: Wed, 15 Jul 2026 13:23:22 -0500 Subject: [PATCH 8/9] documentation --- .../sgp_mode_test/unit_tests/SGPHost.test.cc | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc b/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc index 9d6736bd..d1794e7c 100644 --- a/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc +++ b/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc @@ -286,19 +286,23 @@ TEST_CASE("ProcessOutputBuffer", "[sgp][sgp-unit]") { TEST_CASE("debt", "[sgp][sgp-unit]"){ - GIVEN("A zero point value"){ - emp::Random random(31); - sgpmode::SymConfigSGP config; - config.TASK_ENV_CFG_PATH("source/test/sgp_mode_test/hardware-test-env.json"); - world_t world(random, &config); - auto& prog_builder = world.GetProgramBuilder(); - emp::Ptr host = emp::NewPtr(&random, &world, &config, prog_builder.CreateNotProgram(100)); - - WHEN("points are added to make total points negative"){ - host->AddPoints(-100); - THEN("point value should be set to zero"){ - REQUIRE(host->GetPoints() == 0); - } - } + using world_t = sgpmode::SGPWorld; + using cpu_state_t = sgpmode::CPUState; + using hw_spec_t = sgpmode::SGPHardwareSpec; + using sgp_host_t = sgpmode::SGPHost; + GIVEN("A zero point value"){ + emp::Random random(31); + sgpmode::SymConfigSGP config; + config.TASK_ENV_CFG_PATH("source/test/sgp_mode_test/hardware-test-env.json"); + world_t world(random, &config); + auto& prog_builder = world.GetProgramBuilder(); + emp::Ptr host = emp::NewPtr(&random, &world, &config, prog_builder.CreateNotProgram(100)); + + WHEN("points are added to make total points negative"){ + host->AddPoints(-100); + THEN("point value should be set to zero"){ + REQUIRE(host->GetPoints() == 0); + } } + } } \ No newline at end of file From db5544d2813fc900d5aebe48a8b078a93354e669 Mon Sep 17 00:00:00 2001 From: LaurenC267 Date: Wed, 15 Jul 2026 15:24:51 -0500 Subject: [PATCH 9/9] some changes --- .../TempChangingEnvironments.test.cc | 24 +++++++++---------- .../sgp_mode_test/unit_tests/SGPHost.test.cc | 10 +++++--- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/source/test/sgp_mode_test/functional_tests/TempChangingEnvironments.test.cc b/source/test/sgp_mode_test/functional_tests/TempChangingEnvironments.test.cc index 6bbf8fb4..61f15bb7 100644 --- a/source/test/sgp_mode_test/functional_tests/TempChangingEnvironments.test.cc +++ b/source/test/sgp_mode_test/functional_tests/TempChangingEnvironments.test.cc @@ -26,7 +26,7 @@ using sgp_host_t = sgpmode::SGPHost; using sgp_sym_t = sgpmode::SGPSymbiont; using program_t = typename world_t::sgp_prog_t; -TEST_CASE("Hosts start with a rewarded task in a temporally changing environment"){ +TEST_CASE("Hosts start with a poisoned task in a temporally changing environment","[sgp]"){ // set up configs sgpmode::SymConfigSGP config; config.TASK_ENV_CFG_PATH("source/test/sgp_mode_test/hardware-test-env.json"); @@ -64,23 +64,23 @@ TEST_CASE("Hosts start with a rewarded task in a temporally changing environment world.Update(); size_t host_not_count = world.GetHostTaskSuccesses().at(not_task_id); - THEN("The host initially gains points for completing its task") { + THEN("The host initially gains loses for completing its task") { REQUIRE(host_not_count == 1); - REQUIRE(host_not_only->GetPoints() == 5); + REQUIRE(host_not_only->GetPoints() == 0); } // event update world.Update(); host_not_count += world.GetHostTaskSuccesses().at(not_task_id); - THEN("After the environment changes, the host loses points for completing its task") { + THEN("After the environment changes, the host gains points for completing its task") { REQUIRE(host_not_count == 2); - REQUIRE(host_not_only->GetPoints() == 0); + REQUIRE(host_not_only->GetPoints() == 5); } } } -TEST_CASE("Symbionts start with a rewarded task in a temporally changing environment"){ +TEST_CASE("Symbionts start with a poisoned task in a temporally changing environment", "[sgp]"){ // set up configs sgpmode::SymConfigSGP config; config.TASK_ENV_CFG_PATH("source/test/sgp_mode_test/hardware-test-env.json"); @@ -120,23 +120,23 @@ TEST_CASE("Symbionts start with a rewarded task in a temporally changing environ world.Update(); size_t sym_not_count = world.GetSymTaskSuccesses().at(not_task_id); - THEN("The symbiont initially gains points for completing its task") { + THEN("The symbiont initially loses points for completing its task") { REQUIRE(sym_not_count == 1); - REQUIRE(symbiont_not_only->GetPoints() == 5); + REQUIRE(symbiont_not_only->GetPoints() == 0); } // event update world.Update(); sym_not_count += world.GetSymTaskSuccesses().at(not_task_id); - THEN("After the environment changes, the symbiont loses points for completing its task") { + THEN("After the environment changes, the symbiont gains points for completing its task") { REQUIRE(sym_not_count == 2); - REQUIRE(symbiont_not_only->GetPoints() == 0); + REQUIRE(symbiont_not_only->GetPoints() == 5); } } } -TEST_CASE("Hosts start with a punished task in a temporally changing environment", "[sgp]") { +TEST_CASE("Hosts start with a rewarded task in a temporally changing environment", "[sgp]") { // set up configs sgpmode::SymConfigSGP config; config.TASK_ENV_CFG_PATH("source/test/sgp_mode_test/hardware-test-env.json"); @@ -191,7 +191,7 @@ TEST_CASE("Hosts start with a punished task in a temporally changing environment } -TEST_CASE("Symbionts start with a punished task in a temporally changing environment", "[sgp]") { +TEST_CASE("Symbionts start with a rewarded task in a temporally changing environment", "[sgp]") { // set up configs sgpmode::SymConfigSGP config; config.TASK_ENV_CFG_PATH("source/test/sgp_mode_test/hardware-test-env.json"); diff --git a/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc b/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc index d1794e7c..79401dca 100644 --- a/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc +++ b/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc @@ -285,23 +285,27 @@ TEST_CASE("ProcessOutputBuffer", "[sgp][sgp-unit]") { } -TEST_CASE("debt", "[sgp][sgp-unit]"){ +TEST_CASE("Check that hosts and syms can't have negative points", "[sgp][sgp-unit]"){ using world_t = sgpmode::SGPWorld; using cpu_state_t = sgpmode::CPUState; using hw_spec_t = sgpmode::SGPHardwareSpec; using sgp_host_t = sgpmode::SGPHost; - GIVEN("A zero point value"){ + using sgp_sym_t = sgpmode::SGPSymbiont; + GIVEN("A host and sym starting with zero points"){ emp::Random random(31); sgpmode::SymConfigSGP config; config.TASK_ENV_CFG_PATH("source/test/sgp_mode_test/hardware-test-env.json"); world_t world(random, &config); auto& prog_builder = world.GetProgramBuilder(); - emp::Ptr host = emp::NewPtr(&random, &world, &config, prog_builder.CreateNotProgram(100)); + emp::Ptr host = emp::NewPtr(&random, &world, &config, prog_builder.CreateReproProgram(100)); + emp::Ptr sym = emp::NewPtr(&random, &world, &config, prog_builder.CreateNotProgram(100)); WHEN("points are added to make total points negative"){ + sym->AddPoints(-100); host->AddPoints(-100); THEN("point value should be set to zero"){ REQUIRE(host->GetPoints() == 0); + REQUIRE(sym->GetPoints() == 0); } } }