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

barrick at myxo.css.msu.edu barrick at myxo.css.msu.edu
Mon Nov 5 20:24:49 PST 2007


Author: barrick
Date: 2007-11-05 23:24:49 -0500 (Mon, 05 Nov 2007)
New Revision: 2181

Modified:
   development/source/cpu/cTestCPU.cc
   development/source/main/cPhenPlastGenotype.h
Log:
Fixed (hopefully) initialization of test CPU resources...

Modified: development/source/cpu/cTestCPU.cc
===================================================================
--- development/source/cpu/cTestCPU.cc	2007-11-05 13:41:30 UTC (rev 2180)
+++ development/source/cpu/cTestCPU.cc	2007-11-06 04:24:49 UTC (rev 2181)
@@ -56,6 +56,7 @@
 {
   m_world = world;
 	m_use_manual_inputs = false;
+  InitResources();
 }  
 
  
@@ -108,8 +109,8 @@
       }
     }
     m_res = s_resources;
+    assert(m_res != NULL);
   }
-  assert(m_res != NULL);
   
   const cResourceLib& resource_lib = m_world->GetEnvironment().GetResourceLib();
   assert(resource_lib.GetSize() >= 0);
@@ -122,7 +123,7 @@
   }
     
   SetResourceUpdate(m_res_update, true);
-  // Round down to the closest update to choose how to initializae resources
+  // Round down to the closest update to choose how to initialize resources
 }
 
 void cTestCPU::UpdateResources(int cpu_cycles_used)
@@ -136,7 +137,8 @@
 
 void cTestCPU::SetResourceUpdate(int update, bool round_to_closest)
 {
-  assert(m_res != NULL);
+  // No resources defined? -- you can't do this!
+  if (!m_res) return;
 
   m_res_update = update;
 
@@ -192,7 +194,6 @@
     if(i >= (int)(*m_res)[which].second.size()) {
       m_resource_count.Set(i, 0.0);
     } else {
-      // @DMB - unused - double temp = (*m_res)[which].second[i];
       m_resource_count.Set(i, (*m_res)[which].second[i]);
     }
   }
@@ -239,7 +240,7 @@
     
     // @CAO Need to watch out for parasites.
     
-    // Resources will be updates as if each update takes a number of cpu cycles equal to the average time slice
+    // Resources will be updated as if each update takes a number of cpu cycles equal to the average time slice
     UpdateResources(time_used);
     
     // Add extra info to trace files so that we can watch resource changes. 

Modified: development/source/main/cPhenPlastGenotype.h
===================================================================
--- development/source/main/cPhenPlastGenotype.h	2007-11-05 13:41:30 UTC (rev 2180)
+++ development/source/main/cPhenPlastGenotype.h	2007-11-06 04:24:49 UTC (rev 2181)
@@ -62,9 +62,10 @@
 {
   private:
 
-  typedef set<cPhenotype*, cPhenotype::lt_phenotype  > UniquePhenotypes;  //Actually, these are cPlasticPhenotypes*
-  tList<cPlasticPhenotype> m_plastic_phenotypes;  //This will store a list of our unique plastic phenotype pointers  
-  cGenome m_genome;
+    typedef set<cPhenotype*, cPhenotype::lt_phenotype  > UniquePhenotypes;  //Actually, these are cPlasticPhenotypes*
+    tList<cPlasticPhenotype> m_plastic_phenotypes;  //This will store a list of our unique plastic phenotype pointers  
+    cGenome m_genome;
+
     int m_num_trials;  
     UniquePhenotypes m_unique;
     cWorld* m_world;




More information about the Avida-cvs mailing list