Skip to content

Commit

Permalink
Merge pull request #91 from devosoft/mmore500-death
Browse files Browse the repository at this point in the history
Fixup death functionality
  • Loading branch information
mmore500 authored Feb 15, 2024
2 parents e6a9a70 + d9f590e commit 3a38d1a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
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

0 comments on commit 3a38d1a

Please sign in to comment.