diff --git a/avida-core/source/main/cDeme.cc b/avida-core/source/main/cDeme.cc index d954cc63d5..6887c5b20e 100644 --- a/avida-core/source/main/cDeme.cc +++ b/avida-core/source/main/cDeme.cc @@ -350,6 +350,22 @@ int cDeme::GetNumParasites() const return count; } +void cDeme::UpdateParasiteMemoryScore(const double decay) { + if (GetSize() == 0) return; + const double inc = static_cast(GetNumParasites()) / GetSize(); + SetParasiteMemoryScore(GetParasiteMemoryScore() * decay + inc); +} + +void cDeme::SetParasiteMemoryScore(const double score) { + if (!std::isfinite(score)) { + cerr << "ERROR: SetParasiteMemoryScore() called with " << score + << "current score is " << GetParasiteMemoryScore() + << std::endl; + exit(1); + } + parasite_memory_score = score; +} + void cDeme::ProcessPreUpdate() { deme_resource_count.SetSpatialUpdate(m_world->GetStats().GetUpdate()); diff --git a/avida-core/source/main/cDeme.h b/avida-core/source/main/cDeme.h index 7fbfb25ef2..9da95095e4 100644 --- a/avida-core/source/main/cDeme.h +++ b/avida-core/source/main/cDeme.h @@ -192,14 +192,9 @@ class cDeme else return static_cast(GetNumParasites()) / GetOrgCount(); } - void UpdateParasiteMemoryScore(const double decay) { - parasite_memory_score += static_cast(GetNumParasites()) / GetSize(); - parasite_memory_score *= decay; - } + void UpdateParasiteMemoryScore(const double decay); double GetParasiteMemoryScore() const { return parasite_memory_score; } - void SetParasiteMemoryScore(const double score) { - parasite_memory_score = score; - } + void SetParasiteMemoryScore(const double score); void IncOrgCount() { cur_org_count++; } void DecOrgCount() { cur_org_count--; }