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

updated configuration to work with parasites #55

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
3 changes: 2 additions & 1 deletion avida-core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ SET(CFG_FILES
${CFG_FILES_DIR}/instset-transsmt.cfg
${CFG_FILES_DIR}/default-heads.org
${CFG_FILES_DIR}/default-heads-sex.org
${CFG_FILES_DIR}/default-transsmt.org
${CFG_FILES_DIR}/default-transsmt-host.org
${CFG_FILES_DIR}/default-transsmt-parasite.org
)
INSTALL_FILES(/work FILES ${CFG_FILES})
4 changes: 2 additions & 2 deletions avida-core/include/public/avida/core/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@

namespace Avida {
namespace Version {
LIB_EXPORT inline const char* String() { return "2.14.0"; }
LIB_EXPORT inline const char* String() { return "2.15.0"; }
LIB_EXPORT inline int Major() { return 2; }
LIB_EXPORT inline int Minor() { return 14; }
LIB_EXPORT inline int Minor() { return 15; }
LIB_EXPORT inline int Patch() { return 0; }
LIB_EXPORT inline const char* Tag() { return ""; }

Expand Down
5 changes: 3 additions & 2 deletions avida-core/source/main/cAvidaConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,7 @@ class cAvidaConfig {
// -------- Parasite options --------
CONFIG_ADD_GROUP(PARASITE_GROUP, "Parasite config options");
CONFIG_ADD_VAR(INJECT_METHOD, int, 0, "What should happen to a parasite when it gives birth?\n0 = Leave the parasite thread state untouched.\n1 = Resets the state of the calling thread (for SMT parasites, this must be 1)");
CONFIG_ADD_VAR(INFECTION_MECHANISM, int, 1, "0: Infection always succeeds. \n1: Infection succeeds if parasite matches at least one host task.\n2: Infection succeeds if parasite does NOT match at least one task.\n3: Parasite tasks must match host tasks exactly (Matching Alleles).");
CONFIG_ADD_ALIAS(INJECT_IS_TASK_SPECIFIC);
CONFIG_ADD_VAR(INFECTION_MECHANISM, int, 1, "0: Infection always succeeds. \n1: Infection succeeds if parasite matches at least one host task.\n2: Infection succeeds if parasite does NOT match at least one task.\n3: Parasite tasks must match host tasks exactly (Matching Alleles).\n4: Parasite tasks must overcome hosts (GFG)");
CONFIG_ADD_VAR(INJECT_QMA_EXPONENT, double, 0.2, "The exponent of the equation proportion_overlap^x that determines the probability of infection succeding given the amount a host and parasite phenotype match.");

CONFIG_ADD_VAR(INJECT_STERILIZES_HOST, int, 0, "Infection causes host steralization");
Expand All @@ -462,6 +461,8 @@ class cAvidaConfig {

CONFIG_ADD_VAR(FULL_VERTICAL_TRANS, double, 0.0, "Determines if offspring of infected host is automatically infected. 0 for no, 1 for yes. If you want to keep parent infected as well, you need to set DIVIDE_METHOD to 2.");

CONFIG_ADD_VAR(PARASITE_GENOME_SIZE_AS_PARENT, int, 0, "Change this value to 1 to make the genome size of the parasite's offspring equal to that of its parent");


// -------- CPU Archetecture
CONFIG_ADD_GROUP(ARCHETECTURE_GROUP, "Details on how CPU should work");
Expand Down
3 changes: 3 additions & 0 deletions avida-core/source/main/cParasite.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class cParasite : public Systematics::Unit

cPhenotype m_phenotype;
double virulence;
int m_seq_size;


public:
Expand All @@ -59,6 +60,8 @@ class cParasite : public Systematics::Unit
cPhenotype& GetPhenotype() { return m_phenotype; }
double GetVirulence() { return virulence; }
void SetVirulence(double v) { virulence = v; }
void SetSeqSize(int seq_size) { m_seq_size = seq_size; }
int GetSeqSize() { return m_seq_size; }

private:
cParasite(); // @not_implemented
Expand Down
18 changes: 15 additions & 3 deletions avida-core/source/main/cPopulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,16 @@ bool cPopulation::ActivateParasite(cOrganism* host, Systematics::UnitPtr parent,
// Quick check for empty parasites
if (injected_code.GetSize() == 0) return false;


// Get parent parasite
Apto::SmartPtr<cParasite, Apto::InternalRCObject> parent_parasite;
parent_parasite.DynamicCastFrom(parent);

// Do not activate the parasite if the size of its genome is different from that of its parent
if(m_world->GetConfig().PARASITE_GENOME_SIZE_AS_PARENT.Get() == 1 && parent_parasite != NULL) {
if (parent_parasite->GetSeqSize() != injected_code.GetSize()) {
return false;
}
}
// Pull the host cell
const int host_id = host->GetOrgInterface().GetCellID();
assert(host_id >= 0 && host_id < cell_array.GetSize());
Expand Down Expand Up @@ -1266,8 +1275,8 @@ bool cPopulation::ActivateParasite(cOrganism* host, Systematics::UnitPtr parent,
{
//mutate virulence
// m_world->GetConfig().PARASITE_VIRULENCE.Get()
Apto::SmartPtr<cParasite, Apto::InternalRCObject> parent_parasite;
parent_parasite.DynamicCastFrom(parent);
//Apto::SmartPtr<cParasite, Apto::InternalRCObject> parent_parasite;
//parent_parasite.DynamicCastFrom(parent);
double oldVir = parent_parasite->GetVirulence();

//default to not mutating
Expand Down Expand Up @@ -7149,6 +7158,9 @@ void cPopulation::InjectParasite(const cString& label, const InstructionSequence

//default to configured parasite virulence
parasite->SetVirulence(m_world->GetConfig().PARASITE_VIRULENCE.Get());

// set genome sequence size
parasite->SetSeqSize(injected_code.GetSize());

if (target_organism->ParasiteInfectHost(parasite)) {
Systematics::Manager::Of(m_world->GetNewWorld())->ClassifyNewUnit(parasite);
Expand Down
8 changes: 6 additions & 2 deletions avida-core/support/config/avida.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# For more information, see doc/config.html
#############################################################################

VERSION_ID 2.14.0 # Do not change this value.
VERSION_ID 2.15.0 # Do not change this value.

### GENERAL_GROUP ###
# General Settings
Expand Down Expand Up @@ -203,7 +203,11 @@ MATE_IN_GROUPS 0 # Require all mating to happen within groups
INJECT_METHOD 0 # What should happen to a parasite when it gives birth?
# 0 = Leave the parasite thread state untouched.
# 1 = Resets the state of the calling thread (for SMT parasites, this must be 1)
INJECT_IS_TASK_SPECIFIC 1 # Inject occurs based on task overlap
INFECTION_MECHANISM 0 # 0 = Infection will succeed independent of task-based phenotypes
# 1 = Infection will succeed if the parasite and host have at least one overlapping task (Inverse Gene-for-Gene)
# 2 = Infection will succeed if the parasite does at least one task the host does not perform
# 3 = Infection will succeed if the parasite and host do the same tasks (Matching Alleles)
# 4 = Infection will succeed if the parasite performs all the tasks the host does as well as at least one additional task (Gene-for-Gene)
INJECT_STERILIZES_HOST 0 # Infection causes host steralization
INJECT_IS_VIRULENT 0 # Infection causes host steralization and takes all cpu cycles (setting this to 1 will override inject_virulence)
PARASITE_SKIP_REACTIONS 1 # Parasite tasks do not get processed in the environment (1) or they do trigger reactions (0)
Expand Down
103 changes: 103 additions & 0 deletions avida-core/support/config/default-transsmt-host.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#inst_set transsmt
#hw_type 2

Nop-A
Nop-A
If-Not-Equal
Push-Prev
SetMemory
SetMemory
Nop-B
Nop-D
If-Equal
Nop-C
Nop-C
Head-Move
Nop-C
Push-Next
SetMemory
Inst-Write
Inst-Read
Nop-D
IO
Inst-Read
Val-Inc
Nop-D
Val-Copy
Nop-B
Val-Mult
Val-Sub
Nop-C
Nop-B
Inst-Read
Push-Next
Search
Val-Shift-R
If-Less
Push-Prev
Val-Nand
Nop-D
IO
Search
Inst-Read
Nop-B
Push-Comp
Val-Nand
Nop-C
Nop-B
Nop-D
Inst-Write
Push-Next
If-Not-Equal
Head-Move
IO
Nop-C
Search
Inst-Read
SetMemory
If-Equal
Push-Prev
Nop-C
IO
Val-Delete
If-Greater
Val-Mod
Push-Prev
Inst-Read
Push-Prev
Val-Mult
Val-Div
Val-Dec
If-Greater
Inst-Read
Val-Mult
IO
Val-Div
Val-Div
Val-Inc
Push-Comp
Val-Inc
Val-Shift-R
Val-Mult
Val-Copy
IO
Val-Sub
If-Less
Inst-Read
IO
Val-Delete
Nop-B
Head-Push
Val-Delete
Val-Add
Val-Div
Val-Mod
If-Equal
If-Greater
Val-Dec
IO
Push-Comp
Push-Prev
Val-Div
Val-Sub
Divide-Erase
103 changes: 103 additions & 0 deletions avida-core/support/config/default-transsmt-parasite.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#inst_set transsmt
#hw_type 2

Nop-A
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Nop-B
Inst-Read
Val-Add
Val-Dec
SetMemory
Nop-C
IO
Nop-C
Nop-B
Head-Move
Nop-C
Search
Inst-Write
Inst-Read
If-Greater
Head-Move
Val-Sub
Val-Dec
IO
Val-Div
Val-Dec
Val-Dec
Val-Dec
Val-Div
Inject
37 changes: 19 additions & 18 deletions avida-core/support/config/instset-transsmt.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
INSTSET transsmt:hw_type=2

INST Nop-A #1 (a)
INST Nop-A #1 (a)
INST Nop-B #2 (b)
INST Nop-C #3 (c)
INST Nop-D #4 (d)
Expand All @@ -15,20 +15,21 @@ INST Val-Mod #12 (l)
INST Val-Inc #13 (m)
INST Val-Dec #14 (n)
INST SetMemory #15 (o)
INST Divide #16 (p)
INST Inst-Read #17 (q)
INST Inst-Write #18 (r)
INST If-Equal #19 (s)
INST If-Not-Equal #20 (t)
INST If-Less #21 (u)
INST If-Greater #22 (v)
INST Head-Push #23 (w)
INST Head-Pop #24 (x)
INST Head-Move #25 (y)
INST Search #26 (z)
INST Push-Next #27 (A)
INST Push-Prev #28 (B)
INST Push-Comp #29 (C)
INST Val-Delete #30 (D)
INST Val-Copy #31 (E)
INST IO #32 (F)
INST Inst-Read #16 (p)
INST Inst-Write #17 (q)
INST If-Equal #18 (r)
INST If-Not-Equal #19 (s)
INST If-Less #20 (t)
INST If-Greater #21 (u)
INST Head-Push #22 (v)
INST Head-Pop #23 (w)
INST Head-Move #24 (x)
INST Search #25 (y)
INST Push-Next #26 (z)
INST Push-Prev #27 (A)
INST Push-Comp #28 (B)
INST Val-Delete #29 (C)
INST Val-Copy #30 (D)
INST IO #31 (E)
INST Inject #32 (F)
INST Divide-Erase #33 (G)