Skip to content

Commit 7eed5d2

Browse files
reinstating the interaction_check update and updating some test configs to work with new code
1 parent dc31ea7 commit 7eed5d2

4 files changed

Lines changed: 15 additions & 26 deletions

File tree

source/sgp_mode/SGPHost.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -604,9 +604,7 @@ class SGPHost : public Host {
604604

605605
emp::Ptr<sgp_sym_t> cur_symbiont = static_cast<sgp_sym_t*>(syms[endosym_i].Raw());
606606

607-
const emp::BitVector& endosym_task_profile = my_world->GetSymTaskProfile(*cur_symbiont);
608-
const emp::BitVector& host_task_profile = my_world->GetHostTaskProfile(*this);
609-
bool is_matching = my_world->TaskProfileCompatibilityCheck(host_task_profile,endosym_task_profile);
607+
bool is_matching = my_world->GetInteractionCompatibility(*this,*cur_symbiont);
610608
matching_syms_to_interact_with += is_matching;
611609

612610
}

source/sgp_mode/SGPW_InteractionMechanismSetup.cc

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace sgpmode {
1111
// These are defined in SGPW_TaskProfileSetup
1212
SetupTaskProfileMode();
1313
SetupTaskProfileCompatibilityMode();
14+
SetupInteractionCompatibilityMode();
1415
SetupHorizontalTransmissionCompatibilityMode();
1516

1617
SetupFindHostForHorizontalTransmission();
@@ -79,10 +80,7 @@ namespace sgpmode {
7980
if (sym.GetDead()) { return; }
8081
// Will sym donate?
8182
bool interact = random_ptr->P(sgp_config.HEALTH_INTERACTION_CHANCE());
82-
83-
const auto& host_task_profile = fun_get_host_task_profile(host);
84-
const auto& sym_task_profile = fun_get_sym_task_profile(sym);
85-
interact = interact && fun_task_profile_compatibility_check(host_task_profile, sym_task_profile);
83+
interact = interact && fun_interaction_compatibility_check(host, sym);
8684

8785
const double donate_prop = sgp_config.MUTUALIST_CYCLE_GAIN_PROP();
8886
emp_assert(donate_prop <= 1.0 && donate_prop >= 0.0);
@@ -122,9 +120,7 @@ namespace sgpmode {
122120
auto& host_state = host.GetHardware().GetCPUState();
123121
// Will sym steal?
124122
bool interact = random_ptr->P(sgp_config.HEALTH_INTERACTION_CHANCE());
125-
const auto& host_task_profile = fun_get_host_task_profile(host);
126-
const auto& sym_task_profile = fun_get_sym_task_profile(sym);
127-
interact = interact && fun_task_profile_compatibility_check(host_task_profile, sym_task_profile);
123+
interact = interact && fun_interaction_compatibility_check(host, sym);
128124

129125
const double steal_prop = sgp_config.PARASITE_CYCLE_LOSS_PROP();
130126
emp_assert(steal_prop <= 1.0 && steal_prop >= 0.0);
@@ -162,9 +158,7 @@ namespace sgpmode {
162158
auto& host_state = host.GetHardware().GetCPUState();
163159
// Will host and symbiont interact?
164160
bool interact = random_ptr->P(sgp_config.HEALTH_INTERACTION_CHANCE());
165-
const auto& host_task_profile = fun_get_host_task_profile(host);
166-
const auto& sym_task_profile = fun_get_sym_task_profile(sym);
167-
interact = interact && fun_task_profile_compatibility_check(host_task_profile, sym_task_profile);
161+
interact = interact && fun_interaction_compatibility_check(host, sym);
168162
const double sym_interaction_value = sym.GetIntVal();
169163
emp_assert(sym_interaction_value >= -1.0);
170164
emp_assert(sym_interaction_value <= 1.0 );
@@ -240,7 +234,6 @@ namespace sgpmode {
240234
if (!stress_extinction_update) return;
241235
// If host has a mutualist symbiont with a matching task profile, death_chance = mutualist death chance
242236
// Otherwise, base death chance.
243-
const emp::BitVector& host_task_profile = fun_get_host_task_profile(host);
244237
bool interact = false;
245238
auto& endosymbionts = host.GetSymbionts();
246239
for (size_t sym_i = 0; sym_i < endosymbionts.size(); ++sym_i) {
@@ -250,7 +243,7 @@ namespace sgpmode {
250243
// host_task_profile,
251244
// fun_get_sym_task_profile(*endosym_ptr)
252245
// );
253-
interact = fun_task_profile_compatibility_check(host_task_profile, fun_get_sym_task_profile(*endosym_ptr));
246+
interact = fun_interaction_compatibility_check(host, *endosym_ptr);
254247
if (interact) {
255248
break;
256249
}
@@ -275,12 +268,11 @@ namespace sgpmode {
275268
// Otherwise, base death chance.
276269
double death_chance = sgp_config.BASE_DEATH_CHANCE();
277270
auto& endosymbionts = host.GetSymbionts();
278-
const emp::BitVector& host_task_profile = fun_get_host_task_profile(host);
279271
for (size_t sym_i = 0; sym_i < endosymbionts.size(); ++sym_i) {
280272
// Check if symbiont matches task profile
281273
emp::Ptr<sgp_sym_t> endosym_ptr = static_cast<sgp_sym_t*>(endosymbionts[sym_i].Raw());
282274
const emp::BitVector& endosym_task_profile = fun_get_sym_task_profile(*endosym_ptr);
283-
const bool can_escape = fun_task_profile_compatibility_check(host_task_profile, fun_get_sym_task_profile(*endosym_ptr));
275+
const bool can_escape = fun_interaction_compatibility_check(host, *endosym_ptr);
284276
if (can_escape) {
285277
death_chance = sgp_config.PARASITE_DEATH_CHANCE();
286278
// Endosymbiont gets opportunity to horizontally transmit
@@ -320,7 +312,7 @@ namespace sgpmode {
320312
for (size_t sym_i = 0; sym_i < endosymbionts.size(); ++sym_i) {
321313
// Check if symbiont matches task profile
322314
emp::Ptr<sgp_sym_t> endosym_ptr = static_cast<sgp_sym_t*>(endosymbionts[sym_i].Raw());
323-
const bool can_escape = fun_task_profile_compatibility_check(host_task_profile, fun_get_sym_task_profile(*endosym_ptr));
315+
const bool can_escape = fun_interaction_compatibility_check(host, *endosym_ptr);
324316
if (can_escape) {
325317
death_chance = sgp_config.PARASITE_DEATH_CHANCE();
326318
escapee_ids.emplace_back(sym_i);
@@ -364,17 +356,16 @@ namespace sgpmode {
364356
before_host_cpu_exec_sig.AddAction(
365357
[this](sgp_host_t& host) {
366358
if (!stress_extinction_update) return;
367-
const emp::BitVector& host_task_profile = fun_get_host_task_profile(host);
368359
emp::vector<size_t> escapee_ids; // Any parasite escapees?
369360
bool interact = false;
370361
double endosym_interaction_value = 0.0;
371362
auto& endosymbionts = host.GetSymbionts();
372363
for (size_t sym_i = 0; sym_i < endosymbionts.size(); ++sym_i) {
373364
// Check if symbiont matches task profile
374365
emp::Ptr<sgp_sym_t> endosym_ptr = static_cast<sgp_sym_t*>(endosymbionts[sym_i].Raw());
375-
interact = fun_task_profile_compatibility_check(
376-
host_task_profile,
377-
fun_get_sym_task_profile(*endosym_ptr)
366+
interact = fun_interaction_compatibility_check(
367+
host,
368+
*endosym_ptr
378369
);
379370
if (interact) {
380371
endosym_interaction_value = endosym_ptr->GetIntVal();

source/test/sgp_mode_test/functional_tests/HealthMode.test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void ConfigureHealthTestConfig(sgpmode::SymConfigSGP& config) {
4848

4949
// general sgp settings
5050
config.TASK_ENV_CFG_PATH("source/test/sgp_mode_test/hardware-test-env.json");
51-
config.TASK_PROFILE_COMPATIBILITY_MODE("task-any-match");
51+
config.INTERACTION_PROFILE_COMPATIBILITY_MODE("task-any-match");
5252
config.TASK_PROFILE_MODE("self-all");
5353
config.CYCLES_PER_UPDATE(4);
5454
config.TASK_IO_BANK_SIZE(10);

source/test/sgp_mode_test/functional_tests/TagMatching.test.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ TEST_CASE("SGP Tag Matching for organism interaction compatibility", "[sgp]"){
2727
config.TASK_ENV_CFG_PATH("source/test/sgp_mode_test/hardware-test-env.json");
2828
config.FILE_PATH("TempChangingEnv_test_output");
2929
config.SEED(89);
30-
config.POP_SIZE(0);
31-
config.GRID_X(2);
32-
config.GRID_Y(2);
30+
config.INIT_POP_SIZE(0);
31+
config.WORLD_WIDTH(2);
32+
config.WORLD_HEIGHT(2);
3333
config.CYCLES_PER_UPDATE(4);
3434
config.TAG_MATCHING(1);
3535
config.INTERACTION_PROFILE_COMPATIBILITY_MODE("tag-probabilistic-match");

0 commit comments

Comments
 (0)