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

Fixup death functionality #91

Merged
merged 2 commits into from
Feb 15, 2024
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
3 changes: 2 additions & 1 deletion avida-core/source/main/cAvidaConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ class cAvidaConfig {
CONFIG_ADD_VAR(PREFER_EMPTY, int, 1, "Overide BIRTH_METHOD to preferentially choose empty cells for offsping?");
CONFIG_ADD_VAR(ALLOW_PARENT, int, 1, "Should parents be considered when deciding where to place offspring?");
CONFIG_ADD_VAR(DISPERSAL_RATE, double, 0.0, "Rate of dispersal under birth method 11\n(poisson distributed random connection list hops)");
CONFIG_ADD_VAR(DEATH_PROB, double, 0.0, "Probability of death when dividing.");
CONFIG_ADD_VAR(DEATH_PROB, double, 0.0, "Probability of death when dividing. (@MAM: actually seems to be applied per-update?)");
CONFIG_ADD_VAR(DEATH_PROB_PARENT, double, 0.0, "Probability of death when dividing. (@MAM: proper DEATH_PROB impl)");
CONFIG_ADD_VAR(DEATH_METHOD, int, 2, "When should death by old age occur?\n0 = Never\n1 = When executed AGE_LIMIT (+deviation) total instructions\n2 = When executed genome_length * AGE_LIMIT (+dev) instructions");
CONFIG_ADD_VAR(AGE_LIMIT, int, 20, "See DEATH_METHOD");
CONFIG_ADD_VAR(AGE_DEVIATION, int, 0, "Creates a normal distribution around AGE_LIMIT for time of death");
Expand Down
4 changes: 4 additions & 0 deletions avida-core/source/main/cPopulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,10 @@ bool cPopulation::ActivateOffspring(cAvidaContext& ctx, const Genome& offspring_
// Loop through choosing the later placement of each offspring in the population.
bool parent_alive = true; // Will the parent live through this process?

if (m_world->GetConfig().DEATH_PROB_PARENT.Get() && ctx.GetRandom().P(m_world->GetConfig().DEATH_PROB_PARENT.Get())) {
parent_alive = false;
}

for (int i = 0; i < offspring_array.GetSize(); i++) {
target_cells[i] = PositionOffspring(parent_cell, ctx, m_world->GetConfig().ALLOW_PARENT.Get()).GetID();
// Catch the corner case where birth method = 3 and there are
Expand Down
Loading