[Avida-SVN] r2679 - branches/interrupt/source/main

beckma24 at myxo.css.msu.edu beckma24 at myxo.css.msu.edu
Mon Jun 23 13:03:53 PDT 2008


Author: beckma24
Date: 2008-06-23 16:03:52 -0400 (Mon, 23 Jun 2008)
New Revision: 2679

Modified:
   branches/interrupt/source/main/cDeme.cc
   branches/interrupt/source/main/cPopulation.cc
Log:
CompeteDemes: re-inject count 1 deme into self; hack for energy uptake on deme reset

Modified: branches/interrupt/source/main/cDeme.cc
===================================================================
--- branches/interrupt/source/main/cDeme.cc	2008-06-23 20:00:46 UTC (rev 2678)
+++ branches/interrupt/source/main/cDeme.cc	2008-06-23 20:03:52 UTC (rev 2679)
@@ -276,6 +276,21 @@
 
   if(resetResources) {
     deme_resource_count.ReinitializeResources(additional_resource);
+    if(m_world->GetConfig().ENERGY_ENABLED.Get() == 1) {
+      cPopulation& pop = m_world->GetPopulation();
+      for (int i=0; i<GetSize(); i++) {
+        int cellid = GetCellID(i);
+        cPopulationCell& cell = m_world->GetPopulation().GetCell(cellid);
+        if(cell.IsOccupied()) {
+          cOrganism* organism = cell.GetOrganism();
+          cPhenotype& phenotype = organism->GetPhenotype();
+          phenotype.SetEnergy(cell.UptakeCellEnergy(1.0));
+          phenotype.SetMerit(cMerit(cMerit::EnergyToMerit(phenotype.GetStoredEnergy() * phenotype.GetEnergyUsageRatio(), m_world)));
+          pop.UpdateMerit(cell.GetID(), (phenotype.GetMerit()).GetDouble());
+        }
+      }
+    }
+
   }
 }
 

Modified: branches/interrupt/source/main/cPopulation.cc
===================================================================
--- branches/interrupt/source/main/cPopulation.cc	2008-06-23 20:00:46 UTC (rev 2678)
+++ branches/interrupt/source/main/cPopulation.cc	2008-06-23 20:03:52 UTC (rev 2679)
@@ -1143,6 +1143,12 @@
     }
   }
   
+  // re-inject demes with count of 1
+  for(int i =0; i < deme_counts.size(); i++) {
+    if(deme_counts[i] == 1)
+      ReplaceDeme(deme_array[i], deme_array[i]);
+  }
+  
   // Now, while we can find both a source deme (one with a count greater than 1)
   // and a target deme (one with a count of 0), replace the target with the source.
   while(true) {




More information about the Avida-cvs mailing list