[Avida-cvs] [Avida2-svn] r357 - in branches/brysonda/source: cpu event main

brysonda@myxo.css.msu.edu brysonda at myxo.css.msu.edu
Fri Oct 21 18:56:38 PDT 2005


Author: brysonda
Date: 2005-10-21 21:56:38 -0400 (Fri, 21 Oct 2005)
New Revision: 357

Modified:
   branches/brysonda/source/cpu/cHardware4Stack.cc
   branches/brysonda/source/cpu/cHardwareCPU.cc
   branches/brysonda/source/cpu/cHardwareSMT.cc
   branches/brysonda/source/cpu/cTestCPU.cc
   branches/brysonda/source/cpu/cTestCPU.h
   branches/brysonda/source/cpu/cTestUtil.cc
   branches/brysonda/source/cpu/cTestUtil.h
   branches/brysonda/source/event/cEventManager.cc
   branches/brysonda/source/main/cAnalyze.cc
   branches/brysonda/source/main/cAnalyzeGenotype.cc
   branches/brysonda/source/main/cAnalyzeUtil.cc
   branches/brysonda/source/main/cAnalyzeUtil.h
   branches/brysonda/source/main/cGenebank.cc
   branches/brysonda/source/main/cGenotype.cc
   branches/brysonda/source/main/cInjectGenebank.cc
   branches/brysonda/source/main/cLandscape.cc
   branches/brysonda/source/main/cLandscape.h
   branches/brysonda/source/main/cMxCodeArray.cc
   branches/brysonda/source/main/cOrganism.cc
   branches/brysonda/source/main/cOrganism.h
   branches/brysonda/source/main/cPhenotype.cc
   branches/brysonda/source/main/cPhenotype.h
   branches/brysonda/source/main/cPopulation.cc
   branches/brysonda/source/main/cPopulationInterface.cc
   branches/brysonda/source/main/cSpecies.cc
   branches/brysonda/source/main/cSpecies.h
   branches/brysonda/source/main/cWorld.cc
   branches/brysonda/source/main/cWorld.h
Log:
Remove the TestCPU's 'staticness'.  cWorld now holds the TestCPU object.  Pass the world object around to more classes that need it.  Simplify environment access at various places.

Modified: branches/brysonda/source/cpu/cHardware4Stack.cc
===================================================================
--- branches/brysonda/source/cpu/cHardware4Stack.cc	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/cpu/cHardware4Stack.cc	2005-10-22 01:56:38 UTC (rev 357)
@@ -1643,7 +1643,7 @@
   
   cCPUTestInfo test_info;
   test_info.UseRandomInputs();
-  cTestCPU::TestGenome(test_info, organism->ChildGenome());
+  m_world->GetTestCPU().TestGenome(test_info, organism->ChildGenome());
   const double child_fitness = test_info.GetGenotypeFitness();
   
   bool revert = false;

Modified: branches/brysonda/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/brysonda/source/cpu/cHardwareCPU.cc	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/cpu/cHardwareCPU.cc	2005-10-22 01:56:38 UTC (rev 357)
@@ -1736,7 +1736,7 @@
   
   cCPUTestInfo test_info;
   test_info.UseRandomInputs();
-  cTestCPU::TestGenome(test_info, organism->ChildGenome());
+  m_world->GetTestCPU().TestGenome(test_info, organism->ChildGenome());
   const double child_fitness = test_info.GetGenotypeFitness();
   
   bool revert = false;

Modified: branches/brysonda/source/cpu/cHardwareSMT.cc
===================================================================
--- branches/brysonda/source/cpu/cHardwareSMT.cc	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/cpu/cHardwareSMT.cc	2005-10-22 01:56:38 UTC (rev 357)
@@ -1491,7 +1491,7 @@
   
   cCPUTestInfo test_info;
   test_info.UseRandomInputs();
-  cTestCPU::TestGenome(test_info, organism->ChildGenome());
+  m_world->GetTestCPU().TestGenome(test_info, organism->ChildGenome());
   const double child_fitness = test_info.GetGenotypeFitness();
   
   bool revert = false;

Modified: branches/brysonda/source/cpu/cTestCPU.cc
===================================================================
--- branches/brysonda/source/cpu/cTestCPU.cc	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/cpu/cTestCPU.cc	2005-10-22 01:56:38 UTC (rev 357)
@@ -29,47 +29,19 @@
 
 using namespace std;
 
-
-// Static Variables
-cWorld* cTestCPU::m_world(NULL);
-cInstSet * cTestCPU::inst_set(NULL);
-cEnvironment * cTestCPU::environment(NULL);
-cPopulationInterface* cTestCPU::test_interface;
-tArray<int> cTestCPU::input_array;
-tArray<int> cTestCPU::receive_array;
-int cTestCPU::cur_input;
-int cTestCPU::cur_receive;
-cResourceCount cTestCPU::resource_count;
-
-bool cTestCPU::initialized(false);
-int cTestCPU::time_mod(20);
-bool cTestCPU::d_useResources(false);
-tArray<double> cTestCPU::d_emptyDoubleArray;
-tArray<double> cTestCPU::d_resources;
-
-
-//////////////////////////////
-//  cTestCPU  (Static Class)
-//////////////////////////////
-
-void cTestCPU::Setup(cWorld* world, int resourceSize)
+cTestCPU::cTestCPU(cWorld* world)
+  : m_world(world)
+  , test_interface(world)
+  , time_mod(world->GetConfig().TEST_CPU_TIME_MOD.Get())
 {
-  m_world = world;
-  environment = &world->GetEnvironment();
-  inst_set = &world->GetHardwareManager().GetInstSet();
-  resource_count.SetSize(environment->GetResourceLib().GetSize());
-  test_interface = new cPopulationInterface(world);
+  resource_count.SetSize(world->GetEnvironment().GetResourceLib().GetSize());
   SetupResources();
-  time_mod = world->GetConfig().TEST_CPU_TIME_MOD.Get();
-  initialized = true;
 }
 
-void cTestCPU::SetupResources(void) {
-
-    // Setup the resources...
-  assert(environment);
-
-  const cResourceLib & resource_lib = environment->GetResourceLib();
+void cTestCPU::SetupResources(void)
+{
+  // Setup the resources...
+  const cResourceLib & resource_lib = m_world->GetEnvironment().GetResourceLib();
   assert(resource_lib.GetSize() >= 0);
 
   resource_count.SetSize(resource_lib.GetSize());
@@ -108,25 +80,11 @@
       d_resources[i] = resources[i];
     }
   }
-
-  return;
 }
 
-void cTestCPU::SetInstSet(cInstSet * in_inst_set)
-{
-  inst_set = in_inst_set;
-}
-
-void cTestCPU::SetEnvironment(cEnvironment *e)
-{
-  environment = e;
-  return;
-}
-
 // NOTE: This method assumes that the organism is a fresh creation.
 bool cTestCPU::ProcessGestation(cCPUTestInfo & test_info, int cur_depth)
 {
-  assert(initialized == true);
   assert(test_info.org_array[cur_depth] != NULL);
 
   cOrganism & organism = *( test_info.org_array[cur_depth] );
@@ -178,8 +136,6 @@
 
 bool cTestCPU::TestGenome(cCPUTestInfo & test_info, const cGenome & genome)
 {
-  assert(initialized == true);
-
   test_info.Clear();
   TestGenome_Body(test_info, genome, 0);
 
@@ -189,8 +145,6 @@
 bool cTestCPU::TestGenome(cCPUTestInfo & test_info, const cGenome & genome,
 		       ofstream & out_fp)
 {
-  assert(initialized == true);
-
   test_info.Clear();
   TestGenome_Body(test_info, genome, 0);
 
@@ -223,7 +177,6 @@
 bool cTestCPU::TestGenome_Body(cCPUTestInfo & test_info,
 			       const cGenome & genome, int cur_depth)
 {
-  assert(initialized == true);
   assert(cur_depth < test_info.generation_tests);
 
   if (test_info.GetUseRandomInputs() == false) {
@@ -243,8 +196,8 @@
     receive_array[1] = 0x33083ee5;  // 00110011 00001000 00111110 11100101
     receive_array[2] = 0x5562eb41;  // 01010101 01100010 11101011 01000001
   } else {
-    environment->SetupInputs(input_array);
-    environment->SetupInputs(receive_array);
+    m_world->GetEnvironment().SetupInputs(input_array);
+    m_world->GetEnvironment().SetupInputs(receive_array);
   }
 
   if (cur_depth > test_info.max_depth) test_info.max_depth = cur_depth;
@@ -253,7 +206,7 @@
   if (test_info.org_array[cur_depth] != NULL) {
     delete test_info.org_array[cur_depth];
   }
-  test_info.org_array[cur_depth] = new cOrganism(m_world, genome, environment);
+  test_info.org_array[cur_depth] = new cOrganism(m_world, genome);
   cOrganism & organism = *( test_info.org_array[cur_depth] );
   organism.GetPhenotype().SetupInject(genome.GetSize());
 
@@ -309,41 +262,18 @@
 
 void cTestCPU::TestThreads(const cGenome & genome)
 {
-  assert(initialized == true);
-
   static ofstream fp("threads.dat");
 
   cCPUTestInfo test_info;
   test_info.TestThreads();
   cTestCPU::TestGenome(test_info, genome);
 
-//  fp << cStats::GetUpdate()             << " "    // 1
-//     << genome.GetSize()                << " ";   // 2
-//       << cStats::GetAveNumThreads()      << " "   // 3
-//       << cStats::GetAveThreadDist()      << " ";  // 4
-
-//    fp << test_info.GetGenotypeMerit()          << " "   // 5
-//       << test_info.GetGenotypeGestation()      << " "   // 6
-//       << test_info.GetGenotypeFitness()        << " "   // 7
-//       << test_info.GetGenotypeThreadFrac()     << " "   // 8
-//       << test_info.GetGenotypeThreadTimeDiff() << " "   // 9
-//       << test_info.GetGenotypeThreadCodeDiff() << " ";  // 10
-
-//    fp << test_info.GetColonyMerit()          << " "   // 11
-//       << test_info.GetColonyGestation()      << " "   // 12
-//       << test_info.GetColonyFitness()        << " "   // 13
-//       << test_info.GetColonyThreadFrac()     << " "   // 14
-//       << test_info.GetColonyThreadTimeDiff() << " "   // 15
-//       << test_info.GetColonyThreadCodeDiff() << " ";  // 16
-
   fp << endl;
 }
 
 
 void cTestCPU::PrintThreads(const cGenome & genome)
 {
-  assert(initialized == true);
-
   cCPUTestInfo test_info;
   test_info.TestThreads();
   test_info.PrintThreads();
@@ -389,56 +319,3 @@
   return true;
 }
 
-
-
-int cTestCPU::GetInput()
-{
-  if (cur_input >= input_array.GetSize()) cur_input = 0;
-  return input_array[cur_input++];
-}
-
-int cTestCPU::GetInputAt(int & input_pointer)
-{
-  if (input_pointer >= input_array.GetSize()) input_pointer = 0;
-  return input_array[input_pointer++];
-}
-
-int cTestCPU::GetReceiveValue()
-{
-  if (cur_receive >= receive_array.GetSize()) cur_receive = 0;
-  return receive_array[cur_receive++];
-}
-
-const tArray<double> & cTestCPU::GetResources()
-{
-  if(d_useResources) {
-    //return resource_count.GetResources();  // Changed to use my own vector
-    return d_resources;
-  }
-
-  return d_emptyDoubleArray;
-  //assert(resource_count != NULL);       // Original line
-  //return resource_count.GetResources();   // Original line
-}
-
-
-void cTestCPU::UpdateResources(const tArray<double> & res_change)
-{
-  //resource_count.Modify(res_change);
-}
-
-void cTestCPU::UpdateResource(int id, double change)
-{
-  //resource_count.Modify(id, change);
-}
-
-void cTestCPU::UpdateCellResources(const tArray<double> & res_change, 
-                                      const int cell_id)
-{
-  //resource_count.ModifyCell(res_change, cell_id);
-}
-
-void cTestCPU::SetResource(int id, double new_level)
-{
-  resource_count.Set(id, new_level);
-}

Modified: branches/brysonda/source/cpu/cTestCPU.h
===================================================================
--- branches/brysonda/source/cpu/cTestCPU.h	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/cpu/cTestCPU.h	2005-10-22 01:56:38 UTC (rev 357)
@@ -5,88 +5,105 @@
 // before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
 //////////////////////////////////////////////////////////////////////////////
 
-#ifndef TEST_CPU_HH
-#define TEST_CPU_HH
+#ifndef cTestCPU_h
+#define cTestCPU_h
 
 #include <fstream>
 
-#ifndef TARRAY_HH
+#ifndef tArray_h
 #include "tArray.h"
 #endif
-#ifndef STRING_HH
+#ifndef cString_h
 #include "cString.h"
 #endif
-
-#ifndef RESOURCE_COUNT_HH
+#ifndef cPopulationInterface_h
+#include "cPopulationInterface.h"
+#endif
+#ifndef cResourceCount_h
 #include "cResourceCount.h"
 #endif
 
 class cInstSet;
-class cEnvironment;
-class cPopulationInterface;
-template <class T> class tArray; // aggregate
 class cResourceCount;
 class cCPUTestInfo;
 class cGenome;
-class cString; // aggregate
 class cWorld;
 
 class cTestCPU {
 private:
-  static cWorld* m_world;
-  static cInstSet * inst_set;
-  static cEnvironment * environment;
-  static cPopulationInterface* test_interface;
-  static tArray<int> input_array;
-  static tArray<int> receive_array;
-  static int cur_input;
-  static int cur_receive;
-  static cResourceCount resource_count;
-  static bool d_useResources;
-  static tArray<double> d_emptyDoubleArray;
-  static tArray<double> d_resources;
-  
-  static bool initialized;
-  static int time_mod;
+  cWorld* m_world;
+  cPopulationInterface test_interface;
+  tArray<int> input_array;
+  tArray<int> receive_array;
+  int cur_input;
+  int cur_receive;
+  cResourceCount resource_count;
+  bool d_useResources;
+  tArray<double> d_emptyDoubleArray;
+  tArray<double> d_resources;
+  int time_mod;
 
-  static bool ProcessGestation(cCPUTestInfo & test_info, int cur_depth);
+  bool ProcessGestation(cCPUTestInfo & test_info, int cur_depth);
+  bool TestGenome_Body(cCPUTestInfo & test_info, const cGenome & genome, int cur_depth);
 
-  static bool TestGenome_Body(cCPUTestInfo & test_info, const cGenome & genome,
-			      int cur_depth);
-
 public:
-  static void Setup(cWorld* world, int resourceSize);
-  static void SetInstSet(cInstSet * in_inst_set);
+  cTestCPU(cWorld* world);
+  ~cTestCPU() { ; }
+  
+  bool TestGenome(cCPUTestInfo & test_info, const cGenome & genome);
+  bool TestGenome(cCPUTestInfo & test_info, const cGenome & genome, std::ofstream & out_fp);
 
-  static bool TestGenome(cCPUTestInfo & test_info, const cGenome & genome);
-  static bool TestGenome(cCPUTestInfo & test_info, const cGenome & genome,
-			 std::ofstream & out_fp);
+  void TestThreads(const cGenome & genome);
+  void PrintThreads(const cGenome & genome);
 
-//  static void TraceGenome(const cGenome &genome, cString filename="trace.dat");
-
-  static void TestThreads(const cGenome & genome);
-  static void PrintThreads(const cGenome & genome);
-
   // Test if a genome has any chance of being a replicator (i.e., in the
   // default set, has an allocate, a copy, and a divide).
-  static bool TestIntegrity(const cGenome & test_genome);
+  bool TestIntegrity(const cGenome & test_genome);
 
-  static cInstSet * GetInstSet() { return inst_set; }
-  static cEnvironment * GetEnvironment() { return environment; }
-  static void SetEnvironment(cEnvironment *);
-  static int GetInput();
-  static int GetInputAt(int & input_pointer);
-  static int GetReceiveValue();
-  static const tArray<double> & GetResources();
-  static void UpdateResources(const tArray<double> & res_change);
-  static void UpdateResource(int id, double change);
-  static void UpdateCellResources(const tArray<double> & res_change,
-				  const int cell_id);
-  static void SetResource(int id, double new_level);
-  static void SetupResources(void);
-  static void SetupResourceArray(const tArray<double> &resources);
-  static bool &UseResources(void) { return d_useResources; }
-  static cResourceCount &GetResourceCount(void) {return resource_count;}
+  int GetInput();
+  int GetInputAt(int & input_pointer);
+  int GetReceiveValue();
+  const tArray<double> & GetResources();
+  void SetResource(int id, double new_level);
+  void SetupResources(void);
+  void SetupResourceArray(const tArray<double> &resources);
+  bool& UseResources(void) { return d_useResources; }
+  cResourceCount& GetResourceCount(void) { return resource_count; }
 };
 
+
+// Inline Methods
+
+inline int cTestCPU::GetInput()
+{
+  if (cur_input >= input_array.GetSize()) cur_input = 0;
+  return input_array[cur_input++];
+}
+
+inline int cTestCPU::GetInputAt(int & input_pointer)
+{
+  if (input_pointer >= input_array.GetSize()) input_pointer = 0;
+  return input_array[input_pointer++];
+}
+
+inline int cTestCPU::GetReceiveValue()
+{
+  if (cur_receive >= receive_array.GetSize()) cur_receive = 0;
+  return receive_array[cur_receive++];
+}
+
+inline const tArray<double>& cTestCPU::GetResources()
+{
+  if(d_useResources) {
+    return d_resources;
+  }
+  
+  return d_emptyDoubleArray;
+}
+
+inline void cTestCPU::SetResource(int id, double new_level)
+{
+  resource_count.Set(id, new_level);
+}
+
 #endif

Modified: branches/brysonda/source/cpu/cTestUtil.cc
===================================================================
--- branches/brysonda/source/cpu/cTestUtil.cc	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/cpu/cTestUtil.cc	2005-10-22 01:56:38 UTC (rev 357)
@@ -19,6 +19,7 @@
 #include "cStats.h"
 #include "cTaskEntry.h"
 #include "cTestCPU.h"
+#include "cWorld.h"
 
 #include <fstream>
 #include <iomanip>
@@ -27,7 +28,7 @@
 using namespace std;
 
 
-void cTestUtil::PrintGenome(const cGenome & genome, cString filename,
+void cTestUtil::PrintGenome(cWorld* world, const cGenome & genome, cString filename,
 			    cGenotype * genotype, int update_out)
 {
   if (filename == "") filename.Set("%03d-unnamed", genome.GetSize());
@@ -35,7 +36,7 @@
   // Build the test info for printing.
   cCPUTestInfo test_info;
   test_info.TestThreads();
-  cTestCPU::TestGenome(test_info, genome);
+  world->GetTestCPU().TestGenome(test_info, genome);
 
   // Open the file...
 
@@ -116,8 +117,8 @@
   
   // Display the tasks performed...
   cPhenotype & phenotype = test_info.GetTestOrganism()->GetPhenotype();
-  for (int i = 0; i < phenotype.GetEnvironment().GetTaskLib().GetSize(); i++) {
-    fp << "# "<< phenotype.GetEnvironment().GetTaskLib().GetTask(i).GetName()
+  for (int i = 0; i < world->GetEnvironment().GetTaskLib().GetSize(); i++) {
+    fp << "# "<< world->GetEnvironment().GetTaskLib().GetTask(i).GetName()
        << "\t" << phenotype.GetLastTaskCount()[i]
        << endl;
   }
@@ -129,7 +130,7 @@
   cInstUtil::SaveGenome(fp, inst_set, genome);
 }
 
-void cTestUtil::PrintGenome(cInjectGenotype * inject_genotype, 
+void cTestUtil::PrintGenome(cWorld* world, cInjectGenotype * inject_genotype, 
 			    const cGenome & genome, cString filename, int update_out)
 {
   if (filename == "") filename.Set("p%03d-unnamed", genome.GetSize());
@@ -137,7 +138,7 @@
   // Build the test info for printing.
   cCPUTestInfo test_info;
   test_info.TestThreads();
-  cTestCPU::TestGenome(test_info, genome);
+  world->GetTestCPU().TestGenome(test_info, genome);
 
   // Open the file...
 

Modified: branches/brysonda/source/cpu/cTestUtil.h
===================================================================
--- branches/brysonda/source/cpu/cTestUtil.h	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/cpu/cTestUtil.h	2005-10-22 01:56:38 UTC (rev 357)
@@ -17,16 +17,16 @@
 //  of hardware in order to produce more useful test info.
 // ------------------------------------------------------------------------
 
-class cString; // aggregate
 class cGenome;
 class cGenotype;
 class cInjectGenotype;
+class cWorld;
 
 class cTestUtil {
 public:
-  static void PrintGenome(const cGenome & genome, cString filename="",
+  static void PrintGenome(cWorld* world, const cGenome & genome, cString filename="",
 			  cGenotype * genotype=NULL, int update_out=-1);
-  static void PrintGenome(cInjectGenotype * genotype, const cGenome & genome, 
+  static void PrintGenome(cWorld* world, cInjectGenotype * genotype, const cGenome & genome, 
 			  cString filename="", int update_out=-1);
 };
 

Modified: branches/brysonda/source/event/cEventManager.cc
===================================================================
--- branches/brysonda/source/event/cEventManager.cc	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/event/cEventManager.cc	2005-10-22 01:56:38 UTC (rev 357)
@@ -959,7 +959,7 @@
     cGenotype * dom = m_world->GetPopulation().GetGenebank().GetBestGenotype();
     cString filename(in_filename);
     if (filename == "") filename.Set("genebank/%s", dom->GetName()());
-    cTestUtil::PrintGenome(dom->GetGenome(), filename, dom, m_world->GetPopulation().GetUpdate());
+    cTestUtil::PrintGenome(m_world, dom->GetGenome(), filename, dom, m_world->GetPopulation().GetUpdate());
   }
 };
 
@@ -1022,7 +1022,7 @@
     if (dom!=NULL) {
       cString filename(in_filename);
       if (filename == "") filename.Set("genebank/%s", dom->GetName()());
-      cTestUtil::PrintGenome(dom, dom->GetGenome(), filename, m_world->GetPopulation().GetUpdate()); }
+      cTestUtil::PrintGenome(m_world, dom, dom->GetGenome(), filename, m_world->GetPopulation().GetUpdate()); }
   }
 };
 
@@ -2260,7 +2260,7 @@
   ///// calc_landscape /////
   void Process(){
     cGenome & genome = m_world->GetPopulation().GetGenebank().GetBestGenotype()->GetGenome();
-    cAnalyzeUtil::CalcLandscape(landscape_dist, genome,
+    cAnalyzeUtil::CalcLandscape(m_world, landscape_dist, genome,
                                 m_world->GetHardwareManager().GetInstSet());
   }
 };
@@ -2288,7 +2288,7 @@
   ///// predict_w_landscape /////
   void Process(){
     cGenome & genome = m_world->GetPopulation().GetGenebank().GetBestGenotype()->GetGenome();
-    cLandscape landscape(genome, m_world->GetHardwareManager().GetInstSet());
+    cLandscape landscape(m_world, genome, m_world->GetHardwareManager().GetInstSet());
     static ofstream fp(datafile);
     landscape.PredictWProcess(fp);
   }
@@ -2317,7 +2317,7 @@
   ///// predict_nu_landscape /////
   void Process(){
     cGenome & genome = m_world->GetPopulation().GetGenebank().GetBestGenotype()->GetGenome();
-    cLandscape landscape(genome, m_world->GetHardwareManager().GetInstSet());
+    cLandscape landscape(m_world, genome, m_world->GetHardwareManager().GetInstSet());
     static ofstream fp(datafile);
     landscape.PredictNuProcess(fp);
   }
@@ -2346,7 +2346,7 @@
   ///// sample_landscape /////
   void Process(){
     cGenome & genome = m_world->GetPopulation().GetGenebank().GetBestGenotype()->GetGenome();
-    cLandscape landscape(genome, m_world->GetHardwareManager().GetInstSet());
+    cLandscape landscape(m_world, genome, m_world->GetHardwareManager().GetInstSet());
     if (sample_size == 0) sample_size = m_world->GetHardwareManager().GetInstSet().GetSize() - 1;
     landscape.SampleProcess(sample_size);
     static ofstream fp("land-sample.dat");
@@ -2385,7 +2385,7 @@
   ///// random_landscape /////
   void Process(){
     cGenome & genome = m_world->GetPopulation().GetGenebank().GetBestGenotype()->GetGenome();
-    cLandscape landscape(genome, m_world->GetHardwareManager().GetInstSet());
+    cLandscape landscape(m_world, genome, m_world->GetHardwareManager().GetInstSet());
     landscape.RandomProcess(sample_size, landscape_dist, min_found,
                             max_sample_size, print_if_found);
     static ofstream fp("land-random.dat");
@@ -2420,8 +2420,7 @@
   ///// analyze_landscape /////
   void Process(){
     cGenome & genome = m_world->GetPopulation().GetGenebank().GetBestGenotype()->GetGenome();
-    cAnalyzeUtil::
-    AnalyzeLandscape(genome, m_world->GetHardwareManager().GetInstSet(),
+    cAnalyzeUtil::AnalyzeLandscape(m_world, genome, m_world->GetHardwareManager().GetInstSet(),
                      sample_size, min_found, max_sample_size,
                      m_world->GetPopulation().GetUpdate());
   }
@@ -2451,7 +2450,7 @@
   ///// pairtest_landscape /////
   void Process(){
     cGenome & genome = m_world->GetPopulation().GetGenebank().GetBestGenotype()->GetGenome();
-    cAnalyzeUtil::PairTestLandscape(genome, m_world->GetHardwareManager().GetInstSet(), sample_size, m_world->GetPopulation().GetUpdate());
+    cAnalyzeUtil::PairTestLandscape(m_world, genome, m_world->GetHardwareManager().GetInstSet(), sample_size, m_world->GetPopulation().GetUpdate());
   }
 };
 
@@ -2475,7 +2474,7 @@
   void Process(){
     cGenome & genome = m_world->GetPopulation().GetGenebank().GetBestGenotype()->GetGenome();
     static ofstream fp("dom-test.dat");
-    cAnalyzeUtil::TestGenome(genome, m_world->GetHardwareManager().GetInstSet(), fp, m_world->GetPopulation().GetUpdate());
+    cAnalyzeUtil::TestGenome(m_world, genome, m_world->GetHardwareManager().GetInstSet(), fp, m_world->GetPopulation().GetUpdate());
   }
 };
 
@@ -2558,7 +2557,7 @@
       histofile.open(filename2());
       histofile_testCPU.open(filename3());
     }
-    cAnalyzeUtil::PrintDetailedFitnessData( &m_world->GetPopulation(), datafile, histofile, histofile_testCPU, save_max_f_genotype, print_fitness_histo, hist_fmax, hist_fstep );
+    cAnalyzeUtil::PrintDetailedFitnessData(m_world, datafile, histofile, histofile_testCPU, save_max_f_genotype, print_fitness_histo, hist_fmax, hist_fstep );
   }
 };
 
@@ -2659,7 +2658,7 @@
     if ( auto_filename )
       filename.Set("tasks_%d.dat",m_world->GetPopulation().GetUpdate());
     ofstream snapshot_file(filename());
-    cAnalyzeUtil::TaskSnapshot( &m_world->GetPopulation(), snapshot_file );
+    cAnalyzeUtil::TaskSnapshot(m_world, snapshot_file);
   }
 };
 
@@ -2909,7 +2908,7 @@
   void Process(){
     cGenome & genome = m_world->GetPopulation().GetGenebank().GetBestGenotype()->GetGenome();
     ofstream fp("hillclimb.dat");
-    cLandscape landscape(genome, m_world->GetHardwareManager().GetInstSet());
+    cLandscape landscape(m_world, genome, m_world->GetHardwareManager().GetInstSet());
     landscape.HillClimb(fp);
   }
 };
@@ -2934,7 +2933,7 @@
   void Process(){
     cGenome & genome = m_world->GetPopulation().GetGenebank().GetBestGenotype()->GetGenome();
     ofstream fp("hillclimb.dat");
-    cLandscape landscape(genome, m_world->GetHardwareManager().GetInstSet());
+    cLandscape landscape(m_world, genome, m_world->GetHardwareManager().GetInstSet());
     landscape.HillClimb_Neut(fp);
   }
 };
@@ -2959,7 +2958,7 @@
   void Process(){
     cGenome & genome = m_world->GetPopulation().GetGenebank().GetBestGenotype()->GetGenome();
     ofstream fp("hillclimb.dat");
-    cLandscape landscape(genome, m_world->GetHardwareManager().GetInstSet());
+    cLandscape landscape(m_world, genome, m_world->GetHardwareManager().GetInstSet());
     landscape.HillClimb_Rand(fp);
   }
 };
@@ -3132,7 +3131,7 @@
   ///// test_size_change_robustness /////
   void Process(){
     ofstream & fp = m_world->GetPopulation().GetStats().GetDataFileOFStream(filename);
-    cAnalyzeUtil::TestInsSizeChangeRobustness(fp,
+    cAnalyzeUtil::TestInsSizeChangeRobustness(m_world, fp,
                                               m_world->GetHardwareManager().GetInstSet(),
                                               m_world->GetPopulation().GetGenebank().GetBestGenotype()->GetGenome(),
                                               num_trials, m_world->GetPopulation().GetUpdate());
@@ -3159,7 +3158,7 @@
   
   ///// test_threads /////
   void Process(){
-    cTestCPU::TestThreads(m_world->GetPopulation().GetGenebank().GetBestGenotype()->GetGenome());
+    m_world->GetTestCPU().TestThreads(m_world->GetPopulation().GetGenebank().GetBestGenotype()->GetGenome());
   }
 };
 
@@ -3182,7 +3181,7 @@
   }
   ///// print_threads /////
   void Process(){
-    cTestCPU::PrintThreads( m_world->GetPopulation().GetGenebank().GetBestGenotype()->GetGenome() );
+    m_world->GetTestCPU().PrintThreads( m_world->GetPopulation().GetGenebank().GetBestGenotype()->GetGenome() );
   }
 };
 
@@ -3289,7 +3288,7 @@
     cString filename;
     filename.Set("task_grid_%d.dat",m_world->GetPopulation().GetUpdate());
     ofstream fp(filename());
-    cAnalyzeUtil::TaskGrid( &m_world->GetPopulation(), fp );
+    cAnalyzeUtil::TaskGrid(m_world, fp );
   }
 };
 

Modified: branches/brysonda/source/main/cAnalyze.cc
===================================================================
--- branches/brysonda/source/main/cAnalyze.cc	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/main/cAnalyze.cc	2005-10-22 01:56:38 UTC (rev 357)
@@ -471,7 +471,7 @@
 for(unsigned int i=0; i<resources[which].second.size(); i++) {
   temp[i] = resources[which].second[i];
 }
-cTestCPU::SetupResourceArray(temp);
+m_world->GetTestCPU().SetupResourceArray(temp);
 
 return;
 }
@@ -1426,7 +1426,7 @@
       filename += ".gen";
     }
     
-    cTestUtil::PrintGenome(genotype->GetGenome(), filename);
+    cTestUtil::PrintGenome(m_world, genotype->GetGenome(), filename);
     if (verbose) cout << "Printing: " << filename << endl;
   }
 }
@@ -1456,10 +1456,10 @@
   
   if(useResources) {
     // Backup test cpu data
-    backupUsage = cTestCPU::UseResources();
-    backupResources = cTestCPU::GetResources();
+    backupUsage = m_world->GetTestCPU().UseResources();
+    backupResources = m_world->GetTestCPU().GetResources();
     
-    cTestCPU::UseResources() = true;
+    m_world->GetTestCPU().UseResources() = true;
   }
   
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
@@ -1484,7 +1484,7 @@
     test_info.TestThreads();
     test_info.SetTraceExecution(&trace_printer);
     
-    cTestCPU::TestGenome(test_info, genotype->GetGenome());
+    m_world->GetTestCPU().TestGenome(test_info, genotype->GetGenome());
     
     if (verbose) cout << "  Tracing: " << filename << endl;
     trace_fp.close();
@@ -1492,8 +1492,8 @@
   
   if(useResources) {
     // Set the test cpu back to the state it was in before we messed with it
-    cTestCPU::UseResources() = backupUsage;
-    cTestCPU::SetupResourceArray(backupResources);
+    m_world->GetTestCPU().UseResources() = backupUsage;
+    m_world->GetTestCPU().SetupResourceArray(backupResources);
   }
   
   return;
@@ -2476,9 +2476,9 @@
 
   ///////////////////////
   // Backup test CPU data
-  bool backupUsage = cTestCPU::UseResources();
-  tArray<double> backupResources(cTestCPU::GetResources());
-  cTestCPU::UseResources() = true;
+  bool backupUsage = m_world->GetTestCPU().UseResources();
+  tArray<double> backupResources(m_world->GetTestCPU().GetResources());
+  m_world->GetTestCPU().UseResources() = true;
   FillResources(update);
 
   ///////////////////////////////////////////////////////////////////////
@@ -2896,8 +2896,8 @@
   }
 
   // Set the test CPU back to the state it was 
-  cTestCPU::UseResources() = backupUsage;
-  cTestCPU::SetupResourceArray(backupResources);
+  m_world->GetTestCPU().UseResources() = backupUsage;
+  m_world->GetTestCPU().SetupResourceArray(backupResources);
     
   cpx_fp.close();
   return;
@@ -2948,9 +2948,9 @@
 
   ///////////////////////
   // Backup test CPU data
-  bool backupUsage = cTestCPU::UseResources();
-  tArray<double> backupResources(cTestCPU::GetResources());
-  cTestCPU::UseResources() = true;
+  bool backupUsage = m_world->GetTestCPU().UseResources();
+  tArray<double> backupResources(m_world->GetTestCPU().GetResources());
+  m_world->GetTestCPU().UseResources() = true;
   FillResources(update);
 
   
@@ -3238,8 +3238,8 @@
   
   
   // Set the test CPU back to the state it was 
-  cTestCPU::UseResources() = backupUsage;
-  cTestCPU::SetupResourceArray(backupResources);
+  m_world->GetTestCPU().UseResources() = backupUsage;
+  m_world->GetTestCPU().SetupResourceArray(backupResources);
     
   cpx_fp.close();
   return;
@@ -3268,7 +3268,7 @@
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   cAnalyzeGenotype * genotype = NULL;
   while ((genotype = batch_it.Next()) != NULL) {
-    cLandscape landscape(genotype->GetGenome(), inst_set);
+    cLandscape landscape(m_world, genotype->GetGenome(), inst_set);
     if (num_test == 0) landscape.Process(dist);
     else landscape.RandomProcess(num_test,dist,num_test,num_test*2);
     landscape.PrintStats(fp);
@@ -3293,7 +3293,7 @@
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   cAnalyzeGenotype * genotype = NULL;
   while ((genotype = batch_it.Next()) != NULL) {
-    cLandscape landscape(genotype->GetGenome(), inst_set);
+    cLandscape landscape(m_world, genotype->GetGenome(), inst_set);
     if (test_num == 1)  landscape.TestAllPairs(fp);
     else 		landscape.TestPairs(test_num,fp); 
     landscape.PrintStats(fp);
@@ -3428,7 +3428,7 @@
     cCPUTestInfo test_info;
           
     // Run each side, and determine viability...
-    cTestCPU::TestGenome(test_info, test_genome0);
+    m_world->GetTestCPU().TestGenome(test_info, test_genome0);
     if( test_info.IsViable() == false ) {
       fail_count++;
       if (same_mate_id == true) match_fail_count++;
@@ -4712,10 +4712,10 @@
           
 	  // Run each side, and determine viability...
           cCPUTestInfo test_info;
-          cTestCPU::TestGenome(test_info, test_genome0);
+          m_world->GetTestCPU().TestGenome(test_info, test_genome0);
           cross1_viable = test_info.IsViable();
           
-          cTestCPU::TestGenome(test_info, test_genome1);
+          m_world->GetTestCPU().TestGenome(test_info, test_genome1);
           cross2_viable = test_info.IsViable();
           
           if (cross1_viable == false) fail_count++;   
@@ -5334,7 +5334,7 @@
       cGenome test_genome(test_sequence);
       cCPUTestInfo test_info;
       test_info.TestThreads();
-      cTestCPU::TestGenome(test_info, test_genome);
+      m_world->GetTestCPU().TestGenome(test_info, test_genome);
       const double fitness = test_info.GetGenotypeFitness();
       
       //cAnalyzeGenotype test_genotype(test_sequence);
@@ -5671,14 +5671,14 @@
     
     cGenome test_genome = genotype->GetGenome();
     cCPUTestInfo test_info;
-    cTestCPU::TestGenome(test_info, test_genome);
+    m_world->GetTestCPU().TestGenome(test_info, test_genome);
     const double base_fitness = test_info.GetGenotypeFitness();
     
     for (int i = 0; i < size; i++) {
       if (prev_inst[i] == -1) num_static++;
       else {
         test_genome[i].SetOp(prev_inst[i]);
-        cTestCPU::TestGenome(test_info, test_genome);
+        m_world->GetTestCPU().TestGenome(test_info, test_genome);
         const double cur_fitness = test_info.GetGenotypeFitness();
         if (cur_fitness > base_fitness) num_detrimental++;
         else if (cur_fitness < base_fitness) num_beneficial++;
@@ -5747,10 +5747,10 @@
   
   if(useResources) {
     // Backup test cpu data
-    backupUsage = cTestCPU::UseResources();
-    backupResources = cTestCPU::GetResources();
+    backupUsage = m_world->GetTestCPU().UseResources();
+    backupResources = m_world->GetTestCPU().GetResources();
     
-    cTestCPU::UseResources() = true;
+    m_world->GetTestCPU().UseResources() = true;
   }
   
   ///////////////////////////////////////////////////////
@@ -5910,8 +5910,8 @@
   
   if(useResources) {
     // Set the test cpu back to the state it was in before we messed with it
-    cTestCPU::UseResources() = backupUsage;
-    cTestCPU::SetupResourceArray(backupResources);
+    m_world->GetTestCPU().UseResources() = backupUsage;
+    m_world->GetTestCPU().SetupResourceArray(backupResources);
   }
   
   return;
@@ -6020,7 +6020,7 @@
   cout << "Running environment command: " << endl
   << "  " << cur_string << endl;
   
-  cTestCPU::GetEnvironment()->LoadLine(cur_string);
+  m_world->GetEnvironment().LoadLine(cur_string);
 }
 
 
@@ -6179,10 +6179,10 @@
   
   if(useResources) {
     // Backup test cpu data
-    backupUsage = cTestCPU::UseResources();
-    backupResources = cTestCPU::GetResources();
+    backupUsage = m_world->GetTestCPU().UseResources();
+    backupResources = m_world->GetTestCPU().GetResources();
     
-    cTestCPU::UseResources() = true;
+    m_world->GetTestCPU().UseResources() = true;
   }
   
   if (verbose == true) {
@@ -6225,8 +6225,8 @@
   
   if(useResources) {
     // Set the test cpu back to the state it was in before we messed with it
-    cTestCPU::UseResources() = backupUsage;
-    cTestCPU::SetupResourceArray(backupResources);
+    m_world->GetTestCPU().UseResources() = backupUsage;
+    m_world->GetTestCPU().SetupResourceArray(backupResources);
   }
   
   return;
@@ -6322,9 +6322,9 @@
 void cAnalyze::PrintTestCPUResources(cString cur_string)
 {
   cout << "TestCPU is using resources: ";
-  cout << cTestCPU::UseResources() << endl;
+  cout << m_world->GetTestCPU().UseResources() << endl;
   cout << "Resources currently in TestCPU: ";
-  const tArray<double> &quantity = cTestCPU::GetResources();
+  const tArray<double> &quantity = m_world->GetTestCPU().GetResources();
   for(int i=0; i<quantity.GetSize(); i++) {
     cout << quantity.ElementAt(i) << " ";
   }
@@ -6850,7 +6850,7 @@
                                (void (cAnalyzeGenotype::*)(cString)) NULL,
                                &cAnalyzeGenotype::CompareNULL, "(N/A)", ""));
   
-  const cTaskLib & task_lib = cTestCPU::GetEnvironment()->GetTaskLib();
+  const cTaskLib & task_lib = m_world->GetEnvironment().GetTaskLib();
   for (int i = 0; i < task_lib.GetSize(); i++) {
     cString t_name, t_desc;
     t_name.Set("task.%d", i);

Modified: branches/brysonda/source/main/cAnalyzeGenotype.cc
===================================================================
--- branches/brysonda/source/main/cAnalyzeGenotype.cc	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/main/cAnalyzeGenotype.cc	2005-10-22 01:56:38 UTC (rev 357)
@@ -153,7 +153,7 @@
   if (landscape_stats != NULL) return;
 
   landscape_stats = new cAnalyzeLandscape;
-  cLandscape landscape(genome, inst_set);
+  cLandscape landscape(m_world, genome, inst_set);
   landscape.Process(1);
   landscape_stats->frac_dead = landscape.GetProbDead();
   landscape_stats->frac_neg  = landscape.GetProbNeg();
@@ -171,15 +171,14 @@
   // DDD - This does some 'interesting' things with the instruction set
   
   // Use the inst lib for this genotype... and syncrhonize environment
-  cInstSet* inst_set_backup   = cTestCPU::GetInstSet();
-  cTestCPU::SetInstSet(&inst_set);
+  
+  // Backup old instruction set, update with new
   cInstSet env_inst_set_backup = m_world->GetHardwareManager().GetInstSet();
   m_world->GetHardwareManager().GetInstSet() = inst_set;
 
-  cTestCPU::TestGenome(test_info, genome);
+  m_world->GetTestCPU().TestGenome(test_info, genome);
   
-  // Restore test CPU and environment instruction set
-  cTestCPU::SetInstSet(inst_set_backup);
+  // Restore the instruction set
   m_world->GetHardwareManager().GetInstSet() = env_inst_set_backup;
 
   viable = test_info.IsViable();

Modified: branches/brysonda/source/main/cAnalyzeUtil.cc
===================================================================
--- branches/brysonda/source/main/cAnalyzeUtil.cc	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/main/cAnalyzeUtil.cc	2005-10-22 01:56:38 UTC (rev 357)
@@ -34,11 +34,11 @@
 
 using namespace std;
 
-void cAnalyzeUtil::TestGenome(const cGenome & genome, cInstSet & inst_set,
+void cAnalyzeUtil::TestGenome(cWorld* world, const cGenome & genome, cInstSet & inst_set,
 			      ofstream & fp, int update)
 {
   cCPUTestInfo test_info;
-  cTestCPU::TestGenome(test_info, genome);
+  world->GetTestCPU().TestGenome(test_info, genome);
 
   cPhenotype &colony_phenotype = test_info.GetColonyOrganism()->GetPhenotype();
   fp << update << " "                                //  1
@@ -53,7 +53,7 @@
 
 
 
-void cAnalyzeUtil::TestInsSizeChangeRobustness(ofstream & fp,
+void cAnalyzeUtil::TestInsSizeChangeRobustness(cWorld* world, ofstream & fp,
 		    const cInstSet & inst_set, const cGenome & in_genome,
 		    int num_trials, int update)
 {
@@ -79,7 +79,7 @@
     for (int j = 0; j < num_nops; j++)  genome.Insert(ins_pos, inst_none);
 
     // Test the genome and output stats
-    if ( cTestCPU::TestGenome(test_info, genome) ){ // Daughter viable...
+    if (world->GetTestCPU().TestGenome(test_info, genome)){ // Daughter viable...
       num_viable++;
       const double child_size =
 	test_info.GetColonyOrganism()->GetGenome().GetSize();
@@ -99,10 +99,10 @@
 
 
 // Returns the genome of maximal fitness.
-cGenome cAnalyzeUtil::CalcLandscape(int dist, const cGenome & genome,
+cGenome cAnalyzeUtil::CalcLandscape(cWorld* world, int dist, const cGenome & genome,
 				    cInstSet & inst_set)
 {
-  cLandscape landscape(genome, inst_set);
+  cLandscape landscape(world, genome, inst_set);
   landscape.Process(dist);
   double peak_fitness = landscape.GetPeakFitness();
   cGenome peak_genome = landscape.GetPeakGenome();
@@ -145,10 +145,10 @@
 }
 
 
-void cAnalyzeUtil::AnalyzeLandscape(const cGenome & genome, cInstSet &inst_set,
+void cAnalyzeUtil::AnalyzeLandscape(cWorld* world, const cGenome & genome, cInstSet &inst_set,
 	       int sample_size, int min_found, int max_sample_size, int update)
 {
-  cLandscape landscape(genome, inst_set);
+  cLandscape landscape(world, genome, inst_set);
 
   static ofstream fp("land_analyze.dat");
 
@@ -180,10 +180,10 @@
 }
 
 
-void cAnalyzeUtil::PairTestLandscape(const cGenome &genome, cInstSet &inst_set,
+void cAnalyzeUtil::PairTestLandscape(cWorld* world, const cGenome &genome, cInstSet &inst_set,
 				     int sample_size, int update)
 {
-  cLandscape landscape(genome, inst_set);
+  cLandscape landscape(world, genome, inst_set);
 
   cString filename;
   filename.Set("pairtest.%d.dat", update);
@@ -297,7 +297,7 @@
 
   cString con_name;
   con_name.Set("genebank/%03d-consensus-u%i.gen", con_genome.GetSize(),update);
-  cTestUtil::PrintGenome( con_genome, con_name() );
+  cTestUtil::PrintGenome(world, con_genome, con_name());
 
 
   if (con_genotype) {
@@ -325,7 +325,7 @@
   }
   else {
     cCPUTestInfo test_info;
-    cTestCPU::TestGenome(test_info, con_genome);
+    world->GetTestCPU().TestGenome(test_info, con_genome);
     cPhenotype & colony_phenotype =
       test_info.GetColonyOrganism()->GetPhenotype();
     fp << update                                             << " "   //  1
@@ -408,7 +408,7 @@
 
     // create landscape object for this creature
     if (landscape &&  genotype->GetTestFitness() > 0) {
-      cLandscape landscape( genome, world->GetHardwareManager().GetInstSet());
+      cLandscape landscape(world, genome, world->GetHardwareManager().GetInstSet());
       landscape.Process(1);
       landscape.PrintStats(fp);
     }
@@ -416,7 +416,7 @@
     if ( save_genotype ){
       char filename[40];
       sprintf( filename, "genebank/%s", creature_name() );
-      cTestUtil::PrintGenome( genome, filename );
+      cTestUtil::PrintGenome(world, genome, filename);
     }
   }
 }
@@ -446,10 +446,11 @@
  * histograms.
  **/
 
-void cAnalyzeUtil::PrintDetailedFitnessData(cPopulation *pop, ofstream &datafp,
+void cAnalyzeUtil::PrintDetailedFitnessData(cWorld* world, ofstream &datafp,
    ofstream & hist_fp, ofstream & histo_testCPU_fp, bool save_max_f_genotype,
    bool print_fitness_histo, double hist_fmax, double hist_fstep)
 {
+  cPopulation* pop = &world->GetPopulation();
   const int update = pop->GetStats().GetUpdate();
   const double generation = pop->GetStats().SumGeneration().Average();
 
@@ -479,7 +480,7 @@
     cGenotype * genotype = organism->GetGenotype();
 
     cCPUTestInfo test_info;
-    cTestCPU::TestGenome( test_info, genotype->GetGenome() );
+    world->GetTestCPU().TestGenome( test_info, genotype->GetGenome() );
     // We calculate the fitness based on the current merit,
     // but with the true gestation time. Also, we set the fitness
     // to zero if the creature is not viable.
@@ -532,7 +533,7 @@
   if (save_max_f_genotype) {
     char filename[40];
     sprintf( filename, "genebank/%s", max_f_name() );
-    cTestUtil::PrintGenome( max_f_genotype->GetGenome(), filename );
+    cTestUtil::PrintGenome(world, max_f_genotype->GetGenome(), filename);
   }
 
   if (print_fitness_histo) {
@@ -662,7 +663,7 @@
     if (save_creatures) {
       char filename[40];
       sprintf( filename, "genebank/%s", cur_genotype->GetName()() );
-      cTestUtil::PrintGenome( genome, filename );
+      cTestUtil::PrintGenome(world, genome, filename);
     }
 
     // ...and advance to the next genotype...
@@ -682,8 +683,9 @@
  * @param fp The file into which the result should be written.
  **/
 
-void cAnalyzeUtil::TaskSnapshot(cPopulation * pop, ofstream & fp)
+void cAnalyzeUtil::TaskSnapshot(cWorld* world, ofstream & fp)
 {
+  cPopulation* pop = &world->GetPopulation();
   fp << "# (1) cell number\n# (2) number of rewarded tasks done so far\n# (3) total number of tasks done so far\n# (4) same as 2, but right before divide\n# (5) same as 3, but right before divide\n# (6) same as 2, but for parent\n# (7) same as 3, but for parent\n# (8) genotype fitness\n# (9) genotype name" << endl;
 
   for (int i = 0; i < pop->GetSize(); i++) {
@@ -692,11 +694,11 @@
 
     // create a test-cpu for the current creature
     cCPUTestInfo test_info;
-    cTestCPU::TestGenome( test_info, organism->GetGenome() );
+    world->GetTestCPU().TestGenome( test_info, organism->GetGenome() );
     cPhenotype & test_phenotype = test_info.GetTestOrganism()->GetPhenotype();
     cPhenotype & phenotype = organism->GetPhenotype();
 
-    int num_tasks = phenotype.GetEnvironment().GetTaskLib().GetSize();
+    int num_tasks = world->GetEnvironment().GetTaskLib().GetSize();
     int sum_tasks_all = 0;
     int sum_tasks_rewarded = 0;
     int divide_sum_tasks_all = 0;
@@ -735,8 +737,9 @@
   }
 }
 
-void cAnalyzeUtil::TaskGrid(cPopulation * pop, ofstream & fp)
+void cAnalyzeUtil::TaskGrid(cWorld* world, ofstream & fp)
 { 
+  cPopulation* pop = &world->GetPopulation();
   for (int i = 0; i < pop->GetWorldX(); i++) {
     for (int j = 0; j < pop->GetWorldY(); j++) {
       int task_sum = 0;
@@ -744,9 +747,9 @@
       if (pop->GetCell(cell_num).IsOccupied() == true) {
         cOrganism * organism = pop->GetCell(cell_num).GetOrganism();
         cCPUTestInfo test_info;
-        cTestCPU::TestGenome( test_info, organism->GetGenome() );
+        world->GetTestCPU().TestGenome( test_info, organism->GetGenome() );
         cPhenotype & test_phenotype = test_info.GetTestOrganism()->GetPhenotype();
-        int num_tasks = test_phenotype.GetEnvironment().GetTaskLib().GetSize();   
+        int num_tasks = world->GetEnvironment().GetTaskLib().GetSize();   
         for (int k = 0; k < num_tasks; k++) {
           if (test_phenotype.GetLastTaskCount()[k]>0) {
 	    task_sum = task_sum + (int) pow(2.0,k); 

Modified: branches/brysonda/source/main/cAnalyzeUtil.h
===================================================================
--- branches/brysonda/source/main/cAnalyzeUtil.h	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/main/cAnalyzeUtil.h	2005-10-22 01:56:38 UTC (rev 357)
@@ -22,21 +22,21 @@
 private:
 public:
   // Generic test-CPU analysis
-  static void TestGenome(const cGenome & genome, cInstSet & inst_set,
+  static void TestGenome(cWorld* world, const cGenome & genome, cInstSet & inst_set,
 			 std::ofstream & fp, int update);
 
-  static void TestInsSizeChangeRobustness(std::ofstream & fp,
+  static void TestInsSizeChangeRobustness(cWorld* world, std::ofstream & fp,
                  const cInstSet & inst_set, const cGenome & in_genome,
                  int num_trials, int update);
 
 
   // Landscape-based analysis
-  static cGenome CalcLandscape(int dist, const cGenome & genome,
+  static cGenome CalcLandscape(cWorld* world, int dist, const cGenome & genome,
 			       cInstSet & inst_set);
-  static void AnalyzeLandscape(const cGenome & genome, cInstSet & inst_set,
+  static void AnalyzeLandscape(cWorld* world, const cGenome & genome, cInstSet & inst_set,
 			       int sample_size=1000, int min_found=0,
 			       int max_sample_size=0, int update=-1);
-  static void PairTestLandscape(const cGenome & genome, cInstSet & inst_set,
+  static void PairTestLandscape(cWorld* world, const cGenome & genome, cInstSet & inst_set,
 				int sample_size=0, int update=-1);
 
 
@@ -47,7 +47,7 @@
 				double sample_prob=1, bool landscape=false,
 				bool save_genotype=false);
 
-  static void PrintDetailedFitnessData(cPopulation * pop, std::ofstream & datafp,
+  static void PrintDetailedFitnessData(cWorld* world, std::ofstream & datafp,
     std::ofstream & histofp, std::ofstream & histo_testCPU_fp, bool save_max_f_genotype,
     bool print_fitness_histo, double hist_fmax, double hist_fstep);
 
@@ -56,8 +56,8 @@
   static void GeneticDistancePopDump(cWorld* world, std::ofstream & fp,
 		    const char * creature_name, bool save_creatures=false);
 
-  static void TaskSnapshot(cPopulation * pop, std::ofstream & fp);
-  static void TaskGrid(cPopulation * pop, std::ofstream & fp);
+  static void TaskSnapshot(cWorld* world, std::ofstream & fp);
+  static void TaskGrid(cWorld* world, std::ofstream & fp);
   static void PrintViableTasksData(cWorld* world, std::ofstream &fp);
   static void PrintTreeDepths(cPopulation * pop, std::ofstream & fp);
 

Modified: branches/brysonda/source/main/cGenebank.cc
===================================================================
--- branches/brysonda/source/main/cGenebank.cc	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/main/cGenebank.cc	2005-10-22 01:56:38 UTC (rev 357)
@@ -52,7 +52,7 @@
     if (genotype_dom_time == m_world->GetConfig().GENOTYPE_PRINT_DOM.Get()) {
       cString filename;
       filename.Set("genebank/%s", best_genotype->GetName()());
-      cTestUtil::PrintGenome(best_genotype->GetGenome(), 
+      cTestUtil::PrintGenome(m_world, best_genotype->GetGenome(), 
 			     filename, best_genotype, stats.GetUpdate());
     }
   }
@@ -348,7 +348,7 @@
     // If no species was found, create a new one.
 
     if (!found_species) {
-      found_species = new cSpecies(in_genotype.GetGenome(), stats.GetUpdate());
+      found_species = new cSpecies(m_world, in_genotype.GetGenome(), stats.GetUpdate());
       if (in_genotype.GetSpecies())
 	found_species->SetParentID(in_genotype.GetSpecies()->GetID());
       species_control->SetActive(*found_species);
@@ -359,7 +359,7 @@
       if (m_world->GetConfig().SPECIES_PRINT.Get()) {
 	cString filename;
 	filename.Set("genebank/spec-%04d", found_species->GetID());
-	cTestUtil::PrintGenome(in_genotype.GetGenome(), filename,
+	cTestUtil::PrintGenome(m_world, in_genotype.GetGenome(), filename,
 			       &in_genotype, stats.GetUpdate());
       }
     }
@@ -411,7 +411,7 @@
   if (m_world->GetConfig().GENOTYPE_PRINT.Get()) {
     cString filename;
     filename.Set("genebank/%s", in_genotype.GetName()());
-    cTestUtil::PrintGenome(in_genotype.GetGenome(), filename,
+    cTestUtil::PrintGenome(m_world, in_genotype.GetGenome(), filename,
 			   &in_genotype, stats.GetUpdate());
   }
 }

Modified: branches/brysonda/source/main/cGenotype.cc
===================================================================
--- branches/brysonda/source/main/cGenotype.cc	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/main/cGenotype.cc	2005-10-22 01:56:38 UTC (rev 357)
@@ -198,7 +198,7 @@
   //  cerr << ".......Calculating test stats..." << endl;
 
   cCPUTestInfo test_info;
-  cTestCPU::TestGenome(test_info, genome);
+  m_world->GetTestCPU().TestGenome(test_info, genome);
   test_data.is_viable = test_info.IsViable();
 
   // Setup all possible test values.

Modified: branches/brysonda/source/main/cInjectGenebank.cc
===================================================================
--- branches/brysonda/source/main/cInjectGenebank.cc	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/main/cInjectGenebank.cc	2005-10-22 01:56:38 UTC (rev 357)
@@ -52,7 +52,7 @@
     if (genotype_dom_time == m_world->GetConfig().GENOTYPE_PRINT_DOM.Get()) {
       cString filename;
       filename.Set("genebank/%s", best_inject_genotype->GetName()());
-      cTestUtil::PrintGenome(best_inject_genotype, best_inject_genotype->GetGenome(), 
+      cTestUtil::PrintGenome(m_world, best_inject_genotype, best_inject_genotype->GetGenome(), 
 			     filename, stats.GetUpdate());
     }
   }
@@ -184,7 +184,7 @@
   if (m_world->GetConfig().GENOTYPE_PRINT.Get()) {
     cString filename;
     filename.Set("genebank/%s", in_inject_genotype.GetName()());
-    //cTestUtil::PrintGenome(in_inject_genotype.GetGenome(), filename,
+    //cTestUtil::PrintGenome(m_world, in_inject_genotype.GetGenome(), filename,
     //			   &in_inject_genotype, stats.GetUpdate());
   }
 }

Modified: branches/brysonda/source/main/cLandscape.cc
===================================================================
--- branches/brysonda/source/main/cLandscape.cc	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/main/cLandscape.cc	2005-10-22 01:56:38 UTC (rev 357)
@@ -16,6 +16,7 @@
 #include "cTestCPU.h"
 #include "cTestUtil.h"
 #include "cTools.h"
+#include "cWorld.h"
 
 using namespace std;
 
@@ -24,8 +25,8 @@
 //  cLandscape
 ////////////////
 
-cLandscape::cLandscape(const cGenome & in_genome, const cInstSet & in_inst_set)
-  : inst_set(in_inst_set), base_genome(1), peak_genome(1)
+cLandscape::cLandscape(cWorld* world, const cGenome & in_genome, const cInstSet & in_inst_set)
+  : m_world(world), inst_set(in_inst_set), base_genome(1), peak_genome(1)
 {
   site_count = NULL;
   Reset(in_genome);
@@ -82,7 +83,7 @@
 
 void cLandscape::ProcessGenome(cGenome & in_genome)
 {
-  cTestCPU::TestGenome(test_info, in_genome);
+  m_world->GetTestCPU().TestGenome(test_info, in_genome);
 
   test_fitness = test_info.GetColonyFitness();
 
@@ -110,7 +111,7 @@
 {
   // Collect info on base creature.
 
-  cTestCPU::TestGenome(test_info, base_genome);
+  m_world->GetTestCPU().TestGenome(test_info, base_genome);
 
   cPhenotype & phenotype = test_info.GetColonyOrganism()->GetPhenotype();
   base_fitness = phenotype.GetFitness();
@@ -541,18 +542,7 @@
 
     ProcessGenome(mod_genome);
 
-    // if (test_info.IsViable()) {
-    //if (test_fitness >= neut_min) {
-      // total_found++;
-      // If we are supposed to print those found, do so!
-      //  if (print_if_found) {
-      //    cString filename;
-      //    filename.Set("creature.land.%d.%d", distance, cur_trial);
-      //    cTestUtil::PrintGenome(mod_genome, filename);
-      //  }
-    //}
 
-
     // And reset the genome.
     for (mut_num = 0; mut_num < distance; mut_num++) {
       mod_genome[ mut_lines[mut_num] ] = base_genome[ mut_lines[mut_num] ];
@@ -737,7 +727,7 @@
 void cLandscape::HillClimb_Print(ofstream & fp, const cGenome & _genome, const int gen) const
 {
   cCPUTestInfo test_info;
-  cTestCPU::TestGenome(test_info, _genome);
+  m_world->GetTestCPU().TestGenome(test_info, _genome);
   cPhenotype &colony_phenotype = test_info.GetColonyOrganism()->GetPhenotype();
   fp << gen << " "
      << colony_phenotype.GetMerit().GetDouble() << " "
@@ -756,7 +746,7 @@
 {
   mod_genome[line1] = mut1;
   mod_genome[line2] = mut2;
-  cTestCPU::TestGenome(test_info, mod_genome);
+  m_world->GetTestCPU().TestGenome(test_info, mod_genome);
   double combo_fitness = test_info.GetColonyFitness() / base_fitness;
 
   mod_genome[line1] = base_genome[line1];
@@ -853,11 +843,11 @@
 
 void cLandscape::PrintBase(cString filename)
 {
-  cTestUtil::PrintGenome(base_genome, filename);
+  cTestUtil::PrintGenome(m_world, base_genome, filename);
 }
 
 void cLandscape::PrintPeak(cString filename)
 {
-  cTestUtil::PrintGenome(peak_genome, filename);
+  cTestUtil::PrintGenome(m_world, peak_genome, filename);
 }
 

Modified: branches/brysonda/source/main/cLandscape.h
===================================================================
--- branches/brysonda/source/main/cLandscape.h	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/main/cLandscape.h	2005-10-22 01:56:38 UTC (rev 357)
@@ -5,19 +5,19 @@
 // before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
 //////////////////////////////////////////////////////////////////////////////
 
-#ifndef LANDSCAPE_HH
-#define LANDSCAPE_HH
+#ifndef cLandscape_h
+#define cLandscape_h
 
-#ifndef CPU_TEST_INFO_HH
+#ifndef cCPUTestInfo_h
 #include "cCPUTestInfo.h"
 #endif
-#ifndef GENOME_HH
+#ifndef cGenome_h
 #include "cGenome.h"
 #endif
-#ifndef STRING_HH
+#ifndef cString_h
 #include "cString.h"
 #endif
-#ifndef TMATRIX_HH
+#ifndef tMatrix_h
 #include "tMatrix.h"
 #endif
 
@@ -28,10 +28,11 @@
 class cCPUTestInfo; // aggregate
 template <class T> class tMatrix; // aggregate
 class cInstruction;
-class cString; // aggregate
+class cWorld;
 
 struct cLandscape {
 private:
+  cWorld* m_world;
   const cInstSet & inst_set;
   cGenome base_genome;
   cGenome peak_genome;
@@ -97,7 +98,7 @@
   // disabled copy constructor.
   cLandscape(const cLandscape &);
 public:
-  cLandscape(const cGenome & in_genome, const cInstSet & in_inst_set);
+  cLandscape(cWorld* world, const cGenome & in_genome, const cInstSet & in_inst_set);
   ~cLandscape();
 
   void Reset(const cGenome & in_genome);

Modified: branches/brysonda/source/main/cMxCodeArray.cc
===================================================================
--- branches/brysonda/source/main/cMxCodeArray.cc	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/main/cMxCodeArray.cc	2005-10-22 01:56:38 UTC (rev 357)
@@ -449,7 +449,7 @@
   cGenome temp(1);
   cCPUTestInfo test_info;
   CopyDataTo(temp); 
-  cTestCPU::TestGenome(test_info, temp);
+  m_world->GetTestCPU().TestGenome(test_info, temp);
   if ( test_info.IsViable() )
     m_gestation_time =
       test_info.GetTestOrganism()->GetPhenotype().GetGestationTime();

Modified: branches/brysonda/source/main/cOrganism.cc
===================================================================
--- branches/brysonda/source/main/cOrganism.cc	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/main/cOrganism.cc	2005-10-22 01:56:38 UTC (rev 357)
@@ -33,12 +33,12 @@
 int cOrganism::instance_count(0);
 
 
-cOrganism::cOrganism(cWorld* world, const cGenome & in_genome, cEnvironment* in_env)
+cOrganism::cOrganism(cWorld* world, const cGenome & in_genome)
   : m_world(world)
   , genotype(NULL)
-  , phenotype(world, in_env ? *in_env : world->GetEnvironment())
+  , phenotype(world)
   , initial_genome(in_genome)
-  , mut_info(in_env ? in_env->GetMutationLib() : world->GetEnvironment().GetMutationLib(), in_genome.GetSize())
+  , mut_info(world->GetEnvironment().GetMutationLib(), in_genome.GetSize())
   , pop_interface(world)
   , input_pointer(0)
   , input_buf(INPUT_BUF_SIZE)
@@ -111,7 +111,7 @@
   tList<tBuffer<int> > other_output_list;
 
   // If tasks require us to consider neighbor inputs, collect them...
-  if (phenotype.GetEnvironment().GetTaskLib().UseNeighborInput() == true) {
+  if (m_world->GetEnvironment().GetTaskLib().UseNeighborInput() == true) {
     const int num_neighbors = pop_interface.GetNumNeighbors();
     for (int i = 0; i < num_neighbors; i++) {
       pop_interface.Rotate();
@@ -123,7 +123,7 @@
   }
 
   // If tasks require us to consider neighbor outputs, collect them...
-  if (phenotype.GetEnvironment().GetTaskLib().UseNeighborOutput() == true) {
+  if (m_world->GetEnvironment().GetTaskLib().UseNeighborOutput() == true) {
     const int num_neighbors = pop_interface.GetNumNeighbors();
     for (int i = 0; i < num_neighbors; i++) {
       pop_interface.Rotate();

Modified: branches/brysonda/source/main/cOrganism.h
===================================================================
--- branches/brysonda/source/main/cOrganism.h	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/main/cOrganism.h	2005-10-22 01:56:38 UTC (rev 357)
@@ -112,7 +112,7 @@
   void Fault(int fault_loc, int fault_type, cString fault_desc="");
 
 public:
-  cOrganism(cWorld* world, const cGenome & in_genome, cEnvironment* in_env = NULL);
+  cOrganism(cWorld* world, const cGenome & in_genome);
   ~cOrganism();
 
   cHardwareBase & GetHardware() { return *hardware; }

Modified: branches/brysonda/source/main/cPhenotype.cc
===================================================================
--- branches/brysonda/source/main/cPhenotype.cc	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/main/cPhenotype.cc	2005-10-22 01:56:38 UTC (rev 357)
@@ -18,16 +18,15 @@
 using namespace std;
 
 
-cPhenotype::cPhenotype(cWorld* world, const cEnvironment & _environment)
+cPhenotype::cPhenotype(cWorld* world)
   : m_world(world)
-  , environment(_environment)
   , initialized(false)
-  , cur_task_count(environment.GetTaskLib().GetSize())
-  , cur_reaction_count(environment.GetReactionLib().GetSize())
+  , cur_task_count(m_world->GetEnvironment().GetTaskLib().GetSize())
+  , cur_reaction_count(m_world->GetEnvironment().GetReactionLib().GetSize())
   , cur_inst_count(world->GetHardwareManager().GetInstSet().GetSize())
-  , sensed_resources(environment.GetResourceLib().GetSize())
-  , last_task_count(environment.GetTaskLib().GetSize())
-  , last_reaction_count(environment.GetReactionLib().GetSize())
+  , sensed_resources(m_world->GetEnvironment().GetResourceLib().GetSize())
+  , last_task_count(m_world->GetEnvironment().GetTaskLib().GetSize())
+  , last_reaction_count(m_world->GetEnvironment().GetReactionLib().GetSize())
   , last_inst_count(world->GetHardwareManager().GetInstSet().GetSize())
 {
 }
@@ -496,14 +495,15 @@
 {
   assert(initialized == true);
 
-  const int num_resources = environment.GetResourceLib().GetSize();
-  const int num_tasks = environment.GetTaskLib().GetSize();
-  const int num_reactions = environment.GetReactionLib().GetSize();
+  const cEnvironment& env = m_world->GetEnvironment();
+  const int num_resources = env.GetResourceLib().GetSize();
+  const int num_tasks = env.GetTaskLib().GetSize();
+  const int num_reactions = env.GetReactionLib().GetSize();
 
   cReactionResult result(num_resources, num_tasks, num_reactions);
 			
   // Run everything through the environment.
-  bool found = environment.TestOutput(result, input_buf, output_buf, send_buf,
+  bool found = env.TestOutput(result, input_buf, output_buf, send_buf,
 			      receive_buf, cur_task_count, cur_reaction_count,
 			      res_in, other_inputs, other_outputs);
 

Modified: branches/brysonda/source/main/cPhenotype.h
===================================================================
--- branches/brysonda/source/main/cPhenotype.h	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/main/cPhenotype.h	2005-10-22 01:56:38 UTC (rev 357)
@@ -58,7 +58,6 @@
 class cPhenotype {
 private:
   cWorld* m_world;
-  const cEnvironment & environment;
   bool initialized;
 
   // 1. These are values calculated at the last divide (of self or offspring)
@@ -127,7 +126,7 @@
   int child_copied_size; // Instruction copied into child.
 
 public:
-  cPhenotype(cWorld* world, const cEnvironment & environment);
+  cPhenotype(cWorld* world);
   ~cPhenotype();
 
   bool OK();
@@ -171,8 +170,6 @@
   }
 
   /////////////////////  Accessors -- Retrieving  ////////////////////
-  const cEnvironment & GetEnvironment() const { return environment; };
-
   const cMerit & GetMerit() const
     { assert(initialized == true); return merit; }
   int GetGenomeLength() const

Modified: branches/brysonda/source/main/cPopulation.cc
===================================================================
--- branches/brysonda/source/main/cPopulation.cc	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/main/cPopulation.cc	2005-10-22 01:56:38 UTC (rev 357)
@@ -1233,7 +1233,7 @@
     if (cur_genome_length < min_genome_length) min_genome_length = cur_genome_length;
     
     // Test what tasks this creatures has completed.
-    for (int j=0; j < phenotype.GetEnvironment().GetTaskLib().GetSize(); j++) {
+    for (int j=0; j < m_world->GetEnvironment().GetTaskLib().GetSize(); j++) {
       if (phenotype.GetCurTaskCount()[j] > 0)  stats.AddCurTask(j);
       if (phenotype.GetLastTaskCount()[j] > 0) stats.AddLastTask(j);
       if (phenotype.GetLastTaskCount()[j] > 0) 

Modified: branches/brysonda/source/main/cPopulationInterface.cc
===================================================================
--- branches/brysonda/source/main/cPopulationInterface.cc	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/main/cPopulationInterface.cc	2005-10-22 01:56:38 UTC (rev 357)
@@ -81,7 +81,7 @@
 
 int cPopulationInterface::GetInput()
 {
-  if (InTestPop()) return cTestCPU::GetInput();
+  if (InTestPop()) return m_world->GetTestCPU().GetInput();
   
   cPopulationCell & cell = m_world->GetPopulation().GetCell(cell_id);
   assert(cell.IsOccupied());
@@ -90,7 +90,7 @@
 
 int cPopulationInterface::GetInputAt(int& input_pointer)
 {
-  if (InTestPop()) return cTestCPU::GetInputAt(input_pointer);
+  if (InTestPop()) return m_world->GetTestCPU().GetInputAt(input_pointer);
   
   cPopulationCell& cell = m_world->GetPopulation().GetCell(cell_id);
   assert(cell.IsOccupied());
@@ -108,13 +108,13 @@
 
 const tArray<double> & cPopulationInterface::GetResources()
 {
-  if (InTestPop()) return cTestCPU::GetResources();  
+  if (InTestPop()) return m_world->GetTestCPU().GetResources();  
   return m_world->GetPopulation().GetCellResources(cell_id);
 }
 
 void cPopulationInterface::UpdateResources(const tArray<double> & res_change)
 {
-  if (InTestPop()) return cTestCPU::UpdateResources(res_change);
+  if (InTestPop()) return;
   return m_world->GetPopulation().UpdateCellResources(res_change, cell_id);
 }
 
@@ -149,7 +149,7 @@
 
 int cPopulationInterface::ReceiveValue()
 {
-  if (InTestPop()) return cTestCPU::GetReceiveValue();
+  if (InTestPop()) return m_world->GetTestCPU().GetReceiveValue();
   
   cPopulationCell & cell = m_world->GetPopulation().GetCell(cell_id);
   assert(cell.IsOccupied());

Modified: branches/brysonda/source/main/cSpecies.cc
===================================================================
--- branches/brysonda/source/main/cSpecies.cc	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/main/cSpecies.cc	2005-10-22 01:56:38 UTC (rev 357)
@@ -5,35 +5,19 @@
 // before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
 //////////////////////////////////////////////////////////////////////////////
 
-#ifndef SPECIES_HH
 #include "cSpecies.h"
-#endif
 
-#ifndef CPU_TEST_INFO_HH
 #include "cCPUTestInfo.h"
-#endif
-#ifndef FUNCTIONS_HH
 #include "functions.h"
-#endif
-#ifndef GENOTYPE_HH
 #include "cGenotype.h"
-#endif
-#ifndef GENOME_UTIL_HH
 #include "cGenomeUtil.h"
-#endif
-#ifndef TEST_CPU_HH
 #include "cTestCPU.h"
-#endif
 
 using namespace std;
 
-
-/////////////////
-//  cSpecies
-/////////////////
-
-cSpecies::cSpecies(const cGenome & in_genome, int update )
-  : genome(in_genome)
+cSpecies::cSpecies(cWorld* world, const cGenome & in_genome, int update )
+  : m_world(world)
+  , genome(in_genome)
   , update_born(update)
 {
   static int species_count = 0;
@@ -94,7 +78,7 @@
   // First, make some phenotypic comparisons between organisms.
   // For now, just check that they both copy-true.
 
-  cTestCPU::TestGenome(test_info, test_genome);
+  m_world->GetTestCPU().TestGenome(test_info, test_genome);
 
   // If the organisms aren't viable, return a -1...
   if (test_info.IsViable() == false) {
@@ -128,10 +112,10 @@
       cross_genome2[i] = genome[i];
    
       // Run each side, and determine viability...
-      cTestCPU::TestGenome(test_info, cross_genome1);
+      m_world->GetTestCPU().TestGenome(test_info, cross_genome1);
       cross1_viable = test_info.IsViable();
 
-      cTestCPU::TestGenome(test_info, cross_genome2);
+      m_world->GetTestCPU().TestGenome(test_info, cross_genome2);
       cross2_viable = test_info.IsViable();
     }
 

Modified: branches/brysonda/source/main/cSpecies.h
===================================================================
--- branches/brysonda/source/main/cSpecies.h	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/main/cSpecies.h	2005-10-22 01:56:38 UTC (rev 357)
@@ -22,9 +22,11 @@
 #define SPECIES_MAX_DISTANCE 20
 
 class cGenotype;
+class cWorld;
 
 class cSpecies {
 private:
+  cWorld* m_world;
   int id_num;
   int parent_id;
   cGenome genome;
@@ -42,7 +44,7 @@
   cSpecies * next;
   cSpecies * prev;
 public:
-  cSpecies(const cGenome & in_genome, int update);
+  cSpecies(cWorld* world, const cGenome & in_genome, int update);
   ~cSpecies();
 
   int Compare(const cGenome & test_genome, int max_fail_count=-1);

Modified: branches/brysonda/source/main/cWorld.cc
===================================================================
--- branches/brysonda/source/main/cWorld.cc	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/main/cWorld.cc	2005-10-22 01:56:38 UTC (rev 357)
@@ -57,9 +57,7 @@
     ExitAvida(-1);
   }
     
-  // Setup the test CPUs.
-  cTestCPU::Setup(this, m_env->GetResourceLib().GetSize());
-
+  m_test_cpu = new cTestCPU(this);
   m_pop = new cPopulation(this);
 
   //Setup Event List
@@ -70,6 +68,19 @@
   
   // Make sure the directory 'genebank' exits!
   cTools::MkDir("genebank", true);
+  
+  const bool revert_fatal = m_conf->REVERT_FATAL.Get() > 0.0;
+  const bool revert_neg = m_conf->REVERT_DETRIMENTAL.Get() > 0.0;
+  const bool revert_neut = m_conf->REVERT_NEUTRAL.Get() > 0.0;
+  const bool revert_pos = m_conf->REVERT_BENEFICIAL.Get() > 0.0;
+  const bool fail_implicit = m_conf->FAIL_IMPLICIT.Get() > 0;
+  m_test_on_div = (revert_fatal || revert_neg || revert_neut || revert_pos || fail_implicit);
+
+  const bool sterilize_fatal = m_conf->STERILIZE_FATAL.Get() > 0.0;
+  const bool sterilize_neg = m_conf->STERILIZE_DETRIMENTAL.Get() > 0.0;
+  const bool sterilize_neut = m_conf->STERILIZE_NEUTRAL.Get() > 0.0;
+  const bool sterilize_pos = m_conf->STERILIZE_BENEFICIAL.Get() > 0.0;
+  m_test_sterilize = (sterilize_fatal || sterilize_neg || sterilize_neut || sterilize_pos);
 }
 
 void cWorld::ReadEventListFile(const cString & filename)
@@ -116,6 +127,8 @@
   }
 }
 
+void cWorld::SyncEventList() { m_event_list->Sync(); }
+
 void cWorld::GetEvents()
 {  
   if (m_pop->GetSyncEvents() == true) {

Modified: branches/brysonda/source/main/cWorld.h
===================================================================
--- branches/brysonda/source/main/cWorld.h	2005-10-21 18:13:24 UTC (rev 356)
+++ branches/brysonda/source/main/cWorld.h	2005-10-22 01:56:38 UTC (rev 357)
@@ -16,12 +16,13 @@
 #ifndef cRandom_h
 #include "cRandom.h"
 #endif
-#include "cEventList.h"
 
 class cEnvironment;
 class cEventManager;
+class cEventList;
 class cHardwareManager;
 class cPopulation;
+class cTestCPU;
 
 class cWorld
 {
@@ -32,8 +33,12 @@
   cEnvironment* m_env;
   cHardwareManager* m_hw_mgr;
   cPopulation* m_pop;
+  cTestCPU* m_test_cpu;
 
   cRandom m_rng;
+  
+  bool m_test_on_div;
+  bool m_test_sterilize;
 
   void Setup();
 
@@ -43,40 +48,28 @@
   ~cWorld();
   
   void SetConfig(cAvidaConfig* cfg) { delete m_conf; m_conf = cfg; }
+  
   cAvidaConfig& GetConfig() { return *m_conf; }
+  cEnvironment& GetEnvironment() { return *m_env; }
   cHardwareManager& GetHardwareManager() { return *m_hw_mgr; }
   cPopulation& GetPopulation() { return *m_pop; }
-  cEnvironment& GetEnvironment() { return *m_env; }
+  cRandom& GetRandom() { return m_rng; }
+  cTestCPU& GetTestCPU() { return *m_test_cpu; }
 
   // Config Dependent Modes
-  bool GetTestOnDivide() const
-  {
-    const bool revert_fatal = m_conf->REVERT_FATAL.Get() > 0.0;
-    const bool revert_neg = m_conf->REVERT_DETRIMENTAL.Get() > 0.0;
-    const bool revert_neut = m_conf->REVERT_NEUTRAL.Get() > 0.0;
-    const bool revert_pos = m_conf->REVERT_BENEFICIAL.Get() > 0.0;
-    const bool fail_implicit = m_conf->FAIL_IMPLICIT.Get() > 0;
-    return (revert_fatal || revert_neg || revert_neut || revert_pos || fail_implicit);
-  }
-  bool GetTestSterilize() const
-  {
-    const bool sterilize_fatal = m_conf->STERILIZE_FATAL.Get() > 0.0;
-    const bool sterilize_neg = m_conf->STERILIZE_DETRIMENTAL.Get() > 0.0;
-    const bool sterilize_neut = m_conf->STERILIZE_NEUTRAL.Get() > 0.0;
-    const bool sterilize_pos = m_conf->STERILIZE_BENEFICIAL.Get() > 0.0;
-    return (sterilize_fatal || sterilize_neg || sterilize_neut || sterilize_pos);
-  }
+  bool GetTestOnDivide() const { return m_test_on_div; }
+  bool GetTestSterilize() const { return m_test_sterilize; }
   
-  cRandom& GetRandom() { return m_rng; }
-
-  void GetEvents();
-  void ReadEventListFile(const cString & filename);
-  void SyncEventList() { m_event_list->Sync(); }
-
+  // Convenience Accessors
   int GetNumInstructions();
   int GetNumTasks();
   int GetNumReactions();
   int GetNumResources();
+
+  // DDD - Inherited from cAvidaDriver heritage
+  void GetEvents();
+  void ReadEventListFile(const cString & filename);
+  void SyncEventList();
 };
 
 #endif




More information about the Avida-cvs mailing list