[Avida-SVN] r2194 - branches/dkdev/source/main

dknoester at myxo.css.msu.edu dknoester at myxo.css.msu.edu
Mon Nov 12 06:43:57 PST 2007


Author: dknoester
Date: 2007-11-12 09:43:56 -0500 (Mon, 12 Nov 2007)
New Revision: 2194

Modified:
   branches/dkdev/source/main/cDeme.cc
   branches/dkdev/source/main/cDeme.h
   branches/dkdev/source/main/cOrganism.h
   branches/dkdev/source/main/cPopulation.cc
Log:
Clearing organism region declaration on new trial.

Modified: branches/dkdev/source/main/cDeme.cc
===================================================================
--- branches/dkdev/source/main/cDeme.cc	2007-11-12 14:20:22 UTC (rev 2193)
+++ branches/dkdev/source/main/cDeme.cc	2007-11-12 14:43:56 UTC (rev 2194)
@@ -31,6 +31,7 @@
 {
   _world = world;
   _deme_id = deme_id;
+  _pop = pop;
   cell_ids = in_cells;
   birth_count = 0;
   org_count = 0;
@@ -135,6 +136,13 @@
     //re-seed this deme from its germline
     _world->GetPopulation().SeedDeme(*this, GetGermline().GetLatest());
   }
+  
+  // Clear the organism's region declarations.
+  for(int i=0; i<cell_ids.GetSize(); ++i) {
+    if(_pop->GetCell(cell_ids[i]).IsOccupied()) {
+      _pop->GetCell(cell_ids[i]).GetOrganism()->ClearRegion();
+    }
+  }
 }
 
 

Modified: branches/dkdev/source/main/cDeme.h
===================================================================
--- branches/dkdev/source/main/cDeme.h	2007-11-12 14:20:22 UTC (rev 2193)
+++ branches/dkdev/source/main/cDeme.h	2007-11-12 14:43:56 UTC (rev 2194)
@@ -127,6 +127,7 @@
   cGermline _germline; //!< The germline for this deme, if used.
   int _age; //!< How old this deme is, in updates.
   cWorld* _world; //!< Pointer to the world.
+  cPopulation* _pop; //!< Pointer to the population, because the world isn't initialized early enough.
   int _links; //!< The number of links currently available to members of this deme.
   std::pair<int, int> _cellsToLink; //! The ids of cells that should be linked.
   

Modified: branches/dkdev/source/main/cOrganism.h
===================================================================
--- branches/dkdev/source/main/cOrganism.h	2007-11-12 14:20:22 UTC (rev 2193)
+++ branches/dkdev/source/main/cOrganism.h	2007-11-12 14:43:56 UTC (rev 2194)
@@ -291,6 +291,7 @@
   int GetRegionCount() const { return _region_count; }
   int GetLatestRegion() const { return _region_latest; }
   bool IsRegionLatched() const { return _region_latched; }
+  void ClearRegion() { _region_latched = false; _region = 0; _region_count = 0; _region_latest = 0; }
 };
 
 

Modified: branches/dkdev/source/main/cPopulation.cc
===================================================================
--- branches/dkdev/source/main/cPopulation.cc	2007-11-12 14:20:22 UTC (rev 2193)
+++ branches/dkdev/source/main/cPopulation.cc	2007-11-12 14:43:56 UTC (rev 2194)
@@ -1248,7 +1248,7 @@
         
         bool all_latched=true;
         for(int i=0; i<source_deme.GetSize() && all_latched; ++i) {
-          all_latched = all_latched && (cell_array[source_deme.GetCellID(i)].GetOrganism()->IsRegionLatched() != 0);
+          all_latched = all_latched && (cell_array[source_deme.GetCellID(i)].GetOrganism()->IsRegionLatched());
         }
         if(!all_latched) continue;
         




More information about the Avida-cvs mailing list