Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Organism refactor with multiple inheritance #198

Draft
wants to merge 26 commits into
base: complex-genomes
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
dc9187c
Start SGPOrganism migration
naalit Nov 8, 2022
96a7172
Initial Host/BaseHost split for default mode
naalit Nov 10, 2022
ada574f
Reduce duplication in default and base classes
naalit Nov 28, 2022
6871056
Update SGP mode for new class structure
naalit Nov 28, 2022
826706f
Fix default-mode tests
naalit Nov 28, 2022
1e6fa99
Minimal fix to make efficient mode work again
naalit Nov 28, 2022
89c0aba
Minimal fix to make lysis mode work again
naalit Nov 29, 2022
0bb3cba
Minimal fix to make PGG mode work again
naalit Dec 1, 2022
5d62302
Put phylogeny back with per-subclass calcinfofun
naalit Dec 1, 2022
75692b9
Move int val code to new DefaultOrganism class
naalit Dec 1, 2022
6af38d0
Fix minor bugs from host migration
naalit Dec 6, 2022
e439467
Re-enable phylogeny tests
naalit Dec 6, 2022
d39cd22
Fix efficient mode tests
naalit Dec 7, 2022
0211cca
Replace transmission mode strings with enum in efficient mode
naalit Dec 7, 2022
636604b
Fix lysis mode tests
naalit Dec 8, 2022
b71a007
Temporarily disable Empirical pointer tracking
naalit Dec 12, 2022
d32b8db
Fix web build
naalit Dec 12, 2022
dba859a
Fix web build, for real this time
naalit Dec 12, 2022
08b3edb
Fix occasional segfault on free sym birth
naalit Dec 13, 2022
ea9fff1
Set fixed random seed for Symbiont Process test
naalit Dec 13, 2022
064e742
Fix PGG mode tests
naalit Dec 13, 2022
1e3584c
Update this branch for SGP ectosymbiosis changes
naalit Dec 15, 2022
7936849
Fix SGP tests, part 1
naalit Dec 16, 2022
266474b
Fix SGP free sym tests by changing infection chance
naalit Dec 16, 2022
c0337c7
Re-enable integration tests
naalit Dec 16, 2022
20be7cf
Deal with changing randomness in default mode tests again
naalit Dec 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CFLAGS_all := -Wall -Wno-unused-function -std=c++17 -I$(EMP_DIR)/ -I$(SGP_DIR)/
# Native compiler information
CXX_nat := g++
CFLAGS_nat := -O3 -DNDEBUG -pthread $(CFLAGS_all)
CFLAGS_nat_debug := -g -DEMP_TRACK_MEM -pthread $(CFLAGS_all)
CFLAGS_nat_debug := -g -pthread $(CFLAGS_all)
CFLAGS_nat_coverage := --coverage -pthread $(CFLAGS_all)

# Emscripten compiler information
Expand Down
48 changes: 48 additions & 0 deletions source/Organism.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include "Organism.h"
#include "default_mode/SymWorld.h"

size_t BaseHost::AddSymbiont(emp::Ptr<BaseSymbiont> _in) {
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;
}
}

bool BaseHost::SymAllowedIn() const {
bool do_phage_exclusion = my_config->PHAGE_EXCLUDE();
if (!do_phage_exclusion) {
return true;
} else {
int num_syms = syms.size();
// essentially imitaties a 1/ 2^n chance, with n = number of symbionts
int enter_chance = random->GetUInt((int)pow(2.0, num_syms));
if (enter_chance == 0) {
return true;
}
return false;
}
}

void BaseSymbiont::VerticalTransmission(emp::Ptr<Organism> host_baby) {
if (my_world->WillTransmit()) {
// Vertical transmission data nodes
// Attempt vs success for vertical transmission is just whether it has
// enough resources
my_world->GetVerticalTransmissionAttemptCount().AddDatum(1);

// If the world permits vertical transmission and the sym has enough
// resources, transmit!
if (GetPoints() >= my_config->SYM_VERT_TRANS_RES()) {
emp::Ptr<BaseSymbiont> sym_baby = ReproduceSym();
points -= my_config->SYM_VERT_TRANS_RES();
host_baby->AddSymbiont(sym_baby);

my_world->GetVerticalTransmissionSuccessCount().AddDatum(1);
}
}
}
Loading