[Avida-SVN] r1159 - in development: Avida.xcodeproj source/actions source/analyze source/classification source/cpu source/main source/targets/avida-viewer

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Fri Dec 29 11:25:25 PST 2006


Author: brysonda
Date: 2006-12-29 14:25:24 -0500 (Fri, 29 Dec 2006)
New Revision: 1159

Removed:
   development/source/cpu/cTestUtil.cc
   development/source/cpu/cTestUtil.h
Modified:
   development/Avida.xcodeproj/project.pbxproj
   development/source/actions/LandscapeActions.cc
   development/source/actions/PrintActions.cc
   development/source/analyze/cAnalyze.cc
   development/source/analyze/cMutationalNeighborhood.cc
   development/source/classification/cClassificationManager.cc
   development/source/cpu/CMakeLists.txt
   development/source/cpu/SConscript
   development/source/cpu/cHardwareStatusPrinter.cc
   development/source/cpu/cHardwareStatusPrinter.h
   development/source/cpu/cHardwareTracer.h
   development/source/cpu/cTestCPU.cc
   development/source/cpu/cTestCPU.h
   development/source/main/cEnvReqs.h
   development/source/main/cEnvironment.cc
   development/source/main/cEnvironment.h
   development/source/main/cLandscape.cc
   development/source/main/cLandscape.h
   development/source/main/cOrganism.cc
   development/source/main/cOrganism.h
   development/source/main/cPhenotype.cc
   development/source/main/cPhenotype.h
   development/source/main/cPopulation.cc
   development/source/main/cStats.cc
   development/source/main/cStats.h
   development/source/main/cTaskEntry.h
   development/source/main/cTaskLib.cc
   development/source/main/cWorld.cc
   development/source/main/cWorld.h
   development/source/targets/avida-viewer/cAnalyzeView.cc
   development/source/targets/avida-viewer/cStatsScreen.cc
   development/source/targets/avida-viewer/cView.cc
   development/source/targets/avida-viewer/cZoomScreen.cc
Log:
Add support for true random inputs (all bits random) within the environment.  This can be enabled by a task via the cEnvReqs object.

Add PrintFinalStatus method to cOrganism, called when tracing organisms.   Prints out the final phenotype stats to the trace file, so that on-divide tasks can be seen.

Enhance cPhenotype PrintStatus to output task quality next to the task count.

Merge all usage of PrintGenome into cTestCPU for consistency.  Removed cTestUtil.

Adjusted task access methods so that cTaskLib is now effectively an implementation detail of cEnvironment, rather than an exposed data structure.

cStats now initializes its own dependencies upon cEnvironment for task related stats.   Additional dependencies should be cleared up in the future.

Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/Avida.xcodeproj/project.pbxproj	2006-12-29 19:25:24 UTC (rev 1159)
@@ -233,12 +233,10 @@
 		70C1F02C08C3C71300F50912 /* cHardwareStatusPrinter.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02408C3C71300F50912 /* cHardwareStatusPrinter.cc */; };
 		70C1F02E08C3C71300F50912 /* cHeadCPU.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02608C3C71300F50912 /* cHeadCPU.cc */; };
 		70C1F03008C3C71300F50912 /* cTestCPU.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02808C3C71300F50912 /* cTestCPU.cc */; };
-		70C1F03108C3C71300F50912 /* cTestUtil.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02908C3C71300F50912 /* cTestUtil.cc */; };
 		70C1F03308C3C71300F50912 /* cHardwareSMT.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02308C3C71300F50912 /* cHardwareSMT.cc */; };
 		70C1F03408C3C71300F50912 /* cHardwareStatusPrinter.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02408C3C71300F50912 /* cHardwareStatusPrinter.cc */; };
 		70C1F03608C3C71300F50912 /* cHeadCPU.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02608C3C71300F50912 /* cHeadCPU.cc */; };
 		70C1F03808C3C71300F50912 /* cTestCPU.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02808C3C71300F50912 /* cTestCPU.cc */; };
-		70C1F03908C3C71300F50912 /* cTestUtil.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02908C3C71300F50912 /* cTestUtil.cc */; };
 		70C5BC6509059A970028A785 /* cWorld.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C5BC6309059A970028A785 /* cWorld.cc */; };
 		70C5BC6709059A970028A785 /* cWorld.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C5BC6309059A970028A785 /* cWorld.cc */; };
 		70C5BD6B0905CE5F0028A785 /* cHardwareManager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C5BD690905CE5F0028A785 /* cHardwareManager.cc */; };
@@ -284,7 +282,6 @@
 		70DCACAF097AF7CC002F8733 /* cHardwareStatusPrinter.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02408C3C71300F50912 /* cHardwareStatusPrinter.cc */; };
 		70DCACB0097AF7CC002F8733 /* cHeadCPU.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02608C3C71300F50912 /* cHeadCPU.cc */; };
 		70DCACB2097AF7CC002F8733 /* cTestCPU.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02808C3C71300F50912 /* cTestCPU.cc */; };
-		70DCACB3097AF7CC002F8733 /* cTestUtil.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02908C3C71300F50912 /* cTestUtil.cc */; };
 		70DCACB6097AF7CC002F8733 /* cEnvironment.cc in Sources */ = {isa = PBXBuildFile; fileRef = 702D4EFC08DA5341007BA469 /* cEnvironment.cc */; };
 		70DCACB7097AF7CC002F8733 /* cPopulationInterface.cc in Sources */ = {isa = PBXBuildFile; fileRef = 702D4EFD08DA5341007BA469 /* cPopulationInterface.cc */; };
 		70DCACB8097AF7CC002F8733 /* cBirthChamber.cc in Sources */ = {isa = PBXBuildFile; fileRef = 702D4F3F08DA61FE007BA469 /* cBirthChamber.cc */; };
@@ -813,12 +810,10 @@
 		70C1F01B08C3C6FC00F50912 /* cHeadCPU.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cHeadCPU.h; sourceTree = "<group>"; };
 		70C1F01D08C3C6FC00F50912 /* cInstLibCPU.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cInstLibCPU.h; sourceTree = "<group>"; };
 		70C1F01F08C3C6FC00F50912 /* cTestCPU.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cTestCPU.h; sourceTree = "<group>"; };
-		70C1F02008C3C6FC00F50912 /* cTestUtil.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cTestUtil.h; sourceTree = "<group>"; };
 		70C1F02308C3C71300F50912 /* cHardwareSMT.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cHardwareSMT.cc; sourceTree = "<group>"; };
 		70C1F02408C3C71300F50912 /* cHardwareStatusPrinter.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cHardwareStatusPrinter.cc; sourceTree = "<group>"; };
 		70C1F02608C3C71300F50912 /* cHeadCPU.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cHeadCPU.cc; sourceTree = "<group>"; };
 		70C1F02808C3C71300F50912 /* cTestCPU.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cTestCPU.cc; sourceTree = "<group>"; };
-		70C1F02908C3C71300F50912 /* cTestUtil.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cTestUtil.cc; sourceTree = "<group>"; };
 		70C1F0A808C3FF1800F50912 /* nHardware.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nHardware.h; sourceTree = "<group>"; };
 		70C5BC6209059A970028A785 /* cWorld.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cWorld.h; sourceTree = "<group>"; };
 		70C5BC6309059A970028A785 /* cWorld.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cWorld.cc; sourceTree = "<group>"; };
@@ -1410,8 +1405,6 @@
 				70C1EF6008C3953A00F50912 /* cCPUStack.h */,
 				70C1F02808C3C71300F50912 /* cTestCPU.cc */,
 				70C1F01F08C3C6FC00F50912 /* cTestCPU.h */,
-				70C1F02908C3C71300F50912 /* cTestUtil.cc */,
-				70C1F02008C3C6FC00F50912 /* cTestUtil.h */,
 				70C1F0A808C3FF1800F50912 /* nHardware.h */,
 				70C1EF6708C395D300F50912 /* sCPUStats.h */,
 				706D30CC0852328F00D7DC8F /* tInstLib.h */,
@@ -1917,7 +1910,6 @@
 				70C1F03408C3C71300F50912 /* cHardwareStatusPrinter.cc in Sources */,
 				70C1F03608C3C71300F50912 /* cHeadCPU.cc in Sources */,
 				70C1F03808C3C71300F50912 /* cTestCPU.cc in Sources */,
-				70C1F03908C3C71300F50912 /* cTestUtil.cc in Sources */,
 				702D4F0608DA5341007BA469 /* cEnvironment.cc in Sources */,
 				702D4F0708DA5341007BA469 /* cPopulationInterface.cc in Sources */,
 				702D4F4B08DA61FE007BA469 /* cBirthChamber.cc in Sources */,
@@ -2060,7 +2052,6 @@
 				70DCACAF097AF7CC002F8733 /* cHardwareStatusPrinter.cc in Sources */,
 				70DCACB0097AF7CC002F8733 /* cHeadCPU.cc in Sources */,
 				70DCACB2097AF7CC002F8733 /* cTestCPU.cc in Sources */,
-				70DCACB3097AF7CC002F8733 /* cTestUtil.cc in Sources */,
 				70DCACB6097AF7CC002F8733 /* cEnvironment.cc in Sources */,
 				70DCACB7097AF7CC002F8733 /* cPopulationInterface.cc in Sources */,
 				70DCACB8097AF7CC002F8733 /* cBirthChamber.cc in Sources */,
@@ -2178,7 +2169,6 @@
 				70C1F02C08C3C71300F50912 /* cHardwareStatusPrinter.cc in Sources */,
 				70C1F02E08C3C71300F50912 /* cHeadCPU.cc in Sources */,
 				70C1F03008C3C71300F50912 /* cTestCPU.cc in Sources */,
-				70C1F03108C3C71300F50912 /* cTestUtil.cc in Sources */,
 				702D4F0108DA5341007BA469 /* cEnvironment.cc in Sources */,
 				702D4F0208DA5341007BA469 /* cPopulationInterface.cc in Sources */,
 				702D4F4508DA61FE007BA469 /* cBirthChamber.cc in Sources */,

Modified: development/source/actions/LandscapeActions.cc
===================================================================
--- development/source/actions/LandscapeActions.cc	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/actions/LandscapeActions.cc	2006-12-29 19:25:24 UTC (rev 1159)
@@ -27,7 +27,6 @@
 #include "cPopulationCell.h"
 #include "cStats.h"
 #include "cString.h"
-#include "cTestUtil.h"
 #include "cWorld.h"
 #include "cWorldDriver.h"
 #include "tSmartArray.h"

Modified: development/source/actions/PrintActions.cc
===================================================================
--- development/source/actions/PrintActions.cc	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/actions/PrintActions.cc	2006-12-29 19:25:24 UTC (rev 1159)
@@ -13,6 +13,7 @@
 #include "cActionLibrary.h"
 #include "cClassificationManager.h"
 #include "cCPUTestInfo.h"
+#include "cEnvironment.h"
 #include "cGenome.h"
 #include "cGenomeUtil.h"
 #include "cGenotype.h"
@@ -27,7 +28,6 @@
 #include "cPopulationCell.h"
 #include "cSpecies.h"
 #include "cStats.h"
-#include "cTestUtil.h"
 #include "cWorld.h"
 #include "cWorldDriver.h"
 
@@ -394,7 +394,9 @@
     cGenotype* dom = m_world->GetClassificationManager().GetBestGenotype();
     cString filename(m_filename);
     if (filename == "") filename.Set("archive/%s.org", static_cast<const char*>(dom->GetName()));
-    cTestUtil::PrintGenome(m_world, dom->GetGenome(), filename, dom, m_world->GetStats().GetUpdate());
+    cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
+    testcpu->PrintGenome(ctx, dom->GetGenome(), filename, dom, m_world->GetStats().GetUpdate());
+    delete testcpu;
   }
 };
 
@@ -428,7 +430,9 @@
     if (dom != NULL) {
       cString filename(m_filename);
       if (filename == "") filename.Set("archive/%s.para", static_cast<const char*>(dom->GetName()));
-      cTestUtil::PrintGenome(m_world, dom, dom->GetGenome(), filename, m_world->GetStats().GetUpdate());
+      cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
+      testcpu->PrintInjectGenome(ctx, dom, dom->GetGenome(), filename, m_world->GetStats().GetUpdate());
+      delete testcpu;
     }
   }
 };
@@ -608,7 +612,6 @@
       }
     }
     
-    delete testcpu;
     
     // determine the name of the maximum fitness genotype
     cString max_f_name;
@@ -629,9 +632,11 @@
     
     if (m_save_max) {
       cString filename;
-      filename.Set("classmgr/%s", static_cast<const char*>(max_f_name));
-      cTestUtil::PrintGenome(m_world, max_f_genotype->GetGenome(), filename);
+      filename.Set("archive/%s", static_cast<const char*>(max_f_name));
+      testcpu->PrintGenome(ctx, max_f_genotype->GetGenome(), filename);
     }
+
+    delete testcpu;
     
     if (m_print_fitness_histo) {
       cDataFile& hdf = m_world->GetDataFile(m_filenames[1]);
@@ -817,7 +822,9 @@
       
       // save into archive
       if (m_save_genotypes) {
-        cTestUtil::PrintGenome(m_world, genome, cStringUtil::Stringf("archive/%s.org", static_cast<const char*>(cur_genotype->GetName())));
+        cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
+        testcpu->PrintGenome(ctx, genome, cStringUtil::Stringf("archive/%s.org", static_cast<const char*>(cur_genotype->GetName())));
+        delete testcpu;
       }
       
       // ...and advance to the next genotype...
@@ -898,7 +905,7 @@
       cPhenotype& test_phenotype = test_info.GetTestPhenotype();
       cPhenotype& phenotype = organism->GetPhenotype();
       
-      int num_tasks = m_world->GetNumTasks();
+      int num_tasks = m_world->GetEnvironment().GetNumTasks();
       int sum_tasks_all = 0;
       int sum_tasks_rewarded = 0;
       int divide_sum_tasks_all = 0;
@@ -958,7 +965,7 @@
   {
     cDataFile& df = m_world->GetDataFile(m_filename);
     cPopulation& pop = m_world->GetPopulation();
-    const int num_tasks = m_world->GetNumTasks();
+    const int num_tasks = m_world->GetEnvironment().GetNumTasks();
     
     tArray<int> tasks(num_tasks);
     tasks.SetAll(0);
@@ -1136,7 +1143,9 @@
     
     cString con_name;
     con_name.Set("archive/%03d-consensus-u%i.gen", con_genome.GetSize(),update);
-    cTestUtil::PrintGenome(m_world, con_genome, con_name);
+    cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
+    testcpu->PrintGenome(ctx, con_genome, con_name);
+    delete testcpu;
     
     
     if (con_genotype) {
@@ -1310,7 +1319,7 @@
     cPopulation* pop = &m_world->GetPopulation();
     cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
     
-    const int num_tasks = m_world->GetNumTasks();
+    const int num_tasks = m_world->GetEnvironment().GetNumTasks();
 
     for (int i = 0; i < pop->GetWorldX(); i++) {
       for (int j = 0; j < pop->GetWorldY(); j++) {

Modified: development/source/analyze/cAnalyze.cc
===================================================================
--- development/source/analyze/cAnalyze.cc	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/analyze/cAnalyze.cc	2006-12-29 19:25:24 UTC (rev 1159)
@@ -42,13 +42,11 @@
 #include "cPhenotype.h"
 #include "cSpecies.h"
 #include "tArgDataEntry.h"
-#include "cTaskEntry.h"
 #include "tDataEntry.h"
 #include "tDataEntryCommand.h"
 #include "tMatrix.h"
 #include "cTestCPU.h"
 #include "cCPUTestInfo.h"
-#include "cTestUtil.h"
 #include "cResource.h"
 #include "tHashTable.h"
 #include "cWorld.h"
@@ -117,8 +115,8 @@
 
 void cAnalyze::RunFile(cString filename)
 {
-  bool saved_analyze = m_world->GetDefaultContext().GetAnalyzeMode();
-  m_world->GetDefaultContext().SetAnalyzeMode();
+  bool saved_analyze = m_ctx.GetAnalyzeMode();
+  m_ctx.SetAnalyzeMode();
 
   cInitFile analyze_file(filename);
   analyze_file.Load();
@@ -128,7 +126,7 @@
   LoadCommandList(analyze_file, command_list);
   ProcessCommands(command_list);
   
-  if (!saved_analyze) m_world->GetDefaultContext().ClearAnalyzeMode();
+  if (!saved_analyze) m_ctx.ClearAnalyzeMode();
 }
 
 //////////////// Loading methods...
@@ -1581,7 +1579,7 @@
   if (cur_string.GetSize()) type = cur_string.PopWord();
   if (type == "task") {
     if (cur_string.GetSize()) arg_i = cur_string.PopWord().AsInt();
-    const int env_size = m_world->GetEnvironment().GetTaskLib().GetSize();
+    const int env_size = m_world->GetEnvironment().GetNumTasks();
     if (arg_i < 0 || arg_i >= env_size) arg_i = env_size - 1;
   }
   cString lin_type("num_cpus");
@@ -1621,7 +1619,8 @@
   cString directory = PopDirectory(cur_string, "archive/");
   
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * genotype = NULL;
+  cAnalyzeGenotype* genotype = NULL;
+  cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
   while ((genotype = batch_it.Next()) != NULL) {
     cString filename(directory);
     
@@ -1633,9 +1632,10 @@
       filename += ".gen";
     }
     
-    cTestUtil::PrintGenome(m_world, genotype->GetGenome(), filename);
+    testcpu->PrintGenome(m_ctx, genotype->GetGenome(), filename);
     if (m_world->GetVerbosity() >= VERBOSE_ON) cout << "Printing: " << filename << endl;
   }
+  delete testcpu;
 }
 
 void cAnalyze::CommandTrace(cString cur_string)
@@ -4266,7 +4266,9 @@
   
   cFitnessMatrix matrix(m_world, genotype->GetGenome(), &inst_set);
   
-  matrix.CalcFitnessMatrix( depth_limit, fitness_threshold_ratio, ham_thresh, error_rate_min, error_rate_max, error_rate_step, vect_fmax, vect_fstep, diag_iters, write_ham_vector, write_full_vector );
+  matrix.CalcFitnessMatrix(depth_limit, fitness_threshold_ratio, ham_thresh, error_rate_min,
+                           error_rate_max, error_rate_step, vect_fmax, vect_fstep, diag_iters,
+                           write_ham_vector, write_full_vector );
 }
 
 
@@ -7674,14 +7676,13 @@
                                (void (cAnalyzeGenotype::*)(cString)) NULL,
                                &cAnalyzeGenotype::CompareNULL, "(N/A)", ""));
   
-  const cTaskLib & task_lib = m_world->GetEnvironment().GetTaskLib();
-  for (int i = 0; i < task_lib.GetSize(); i++) {
+  const cEnvironment& environment = m_world->GetEnvironment();
+  for (int i = 0; i < environment.GetNumTasks(); i++) {
     cString t_name, t_desc;
     t_name.Set("task.%d", i);
-    t_desc = task_lib.GetTask(i).GetDesc();
+    t_desc = environment.GetTask(i).GetDesc();
     genotype_data_list.PushRear(new tArgDataEntry<cAnalyzeGenotype, int, int>
-                                (t_name, t_desc, &cAnalyzeGenotype::GetTaskCount, i,
-                                 &cAnalyzeGenotype::CompareTaskCount));
+                                (t_name, t_desc, &cAnalyzeGenotype::GetTaskCount, i, &cAnalyzeGenotype::CompareTaskCount));
   }
   
   // The remaining values should actually go in a seperate list called
@@ -7919,8 +7920,8 @@
 
 void cAnalyze::RunInteractive()
 {
-  bool saved_analyze = m_world->GetDefaultContext().GetAnalyzeMode();
-  m_world->GetDefaultContext().SetAnalyzeMode();
+  bool saved_analyze = m_ctx.GetAnalyzeMode();
+  m_ctx.SetAnalyzeMode();
   
   cout << "Entering interactive mode..." << endl;
   
@@ -7964,5 +7965,5 @@
     else cerr << "Error: Unknown command '" << command << "'." << endl;
   }
   
-  if (!saved_analyze) m_world->GetDefaultContext().ClearAnalyzeMode();
+  if (!saved_analyze) m_ctx.ClearAnalyzeMode();
 }

Modified: development/source/analyze/cMutationalNeighborhood.cc
===================================================================
--- development/source/analyze/cMutationalNeighborhood.cc	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/analyze/cMutationalNeighborhood.cc	2006-12-29 19:25:24 UTC (rev 1159)
@@ -18,9 +18,8 @@
 #include "cHardwareManager.h"
 #include "cOrganism.h"
 #include "cPhenotype.h"
-#include "cStats.h"             // For GetUpdate in outputs...
+#include "cStats.h"
 #include "cTestCPU.h"
-#include "cTestUtil.h"
 #include "cTools.h"
 #include "cWorld.h"
 #include "tAnalyzeJob.h"

Modified: development/source/classification/cClassificationManager.cc
===================================================================
--- development/source/classification/cClassificationManager.cc	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/classification/cClassificationManager.cc	2006-12-29 19:25:24 UTC (rev 1159)
@@ -13,13 +13,14 @@
 #include "cDataFile.h"
 #include "cGenome.h"
 #include "cGenotype.h"
+#include "cHardwareManager.h"
 #include "cInjectGenotype.h"
 #include "cLineage.h"
 #include "cOrganism.h"
 #include "cSpecies.h"
 #include "cStats.h"
 #include "cStringList.h"
-#include "cTestUtil.h"
+#include "cTestCPU.h"
 #include "cWorld.h"
 #include "cWorldDriver.h"
 
@@ -59,6 +60,8 @@
 {
   cGenotype* best_genotype = GetBestGenotype();
   
+  cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
+
   m_species_ctl->Purge(m_world->GetStats());
   if (best_genotype && best_genotype->GetID() != m_genotype_prev_dom) {
     m_genotype_dom_time = 0;
@@ -69,8 +72,8 @@
     if (m_genotype_dom_time == m_world->GetConfig().GENOTYPE_PRINT_DOM.Get()) {
       cString filename;
       filename.Set("archive/%s", static_cast<const char*>(best_genotype->GetName()));
-      cTestUtil::PrintGenome(m_world, best_genotype->GetGenome(), 
-                             filename, best_genotype, m_world->GetStats().GetUpdate());
+      testcpu->PrintGenome(m_world->GetDefaultContext(), best_genotype->GetGenome(), 
+                           filename, best_genotype, m_world->GetStats().GetUpdate());
     }
   }
   
@@ -86,11 +89,13 @@
       if (m_inject_dom_time == m_world->GetConfig().GENOTYPE_PRINT_DOM.Get()) {
         cString filename;
         filename.Set("archive/%s", static_cast<const char*>(best_inject_genotype->GetName()));
-        cTestUtil::PrintGenome(m_world, best_inject_genotype, best_inject_genotype->GetGenome(), 
+        testcpu->PrintInjectGenome(m_world->GetDefaultContext(), best_inject_genotype, best_inject_genotype->GetGenome(), 
                                filename, m_world->GetStats().GetUpdate());
       }
     }
   }
+
+  delete testcpu;
 }
 
 void cClassificationManager::AddGenotype(cGenotype* in_genotype, int list_num)
@@ -362,8 +367,10 @@
       if (m_world->GetConfig().SPECIES_PRINT.Get()) {
         cString filename;
         filename.Set("archive/spec-%04d", found_species->GetID());
-        cTestUtil::PrintGenome(m_world, in_genotype.GetGenome(), filename,
-                               &in_genotype, m_world->GetStats().GetUpdate());
+        cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
+        testcpu->PrintGenome(m_world->GetDefaultContext(), in_genotype.GetGenome(), filename,
+                             &in_genotype, m_world->GetStats().GetUpdate());
+        delete testcpu;
       }
     } else {
       // If we are not creating a new species, but are adding a threshold
@@ -411,8 +418,10 @@
   if (m_world->GetConfig().GENOTYPE_PRINT.Get()) {
     cString filename;
     filename.Set("archive/%s", static_cast<const char*>(in_genotype.GetName()));
-    cTestUtil::PrintGenome(m_world, in_genotype.GetGenome(), filename,
-                           &in_genotype, m_world->GetStats().GetUpdate());
+    cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
+    testcpu->PrintGenome(m_world->GetDefaultContext(), in_genotype.GetGenome(), filename,
+                         &in_genotype, m_world->GetStats().GetUpdate());
+    delete testcpu;
   }
 }
 

Modified: development/source/cpu/CMakeLists.txt
===================================================================
--- development/source/cpu/CMakeLists.txt	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/cpu/CMakeLists.txt	2006-12-29 19:25:24 UTC (rev 1159)
@@ -12,7 +12,6 @@
   cHeadCPU.cc
   cTestCPU.cc
   cTestCPUInterface.cc
-  cTestUtil.cc
 )
 
 INCLUDE_DIRECTORIES(${ALL_INC_DIRS})

Modified: development/source/cpu/SConscript
===================================================================
--- development/source/cpu/SConscript	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/cpu/SConscript	2006-12-29 19:25:24 UTC (rev 1159)
@@ -19,7 +19,6 @@
   'cInstLibCPU.h',
   'cTestCPU.h',
   'cTestCPUInterface.h',
-  'cTestUtil.h',
   'nHardware.h',
   'sCPUStats.h',
   'tInstLib.h',
@@ -39,7 +38,6 @@
   'cHeadCPU.cc',
   'cTestCPU.cc',
   'cTestCPUInterface.cc',
-  'cTestUtil.cc',
 ]
 
 environment.Library('cpu', srcs) 

Modified: development/source/cpu/cHardwareStatusPrinter.cc
===================================================================
--- development/source/cpu/cHardwareStatusPrinter.cc	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/cpu/cHardwareStatusPrinter.cc	2006-12-29 19:25:24 UTC (rev 1159)
@@ -26,16 +26,7 @@
   if (organism) organism->PrintStatus(m_trace_fp, next_name);
 }
 
-void cHardwareStatusPrinter::TraceTestCPU(int time_used, int time_allocated, int size, 
-                                          const cString& final_memory, const cString& child_memory)
+void cHardwareStatusPrinter::TraceTestCPU(int time_used, int time_allocated, const cOrganism& organism)
 {
-  if (time_used == time_allocated) {
-    m_trace_fp << endl << "# TIMEOUT: No offspring produced." << endl;
-  } else if (size == 0) {
-    m_trace_fp << endl << "# ORGANISM DEATH: No offspring produced." << endl;
-  } else {
-    m_trace_fp << endl;
-    m_trace_fp << "# Final Memory: " << final_memory << endl;
-    m_trace_fp << "# Child Memory: " << child_memory << endl;
-  }
+  organism.PrintFinalStatus(m_trace_fp, time_used, time_allocated);
 }

Modified: development/source/cpu/cHardwareStatusPrinter.h
===================================================================
--- development/source/cpu/cHardwareStatusPrinter.h	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/cpu/cHardwareStatusPrinter.h	2006-12-29 19:25:24 UTC (rev 1159)
@@ -16,11 +16,7 @@
 #ifndef cHardwareTracer_h
 #include "cHardwareTracer.h"
 #endif
-#ifndef cString_h
-#include "cString.h"
-#endif
 
-class cHardwareBase;
 
 class cHardwareStatusPrinter : public cHardwareTracer
 {
@@ -36,8 +32,7 @@
   cHardwareStatusPrinter(std::ostream& trace_fp) : m_trace_fp(trace_fp) { ; }
 
   virtual void TraceHardware(cHardwareBase& hardware, bool bonus);
-  virtual void TraceTestCPU(int time_used, int time_allocated, int size,
-                            const cString& final_memory, const cString& child_memory);
+  virtual void TraceTestCPU(int time_used, int time_allocated, const cOrganism& organism);
 };
 
 

Modified: development/source/cpu/cHardwareTracer.h
===================================================================
--- development/source/cpu/cHardwareTracer.h	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/cpu/cHardwareTracer.h	2006-12-29 19:25:24 UTC (rev 1159)
@@ -12,6 +12,7 @@
 #define cHardwareTracer_h
 
 class cHardwareBase;
+class cOrganism;
 class cString;
 
 class cHardwareTracer
@@ -19,8 +20,7 @@
 public:
   virtual ~cHardwareTracer() { ; }
   virtual void TraceHardware(cHardwareBase&, bool bonus = false) = 0;
-  virtual void TraceTestCPU(int time_used, int time_allocated, int size,
-                            const cString& final_memory, const cString& child_memory) = 0;
+  virtual void TraceTestCPU(int time_used, int time_allocated, const cOrganism& organism)= 0;
 };
 
 #endif

Modified: development/source/cpu/cTestCPU.cc
===================================================================
--- development/source/cpu/cTestCPU.cc	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/cpu/cTestCPU.cc	2006-12-29 19:25:24 UTC (rev 1159)
@@ -18,6 +18,7 @@
 #include "cHardwareBase.h"
 #include "cHardwareManager.h"
 #include "cHardwareStatusPrinter.h"
+#include "cInjectGenotype.h"
 #include "cInstSet.h"
 #include "cInstUtil.h"
 #include "cOrganism.h"
@@ -155,8 +156,7 @@
   organism.GetHardware().SetTrace(NULL);
 
   // Print out some final info in trace...
-  if (tracer != NULL) tracer->TraceTestCPU(time_used, time_allocated, organism.GetHardware().GetMemory().GetSize(),
-                                           organism.GetHardware().GetMemory().AsString(), organism.ChildGenome().AsString());
+  if (tracer != NULL) tracer->TraceTestCPU(time_used, time_allocated, organism);
 
   // For now, always return true.
   return true;
@@ -333,20 +333,26 @@
     df.WriteComment(c.Set("Copied Size.....: %d", phenotype.GetCopiedSize()));
     df.WriteComment(c.Set("Executed Size...: %d", phenotype.GetExecutedSize()));
     
-    if (phenotype.GetNumDivides() == 0) df.WriteComment("Offspring.......: NONE");
-    else if (phenotype.CopyTrue() == true) df.WriteComment("Offspring.......: SELF");
-    else if (test_info.GetCycleTo() != -1) df.WriteComment(c.Set("Offspring.......: %d", test_info.GetCycleTo()));
-    else df.WriteComment(c.Set("Offspring.......: %d", j + 1));
+    if (phenotype.GetNumDivides() == 0)
+      df.WriteComment("Offspring.......: NONE");
+    else if (phenotype.CopyTrue())
+      df.WriteComment("Offspring.......: SELF");
+    else if (test_info.GetCycleTo() != -1)
+      df.WriteComment(c.Set("Offspring.......: %d", test_info.GetCycleTo()));
+    else
+      df.WriteComment(c.Set("Offspring.......: %d", j + 1));
     
     df.WriteComment("");
   }
   
   df.WriteComment("Tasks Performed:");
-  cPhenotype& phenotype = test_info.GetTestPhenotype();
-  for (int i = 0; i < m_world->GetEnvironment().GetTaskLib().GetSize(); i++) {
-    df.WriteComment(c.Set("%s %d",
-                          static_cast<const char*>(m_world->GetEnvironment().GetTaskLib().GetTask(i).GetName()),
-                          phenotype.GetLastTaskCount()[i]));
+  
+  const cEnvironment& env = m_world->GetEnvironment();
+  const tArray<int>& task_count = test_info.GetTestPhenotype().GetLastTaskCount();
+  const tArray<double>& task_qual = test_info.GetTestPhenotype().GetLastTaskQuality();
+  for (int i = 0; i < task_count.GetSize(); i++) {
+    df.WriteComment(c.Set("%s %d (%f)", static_cast<const char*>(env.GetTask(i).GetName()),
+                          task_count[i], task_qual[i]));
   }
 
   df.Endl();
@@ -357,3 +363,44 @@
   m_world->GetDataFileManager().Remove(filename);
 }
 
+
+void cTestCPU::PrintInjectGenome(cAvidaContext& ctx, cInjectGenotype* inject_genotype,
+                                 const cGenome& genome, cString filename, int update)
+{
+  if (filename == "") filename.Set("p%03d-unnamed", genome.GetSize());
+  
+  // Build the test info for printing.
+  cCPUTestInfo test_info;
+  TestGenome(ctx, test_info, genome);
+  
+  // Open the file...
+  ofstream& fp = m_world->GetDataFileOFStream(filename);
+  
+  // @CAO Fix!!!!!!
+  if( fp.good() == false ) {
+    cerr << "Unable to open output file '" <<  filename << "'" << endl;
+    return;
+  }
+  
+  // Print the useful info at the top...
+  
+  fp << "# Filename........: " << filename << endl;
+  
+  if (update >= 0) fp << "# Update Output...: " << update << endl;
+  else fp << "# Update Output...: N/A" << endl;
+  
+  
+  if (inject_genotype != NULL) {
+    fp << "# Update Created..: " << inject_genotype->GetUpdateBorn() << endl;
+    fp << "# Genotype ID.....: " << inject_genotype->GetID() << endl;
+    fp << "# Parent Gen ID...: " << inject_genotype->GetParentID() << endl;
+    fp << "# Tree Depth......: " << inject_genotype->GetDepth() << endl;
+  }
+  fp << endl;
+  
+  // Display the genome
+  cInstUtil::SaveGenome(fp, test_info.GetTestOrganism()->GetHardware().GetInstSet(), genome);
+  
+  m_world->GetDataFileManager().Remove(filename);
+}
+

Modified: development/source/cpu/cTestCPU.h
===================================================================
--- development/source/cpu/cTestCPU.h	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/cpu/cTestCPU.h	2006-12-29 19:25:24 UTC (rev 1159)
@@ -24,13 +24,15 @@
 #endif
 
 class cAvidaContext;
-class cInstSet;
-class cResourceCount;
 class cCPUTestInfo;
 class cGenome;
 class cGenotype;
+class cInjectGenotype;
+class cInstSet;
+class cResourceCount;
 class cWorld;
 
+
 class cTestCPU
 {
 private:
@@ -61,6 +63,8 @@
   
   void PrintGenome(cAvidaContext& ctx, const cGenome& genome, cString filename,
                    cGenotype* genotype = NULL, int update = -1);
+  void PrintInjectGenome(cAvidaContext& ctx, cInjectGenotype* inject_genotype,
+                         const cGenome& genome, cString filename = "", int update = -1);
 
   inline int GetInput();
   inline int GetInputAt(int & input_pointer);

Deleted: development/source/cpu/cTestUtil.cc
===================================================================
--- development/source/cpu/cTestUtil.cc	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/cpu/cTestUtil.cc	2006-12-29 19:25:24 UTC (rev 1159)
@@ -1,190 +0,0 @@
-/*
- *  cTestUtil.cc
- *  Avida
- *
- *  Called "test_util.cc" prior to 11/30/05.
- *  Copyright 2005-2006 Michigan State University. All rights reserved.
- *  Copyright 1999-2003 California Institute of Technology.
- *
- */
-
-#include "cTestUtil.h"
-
-#include "cAvidaContext.h"
-#include "cCPUTestInfo.h"
-#include "cDataFileManager.h"
-#include "cEnvironment.h"
-#include "cGenome.h"
-#include "cGenotype.h"
-#include "cHardwareBase.h"
-#include "cHardwareManager.h"
-#include "cInjectGenotype.h"
-#include "cInstUtil.h"
-#include "cOrganism.h"
-#include "cPhenotype.h"
-#include "cStats.h"
-#include "cTaskEntry.h"
-#include "cTestCPU.h"
-#include "cWorld.h"
-
-#include <fstream>
-#include <iomanip>
-
-using namespace std;
-
-
-void cTestUtil::PrintGenome(cWorld* world, const cGenome & genome, cString filename,
-			    cGenotype * genotype, int update_out)
-{
-  if (filename == "") filename.Set("%03d-unnamed", genome.GetSize());
-
-  // Build the test info for printing.
-  cTestCPU* testcpu = world->GetHardwareManager().CreateTestCPU();
-  cAvidaContext& ctx = world->GetDefaultContext();
-  
-  cCPUTestInfo test_info;
-  testcpu->TestGenome(ctx, test_info, genome);
-  delete testcpu;
-
-  // Open the file...
-  ofstream& fp = world->GetDataFileOFStream(filename);
-
-  // @CAO Fix!!!!!!
-  if( fp.good() == false ) {
-    cerr << "Unable to open output file '" <<  filename << "'" << endl;
-    return;
-  }
-
-  // Print the useful info at the top...
-
-  fp << "# Filename........: " << filename << endl;
-
-  if (update_out >= 0) fp << "# Update Output...: " << update_out << endl;
-  else fp << "# Update Output...: N/A" << endl;
-
-  fp << "# Is Viable.......: " << test_info.IsViable() << endl
-     << "# Repro Cycle Size: " << test_info.GetMaxCycle()
-     << endl
-     << "# Depth to Viable.: " << test_info.GetDepthFound()
-     << endl;
-
-  if (genotype != NULL) {
-    fp << "# Update Created..: " << genotype->GetUpdateBorn()     <<
-       endl
-       << "# Genotype ID.....: " << genotype->GetID()             <<
-       endl
-       << "# Parent Gen ID...: " << genotype->GetParentID()       <<
-       endl
-       << "# Tree Depth......: " << genotype->GetDepth()          <<
-       endl
-       << "# Parent Distance.: " << genotype->GetParentDistance() <<
-       endl
-      ;
-  }
-  fp << endl;
-
-  const int num_levels = test_info.GetMaxDepth() + 1;
-  for (int j = 0; j < num_levels; j++) {
-    fp << "# Generation: " << j << endl;
-    cOrganism* organism = test_info.GetTestOrganism(j);
-    assert(organism != NULL);
-    cPhenotype& phenotype = organism->GetPhenotype();
-
-    fp << "# Merit...........: "
-       << setw(12) << setfill(' ') << phenotype.GetMerit() << endl;
-    fp << "# Gestation Time..: "
-       << setw(12) << setfill(' ') << phenotype.GetGestationTime() << endl;
-    fp << "# Fitness.........: "
-       << setw(12) << setfill(' ') << phenotype.GetFitness() << endl;
-    fp << "# Errors..........: "
-       << setw(12) << setfill(' ') << phenotype.GetLastNumErrors() << endl;
-    fp << "# Genome Size.....: "
-       << setw(12) << setfill(' ') << organism->GetGenome().GetSize() << endl;
-    fp << "# Copied Size.....: "
-       << setw(12) << setfill(' ') << phenotype.GetCopiedSize() << endl;
-    fp << "# Executed Size...: "
-       << setw(12) << setfill(' ') << phenotype.GetExecutedSize() << endl;
-
-    fp << "# Offspring.......: ";
-    if (phenotype.GetNumDivides() == 0)
-      fp << setw(12) << setfill(' ') << "NONE";
-    else if (phenotype.CopyTrue() == true)
-      fp << setw(12) << setfill(' ') << "SELF";
-    else if (test_info.GetCycleTo() != -1)
-      fp << setw(12) << setfill(' ') << test_info.GetCycleTo();
-    else
-      fp << setw(12) << setfill(' ') << (j+1);
-    fp << endl;
-
-    fp << endl;     // Skip line
-  }
-  
-  // Display the tasks performed...
-  cPhenotype& phenotype = test_info.GetTestPhenotype();
-  for (int i = 0; i < world->GetEnvironment().GetTaskLib().GetSize(); i++) {
-    fp << "# "<< world->GetEnvironment().GetTaskLib().GetTask(i).GetName()
-       << "\t" << phenotype.GetLastTaskCount()[i]
-       << endl;
-  }
-  fp << endl; // Skip line
-
-  // Display the genome
-  const cInstSet & inst_set =
-    test_info.GetTestOrganism()->GetHardware().GetInstSet();
-  cInstUtil::SaveGenome(fp, inst_set, genome);
-  
-  world->GetDataFileManager().Remove(filename);
-}
-
-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());
-
-  // Build the test info for printing.
-  cTestCPU* testcpu = world->GetHardwareManager().CreateTestCPU();
-  cAvidaContext& ctx = world->GetDefaultContext();
-
-  cCPUTestInfo test_info;
-  testcpu->TestGenome(ctx, test_info, genome);
-  delete testcpu;
-
-  // Open the file...
-  ofstream& fp = world->GetDataFileOFStream(filename);
-
-  // @CAO Fix!!!!!!
-  if( fp.good() == false ) {
-    cerr << "Unable to open output file '" <<  filename << "'" <<
-    endl;
-    return;
-  }
-
-  // Print the useful info at the top...
-
-  fp << "# Filename........: " << filename << endl;
-
-  if (update_out >= 0) fp << "# Update Output...: " << update_out <<
-  endl;
-  else fp << "# Update Output...: N/A" << endl;
-
-
-  if (inject_genotype != NULL) {
-    fp << "# Update Created..: " << inject_genotype->GetUpdateBorn()     <<
-       endl
-       << "# Genotype ID.....: " << inject_genotype->GetID()             <<
-       endl
-       << "# Parent Gen ID...: " << inject_genotype->GetParentID()       <<
-       endl
-       << "# Tree Depth......: " << inject_genotype->GetDepth()          <<
-       endl
-      ;
-  }
-  fp << endl;
-
-  // Display the genome
-  const cInstSet & inst_set =
-    test_info.GetTestOrganism()->GetHardware().GetInstSet();
-  cInstUtil::SaveGenome(fp, inst_set, genome);
-  
-  world->GetDataFileManager().Remove(filename);
-}

Deleted: development/source/cpu/cTestUtil.h
===================================================================
--- development/source/cpu/cTestUtil.h	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/cpu/cTestUtil.h	2006-12-29 19:25:24 UTC (rev 1159)
@@ -1,52 +0,0 @@
-/*
- *  cTestUtil.h
- *  Avida
- *
- *  Called "test_util.hh" prior to 11/30/05.
- *  Copyright 2005-2006 Michigan State University. All rights reserved.
- *  Copyright 1999-2003 California Institute of Technology.
- *
- */
-
-#ifndef cTestUtil_h
-#define cTestUtil_h
-
-#ifndef cString_h
-#include "cString.h"
-#endif
-
-// ------------------------------------------------------------------------
-//  This class uses test CPUs in combination with genotypes and all types
-//  of hardware in order to produce more useful test info.
-// ------------------------------------------------------------------------
-
-class cGenome;
-class cGenotype;
-class cInjectGenotype;
-class cWorld;
-
-class cTestUtil
-{
-private:
-  cTestUtil(); // @not_implemented
-  
-public:
-  static void PrintGenome(cWorld* world, const cGenome & genome, cString filename="",
-                          cGenotype * genotype=NULL, int update_out=-1);
-  static void PrintGenome(cWorld* world, cInjectGenotype * genotype, const cGenome & genome, 
-                          cString filename="", int update_out=-1);
-};
-
-
-#ifdef ENABLE_UNIT_TESTS
-namespace nTestUtil {
-  /**
-   * Run unit tests
-   *
-   * @param full Run full test suite; if false, just the fast tests.
-   **/
-  void UnitTests(bool full = false);
-}
-#endif  
-
-#endif

Modified: development/source/main/cEnvReqs.h
===================================================================
--- development/source/main/cEnvReqs.h	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/main/cEnvReqs.h	2006-12-29 19:25:24 UTC (rev 1159)
@@ -15,15 +15,18 @@
 private:
   int m_min_inputs;
   int m_min_outputs;
+  bool m_true_rand_inputs;
 
 
 public:
-  cEnvReqs() : m_min_inputs(0), m_min_outputs(0) { ; }
+  cEnvReqs() : m_min_inputs(0), m_min_outputs(0), m_true_rand_inputs(false) { ; }
   
   int GetMinInputs() { return m_min_inputs; }
   void SetMinInputs(int v) { m_min_inputs = v; }
   int GetMinOutputs() { return m_min_outputs; }
   void SetMinOutputs(int v) { m_min_outputs = v; }
+  void SetTrueRandInputs(bool v = true) { m_true_rand_inputs = v; }
+  bool GetTrueRandInputs() { return m_true_rand_inputs; }
 };
 
 #endif

Modified: development/source/main/cEnvironment.cc
===================================================================
--- development/source/main/cEnvironment.cc	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/main/cEnvironment.cc	2006-12-29 19:25:24 UTC (rev 1159)
@@ -540,6 +540,7 @@
   // Process the environment requirements of this task
   if (envreqs.GetMinInputs() > m_input_size) m_input_size = envreqs.GetMinInputs();
   if (envreqs.GetMinOutputs() > m_output_size) m_output_size = envreqs.GetMinOutputs();
+  if (envreqs.GetTrueRandInputs()) m_true_rand = true;
   
   return true;
 }
@@ -733,15 +734,21 @@
 {
   input_array.Resize(m_input_size);
   
-  if (random) {    
-    // Set the top 8 bits of the input buffer...
-    input_array[0] = 15 << 24;  // 00001111
-    input_array[1] = 51 << 24;  // 00110011
-    input_array[2] = 85 << 24;  // 01010101
-    
-    // And randomize the rest...
-    for (int i = 0; i < m_input_size; i++) {
-      input_array[i] += ctx.GetRandom().GetUInt(1 << 24);
+  if (random) {
+    if (m_true_rand) {
+      for (int i = 0; i < m_input_size; i++) {
+        input_array[i] = ctx.GetRandom().GetUInt(1 << 31);
+      }
+    } else {
+      // Set the top 8 bits of the input buffer...
+      input_array[0] = 15 << 24;  // 00001111
+      input_array[1] = 51 << 24;  // 00110011
+      input_array[2] = 85 << 24;  // 01010101
+      
+      // And randomize the rest...
+      for (int i = 0; i < m_input_size; i++) {
+        input_array[i] += ctx.GetRandom().GetUInt(1 << 24);
+      }
     }
   } else {
     // We make sure that all combinations of inputs are present.  This is

Modified: development/source/main/cEnvironment.h
===================================================================
--- development/source/main/cEnvironment.h	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/main/cEnvironment.h	2006-12-29 19:25:24 UTC (rev 1159)
@@ -73,6 +73,7 @@
 
   int m_input_size;
   int m_output_size;
+  bool m_true_rand;
   
   
   static bool ParseSetting(cString entry, cString& var_name, cString& var_value, const cString& var_type);
@@ -116,10 +117,14 @@
                   const tArray<double>& resource_count) const;
 
   // Accessors
+  int GetNumTasks() const { return m_tasklib.GetSize(); }
+  const cTaskEntry& GetTask(int id) const { return m_tasklib.GetTask(id); }
+  bool UseNeighborInput() const { return m_tasklib.UseNeighborInput(); }
+  bool UseNeighborOutput() const { return m_tasklib.UseNeighborOutput(); }
+
   const cResourceLib& GetResourceLib() const { return resource_lib; }
   const cReactionLib& GetReactionLib() const { return reaction_lib; }
   const cMutationLib& GetMutationLib() const { return mutation_lib; }
-  const cTaskLib& GetTaskLib() const { return m_tasklib; }
   const cMutationRates& GetMutRates() const { return mut_rates; }
 
   cResourceLib& GetResourceLib() { return resource_lib; }
@@ -141,6 +146,7 @@
   , inst_set(world)
   , m_input_size(INPUT_SIZE_DEFAULT)
   , m_output_size(OUTPUT_SIZE_DEFAULT)
+  , m_true_rand(false)
 {
   mut_rates.Setup(world);
 }

Modified: development/source/main/cLandscape.cc
===================================================================
--- development/source/main/cLandscape.cc	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/main/cLandscape.cc	2006-12-29 19:25:24 UTC (rev 1159)
@@ -19,7 +19,6 @@
 #include "cPhenotype.h"
 #include "cStats.h"             // For GetUpdate in outputs...
 #include "cTestCPU.h"
-#include "cTestUtil.h"
 #include "cTools.h"
 #include "cWorld.h"
 
@@ -819,13 +818,3 @@
   for (int j = 0; j < base_genome.GetSize(); j++) df.WriteAnonymous(site_count[j]);
   df.Endl();
 }
-
-void cLandscape::PrintBase(cString filename)
-{
-  cTestUtil::PrintGenome(m_world, base_genome, filename);
-}
-
-void cLandscape::PrintPeak(cString filename)
-{
-  cTestUtil::PrintGenome(m_world, peak_genome, filename);
-}

Modified: development/source/main/cLandscape.h
===================================================================
--- development/source/main/cLandscape.h	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/main/cLandscape.h	2006-12-29 19:25:24 UTC (rev 1159)
@@ -126,8 +126,6 @@
   void PrintStats(cDataFile& df, int update = -1);
   void PrintEntropy(cDataFile& fp);
   void PrintSiteCount(cDataFile& fp);
-  void PrintBase(cString filename);
-  void PrintPeak(cString filename);
 
   inline const cGenome& GetPeakGenome() { return peak_genome; }
   inline double GetAveFitness() { return total_fitness / total_count; }

Modified: development/source/main/cOrganism.cc
===================================================================
--- development/source/main/cOrganism.cc	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/main/cOrganism.cc	2006-12-29 19:25:24 UTC (rev 1159)
@@ -153,7 +153,7 @@
   tList<tBuffer<int> > other_output_list;
 
   // If tasks require us to consider neighbor inputs, collect them...
-  if (m_world->GetEnvironment().GetTaskLib().UseNeighborInput() == true) {
+  if (m_world->GetEnvironment().UseNeighborInput()) {
     const int num_neighbors = m_interface->GetNumNeighbors();
     for (int i = 0; i < num_neighbors; i++) {
       m_interface->Rotate();
@@ -165,7 +165,7 @@
   }
 
   // If tasks require us to consider neighbor outputs, collect them...
-  if (m_world->GetEnvironment().GetTaskLib().UseNeighborOutput() == true) {
+  if (m_world->GetEnvironment().UseNeighborOutput()) {
     const int num_neighbors = m_interface->GetNumNeighbors();
     for (int i = 0; i < num_neighbors; i++) {
       m_interface->Rotate();
@@ -324,7 +324,7 @@
     tList<tBuffer<int> > other_output_list;
     
     // If tasks require us to consider neighbor inputs, collect them...
-    if (m_world->GetEnvironment().GetTaskLib().UseNeighborInput() == true) {
+    if (m_world->GetEnvironment().UseNeighborInput()) {
       const int num_neighbors = m_interface->GetNumNeighbors();
       for (int i = 0; i < num_neighbors; i++) {
         m_interface->Rotate();
@@ -336,7 +336,7 @@
     }
     
     // If tasks require us to consider neighbor outputs, collect them...
-    if (m_world->GetEnvironment().GetTaskLib().UseNeighborOutput() == true) {
+    if (m_world->GetEnvironment().UseNeighborOutput()) {
       const int num_neighbors = m_interface->GetNumNeighbors();
       for (int i = 0; i < num_neighbors; i++) {
         m_interface->Rotate();
@@ -443,7 +443,24 @@
   fp << "ABOUT TO EXECUTE: " << next_name << endl;
 }
 
+void cOrganism::PrintFinalStatus(ostream& fp, int time_used, int time_allocated) const
+{
+  fp << "---------------------------" << endl;
+  m_phenotype.PrintStatus(fp);
+  fp << endl;
 
+  if (time_used == time_allocated) {
+    fp << endl << "# TIMEOUT: No offspring produced." << endl;
+  } else if (m_hardware->GetMemory().GetSize() == 0) {
+    fp << endl << "# ORGANISM DEATH: No offspring produced." << endl;
+  } else {
+    fp << endl;
+    fp << "# Final Memory: " << m_hardware->GetMemory().AsString() << endl;
+    fp << "# Child Memory: " << m_child_genome.AsString() << endl;
+  }
+}
+
+
 bool cOrganism::Divide_CheckViable()
 {
   // Make sure required task (if any) has been performed...

Modified: development/source/main/cOrganism.h
===================================================================
--- development/source/main/cOrganism.h	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/main/cOrganism.h	2006-12-29 19:25:24 UTC (rev 1159)
@@ -212,7 +212,8 @@
   double GetTestFitness(cAvidaContext& ctx);
   double CalcMeritRatio();
   
-  void PrintStatus(std::ostream& fp, const cString & next_name);
+  void PrintStatus(std::ostream& fp, const cString& next_name);
+  void PrintFinalStatus(std::ostream& fp, int time_used, int time_allocated) const;
   void Fault(int fault_loc, int fault_type, cString fault_desc="");
 
 

Modified: development/source/main/cPhenotype.cc
===================================================================
--- development/source/main/cPhenotype.cc	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/main/cPhenotype.cc	2006-12-29 19:25:24 UTC (rev 1159)
@@ -24,14 +24,14 @@
 cPhenotype::cPhenotype(cWorld* world)
   : m_world(world)
   , initialized(false)
-  , cur_task_count(m_world->GetEnvironment().GetTaskLib().GetSize())
-  , cur_task_quality(m_world->GetEnvironment().GetTaskLib().GetSize())
+  , cur_task_count(m_world->GetEnvironment().GetNumTasks())
+  , cur_task_quality(m_world->GetEnvironment().GetNumTasks())
   , cur_reaction_count(m_world->GetEnvironment().GetReactionLib().GetSize())
   , cur_inst_count(world->GetHardwareManager().GetInstSet().GetSize())
   , cur_sense_count(m_world->GetStats().GetSenseSize())
   , sensed_resources(m_world->GetEnvironment().GetResourceLib().GetSize())
-  , last_task_count(m_world->GetEnvironment().GetTaskLib().GetSize())
-  , last_task_quality(m_world->GetEnvironment().GetTaskLib().GetSize())
+  , last_task_count(m_world->GetEnvironment().GetNumTasks())
+  , last_task_quality(m_world->GetEnvironment().GetNumTasks())
   , last_reaction_count(m_world->GetEnvironment().GetReactionLib().GetSize())
   , last_inst_count(world->GetHardwareManager().GetInstSet().GetSize())
   , last_sense_count(m_world->GetStats().GetSenseSize())
@@ -511,7 +511,7 @@
 
 
 
-bool cPhenotype::TestInput(tBuffer<int> & inputs, tBuffer<int> & outputs)
+bool cPhenotype::TestInput(tBuffer<int>& inputs, tBuffer<int>& outputs)
 {
   assert(initialized == true);
   // For the moment, lets not worry about inputs...
@@ -526,7 +526,7 @@
 
   const cEnvironment& env = m_world->GetEnvironment();
   const int num_resources = env.GetResourceLib().GetSize();
-  const int num_tasks = env.GetTaskLib().GetSize();
+  const int num_tasks = env.GetNumTasks();
   const int num_reactions = env.GetReactionLib().GetSize();
 
   cReactionResult result(num_resources, num_tasks, num_reactions);
@@ -724,20 +724,19 @@
   return true;
 }
 
-void cPhenotype::PrintStatus(ostream& fp)
+void cPhenotype::PrintStatus(ostream& fp) const
 {
   fp << "  MeritBase:"
      << CalcSizeMerit()
      << " Bonus: " << cur_bonus
      << " Errors:" << cur_num_errors
-     << " Donates:" << cur_num_donates
-     << " Tasks:";
-
-  for (int i = 0; i < cur_task_count.GetSize(); i++) {
-    fp << " " << cur_task_count[i];
-  }
-
+     << " Donates:" << cur_num_donates;
   fp << endl;
+  
+  fp << "  Task Count (Quality):";
+  for (int i = 0; i < cur_task_count.GetSize(); i++)
+    fp << " " << cur_task_count[i] << " (" << cur_task_quality[i] << ")";
+  fp << endl;
 }
 
 int cPhenotype::CalcSizeMerit() const

Modified: development/source/main/cPhenotype.h
===================================================================
--- development/source/main/cPhenotype.h	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/main/cPhenotype.h	2006-12-29 19:25:24 UTC (rev 1159)
@@ -172,7 +172,7 @@
   // State saving and loading, and printing...
   bool SaveState(std::ofstream& fp);
   bool LoadState(std::ifstream & fp);
-  void PrintStatus(std::ostream& fp);
+  void PrintStatus(std::ostream& fp) const;
 
   // Some useful methods...
   int CalcSizeMerit() const;
@@ -212,7 +212,7 @@
   int GetLastNumErrors() const { assert(initialized == true); return last_num_errors; }
   int GetLastNumDonates() const { assert(initialized == true); return last_num_donates; }
   const tArray<int>& GetLastTaskCount() const { assert(initialized == true); return last_task_count; }
-    const tArray<double> & GetLastTaskQuality() const { assert(initialized == true); return last_task_quality; }
+  const tArray<double>& GetLastTaskQuality() const { assert(initialized == true); return last_task_quality; }
   const tArray<int>& GetLastReactionCount() const { assert(initialized == true); return last_reaction_count; }
   const tArray<int>& GetLastInstCount() const { assert(initialized == true); return last_inst_count; }
   const tArray<int>& GetLastSenseCount() const { assert(initialized == true); return last_sense_count; }

Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/main/cPopulation.cc	2006-12-29 19:25:24 UTC (rev 1159)
@@ -35,7 +35,6 @@
 #include "cSaleItem.h"
 #include "cSpecies.h"
 #include "cStats.h"
-#include "cTaskEntry.h"
 #include "cWorld.h"
 
 #include <fstream>
@@ -64,7 +63,7 @@
   world_y = world->GetConfig().WORLD_Y.Get();
   int geometry = world->GetConfig().WORLD_GEOMETRY.Get();
   const int num_cells = world_x * world_y;
-
+  
   // Print out world details
   if (world->GetVerbosity() > VERBOSE_NORMAL) {
     cout << "Building world " << world_x << "x" << world_y << " = " << num_cells << " organisms." << endl;
@@ -92,14 +91,14 @@
     bool top_flag = true;
     bool right_flag = true;
     bool left_flag = true;
-
+    
     if (geometry == nGeometry::GRID) {
       if (y == 0)  bottom_flag = false;
       if (y == world_y-1)  top_flag = false;
       if (x == 0) left_flag = false;
       if (x == world_x-1) right_flag = false;
     }
-
+    
     // Setup the connection list for each cell. (Clockwise from -1 to 1)
     
     tList<cPopulationCell> & conn_list=cell_array[cell_id].ConnectionList();
@@ -127,7 +126,7 @@
     if (left_flag) {
       conn_list.Push(&(cell_array[GridNeighbor(cell_id,world_x,world_y, -1,  0)]));
     }
-
+    
     // Setup the reaper queue...
     if (world->GetConfig().BIRTH_METHOD.Get() == POSITION_CHILD_FULL_SOUP_ELDEST) {
       reaper_queue.Push(&(cell_array[cell_id]));
@@ -158,19 +157,7 @@
                          world->GetVerbosity() );
     m_world->GetStats().SetResourceName(i, res->GetName());
   }
- 
-  // Give stats information about the environment...
-  const cTaskLib & task_lib = environment.GetTaskLib();
-  for (int i = 0; i < task_lib.GetSize(); i++) {
-    const cTaskEntry & cur_task = task_lib.GetTask(i);
-    m_world->GetStats().SetTaskName(i, cur_task.GetDesc());
-  }
   
-  const cInstSet & inst_set = world->GetHardwareManager().GetInstSet();
-  for (int i = 0; i < inst_set.GetSize(); i++) {
-    m_world->GetStats().SetInstName(i, inst_set.GetName(i));
-  }
-
   // Load a clone if one is provided, otherwise setup start organism.
   if (m_world->GetConfig().CLONE_FILE.Get() == "-" || m_world->GetConfig().CLONE_FILE.Get() == "") {
     cGenome start_org = cInstUtil::LoadGenome(m_world->GetConfig().START_CREATURE.Get(), world->GetHardwareManager().GetInstSet());
@@ -209,7 +196,7 @@
   }
   
   deme_array.Resize(num_demes);
-
+  
   // Check to make sure all other settings are reasonable to have demes.
   // ...make sure populaiton can be divided up evenly.
   if (world_y % num_demes != 0) {
@@ -240,8 +227,8 @@
     }
     deme_array[deme_id].Setup(deme_cells);
   }
-
   
+  
   // Build walls in the population.
   for (int row_id = 0; row_id < world_y; row_id += deme_size_y) {
     // Loop through all of the cols and make the cut on each...
@@ -291,7 +278,7 @@
   const int parent_id = parent_organism.GetOrgInterface().GetCellID();
   assert(parent_id >= 0 && parent_id < cell_array.GetSize());
   cPopulationCell& parent_cell = cell_array[parent_id];
-    
+  
   tArray<int> target_cells(child_array.GetSize());
   
   // Loop through choosing the later placement of each child in the population.
@@ -311,10 +298,10 @@
       child_array[i]->MutationRates().Copy(parent_organism.MutationRates());
       // If there is a meta-mutation rate, do tests for it.
       if (child_array[i]->MutationRates().GetMetaCopyMutProb() > 0.0) {
-	child_array[i]->MutationRates().DoMetaCopyMut(ctx);
+        child_array[i]->MutationRates().DoMetaCopyMut(ctx);
       }    
     }
-
+    
     // Update the phenotypes of each child....
     const int child_length = child_array[i]->GetGenome().GetSize();
     child_array[i]->GetPhenotype().SetupOffspring(parent_phenotype,child_length);
@@ -335,7 +322,7 @@
     // In a local run, face the child toward the parent. 
     const int birth_method = m_world->GetConfig().BIRTH_METHOD.Get();
     if (birth_method < NUM_LOCAL_POSITION_CHILD ||
-	birth_method == POSITION_CHILD_PARENT_FACING) {
+        birth_method == POSITION_CHILD_PARENT_FACING) {
       for (int i = 0; i < child_array.GetSize(); i++) {
         GetCell(target_cells[i]).Rotate(parent_cell);
       }
@@ -386,7 +373,7 @@
   
   if (target_organism->InjectHost(parent_cpu.GetLabel(), injected_code)) {
     cInjectGenotype* child_genotype = parent_genotype;
-
+    
     // If the parent genotype is not correct for the child, adjust it.
     if (parent_genotype == NULL || parent_genotype->GetGenome() != injected_code) {
       child_genotype = m_world->GetClassificationManager().GetInjectGenotype(injected_code, parent_genotype);
@@ -432,7 +419,7 @@
   // Update the contents of the target cell.
   KillOrganism(target_cell);
   target_cell.InsertOrganism(*in_organism);
-
+  
   // Setup the inputs in the target cell.
   environment.SetupInputs(ctx, target_cell.input_array);
   
@@ -473,18 +460,18 @@
   cOrganism* organism = in_cell.GetOrganism();
   cGenotype* genotype = organism->GetGenotype();
   m_world->GetStats().RecordDeath();
-
+  
   tList<tListNode<cSaleItem> >* sold_items = organism->GetSoldItems();
   if (sold_items)
   {
 	  tListIterator<tListNode<cSaleItem> > sold_it(*sold_items);
 	  tListNode<cSaleItem> * test_node;
-
+    
 	  while ( (test_node = sold_it.Next()) != NULL)
 	  {
-		tListIterator<cSaleItem> market_it(market[test_node->data->GetLabel()]);
-		market_it.Set(test_node);
-		delete market_it.Remove();
+      tListIterator<cSaleItem> market_it(market[test_node->data->GetLabel()]);
+      market_it.Set(test_node);
+      delete market_it.Remove();
 	  }
   }
   // Do the lineage handling
@@ -496,19 +483,19 @@
     deme_array[in_cell.GetDemeID()].DecOrgCount();
   }
   genotype->RemoveOrganism();
-
+  
   for (int i = 0; i < organism->GetNumParasites(); i++) {
     organism->GetParasite(i).RemoveParasite();
   }
-
+  
   // And clear it!
   in_cell.RemoveOrganism();
   if (!organism->IsRunning()) delete organism;
   else organism->GetPhenotype().SetToDelete();
-
+  
   // Alert the scheduler that this cell has a 0 merit.
   schedule->Adjust(in_cell.GetID(), cMerit(0));
-
+  
   // Update the archive (note: genotype adjustment may be defered)
   m_world->GetClassificationManager().AdjustGenotype(*genotype);
 }
@@ -563,7 +550,7 @@
 	// find list under appropriate label, labels more than 8 nops long are simply the same
 	// as a smaller label modded by the market size
 	//int pos = label % market.GetSize();
-
+  
 	//// id of genotype currently residing in cell that seller live(d) in compared to 
 	//// id of genotype of actual seller, if different than seller is dead, remove item from list
 	//while ( market[pos].GetSize() > 0 && 
@@ -573,15 +560,15 @@
 	//{
 	//	market[pos].Pop();
 	//}
-
+    
 	// create sale item
 	cSaleItem *new_item = new cSaleItem(data, label, sell_price, org_id, cell_id);
-
+  
 	// place into array by label, array is big enough for labels up to 8 nops long
 	tListNode<cSaleItem>* sell_node = market[label].PushRear(new_item);
 	tListNode<tListNode<cSaleItem> >* org_node = GetCell(cell_id).GetOrganism()->AddSoldItem(sell_node);
 	sell_node->data->SetNodePtr(org_node);
-
+  
 	//:7 for Kolby
 }
 
@@ -590,7 +577,7 @@
 	// find list under appropriate label, labels more than 8 nops long are simply the same
 	// as a smaller label modded by the market size
 	//int pos = label % market.GetSize();
-
+  
 	//// id of genotype currently residing in cell that seller live(d) in compared to 
 	//// id of genotype of actual seller, if different than seller is dead, remove item from list
 	//while ( market[pos].GetSize() > 0 && 
@@ -600,25 +587,25 @@
 	//{
 	//	market[pos].Pop();
 	//}
-
+    
 	// if there's nothing in the list don't bother with rest
 	if (market[label].GetSize() <= 0)
 		return 0;
-
+  
 	// if the sell price is higher than we're willing to pay no purchase made
 	if (market[label].GetFirst()->GetPrice() > buy_price)
 		return 0;
-
+  
 	// if the buy price is higher than buying org's current merit no purchase made
 	if (GetCell(cell_id).GetOrganism()->GetPhenotype().GetMerit().GetDouble() < buy_price)
 		return 0;
-
+  
 	// otherwise transaction should be completed!
 	cSaleItem* chosen = market[label].Pop();
 	tListIterator<tListNode<cSaleItem> > sold_it(*GetCell(chosen->GetCellID()).GetOrganism()->GetSoldItems());
 	sold_it.Set(chosen->GetNodePtr());
 	sold_it.Remove();
-
+  
 	// first update sellers merit
 	double cur_merit = GetCell(chosen->GetCellID()).GetOrganism()->GetPhenotype().GetMerit().GetDouble();
 	cur_merit += buy_price;
@@ -627,8 +614,8 @@
 	
 	// next remove sold item from list in market 
 	//market[pos].Remove(chosen);
-
-
+  
+  
 	// finally return recieve value, buyer merit will be updated if return a valid value here
 	int receive_value = chosen->GetData();
 	return receive_value;
@@ -641,12 +628,12 @@
  0: deme fitness = 1 (control, random deme selection)
  1: deme fitness = number of births since last competition (default) 
  2: deme fitness = average organism fitness at the current update (uses parent's fitness, so
-                     does not work with donations)
+                                                                   does not work with donations)
  3: deme fitness = average mutation rate at the current update
  4: deme fitness = strong rank selection on (parents) fitness (2^-deme fitness rank)
  5: deme fitness = average organism life (current, not parents) fitness (works with donations)
  6: deme fitness = strong rank selection on life (current, not parents) fitness
-*/
+ */
 //  For ease of use, each organism 
 // is setup as if it we just injected into the population.
 
@@ -665,7 +652,7 @@
     case 1:     // deme fitness = number of births
                 // Determine the scale for fitness by totaling births across demes.
       for (int deme_id = 0; deme_id < num_demes; deme_id++) {
-	double cur_fitness = (double) deme_array[deme_id].GetBirthCount();
+        double cur_fitness = (double) deme_array[deme_id].GetBirthCount();
         deme_fitness[deme_id] = cur_fitness;
         total_fitness += cur_fitness;
       }
@@ -673,12 +660,12 @@
     case 2:    // deme fitness = average organism fitness at the current update
       for (int deme_id = 0; deme_id < num_demes; deme_id++) {
         cDoubleSum single_deme_fitness;
-	const cDeme & cur_deme = deme_array[deme_id];
+        const cDeme & cur_deme = deme_array[deme_id];
         for (int i = 0; i < cur_deme.GetSize(); i++) {
           int cur_cell = cur_deme.GetCellID(i);
           if (cell_array[cur_cell].IsOccupied() == false) continue;
           cPhenotype & phenotype =
-	    GetCell(cur_cell).GetOrganism()->GetPhenotype();
+            GetCell(cur_cell).GetOrganism()->GetPhenotype();
           single_deme_fitness.Add(phenotype.GetFitness());
         } 
         deme_fitness[deme_id] = single_deme_fitness.Ave();
@@ -688,12 +675,12 @@
     case 3: 	// deme fitness = average mutation rate at the current update 
       for (int deme_id = 0; deme_id < num_demes; deme_id++) {
         cDoubleSum single_deme_div_type;
-	const cDeme & cur_deme = deme_array[deme_id];
+        const cDeme & cur_deme = deme_array[deme_id];
         for (int i = 0; i < cur_deme.GetSize(); i++) {
           int cur_cell = cur_deme.GetCellID(i);
           if (cell_array[cur_cell].IsOccupied() == false) continue;
           cPhenotype & phenotype =
-	    GetCell(cur_cell).GetOrganism()->GetPhenotype();
+            GetCell(cur_cell).GetOrganism()->GetPhenotype();
           assert(phenotype.GetDivType()>0);
           single_deme_div_type.Add(1/phenotype.GetDivType());
         }
@@ -706,7 +693,7 @@
     {      
       for (int deme_id = 0; deme_id < num_demes; deme_id++) {
         cDoubleSum single_deme_fitness;
-	const cDeme & cur_deme = deme_array[deme_id];
+        const cDeme & cur_deme = deme_array[deme_id];
         for (int i = 0; i < cur_deme.GetSize(); i++) {
           int cur_cell = cur_deme.GetCellID(i);
           if (cell_array[cur_cell].IsOccupied() == false) continue;
@@ -734,11 +721,11 @@
         total_fitness += deme_fitness[deme_id]; 
       } 
     }
-    break; 
-  case 5:    // deme fitness = average organism life fitness at the current update
-    for (int deme_id = 0; deme_id < num_demes; deme_id++) {
+      break; 
+    case 5:    // deme fitness = average organism life fitness at the current update
+      for (int deme_id = 0; deme_id < num_demes; deme_id++) {
         cDoubleSum single_deme_life_fitness;
-	const cDeme & cur_deme = deme_array[deme_id];
+        const cDeme & cur_deme = deme_array[deme_id];
         for (int i = 0; i < cur_deme.GetSize(); i++) {
           int cur_cell = cur_deme.GetCellID(i);
           if (cell_array[cur_cell].IsOccupied() == false) continue;
@@ -747,14 +734,14 @@
         }
         deme_fitness[deme_id] = single_deme_life_fitness.Ave();
         total_fitness += deme_fitness[deme_id];
-    }
-    break; 
-  case 6:     // deme fitness = 2^(-deme life fitness rank) (same as 4, but with life fitness)
-    // first find all the deme fitness values ...
+      }
+      break; 
+    case 6:     // deme fitness = 2^(-deme life fitness rank) (same as 4, but with life fitness)
+                // first find all the deme fitness values ...
     {
       for (int deme_id = 0; deme_id < num_demes; deme_id++) {
         cDoubleSum single_deme_life_fitness;
-	const cDeme & cur_deme = deme_array[deme_id];
+        const cDeme & cur_deme = deme_array[deme_id];
         for (int i = 0; i < cur_deme.GetSize(); i++) {
           int cur_cell = cur_deme.GetCellID(i);
           if (cell_array[cur_cell].IsOccupied() == false) continue;
@@ -782,7 +769,7 @@
         total_fitness += deme_fitness[deme_id];
       }
     }
-    break;
+      break;
   } 
   
   // Pick which demes should be in the next generation.
@@ -830,7 +817,7 @@
     
     cDeme & from_deme = deme_array[from_deme_id];
     cDeme & to_deme   = deme_array[to_deme_id];
-
+    
     // Do the actual copy!
     for (int i = 0; i < from_deme.GetSize(); i++) {
       int from_cell_id = from_deme.GetCellID(i);
@@ -846,7 +833,7 @@
   for (int deme_id = 0; deme_id < num_demes; deme_id++) {
     if (is_init[deme_id] == true) continue;
     cDeme & cur_deme = deme_array[deme_id];
-
+    
     for (int i = 0; i < cur_deme.GetSize(); i++) {
       int cur_cell_id = cur_deme.GetCellID(i);
       if (cell_array[cur_cell_id].IsOccupied() == false) continue;
@@ -862,11 +849,11 @@
 
 
 /* Check if any demes have met the critera to be replicated and do so.
-   There are several bases this can be checked on:
+There are several bases this can be checked on:
 
-    0: 'all'       - ...all non-empty demes in the population.
-    1: 'full_deme' - ...demes that have been filled up.
-    2: 'corners'   - ...demes with upper left and lower right corners filled.
+0: 'all'       - ...all non-empty demes in the population.
+1: 'full_deme' - ...demes that have been filled up.
+2: 'corners'   - ...demes with upper left and lower right corners filled.
 */
 
 void cPopulation::ReplicateDemes(int rep_trigger)
@@ -874,50 +861,50 @@
   // Determine which demes should be replicated.
   const int num_demes = GetNumDemes();
   cRandom & random = m_world->GetRandom();
-
+  
   // Loop through all candidate demes...
   for (int deme_id = 0; deme_id < num_demes; deme_id++) {
     cDeme & source_deme = deme_array[deme_id];
-
+    
     // Test this deme to determine if it should be replicated.  If not,
     // continue on to the next deme.
     switch (rep_trigger) {
-    case 0:    // CASE: Replicate all non-empty demes...
-      // If this deme is empt, continue looping...
-      if (source_deme.IsEmpty()) continue;
-      break;
-    case 1:    // Replicate all full demes...
-      if (source_deme.IsFull() == false) continue;
-      break;
-    case 2:    // Replicate all demes with the corners filled in.
+      case 0:    // CASE: Replicate all non-empty demes...
+                 // If this deme is empt, continue looping...
+        if (source_deme.IsEmpty()) continue;
+        break;
+      case 1:    // Replicate all full demes...
+        if (source_deme.IsFull() == false) continue;
+        break;
+      case 2:    // Replicate all demes with the corners filled in.
       {
-	// The first and last IDs represent the two corners.
-	const int id1 = source_deme.GetCellID(0);
-	const int id2 = source_deme.GetCellID(source_deme.GetSize() - 1);
-	if (cell_array[id1].IsOccupied() == false ||
-	    cell_array[id2].IsOccupied() == false) continue;
+        // The first and last IDs represent the two corners.
+        const int id1 = source_deme.GetCellID(0);
+        const int id2 = source_deme.GetCellID(source_deme.GetSize() - 1);
+        if (cell_array[id1].IsOccupied() == false ||
+            cell_array[id2].IsOccupied() == false) continue;
       }
-      break;
-    default:
-      cerr << "ERROR: Invalid replication trigger " << rep_trigger
-	   << " in cPopulation::ReplicateDemes()" << endl;
-      continue;
+        break;
+      default:
+        cerr << "ERROR: Invalid replication trigger " << rep_trigger
+        << " in cPopulation::ReplicateDemes()" << endl;
+        continue;
     }
-
+    
     // -- If we made it this far, we should replicate this deme --
-
+    
     // Choose a random organism from this deme...
     int cell1_id = -1;
     const int deme1_size = source_deme.GetSize();
     while (cell1_id == -1 || cell_array[cell1_id].IsOccupied() == false) {
       cell1_id = source_deme.GetCellID(random.GetUInt(deme1_size));
     }
-
+    
     // Choose a random target deme to replicate to...
     int target_id = deme_id;
     while (target_id == deme_id) target_id = random.GetUInt(num_demes);
     cDeme & target_deme = deme_array[target_id];
-
+    
     // Clear out existing cells in target deme.
     const int deme2_size = target_deme.GetSize();
     for (int i = 0; i < deme2_size; i++) {
@@ -927,21 +914,21 @@
     // And do the replication into the central cell of the target deme...
     const int cell2_id = target_deme.GetCellID( deme2_size/2 );
     InjectClone( cell2_id, *(cell_array[cell1_id].GetOrganism()) );    
-
+    
     // Clear out the source deme to reset it
     for (int i = 0; i < deme1_size; i++) {
       KillOrganism(cell_array[ source_deme.GetCellID(i) ]);
     }
-
+    
     // Inject the target offspring back into the source ID.
     const int cell3_id = source_deme.GetCellID( deme1_size/2 );
     InjectClone( cell3_id, *(cell_array[cell2_id].GetOrganism()) );        
-
+    
     // Rotate both injected cells to face northwest.
     cell_array[cell2_id].Rotate(
-		cell_array[GridNeighbor(cell2_id, world_x, world_y, -1, -1)] );
+                                cell_array[GridNeighbor(cell2_id, world_x, world_y, -1, -1)] );
     cell_array[cell3_id].Rotate(
-		cell_array[GridNeighbor(cell3_id, world_x, world_y, -1, -1)] );
+                                cell_array[GridNeighbor(cell3_id, world_x, world_y, -1, -1)] );
   }
 }
 
@@ -954,25 +941,25 @@
   // Determine which demes should be replicated.
   const int num_demes = GetNumDemes();
   cRandom & random = m_world->GetRandom();
-
+  
   // Loop through all candidate demes...
   for (int deme_id = 0; deme_id < num_demes; deme_id++) {
     cDeme & source_deme = deme_array[deme_id];
-
+    
     // Only divide full demes.
     if (source_deme.IsFull() == false) continue;
-
+    
     // Choose a random target deme to replicate to...
     int target_id = deme_id;
     while (target_id == deme_id) target_id = random.GetUInt(num_demes);
     cDeme & target_deme = deme_array[target_id];
     const int deme_size = target_deme.GetSize();
-
+    
     // Clear out existing cells in target deme.
     for (int i = 0; i < deme_size; i++) {
       KillOrganism(cell_array[ target_deme.GetCellID(i) ]);
     }
-
+    
     // Setup an array to collect the total number of tasks performed.
     const int num_tasks = cell_array[source_deme.GetCellID(0)].GetOrganism()->
       GetPhenotype().GetLastTaskCount().GetSize();
@@ -984,16 +971,16 @@
       const int cell1_id = source_deme.GetCellID( pos+1 );
       const int cell2_id = target_deme.GetCellID( pos );
       cOrganism * org1 = cell_array[cell1_id].GetOrganism();
-
+      
       // Keep track of what tasks have been done.
       const tArray<int> & cur_tasks = org1->GetPhenotype().GetLastTaskCount();
       for (int i = 0; i < num_tasks; i++) {
-	tot_tasks[i] += cur_tasks[i];
+        tot_tasks[i] += cur_tasks[i];
       }
-
+      
       // Inject a copy of the odd organisms into the even cells.
       InjectClone( cell2_id, *org1 );    
-
+      
       // Kill the organisms in the odd cells.
       KillOrganism( cell_array[cell1_id] );
     }
@@ -1003,13 +990,13 @@
     for (int i = 0; i < num_tasks; i++) {
       if (tot_tasks[i] > 0) merit *= 2;
     }
-
+    
     // Setup the merit of both old and new individuals.
     for (int pos = 0; pos < deme_size; pos += 2) {
       cell_array[source_deme.GetCellID(pos)].GetOrganism()->UpdateMerit(merit);
       cell_array[target_deme.GetCellID(pos)].GetOrganism()->UpdateMerit(merit);
     }
-
+    
   }
 }
 
@@ -1036,7 +1023,7 @@
 {
   cDeme & deme1 = deme_array[deme1_id];
   cDeme & deme2 = deme_array[deme2_id];
-
+  
   for (int i = 0; i < deme1.GetSize(); i++) {
     int from_cell = deme1.GetCellID(i);
     int to_cell = deme2.GetCellID(i);
@@ -1056,26 +1043,26 @@
 {
   // Must spawn into a different deme.
   assert(deme1_id != deme2_id);
-
+  
   const int num_demes = deme_array.GetSize();
-
+  
   // If the second argument is a -1, choose a deme at random.
   cRandom & random = m_world->GetRandom();
   while (deme2_id == -1 || deme2_id == deme1_id) {
     deme2_id = random.GetUInt(num_demes);
   }
-
+  
   // Make sure we have all legal values...
   assert(deme1_id >= 0 && deme1_id < num_demes);
   assert(deme2_id >= 0 && deme2_id < num_demes);
-
+  
   // Find the demes that we're working with.
   cDeme & deme1 = deme_array[deme1_id];
   cDeme & deme2 = deme_array[deme2_id];
-
+  
   // Make sure that the deme we're copying from has at least 1 organism.
   assert(deme1.GetOrgCount() > 0);
-
+  
   // Determine the cell to copy from.
   int cell1_id = deme1.GetCellID( random.GetUInt(deme1.GetSize()) );
   while (cell_array[cell1_id].IsOccupied() == false) {
@@ -1086,7 +1073,7 @@
   for (int i = 0; i < deme2.GetSize(); i++) {
     KillOrganism(cell_array[ deme2.GetCellID(i) ]);
   }
-
+  
   // And do the spawning.
   int cell2_id = deme2.GetCellID( random.GetUInt(deme2.GetSize()) );
   InjectClone( cell2_id, *(cell_array[cell1_id].GetOrganism()) );    
@@ -1136,10 +1123,10 @@
   df_mut_rates.Write(stats.GetUpdate(), "update");
   
   const int num_inst = m_world->GetNumInstructions();
-  const int num_task = environment.GetTaskLib().GetSize();
+  const int num_task = environment.GetNumTasks();
   
   cDoubleSum total_mut_rate;
-
+  
   const int num_demes = deme_array.GetSize();
   for (int deme_id = 0; deme_id < num_demes; deme_id++) {
     cString filename;
@@ -1159,7 +1146,7 @@
     cDoubleSum single_deme_donor;
     cDoubleSum single_deme_receiver;
     cDoubleSum single_deme_mut_rate;
-
+    
     tArray<cIntSum> single_deme_task(num_task);
     tArray<cIntSum> single_deme_inst(num_inst);
     
@@ -1196,9 +1183,9 @@
     df_donor.Write(single_deme_donor.Sum(), comment);
     df_receiver.Write(single_deme_receiver.Sum(), comment);
     df_mut_rates.Write(single_deme_mut_rate.Ave(), comment);
- 
+    
     total_mut_rate.Add(single_deme_mut_rate.Ave());
-   
+    
     for (int j = 0; j < num_task; j++) {
       comment.Set("Deme %d, Task %d", deme_id, j);
       df_task.Write((int) single_deme_task[j].Sum(), comment);
@@ -1210,7 +1197,7 @@
     }
     df_inst.Endl();
   } 
-
+  
   df_mut_rates.Write(total_mut_rate.Ave(), "Average deme mutation rate averaged across Demes.");
   
   df_fit.Endl();
@@ -1276,14 +1263,14 @@
   else if (birth_method == POSITION_CHILD_DEME_RANDOM) {
     const int deme_id = parent_cell.GetDemeID();
     const int deme_size = deme_array[deme_id].GetSize();
-
+    
     int out_pos = m_world->GetRandom().GetUInt(deme_size);
     int out_cell_id = deme_array[deme_id].GetCellID(out_pos);
     while (parent_ok == false && out_cell_id == parent_cell.GetID()) {
       out_pos = m_world->GetRandom().GetUInt(deme_size);
       out_cell_id = deme_array[deme_id].GetCellID(out_pos);
     }
-
+    
     deme_array[deme_id].IncBirthCount();
     return GetCell(out_cell_id);    
   }
@@ -1295,7 +1282,7 @@
     if (out_cell_id == cell_array.GetSize()) out_cell_id = 0;
     return GetCell(out_cell_id);
   }
-    else if (birth_method == POSITION_CHILD_FULL_SOUP_TIME_USED) {
+  else if (birth_method == POSITION_CHILD_FULL_SOUP_TIME_USED) {
     tList<cPopulationCell> found_list;
     int max_time_used = 0;
     for  (int i=0; i < cell_array.GetSize(); i++)
@@ -1316,9 +1303,9 @@
     return *( found_list.GetPos(choice) );
   }
   
-
+  
   // All remaining methods require us to choose among mulitple local positions.
-
+  
   // Construct a list of equally viable locations to place the child...
   tList<cPopulationCell> found_list;
   
@@ -1474,7 +1461,7 @@
     stats.SetGenoMapElement(i, organism->GetGenotype()->GetID());
     
 #if INSTRUCTION_COUNT
-    for (int j=0; j < m_world->GetNumInstructions(); j++) {
+    for (int j = 0; j < m_world->GetNumInstructions(); j++) {
       stats.SumExeInst()[j].Add(organism->GetPhenotype().GetLastInstCount()[j]);
     }
 #endif
@@ -1490,27 +1477,25 @@
     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 < m_world->GetEnvironment().GetTaskLib().GetSize(); j++) {
-      if (phenotype.GetCurTaskCount()[j] > 0)
-	  {
-		  stats.AddCurTask(j);
-		  stats.AddCurTaskQuality(j, phenotype.GetCurTaskQuality()[j]);
-	  }
-      if (phenotype.GetLastTaskCount()[j] > 0)
-	  {
-		  stats.AddLastTask(j);
-		  stats.AddLastTaskQuality(j, phenotype.GetLastTaskQuality()[j]);
-		  stats.IncTaskExeCount(j, phenotype.GetLastTaskCount()[j]);
-	  } 
+    for (int j = 0; j < m_world->GetEnvironment().GetNumTasks(); j++) {
+      if (phenotype.GetCurTaskCount()[j] > 0) {
+        stats.AddCurTask(j);
+        stats.AddCurTaskQuality(j, phenotype.GetCurTaskQuality()[j]);
+      }
+      
+      if (phenotype.GetLastTaskCount()[j] > 0) {
+        stats.AddLastTask(j);
+        stats.AddLastTaskQuality(j, phenotype.GetLastTaskQuality()[j]);
+        stats.IncTaskExeCount(j, phenotype.GetLastTaskCount()[j]);
+      } 
     }
     
     // Test what resource combinations this creature has sensed
-    for (int j=0; j < stats.GetSenseSize(); j++) {
-      if (phenotype.GetLastSenseCount()[j] > 0)
-	  {
-		  stats.AddLastSense(j);
-		  stats.IncLastSenseExeCount(j, phenotype.GetLastSenseCount()[j]);
-	  }
+    for (int j = 0; j < stats.GetSenseSize(); j++) {
+      if (phenotype.GetLastSenseCount()[j] > 0) {
+        stats.AddLastSense(j);
+        stats.IncLastSenseExeCount(j, phenotype.GetLastSenseCount()[j]);
+      }
     }
     
     // Increment the counts for all qualities the organism has...
@@ -1529,7 +1514,7 @@
     
     // Increment the age of this organism.
     organism->GetPhenotype().IncAge();
-    }
+  }
   
   stats.SetBreedTrueCreatures(num_breed_true);
   stats.SetNumNoBirthCreatures(num_no_birth);
@@ -1551,7 +1536,7 @@
   stats.SetResources(resource_count.GetResources());
   stats.SetSpatialRes(resource_count.GetSpatialRes());
   stats.SetResourcesGeometry(resource_count.GetResourcesGeometry());
-  }
+}
 
 
 void cPopulation::UpdateGenotypeStats()
@@ -1924,11 +1909,11 @@
       }
     }
     cout << (*it).id_num << " "
-      << (*it).parent_id << " "
-      << (*it).genotype->GetParentID() << " "
-      << (*it).genotype->GetNumOffspringGenotypes() << " "
-      << (*it).num_cpus << " "
-      << (*it).genotype->GetNumOrganisms() << endl;
+    << (*it).parent_id << " "
+    << (*it).genotype->GetParentID() << " "
+    << (*it).genotype->GetNumOffspringGenotypes() << " "
+    << (*it).num_cpus << " "
+    << (*it).genotype->GetNumOrganisms() << endl;
     if (soup_full){
       cout << "cPopulation::LoadDumpFile: You are trying to load more organisms than there is space!" << endl;
       cout << "cPopulation::LoadDumpFile: Remaining organisms are ignored." << endl;
@@ -2275,7 +2260,7 @@
 void cPopulation::PrintPhenotypeData(const cString& filename)
 {
   set<int> ids;
-
+  
   for (int i = 0; i < cell_array.GetSize(); i++) {
     // Only look at cells with organisms in them.
     if (cell_array[i].IsOccupied() == false) continue;

Modified: development/source/main/cStats.cc
===================================================================
--- development/source/main/cStats.cc	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/main/cStats.cc	2006-12-29 19:25:24 UTC (rev 1159)
@@ -11,6 +11,7 @@
 #include "cStats.h"
 
 #include "cDataFile.h"
+#include "cEnvironment.h"
 #include "functions.h"
 #include "cStringUtil.h"
 #include "tDataEntry.h"
@@ -90,13 +91,16 @@
   , num_own_used(0)
   , sense_size(0)
 {
-  task_cur_count.Resize( m_world->GetNumTasks() );
-  task_last_count.Resize( m_world->GetNumTasks() );
-  task_cur_quality.Resize( m_world->GetNumTasks() );
-  task_last_quality.Resize( m_world->GetNumTasks() );
-  task_cur_max_quality.Resize( m_world->GetNumTasks() );
-  task_last_max_quality.Resize( m_world->GetNumTasks() );
-  task_exe_count.Resize( m_world->GetNumTasks() );
+  const cEnvironment& env = m_world->GetEnvironment();
+  const int num_tasks = env.GetNumTasks();
+    
+  task_cur_count.Resize(num_tasks);
+  task_last_count.Resize(num_tasks);
+  task_cur_quality.Resize(num_tasks);
+  task_last_quality.Resize(num_tasks);
+  task_cur_max_quality.Resize(num_tasks);
+  task_last_max_quality.Resize(num_tasks);
+  task_exe_count.Resize(num_tasks);
   task_cur_count.SetAll(0);
   task_cur_quality.SetAll(0);
   task_cur_max_quality.SetAll(0);
@@ -119,7 +123,10 @@
   resource_count.Resize( m_world->GetNumResources() );
   resource_count.SetAll(0);
 
-  task_names.Resize( m_world->GetNumTasks() );
+  task_names.Resize(num_tasks);
+  for (int i = 0; i < num_tasks; i++)
+    task_names[i] = env.GetTask(i).GetDesc();
+  
   reaction_names.Resize( m_world->GetNumReactions() );
   resource_names.Resize( m_world->GetNumResources() );
 

Modified: development/source/main/cStats.h
===================================================================
--- development/source/main/cStats.h	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/main/cStats.h	2006-12-29 19:25:24 UTC (rev 1159)
@@ -447,7 +447,6 @@
     spatial_res_count = _in;
   }
 
-  void SetTaskName(int id, const cString & name) { task_names[id] = name; }
   void SetInstName(int id, const cString & name) {
     assert(id < inst_names.GetSize());
     inst_names[id] = name;

Modified: development/source/main/cTaskEntry.h
===================================================================
--- development/source/main/cTaskEntry.h	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/main/cTaskEntry.h	2006-12-29 19:25:24 UTC (rev 1159)
@@ -17,9 +17,6 @@
 #ifndef cString_h
 #include "cString.h"
 #endif
-#ifndef cTaskLib_h
-#include "cTaskLib.h"
-#endif
 
 class cTaskLib;
 class cTaskContext;

Modified: development/source/main/cTaskLib.cc
===================================================================
--- development/source/main/cTaskLib.cc	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/main/cTaskLib.cc	2006-12-29 19:25:24 UTC (rev 1159)
@@ -1900,7 +1900,8 @@
   cArgContainer* args = cArgContainer::Load(argstr, schema);
   if (args) {
     envreqs.SetMinInputs(args->GetInt(0));
-    envreqs.SetMinOutputs(args->GetInt(0));
+    envreqs.SetMinOutputs(args->GetInt(0) * 2);
+    envreqs.SetTrueRandInputs();
     NewTask(name, "Sort Inputs", &cTaskLib::Task_SortInputs, 0, args);
   }
 }

Modified: development/source/main/cWorld.cc
===================================================================
--- development/source/main/cWorld.cc	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/main/cWorld.cc	2006-12-29 19:25:24 UTC (rev 1159)
@@ -26,25 +26,27 @@
 
 cWorld::~cWorld()
 {
-  if(m_data_mgr) { m_data_mgr->FlushAll(); }
-
-  if(m_pop){ delete m_pop; m_pop=0; }
-
+  if (m_data_mgr) { m_data_mgr->FlushAll(); }
+  
+  delete m_pop; m_pop = NULL;
+  
   // m_actlib is not owned by cWorld, DO NOT DELETE
-  if(m_analyze){ delete m_analyze; m_analyze=0; }
-  if(m_conf){ delete m_conf; m_conf=0; }
-  if(m_data_mgr){ delete m_data_mgr; m_data_mgr=0; }
-  if(m_env){ delete m_env; m_env=0; }
-  if(m_event_list){ delete m_event_list; m_event_list=0; }
+  delete m_analyze; m_analyze = NULL;
+  delete m_conf; m_conf = NULL;
+  delete m_data_mgr; m_data_mgr = NULL;
+  delete m_env; m_env = NULL;
+  delete m_event_list; m_event_list = NULL;
+  
   // must occur *after* m_pop is deleted. @kgn
-  if(m_hw_mgr){ delete m_hw_mgr; m_hw_mgr=0; }
-  if(m_class_mgr){ delete m_class_mgr; m_class_mgr=0; }
-  if(m_stats){ delete m_stats; m_stats=0; }
-
+  delete m_hw_mgr; m_hw_mgr = NULL;
+  delete m_class_mgr; m_class_mgr = NULL;
+  delete m_stats; m_stats = NULL;
+  
   // cleanup driver object, if needed
-  if (m_own_driver) { assert(m_driver); delete m_driver; m_driver=0; }
+  if (m_own_driver) { delete m_driver; m_driver = NULL; }
 }
 
+
 void cWorld::Setup()
 {
   m_own_driver = true;
@@ -71,22 +73,32 @@
     cerr << "Unable to load environment... aborting!" << endl;
     ExitAvida(-1);
   }
-
+  
   m_hw_mgr = new cHardwareManager(this);
+  
+  
+  // Setup Stats Object
   m_stats = new cStats(this);
+    
+  const cInstSet& inst_set = m_hw_mgr->GetInstSet();
+  for (int i = 0; i < inst_set.GetSize(); i++)
+    m_stats->SetInstName(i, inst_set.GetName(i));
+  
+  
   m_pop = new cPopulation(this);
-
+  
   // Setup Event List
   m_event_list = new cEventList(this);
   m_event_list->LoadEventFile(m_conf->EVENT_FILE.Get());
-    
+  
+  
   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;
@@ -114,11 +126,6 @@
   return m_hw_mgr->GetInstSet().GetSize();
 }
 
-int cWorld::GetNumTasks()
-{
-  return m_env->GetTaskLib().GetSize(); 
-}
-
 int cWorld::GetNumReactions()
 {
   return m_env->GetReactionLib().GetSize();
@@ -132,7 +139,7 @@
 void cWorld::SetDriver(cWorldDriver* driver, bool take_ownership)
 {
   // cleanup current driver, if needed
-  if (m_own_driver) { assert(m_driver); delete m_driver; m_driver=0; }
+  if (m_own_driver) delete m_driver;
   
   // store new driver information
   m_driver = driver;

Modified: development/source/main/cWorld.h
===================================================================
--- development/source/main/cWorld.h	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/main/cWorld.h	2006-12-29 19:25:24 UTC (rev 1159)
@@ -77,24 +77,10 @@
   cWorld& operator=(const cWorld&); // @not_implemented
   
 public:
-  explicit cWorld()
-  : m_actlib(NULL)
-  , m_analyze(NULL)
-  , m_conf(new cAvidaConfig())
-  , m_ctx(m_rng)
-  , m_class_mgr(NULL)
-  , m_data_mgr(NULL)
-  , m_env(NULL)
-  , m_event_list(NULL)
-  , m_hw_mgr(NULL)
-  , m_pop(NULL)
-  , m_stats(NULL)
-  , m_driver(NULL)
-  { Setup(); }
   cWorld(cAvidaConfig* cfg) : m_analyze(NULL), m_conf(cfg), m_ctx(m_rng) { Setup(); }
   ~cWorld();
   
-  void SetConfig(cAvidaConfig* cfg) { assert(m_conf); delete m_conf; m_conf = cfg; }
+  void SetConfig(cAvidaConfig* cfg) { delete m_conf; m_conf = cfg; }
   void SetDriver(cWorldDriver* driver, bool take_ownership = false);
   
   // General Object Accessors
@@ -121,7 +107,6 @@
   
   // Convenience Accessors
   int GetNumInstructions();
-  int GetNumTasks();
   int GetNumReactions();
   int GetNumResources();
   inline int GetVerbosity() { return m_conf->VERBOSITY.Get(); }

Modified: development/source/targets/avida-viewer/cAnalyzeView.cc
===================================================================
--- development/source/targets/avida-viewer/cAnalyzeView.cc	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/targets/avida-viewer/cAnalyzeView.cc	2006-12-29 19:25:24 UTC (rev 1159)
@@ -14,7 +14,6 @@
 #include "cPopulation.h"
 #include "cPopulationCell.h"
 #include "cStats.h"
-#include "cTestUtil.h"
 #include "cHardwareBase.h"
 
 #include "cMenuWindow.h"

Modified: development/source/targets/avida-viewer/cStatsScreen.cc
===================================================================
--- development/source/targets/avida-viewer/cStatsScreen.cc	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/targets/avida-viewer/cStatsScreen.cc	2006-12-29 19:25:24 UTC (rev 1159)
@@ -13,7 +13,6 @@
 #include "cPopulation.h"
 #include "cSpecies.h"
 #include "cStats.h"
-#include "cTaskEntry.h"
 
 using namespace std;
 
@@ -57,14 +56,15 @@
 
 
   int task_num = task_offset;
-  const cTaskLib & task_lib = m_world->GetEnvironment().GetTaskLib();
-  for (int col_id = 3; task_num < info.GetWorld().GetNumTasks(); col_id += 20) {
+  const cEnvironment& environment = m_world->GetEnvironment();
+  const int num_tasks = environment.GetNumTasks();
+  for (int col_id = 3; task_num < num_tasks; col_id += 20) {
     if (col_id + 16 > Width()) break;
     for (int row_id = 15;
-	 row_id < 15 + task_rows && task_num < info.GetWorld().GetNumTasks();
+	 row_id < 15 + task_rows && task_num < num_tasks;
 	 row_id++) {
       Print(row_id, col_id, ".........:");
-      Print(row_id, col_id, "%s", static_cast<const char*>(task_lib.GetTask(task_num).GetName()));
+      Print(row_id, col_id, "%s", static_cast<const char*>(environment.GetTask(task_num).GetName()));
       task_num++;
     }
   }
@@ -73,7 +73,7 @@
 
   Box(14, 0, task_rows + 2, Width(), true);
 
-  if (task_num < info.GetWorld().GetNumTasks() || task_offset != 0) {
+  if (task_num < num_tasks || task_offset != 0) {
     SetBoldColor(COLOR_WHITE);
     Print(15 + task_rows, Width() - 20, " [<-] More [->] ");
     SetBoldColor(COLOR_CYAN);
@@ -163,10 +163,11 @@
 
   // This section needs to be changed to work with new task_lib @TCC
   int task_num = task_offset;
-  for (int col_id = 14; task_num < info.GetWorld().GetNumTasks(); col_id += 20) {
+  const int num_tasks = info.GetWorld().GetEnvironment().GetNumTasks();
+  for (int col_id = 14; task_num < num_tasks; col_id += 20) {
     if (col_id + 5 > Width()) break;
     for (int row_id = 15;
-	 row_id < 15 + task_rows && task_num < info.GetWorld().GetNumTasks();
+	 row_id < 15 + task_rows && task_num < num_tasks;
 	 row_id++) {
       Print(row_id, col_id, "%4d", stats.GetTaskLastCount(task_num));
       task_num++;
@@ -190,7 +191,7 @@
     break;
   case '6':
   case KEY_RIGHT:
-    if (task_rows * task_cols + task_offset < info.GetWorld().GetNumTasks()) {
+    if (task_rows * task_cols + task_offset < info.GetWorld().GetEnvironment().GetNumTasks()) {
       task_offset += 5;
       Draw();
     }

Modified: development/source/targets/avida-viewer/cView.cc
===================================================================
--- development/source/targets/avida-viewer/cView.cc	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/targets/avida-viewer/cView.cc	2006-12-29 19:25:24 UTC (rev 1159)
@@ -9,12 +9,13 @@
 
 #include "cEnvironment.h"
 #include "cGenotype.h"
+#include "cHardwareManager.h"
 #include "cOrganism.h"
 #include "cPhenotype.h"
 #include "cPopulation.h"
 #include "cPopulationCell.h"
 #include "cStats.h"
-#include "cTestUtil.h"
+#include "cTestCPU.h"
 #include "cHardwareBase.h"
 
 #include "cMenuWindow.h"
@@ -338,7 +339,9 @@
 
   if (cur_screen) cur_screen->Print(20, 0, "Extracting %s...", static_cast<const char*>(gen_name));
 
-  cTestUtil::PrintGenome(&info.GetWorld(), cur_gen->GetGenome(), gen_name);
+  cTestCPU* testcpu = info.GetWorld().GetHardwareManager().CreateTestCPU();
+  testcpu->PrintGenome(info.GetWorld().GetDefaultContext(), cur_gen->GetGenome(), gen_name);
+  delete testcpu;
 
   if (cur_screen) {
     cur_screen->Print(20, 24, "Done.");

Modified: development/source/targets/avida-viewer/cZoomScreen.cc
===================================================================
--- development/source/targets/avida-viewer/cZoomScreen.cc	2006-12-28 22:51:04 UTC (rev 1158)
+++ development/source/targets/avida-viewer/cZoomScreen.cc	2006-12-29 19:25:24 UTC (rev 1159)
@@ -16,7 +16,6 @@
 #include "cPopulation.h"
 #include "cPopulationCell.h"
 #include "cStringUtil.h"
-#include "cTaskEntry.h"
 
 #include "cHardwareBase.h"
 #include "cHardwareCPU.h"
@@ -144,22 +143,19 @@
   
   int task_num = task_offset;
   int col_num = 0;
-  const cTaskLib& task_lib = population.GetEnvironment().GetTaskLib();
-  for (int cur_col = TASK_X + 2;
-       task_num < info.GetWorld().GetNumTasks();
-       cur_col += 14) {
-    for (int cur_row = TASK_Y + 1;
-         cur_row < Height() - 1 && task_num < info.GetWorld().GetNumTasks();
-         cur_row++) {
+  const cEnvironment& environment = info.GetWorld().GetEnvironment();
+  const int num_tasks = environment.GetNumTasks();
+  for (int cur_col = TASK_X + 2; task_num < num_tasks; cur_col += 14) {
+    for (int cur_row = TASK_Y + 1; cur_row < Height() - 1 && task_num < num_tasks; cur_row++) {
       Print(cur_row, cur_col, "........:");
-      Print(cur_row, cur_col, "%s", static_cast<const char*>(task_lib.GetTask(task_num).GetName()));
+      Print(cur_row, cur_col, "%s", static_cast<const char*>(environment.GetTask(task_num).GetName()));
       task_num++;
     }
     col_num++;
     if (col_num == 2) break;
   }
   
-  if (task_num < info.GetWorld().GetNumTasks() || task_offset != 0) {
+  if (task_num < num_tasks || task_offset != 0) {
     SetBoldColor(COLOR_WHITE);
     PrintOption(Height()-1, Width() - 23, " [<-] More [->] ");
   }
@@ -481,13 +477,10 @@
   SetColor(COLOR_CYAN);
   
   int task_num = task_offset;
+  int num_tasks = info.GetWorld().GetEnvironment().GetNumTasks();
   int col_num = 0;
-  for (int cur_col = TASK_X + 12;
-       task_num < info.GetWorld().GetNumTasks();
-       cur_col += 14) {
-    for (int cur_row = TASK_Y + 1;
-         cur_row <= Height() - 2 && task_num < info.GetWorld().GetNumTasks();
-         cur_row++) {
+  for (int cur_col = TASK_X + 12; task_num < num_tasks; cur_col += 14) {
+    for (int cur_row = TASK_Y + 1; cur_row <= Height() - 2 && task_num < num_tasks; cur_row++) {
       if (col_num < 2) {
         Print(cur_row, cur_col, "%2d", phenotype.GetCurTaskCount()[task_num]);
       }
@@ -1624,7 +1617,7 @@
     case KEY_RIGHT:
     {
       const int new_task_offset = task_offset + Height() - TASK_Y - 2;
-      if (new_task_offset < info.GetWorld().GetNumTasks()) {
+      if (new_task_offset < info.GetWorld().GetEnvironment().GetNumTasks()) {
         task_offset = new_task_offset;
         Draw();
       }




More information about the Avida-cvs mailing list