Skip to content

Commit

Permalink
Allow specification of REQUIRE_SINGLE_REACTION > 1
Browse files Browse the repository at this point in the history
  • Loading branch information
mmore500 authored Nov 22, 2023
1 parent 424d3b2 commit e9091d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion avida-core/source/main/cAvidaConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ class cAvidaConfig {
CONFIG_ADD_VAR(IMMUNITY_TASK, int, -1, "Task providing immunity from the required task");
CONFIG_ADD_VAR(REQUIRED_REACTION, int, -1, "Reaction ID required for successful divide");
CONFIG_ADD_VAR(IMMUNITY_REACTION, int, -1, "Reaction ID that provides immunity for successful divide");
CONFIG_ADD_VAR(REQUIRE_SINGLE_REACTION, int, 0, "If set to 1, at least one reaction is required for a successful divide");
CONFIG_ADD_VAR(REQUIRE_SINGLE_REACTION, int, 0, "If set to 1, at least one reaction is required for a successful divide; if set to n > 1, at least n reactions are required for a successful divide");
CONFIG_ADD_VAR(MAX_UNIQUE_TASK_COUNT, int, -1, "Division will fail if organism performs more than MAX_TASK_COUNT when MAX_TASK_COUNT >= 0");
CONFIG_ADD_VAR(REQUIRED_BONUS, double, 0.0, "Required bonus to divide");
CONFIG_ADD_VAR(REQUIRE_EXACT_COPY, int, 0, "Require offspring to be an exact copy (checked before divide mutations)");
Expand Down
12 changes: 6 additions & 6 deletions avida-core/source/main/cOrganism.cc
Original file line number Diff line number Diff line change
Expand Up @@ -860,22 +860,22 @@ bool cOrganism::Divide_CheckViable(cAvidaContext& ctx)
}

if (single_reaction != 0) {
bool toFail = true;
int toFail = single_reaction;
Apto::Array<int> reactionCounts = m_phenotype.GetCurReactionCount();
for (int i=0; i<reactionCounts.GetSize(); i++) {
if (reactionCounts[i] > 0) toFail = false;
for (int i=0; i<reactionCounts.GetSize() && toFail; i++) {
if (reactionCounts[i] > 0) --toFail;
}

if (toFail) {
const Apto::Array<int>& stolenReactions = m_phenotype.GetStolenReactionCount();
for (int i = 0; i < stolenReactions.GetSize(); i++)
for (int i = 0; i < stolenReactions.GetSize() && toFail; i++)
{
if (stolenReactions[i] > 0) toFail = false;
if (stolenReactions[i] > 0) --toFail;
}
}

if (toFail) {
Fault(FAULT_LOC_DIVIDE, FAULT_TYPE_ERROR, cStringUtil::Stringf("Lacks any reaction required for divide"));
Fault(FAULT_LOC_DIVIDE, FAULT_TYPE_ERROR, cStringUtil::Stringf("Lacks sufficient reactions required for divide"));
return false; // (divide fails)
}
}
Expand Down

0 comments on commit e9091d9

Please sign in to comment.