Skip to content

Commit

Permalink
health host has ousting code and sgpworld setup makes health hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
anyaevostinar committed Sep 26, 2024
1 parent 12ef45b commit 103db2b
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 798 deletions.
7 changes: 0 additions & 7 deletions source/default_mode/Host.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,13 +439,6 @@ class Host: public Organism {
* Purpose: To add a symbionts to a host's symbionts
*/
int AddSymbiont(emp::Ptr<Organism> _in) {
// Ousting code:
if((int)syms.size() >= my_config->SYM_LIMIT()){
emp::Ptr<Organism> last_sym = syms.back();
syms.pop_back();
last_sym->SetDead();
}

if((int)syms.size() < my_config->SYM_LIMIT() && SymAllowedIn()){
syms.push_back(_in);
_in->SetHost(this);
Expand Down
26 changes: 25 additions & 1 deletion source/sgp_mode/HealthHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,38 @@ class HealthHost : public SGPHost {
*
* Purpose: To avoid creating an organism via constructor in other methods.
*/
emp::Ptr<Organism> MakeNew() {
emp::Ptr<Organism> MakeNew() override {
emp::Ptr<SGPHost> host_baby = emp::NewPtr<HealthHost>(
random, GetWorld(), my_config, GetCPU().GetProgram(), GetIntVal());
// This organism is reproducing, so it must have gotten off the queue
GetCPU().state.in_progress_repro = -1;
return host_baby;
}

//TODO: this is just copied from host for the purpose of getting the tests back to passing
//Ousting should probably be a config option in Host since ousting is a useful thing
int AddSymbiont(emp::Ptr<Organism> _in) override {

// Ousting code:
if((int)syms.size() >= my_config->SYM_LIMIT()){
emp::Ptr<Organism> last_sym = syms.back();
syms.pop_back();
last_sym->SetDead(); //TODO: this isn't ever cleaned up?
}//end ousting code

if((int)syms.size() < my_config->SYM_LIMIT() && SymAllowedIn()){
syms.push_back(_in);
_in->SetHost(this);
_in->UponInjection();
return syms.size();
} else {
_in.Delete();
return 0;
}
}



/**
* Input: The location of the host.
*
Expand Down
4 changes: 3 additions & 1 deletion source/sgp_mode/SGPWorldSetup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@

#include "../ConfigSetup.h"
#include "SGPHost.h"
#include "HealthHost.h"
#include "SGPSymbiont.h"
#include "SGPWorld.h"

void SGPWorld::SetupHosts(unsigned long *POP_SIZE) {
for (size_t i = 0; i < *POP_SIZE; i++) {
emp::Ptr<SGPHost> new_org = emp::NewPtr<SGPHost>(
//TODO: make a config option to decide which type of host to create?
emp::Ptr<HealthHost> new_org = emp::NewPtr<HealthHost>(
&GetRandom(), this, my_config, CreatePrivateNotProgram(100), my_config->HOST_INT());
if(my_config->START_MOI()==1){
emp::Ptr<SGPSymbiont> new_sym = emp::NewPtr<SGPSymbiont>(
Expand Down
124 changes: 0 additions & 124 deletions source/test/sgp_mode_test/AnalysisTools.test.cc

This file was deleted.

189 changes: 0 additions & 189 deletions source/test/sgp_mode_test/SGPDiversity.test.cc

This file was deleted.

Loading

0 comments on commit 103db2b

Please sign in to comment.