[Avida-SVN] r3459 - development/source/actions

connel42 at myxo.css.msu.edu connel42 at myxo.css.msu.edu
Fri Oct 9 10:11:17 PDT 2009


Author: connel42
Date: 2009-10-09 13:11:17 -0400 (Fri, 09 Oct 2009)
New Revision: 3459

Modified:
   development/source/actions/PopulationActions.cc
Log:
Updated a few kill actions to include new stats

Modified: development/source/actions/PopulationActions.cc
===================================================================
--- development/source/actions/PopulationActions.cc	2009-10-09 16:49:56 UTC (rev 3458)
+++ development/source/actions/PopulationActions.cc	2009-10-09 17:11:17 UTC (rev 3459)
@@ -3924,6 +3924,7 @@
     {
       double level;
       int target_cell;
+      cPopulation& pop = m_world->GetPopulation();
       int res_id = m_world->GetPopulation().GetResourceCount().GetResourceCountID(m_resname);
       
       assert(res_id != -1);
@@ -3933,8 +3934,13 @@
         level = m_world->GetPopulation().GetResourceCount().GetSpatialResource(res_id).GetAmount(target_cell);
         
         if(level < m_threshold) {
-          m_world->GetPopulation().KillOrganism(m_world->GetPopulation().GetCell(target_cell));
-          m_world->GetStats().IncNumOrgsKilled();
+          cPopulationCell& cell = pop.GetCell(target_cell);
+          if (cell.IsOccupied()) {
+            pop.KillOrganism(cell);
+            m_world->GetStats().IncNumOrgsKilled();
+          } else {
+            m_world->GetStats().IncNumUnoccupiedCellAttemptedToKill();
+          }
         }
       }
       
@@ -3983,8 +3989,13 @@
         level = pop.GetResourceCount().GetSpatialResource(res_id).GetAmount(target_cell);
         
         if(level > m_threshold) {
-          pop.KillOrganism(pop.GetCell(target_cell));
-          m_world->GetStats().IncNumOrgsKilled();
+          cPopulationCell& cell = pop.GetCell(target_cell);
+          if (cell.IsOccupied()) {
+            pop.KillOrganism(cell);
+            m_world->GetStats().IncNumOrgsKilled();
+          } else {
+            m_world->GetStats().IncNumUnoccupiedCellAttemptedToKill();
+          }
         }
       }
       




More information about the Avida-cvs mailing list