Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into complex-syms-clean
  • Loading branch information
K-Johnson-Horrigan committed Nov 4, 2024
2 parents 133442a + e776925 commit f8eb1f4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
3 changes: 2 additions & 1 deletion source/default_mode/Host.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ class Host: public Organism {
int AddSymbiont(emp::Ptr<Organism> _in) {
bool allowed_in = SymAllowedIn();
if (my_config->OUSTING() && allowed_in && (int)syms.size() == my_config->SYM_LIMIT()) {
int new_sym_pos = (syms.size() > 1) ? random->GetInt(syms.size()) : syms.size()-1;
// if there's more than one sym, randomly choose one to replace, otherwise replace the one sym
const int new_sym_pos = (syms.size() > 1) ? random->GetInt(syms.size()) : 0;
emp::Ptr<Organism> old_sym = syms[new_sym_pos];
my_world->SendToGraveyard(old_sym);
syms[new_sym_pos] = _in;
Expand Down
3 changes: 2 additions & 1 deletion source/default_mode/SymWorld.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class SymWorld : public emp::World<Organism>{

public:
/**
* Input: The world's random seed
* Input: The world's random seed and a pointer to this world's config object
*
* Output: None
*
Expand Down Expand Up @@ -192,6 +192,7 @@ class SymWorld : public emp::World<Organism>{
const emp::Ptr<SymConfigBase> GetConfig() const { return my_config; }



/**
* Input: None
*
Expand Down
3 changes: 2 additions & 1 deletion source/pgg_mode/PGGSymbiont.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ class PGGSymbiont: public Symbiont {

public:
PGGSymbiont(emp::Ptr<emp::Random> _random, emp::Ptr<PGGWorld> _world, emp::Ptr<SymConfigPGG> _config, double _intval = 0.0, double _donation = 0.0, double _points = 0.0) : Symbiont(_random, _world, _config, _intval, _points), PGG_donate(_donation) {
pgg_config = _config;
pgg_config = _config;
my_world = _world;
}


/**
* Input: None
*
Expand Down
2 changes: 1 addition & 1 deletion source/test/default_mode_test/SymWorld.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1663,4 +1663,4 @@ TEST_CASE("SendToGraveyard", "[default]") {
}
host.Delete();
}
}
}
26 changes: 13 additions & 13 deletions source/test/default_mode_test/Symbiont.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

TEST_CASE("Symbiont Constructor", "[default]") {

emp::Ptr<emp::Random> random = new emp::Random(-1);
emp::Ptr<emp::Random> random = emp::NewPtr<emp::Random>(10);
SymConfigBase config;
SymWorld w(*random, &config);
SymWorld * world = &w;
Expand Down Expand Up @@ -54,7 +54,7 @@ TEST_CASE("Symbiont Constructor", "[default]") {

TEST_CASE("SetIntVal, GetIntVal", "[default]") {

emp::Ptr<emp::Random> random = new emp::Random(-1);
emp::Ptr<emp::Random> random = emp::NewPtr<emp::Random>(10);
SymConfigBase config;
SymWorld w(*random, &config);
SymWorld * world = &w;
Expand Down Expand Up @@ -97,7 +97,7 @@ TEST_CASE("SetIntVal, GetIntVal", "[default]") {

TEST_CASE("SetInfectionChance, GetInfectionChance", "[default]") {

emp::Ptr<emp::Random> random = new emp::Random(-1);
emp::Ptr<emp::Random> random = emp::NewPtr<emp::Random>(10);
SymConfigBase config;
SymWorld w(*random, &config);
SymWorld * world = &w;
Expand All @@ -124,7 +124,7 @@ TEST_CASE("SetInfectionChance, GetInfectionChance", "[default]") {

TEST_CASE("SetPoints, GetPoints", "[default]") {

emp::Ptr<emp::Random> random = new emp::Random(-1);
emp::Ptr<emp::Random> random = emp::NewPtr<emp::Random>(10);
SymConfigBase config;
SymWorld w(*random, &config);
SymWorld * world = &w;
Expand Down Expand Up @@ -154,7 +154,7 @@ TEST_CASE("SetPoints, GetPoints", "[default]") {
}

TEST_CASE("Symbiont SetDead, GetDead", "[default]"){
emp::Ptr<emp::Random> random = new emp::Random(-1);
emp::Ptr<emp::Random> random = emp::NewPtr<emp::Random>(10);
SymConfigBase config;
SymWorld w(*random, &config);
SymWorld * world = &w;
Expand All @@ -175,7 +175,7 @@ TEST_CASE("Symbiont SetDead, GetDead", "[default]"){
}

TEST_CASE("WantsToInfect", "[default]"){
emp::Ptr<emp::Random> random = new emp::Random(17);
emp::Ptr<emp::Random> random = emp::NewPtr<emp::Random>(17);
SymConfigBase config;
SymWorld w(*random, &config);
SymWorld * world = &w;
Expand Down Expand Up @@ -211,7 +211,7 @@ TEST_CASE("WantsToInfect", "[default]"){
}

TEST_CASE("InfectionFails", "[default]"){
emp::Ptr<emp::Random> random = new emp::Random(17);
emp::Ptr<emp::Random> random = emp::NewPtr<emp::Random>(17);
SymConfigBase config;
SymWorld w(*random, &config);
SymWorld * world = &w;
Expand Down Expand Up @@ -273,7 +273,7 @@ TEST_CASE("InfectionFails", "[default]"){

TEST_CASE("mutate", "[default]") {

emp::Ptr<emp::Random> random = new emp::Random(37);
emp::Ptr<emp::Random> random = emp::NewPtr<emp::Random>(37);
SymConfigBase config;
SymWorld w(*random, &config);
SymWorld * world = &w;
Expand Down Expand Up @@ -339,7 +339,7 @@ TEST_CASE("mutate", "[default]") {

TEST_CASE("reproduce", "[default]") {

emp::Ptr<emp::Random> random = new emp::Random(3);
emp::Ptr<emp::Random> random = emp::NewPtr<emp::Random>(3);
SymConfigBase config;
SymWorld w(*random, &config);
SymWorld * world = &w;
Expand Down Expand Up @@ -439,7 +439,7 @@ TEST_CASE("reproduce", "[default]") {

TEST_CASE("Process", "[default]") {

emp::Ptr<emp::Random> random = new emp::Random(-1);
emp::Ptr<emp::Random> random = emp::NewPtr<emp::Random>(10);
SymConfigBase config;
SymWorld w(*random, &config);
SymWorld * world = &w;
Expand Down Expand Up @@ -611,7 +611,7 @@ TEST_CASE("Process", "[default]") {
}

TEST_CASE("Symbiont ProcessResources", "[default]"){
emp::Ptr<emp::Random> random = new emp::Random(-1);
emp::Ptr<emp::Random> random = emp::NewPtr<emp::Random>(10);
SymConfigBase config;
SymWorld w(*random, &config);
SymWorld * world = &w;
Expand Down Expand Up @@ -708,7 +708,7 @@ TEST_CASE("Symbiont ProcessResources", "[default]"){
}

TEST_CASE("Symbiont GrowOlder", "[default]"){
emp::Ptr<emp::Random> random = new emp::Random(-1);
emp::Ptr<emp::Random> random = emp::NewPtr<emp::Random>(10);
SymConfigBase config;
SymWorld world(*random, &config);
world.Resize(2,2);
Expand Down Expand Up @@ -751,7 +751,7 @@ TEST_CASE("Symbiont GrowOlder", "[default]"){
}

TEST_CASE("Symbiont MakeNew", "[default]"){
emp::Ptr<emp::Random> random = new emp::Random(-1);
emp::Ptr<emp::Random> random = emp::NewPtr<emp::Random>(10);
SymConfigBase config;
SymWorld world(*random, &config);

Expand Down

0 comments on commit f8eb1f4

Please sign in to comment.