[Avida-SVN] r3253 - development/source/actions
connel42 at myxo.css.msu.edu
connel42 at myxo.css.msu.edu
Thu May 21 11:05:36 PDT 2009
Author: connel42
Date: 2009-05-21 14:05:36 -0400 (Thu, 21 May 2009)
New Revision: 3253
Modified:
development/source/actions/PopulationActions.cc
Log:
Unrolled some killing actions
Modified: development/source/actions/PopulationActions.cc
===================================================================
--- development/source/actions/PopulationActions.cc 2009-05-21 15:26:24 UTC (rev 3252)
+++ development/source/actions/PopulationActions.cc 2009-05-21 18:05:36 UTC (rev 3253)
@@ -2841,16 +2841,17 @@
{
double level;
int target_cell;
+ cPopulation& pop = m_world->GetPopulation();
int res_id = m_world->GetPopulation().GetResourceCount().GetResourceCountID(m_resname);
assert(res_id != -1);
for(int i=0; i < m_numkills; i++) {
- target_cell = m_world->GetRandom().GetInt(0, m_world->GetPopulation().GetSize()-1);
- level = m_world->GetPopulation().GetResourceCount().GetSpatialResource(res_id).GetAmount(target_cell);
+ target_cell = m_world->GetRandom().GetInt(0, pop.GetSize()-1);
+ level = pop.GetResourceCount().GetSpatialResource(res_id).GetAmount(target_cell);
if(level > m_threshold) {
- m_world->GetPopulation().KillOrganism(m_world->GetPopulation().GetCell(target_cell));
+ pop.KillOrganism(pop.GetCell(target_cell));
m_world->GetStats().IncNumOrgsKilled();
}
}
@@ -2860,7 +2861,6 @@
-
/*
Kill a percentage of organisms in all demes
@@ -2887,16 +2887,19 @@
void Process(cAvidaContext& ctx)
{
int target_cell;
-
- for (int d = 0; d < m_world->GetPopulation().GetNumDemes(); d++) {
+ cPopulation& pop = m_world->GetPopulation();
+
+ for (int d = 0; d < pop.GetNumDemes(); d++) {
+
+ cDeme &deme = pop.GetDeme(d);
- if(m_world->GetPopulation().GetDeme(d).IsTreatableNow()) {
+ if(deme.IsTreatableNow()) {
- for (int c = 0; c < m_world->GetPopulation().GetDeme(d).GetWidth() * m_world->GetPopulation().GetDeme(d).GetHeight(); c++) {
- target_cell = m_world->GetPopulation().GetDeme(d).GetCellID(c);
+ for (int c = 0; c < deme.GetWidth() * deme.GetHeight(); c++) {
+ target_cell = deme.GetCellID(c);
if(ctx.GetRandom().P(m_pctkills)) {
- m_world->GetPopulation().KillOrganism(m_world->GetPopulation().GetCell(target_cell));
+ pop.KillOrganism(pop.GetCell(target_cell));
m_world->GetStats().IncNumOrgsKilled();
}
@@ -2909,6 +2912,7 @@
} //End Process()
};
+
/*
Set the ages at which treatable demes can be treated
More information about the Avida-cvs
mailing list