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

Allow specification of REQUIRE_SINGLE_REACTION > 1 #86

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 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
Loading