[Avida-SVN] r3003 - in development/source: cpu main

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Fri Dec 5 18:24:09 PST 2008


Author: brysonda
Date: 2008-12-05 21:24:09 -0500 (Fri, 05 Dec 2008)
New Revision: 3003

Modified:
   development/source/cpu/cTestCPU.cc
   development/source/main/cOrganism.cc
   development/source/main/cOrganism.h
   development/source/main/cPopulation.cc
Log:
Fix initialization of state grids.

Modified: development/source/cpu/cTestCPU.cc
===================================================================
--- development/source/cpu/cTestCPU.cc	2008-12-06 01:20:20 UTC (rev 3002)
+++ development/source/cpu/cTestCPU.cc	2008-12-06 02:24:09 UTC (rev 3003)
@@ -287,7 +287,7 @@
   if (test_info.GetInstSet()) organism = new cOrganism(m_world, ctx, genome, test_info.GetInstSet());
   else organism = new cOrganism(m_world, ctx, genome);
   test_info.org_array[cur_depth] = organism;
-  organism->SetOrgInterface(new cTestCPUInterface(this, test_info));
+  organism->SetOrgInterface(ctx, new cTestCPUInterface(this, test_info));
   organism->GetPhenotype().SetupInject(genome);
 
   // Run the current organism.

Modified: development/source/main/cOrganism.cc
===================================================================
--- development/source/main/cOrganism.cc	2008-12-06 01:20:20 UTC (rev 3002)
+++ development/source/main/cOrganism.cc	2008-12-06 02:24:09 UTC (rev 3003)
@@ -158,11 +158,13 @@
   for (int i = 0; i < received.GetSize(); i++) delete received[i];
 }
 
-void cOrganism::SetOrgInterface(cOrgInterface* interface)
+void cOrganism::SetOrgInterface(cAvidaContext& ctx, cOrgInterface* interface)
 {
   delete m_interface;
   m_interface = interface;
   
+  HardwareReset(ctx);
+  
   // initialize m_rbins as soon as the interface is available
   m_rbins = m_interface->GetResources();
   m_rbins.SetAll(0.0);
@@ -530,7 +532,7 @@
 
 void cOrganism::HardwareReset(cAvidaContext& ctx)
 {
-  if (m_world->GetEnvironment().GetNumStateGrids() > 0) {
+  if (m_world->GetEnvironment().GetNumStateGrids() > 0 && m_interface) {
     // Select random state grid in the environment
     m_cur_sg = m_interface->GetStateGridID(ctx);
     

Modified: development/source/main/cOrganism.h
===================================================================
--- development/source/main/cOrganism.h	2008-12-06 01:20:20 UTC (rev 3002)
+++ development/source/main/cOrganism.h	2008-12-06 02:24:09 UTC (rev 3003)
@@ -187,7 +187,7 @@
   
   const cOrgInterface& GetOrgInterface() const { assert(m_interface); return *m_interface; }
   cOrgInterface& GetOrgInterface() { assert(m_interface); return *m_interface; }
-  void SetOrgInterface(cOrgInterface* interface);
+  void SetOrgInterface(cAvidaContext& ctx, cOrgInterface* interface);
   
   void SetLineageLabel(int in_label) { m_lineage_label = in_label; }
   int GetLineageLabel() const { return m_lineage_label; }  

Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc	2008-12-06 01:20:20 UTC (rev 3002)
+++ development/source/main/cPopulation.cc	2008-12-06 02:24:09 UTC (rev 3003)
@@ -478,7 +478,7 @@
   assert(in_organism != NULL);
   assert(in_organism->GetGenome().GetSize() >= 1);
   
-  in_organism->SetOrgInterface(new cPopulationInterface(m_world));
+  in_organism->SetOrgInterface(ctx, new cPopulationInterface(m_world));
   
   // If the organism does not have a genotype, give it one!  No parent
   // information is provided so we must set parents to NULL.




More information about the Avida-cvs mailing list