[Avida-cvs] [Avida2-svn] r263 - in branches/brysonda: Avida2.xcodeproj CMakeModules source/bindings/Boost.Python source/cpu source/event source/main source/python source/python/AvidaGui2 source/tools

brysonda@myxo.css.msu.edu brysonda at myxo.css.msu.edu
Tue Jul 26 07:44:41 PDT 2005


Author: brysonda
Date: 2005-07-26 10:44:40 -0400 (Tue, 26 Jul 2005)
New Revision: 263

Added:
   branches/brysonda/source/python/AvidaGui2/pyFreezeOrganismCtrl.py
   branches/brysonda/source/python/AvidaGui2/pyFreezeOrganismView.ui
   branches/brysonda/source/python/default.workspace/
Removed:
   branches/brysonda/source/bindings/Boost.Python/kaben_brainstorms.cc
   branches/brysonda/source/bindings/Boost.Python/kaben_brainstorms.cpp
   branches/brysonda/source/bindings/Boost.Python/kaben_brainstorms.pyste
   branches/brysonda/source/event/cPopulation_descr.h
Modified:
   branches/brysonda/Avida2.xcodeproj/project.pbxproj
   branches/brysonda/CMakeModules/AddPysteModule.cmake
   branches/brysonda/source/bindings/Boost.Python/CMakeLists.txt
   branches/brysonda/source/bindings/Boost.Python/cpu_head-fixups.cc
   branches/brysonda/source/bindings/Boost.Python/cpu_head-fixups.hh
   branches/brysonda/source/bindings/Boost.Python/cpu_test_info.pyste
   branches/brysonda/source/cpu/cpu_test_info.cc
   branches/brysonda/source/cpu/cpu_test_info.hh
   branches/brysonda/source/cpu/hardware_4stack.cc
   branches/brysonda/source/cpu/hardware_base.cc
   branches/brysonda/source/cpu/hardware_base.hh
   branches/brysonda/source/cpu/hardware_cpu.cc
   branches/brysonda/source/cpu/hardware_smt.cc
   branches/brysonda/source/cpu/hardware_smt.h
   branches/brysonda/source/cpu/tInstLib.h
   branches/brysonda/source/cpu/test_cpu.cc
   branches/brysonda/source/cpu/test_cpu.hh
   branches/brysonda/source/event/event_list.cc
   branches/brysonda/source/main/analyze.cc
   branches/brysonda/source/main/analyze.hh
   branches/brysonda/source/main/analyze_command.hh
   branches/brysonda/source/main/analyze_function.hh
   branches/brysonda/source/main/avida_triggers.hh
   branches/brysonda/source/main/config.cc
   branches/brysonda/source/main/environment.cc
   branches/brysonda/source/main/environment.hh
   branches/brysonda/source/main/genebank.hh
   branches/brysonda/source/main/genotype_batch.hh
   branches/brysonda/source/main/landscape.hh
   branches/brysonda/source/main/organism.cc
   branches/brysonda/source/main/phenotype.cc
   branches/brysonda/source/main/population.cc
   branches/brysonda/source/main/reaction.hh
   branches/brysonda/source/main/reaction_requisite.hh
   branches/brysonda/source/main/task_lib.cc
   branches/brysonda/source/main/task_lib.hh
   branches/brysonda/source/python/AvidaGui2/pyAnalyzeControlsView.ui
   branches/brysonda/source/python/AvidaGui2/pyAvida.py
   branches/brysonda/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
   branches/brysonda/source/python/AvidaGui2/pyFreezerCtrl.py
   branches/brysonda/source/python/AvidaGui2/pyFreezerView.ui
   branches/brysonda/source/python/AvidaGui2/pyGradientScaleCtrl.py
   branches/brysonda/source/python/AvidaGui2/pyGradientScaleView.py
   branches/brysonda/source/python/AvidaGui2/pyHardwareCPUTrace.py
   branches/brysonda/source/python/AvidaGui2/pyLiveControlsCtrl.py
   branches/brysonda/source/python/AvidaGui2/pyMapProfile.py
   branches/brysonda/source/python/AvidaGui2/pyOneAna_GraphCtrl.py
   branches/brysonda/source/python/AvidaGui2/pyOneAna_PetriDishCtrl.py
   branches/brysonda/source/python/AvidaGui2/pyOneAnalyzeCtrl.py
   branches/brysonda/source/python/AvidaGui2/pyOneOrg_ScopeCtrl.py
   branches/brysonda/source/python/AvidaGui2/pyOneOrg_ScopeView.ui
   branches/brysonda/source/python/AvidaGui2/pyOnePop_GraphCtrl.py
   branches/brysonda/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py
   branches/brysonda/source/python/AvidaGui2/pyOnePop_StatsCtrl.py
   branches/brysonda/source/python/AvidaGui2/pyOnePopulationCtrl.py
   branches/brysonda/source/python/AvidaGui2/pyOrganismScopeCtrl.py
   branches/brysonda/source/python/AvidaGui2/pyOrganismScopeView.py
   branches/brysonda/source/python/AvidaGui2/pyPetriCanvasView.py
   branches/brysonda/source/python/AvidaGui2/pyPetriConfigureCtrl.py
   branches/brysonda/source/python/AvidaGui2/pyPetriDishCtrl.py
   branches/brysonda/source/python/AvidaGui2/pyPopulationCellItem.py
   branches/brysonda/source/python/AvidaGui2/pyQuitDialogCtrl.py
   branches/brysonda/source/python/AvidaGui2/pyQuitDialogView.ui
   branches/brysonda/source/python/AvidaGui2/pyReadFreezer.py
   branches/brysonda/source/python/AvidaGui2/pySessionCtrl.py
   branches/brysonda/source/python/AvidaGui2/pyTemporaryReloads.py
   branches/brysonda/source/python/AvidaGui2/pyWriteGenesisEvent.py
   branches/brysonda/source/python/AvidaGui2/pyWriteToFreezer.py
   branches/brysonda/source/python/AvidaGui2/py_test_utils.py
   branches/brysonda/source/python/CMakeLists.txt
   branches/brysonda/source/python/setup_osx.py.in
   branches/brysonda/source/tools/data_file_manager.hh
   branches/brysonda/source/tools/help_manager.hh
   branches/brysonda/source/tools/help_type.hh
   branches/brysonda/source/tools/tDictionary.hh
   branches/brysonda/source/tools/tList.hh
   branches/brysonda/source/tools/tVector.hh
Log:
Merged in r262 from trunk.

Modified: branches/brysonda/Avida2.xcodeproj/project.pbxproj
===================================================================
--- branches/brysonda/Avida2.xcodeproj/project.pbxproj	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/Avida2.xcodeproj/project.pbxproj	2005-07-26 14:44:40 UTC (rev 263)
@@ -1321,7 +1321,6 @@
 				DCC30D410762539B008F7A48 /* avida_driver_population.pyste */,
 				DCC30D420762539B008F7A48 /* avida_triggers.pyste */,
 				DCC30D430762539B008F7A48 /* AvidaGui */,
-				DCC30D850762539B008F7A48 /* AvidaGui2 */,
 				DCC30ED70762539D008F7A48 /* B.hh */,
 				DCC30ED80762539D008F7A48 /* B.pyste */,
 				DCC30ED90762539D008F7A48 /* birth_chamber.pyste */,
@@ -1530,13 +1529,6 @@
 			path = 0;
 			sourceTree = "<group>";
 		};
-		DCC30D850762539B008F7A48 /* AvidaGui2 */ = {
-			isa = PBXGroup;
-			children = (
-			);
-			path = AvidaGui2;
-			sourceTree = "<group>";
-		};
 		DCC30F7C0762539D008F7A48 /* cpu */ = {
 			isa = PBXGroup;
 			children = (

Modified: branches/brysonda/CMakeModules/AddPysteModule.cmake
===================================================================
--- branches/brysonda/CMakeModules/AddPysteModule.cmake	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/CMakeModules/AddPysteModule.cmake	2005-07-26 14:44:40 UTC (rev 263)
@@ -5,7 +5,7 @@
 #LINK_DIRECTORIES(${PY_BOOST_LIBRARIES})
 
 IF(APPLE)
-  SET(BOOST_PYTHON_COMPILE_FLAGS "-no-cpp-precomp -ftemplate-depth-120 -fcoalesce-templates -fno-inline -fPIC -Wno-long-double -Wno-long-long -DBOOST_PYTHON_DYNAMIC_LIB")
+  SET(BOOST_PYTHON_COMPILE_FLAGS "-no-cpp-precomp -ftemplate-depth-120 -fno-inline -fPIC -Wno-long-double -Wno-long-long -DBOOST_PYTHON_DYNAMIC_LIB")
 ELSE(APPLE)
   SET(BOOST_PYTHON_COMPILE_FLAGS "-Wall -ftemplate-depth-100  -DBOOST_PYTHON_DYNAMIC_LIB  -fno-inline -fPIC")
 ENDIF(APPLE)
@@ -200,7 +200,7 @@
       SET(DepList)
     ENDIF(Args)
 
-    SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/${ModuleName}/_${PysteBase}.cpp
+    SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/${PysteBase}.cpp
       PROPERTIES
         GENERATED TRUE
         COMPILE_FLAGS ${BOOST_PYTHON_COMPILE_FLAGS})
@@ -253,7 +253,7 @@
     ADD_LIBRARY(${ModuleName}/${PysteBase} MODULE ${CMAKE_CURRENT_BINARY_DIR}/${PysteBase}.cpp)
     SET_TARGET_PROPERTIES(${ModuleName}/${PysteBase} PROPERTIES PREFIX "")
     TARGET_LINK_LIBRARIES(${ModuleName}/${PysteBase} ${${LinkLibraries}})
-    INSTALL_TARGETS(${PackageLocation}/${ModuleName} $${ModuleName}/{PysteBase})
+    INSTALL_TARGETS(${PackageLocation}/${ModuleName} $${ModuleName}/${PysteBase})
     FILE(APPEND ${LIBRARY_OUTPUT_PATH}/${ModuleName}/__init__.py "from ${PysteBase} import *\n")
   ENDFOREACH(Entry ${${PysteBases}})
   #FOREACH(Entry ${${PysteBases}})

Modified: branches/brysonda/source/bindings/Boost.Python/CMakeLists.txt
===================================================================
--- branches/brysonda/source/bindings/Boost.Python/CMakeLists.txt	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/bindings/Boost.Python/CMakeLists.txt	2005-07-26 14:44:40 UTC (rev 263)
@@ -30,11 +30,11 @@
 #
 # kaben-brainstorms.
 #
-SET(libkaben_brainstorms_SOURCES kaben_brainstorms.cc)
-SET_SOURCE_FILES_PROPERTIES(${libkaben_brainstorms_SOURCES} PROPERTIES COMPILE_FLAGS ${BOOST_PYTHON_COMPILE_FLAGS})
-ADD_LIBRARY(kaben_brainstorms MODULE ${libkaben_brainstorms_SOURCES})
-SET_TARGET_PROPERTIES(kaben_brainstorms PROPERTIES PREFIX "")
-TARGET_LINK_LIBRARIES(kaben_brainstorms main cpu event main tools ${BOOST_LIBRARY} ${PYTHON_LIBRARY})
+#SET(libkaben_brainstorms_SOURCES kaben_brainstorms.cc)
+#SET_SOURCE_FILES_PROPERTIES(${libkaben_brainstorms_SOURCES} PROPERTIES COMPILE_FLAGS ${BOOST_PYTHON_COMPILE_FLAGS})
+#ADD_LIBRARY(kaben_brainstorms MODULE ${libkaben_brainstorms_SOURCES})
+#SET_TARGET_PROPERTIES(kaben_brainstorms PROPERTIES PREFIX "")
+#TARGET_LINK_LIBRARIES(kaben_brainstorms main cpu event main tools ${BOOST_LIBRARY} ${PYTHON_LIBRARY})
 
 
 #
@@ -246,3 +246,5 @@
   PyAvida_Extra_Cpp_Files
   PyAvida_LinkLibraries
   /lib)
+
+# vim: set ft=conf:

Modified: branches/brysonda/source/bindings/Boost.Python/cpu_head-fixups.cc
===================================================================
--- branches/brysonda/source/bindings/Boost.Python/cpu_head-fixups.cc	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/bindings/Boost.Python/cpu_head-fixups.cc	2005-07-26 14:44:40 UTC (rev 263)
@@ -1,21 +1,21 @@
 #include "cpu_head-fixups.hh"
 
-bool cCPUHead_GetFlagCopied(const cCPUHead &cpu_head){
+bool cCPUHead_GetFlagCopied(cCPUHead &cpu_head){
   return cpu_head.FlagCopied();
 }
-bool cCPUHead_GetFlagMutated(const cCPUHead &cpu_head){
+bool cCPUHead_GetFlagMutated(cCPUHead &cpu_head){
   return cpu_head.FlagMutated();
 }
-bool cCPUHead_GetFlagExecuted(const cCPUHead &cpu_head){
+bool cCPUHead_GetFlagExecuted(cCPUHead &cpu_head){
   return cpu_head.FlagExecuted();
 }
-bool cCPUHead_GetFlagBreakpoint(const cCPUHead &cpu_head){
+bool cCPUHead_GetFlagBreakpoint(cCPUHead &cpu_head){
   return cpu_head.FlagBreakpoint();
 }
-bool cCPUHead_GetFlagPointMut(const cCPUHead &cpu_head){
+bool cCPUHead_GetFlagPointMut(cCPUHead &cpu_head){
   return cpu_head.FlagPointMut();
 }
-bool cCPUHead_GetFlagCopyMut(const cCPUHead &cpu_head){
+bool cCPUHead_GetFlagCopyMut(cCPUHead &cpu_head){
   return cpu_head.FlagCopyMut();
 }
 

Modified: branches/brysonda/source/bindings/Boost.Python/cpu_head-fixups.hh
===================================================================
--- branches/brysonda/source/bindings/Boost.Python/cpu_head-fixups.hh	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/bindings/Boost.Python/cpu_head-fixups.hh	2005-07-26 14:44:40 UTC (rev 263)
@@ -5,12 +5,12 @@
 #include "cpu_head.hh"
 #endif
 
-bool cCPUHead_GetFlagCopied(const cCPUHead &);
-bool cCPUHead_GetFlagMutated(const cCPUHead &);
-bool cCPUHead_GetFlagExecuted(const cCPUHead &);
-bool cCPUHead_GetFlagBreakpoint(const cCPUHead &);
-bool cCPUHead_GetFlagPointMut(const cCPUHead &);
-bool cCPUHead_GetFlagCopyMut(const cCPUHead &);
+bool cCPUHead_GetFlagCopied(cCPUHead &);
+bool cCPUHead_GetFlagMutated(cCPUHead &);
+bool cCPUHead_GetFlagExecuted(cCPUHead &);
+bool cCPUHead_GetFlagBreakpoint(cCPUHead &);
+bool cCPUHead_GetFlagPointMut(cCPUHead &);
+bool cCPUHead_GetFlagCopyMut(cCPUHead &);
 
 void cCPUHead_SetFlagCopied(cCPUHead &, bool);
 void cCPUHead_SetFlagMutated(cCPUHead &, bool);

Modified: branches/brysonda/source/bindings/Boost.Python/cpu_test_info.pyste
===================================================================
--- branches/brysonda/source/bindings/Boost.Python/cpu_test_info.pyste	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/bindings/Boost.Python/cpu_test_info.pyste	2005-07-26 14:44:40 UTC (rev 263)
@@ -4,7 +4,7 @@
 
 cCPUTestInfo = Class("cCPUTestInfo", "cpu_test_info.hh")
 # returns std::ofstream &, i.e., not the Python Way.
-#exclude(cCPUTestInfo.GetTraceFP)
+exclude(cCPUTestInfo.GetTraceFP)
 set_policy(cCPUTestInfo.GetTestOrganism, return_internal_reference())
 set_policy(cCPUTestInfo.GetColonyOrganism, return_internal_reference())
 set_policy(cCPUTestInfo.GetColonyOrganism, return_internal_reference())

Deleted: branches/brysonda/source/bindings/Boost.Python/kaben_brainstorms.cc
===================================================================
--- branches/brysonda/source/bindings/Boost.Python/kaben_brainstorms.cc	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/bindings/Boost.Python/kaben_brainstorms.cc	2005-07-26 14:44:40 UTC (rev 263)
@@ -1,36 +0,0 @@
-#ifndef PRIMITIVE_HH
-#include "primitive.hh"
-#endif
-#include <boost/python/class.hpp>
-#include <boost/python/module.hpp>
-#include <boost/python/def.hpp>
-
-
-using namespace std;
-
-//void ShuntSetup(cEnvironment &environment, cPopulationInterface &test_interface){
-//  char *argv[]={"kaben_brainstorms"};
-//  SetupAvida(1, argv, environment, test_interface);
-//}
-//
-//struct kFu { int m_fu; };
-//class kBar {
-//public:
-//  kBar(){}
-//  int fu(kFu &fu){ return fu.m_fu; }
-//};
-//
-//BOOST_PYTHON_MODULE(kaben_brainstorms)
-//{
-//    using namespace boost::python;
-//    class_<cEnvironment>("cEnvironment");
-//    class_<cPopulationInterface>("cPopulationInterface");
-//    //class_<cConfig>("cConfig")
-//    //  .def(";
-//    
-//    // Also add invite() as a regular function to the module.
-//    def("ShuntSetup", ShuntSetup);
-//
-//    class_<kFu>("kFu");
-//}
-

Deleted: branches/brysonda/source/bindings/Boost.Python/kaben_brainstorms.cpp
===================================================================
--- branches/brysonda/source/bindings/Boost.Python/kaben_brainstorms.cpp	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/bindings/Boost.Python/kaben_brainstorms.cpp	2005-07-26 14:44:40 UTC (rev 263)
@@ -1,120 +0,0 @@
-
-// Boost Includes ==============================================================
-#include <boost/python.hpp>
-#include <boost/cstdint.hpp>
-
-// Includes ====================================================================
-#include <string.hh>
-
-// Using =======================================================================
-using namespace boost::python;
-
-// Declarations ================================================================
-namespace  {
-
-BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(cString_Insert_overloads_1_3, Insert, 1, 3)
-
-BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(cString_Clip_overloads_1_2, Clip, 1, 2)
-
-BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(cString_Replace_overloads_2_3, Replace, 2, 3)
-
-BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(cString_CountWhitespace_overloads_0_1, CountWhitespace, 0, 1)
-
-BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(cString_CountWordsize_overloads_0_1, CountWordsize, 0, 1)
-
-BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(cString_CountLinesize_overloads_0_1, CountLinesize, 0, 1)
-
-BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(cString_GetWord_overloads_0_1, GetWord, 0, 1)
-
-BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(cString_GetWordAt_overloads_0_1, GetWordAt, 0, 1)
-
-BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(cString_Find_overloads_1_2, Find, 1, 2)
-
-BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(cString_FindWord_overloads_1_2, FindWord, 1, 2)
-
-
-}// namespace 
-
-
-// Module ======================================================================
-BOOST_PYTHON_MODULE(kaben_brainstorms)
-{
-    class_< cString >("cString", init< optional< const char* > >())
-        .def(init< const int >())
-        .def(init< const cString& >())
-        .def_readonly("MAX_LENGTH", &cString::MAX_LENGTH)
-        .def("GetData", &cString::GetData)
-        .def("GetSize", &cString::GetSize)
-        .def("Compare", &cString::Compare)
-        .def("Set", &cString::Set)
-        .def("Insert", (cString& (cString::*)(const char, int, int) )&cString::Insert, cString_Insert_overloads_1_3())
-        .def("Insert", (cString& (cString::*)(const char*, int, int) )&cString::Insert, cString_Insert_overloads_1_3())
-        .def("Insert", (cString& (cString::*)(const cString&, int, int) )&cString::Insert, cString_Insert_overloads_1_3())
-        .def("Clip", &cString::Clip, cString_Clip_overloads_1_2())
-        .def("ClipFront", &cString::ClipFront)
-        .def("ClipEnd", &cString::ClipEnd)
-        .def("Replace", &cString::Replace, cString_Replace_overloads_2_3())
-        .def("Pop", &cString::Pop)
-        .def("PopWord", &cString::PopWord)
-        .def("PopLine", &cString::PopLine)
-        .def("LeftJustify", &cString::LeftJustify)
-        .def("RightJustify", &cString::RightJustify)
-        .def("Reverse", &cString::Reverse)
-        .def("ToLower", &cString::ToLower)
-        .def("ToUpper", &cString::ToUpper)
-        .def("CompressWhitespace", &cString::CompressWhitespace)
-        .def("RemoveWhitespace", &cString::RemoveWhitespace)
-        .def("RemoveChar", &cString::RemoveChar)
-        .def("RemovePos", &cString::RemovePos)
-        .def("AsInt", &cString::AsInt)
-        .def("AsDouble", &cString::AsDouble)
-        .def("IsEmpty", &cString::IsEmpty)
-        .def("IsContinueLine", &cString::IsContinueLine)
-        .def("CountWhitespace", &cString::CountWhitespace, cString_CountWhitespace_overloads_0_1())
-        .def("CountWordsize", &cString::CountWordsize, cString_CountWordsize_overloads_0_1())
-        .def("CountLinesize", &cString::CountLinesize, cString_CountLinesize_overloads_0_1())
-        .def("CountNumLines", &cString::CountNumLines)
-        .def("CountNumWords", &cString::CountNumWords)
-        .def("GetWord", &cString::GetWord, cString_GetWord_overloads_0_1())
-        .def("GetWordAt", &cString::GetWordAt, cString_GetWordAt_overloads_0_1())
-        .def("IsWhitespace", (bool (cString::*)(int) const)&cString::IsWhitespace)
-        .def("IsUpperLetter", (bool (cString::*)(int) const)&cString::IsUpperLetter)
-        .def("IsLowerLetter", (bool (cString::*)(int) const)&cString::IsLowerLetter)
-        .def("IsLetter", (bool (cString::*)(int) const)&cString::IsLetter)
-        .def("IsNumber", (bool (cString::*)(int) const)&cString::IsNumber)
-        .def("IsNumeric", (bool (cString::*)(int) const)&cString::IsNumeric)
-        .def("IsAlphaNumeric", (bool (cString::*)(int) const)&cString::IsAlphaNumeric)
-        .def("IsWhitespace", (bool (cString::*)() const)&cString::IsWhitespace)
-        .def("IsUpperLetter", (bool (cString::*)() const)&cString::IsUpperLetter)
-        .def("IsLowerLetter", (bool (cString::*)() const)&cString::IsLowerLetter)
-        .def("IsLetter", (bool (cString::*)() const)&cString::IsLetter)
-        .def("IsNumber", (bool (cString::*)() const)&cString::IsNumber)
-        .def("IsNumeric", (bool (cString::*)() const)&cString::IsNumeric)
-        .def("IsAlphaNumeric", (bool (cString::*)() const)&cString::IsAlphaNumeric)
-        .def("Find", (int (cString::*)(char, int) const)&cString::Find, cString_Find_overloads_1_2())
-        .def("Find", (int (cString::*)(const char*, int) const)&cString::Find, cString_Find_overloads_1_2())
-        .def("Find", (int (cString::*)(const cString&, int) const)&cString::Find, cString_Find_overloads_1_2())
-        .def("FindWord", &cString::FindWord, cString_FindWord_overloads_1_2())
-        .def("Substring", &cString::Substring)
-        .def("IsSubstring", &cString::IsSubstring)
-        .def( other< std::istream >() >> self )
-        .def( other< std::ostream >() << self )
-        .def("__call__", &cString::operator ())
-        .def( self == other< char >() )
-        .def( self == self )
-        .def( self != other< char >() )
-        .def( self < other< char >() )
-        .def( self > other< char >() )
-        .def( self <= other< char >() )
-        .def( self >= other< char >() )
-        .def( self += other< char >() )
-        .def( self += other< char >() )
-        .def( self += self )
-        .def( self + other< char >() )
-        .def( self + other< char >() )
-        .def( self + self )
-        .def("__str__", &cString::operator const char*)
-    ;
-
-}
-

Deleted: branches/brysonda/source/bindings/Boost.Python/kaben_brainstorms.pyste
===================================================================
--- branches/brysonda/source/bindings/Boost.Python/kaben_brainstorms.pyste	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/bindings/Boost.Python/kaben_brainstorms.pyste	2005-07-26 14:44:40 UTC (rev 263)
@@ -1,19 +0,0 @@
-#Function("SetupAvida", "avida.hh")
-#
-#Class("cAvidaDriver_Analyze", "avida_driver_analyze.hh")
-#
-#Class("cAvidaDriver_Base", "avida_driver_base.hh")
-#
-#Class("cAvidaDriver_Population", "avida_driver_population.hh")
-
-#declaration_code("""
-##ifndef ENVIRONMENT_HH
-##include "environment.hh"
-##endif
-##ifndef POPULATION_INTERFACE_HH
-##include "population_interface.hh"
-##endif
-#""")
-#Function("SetupAvida", "avida.hh")
-
-# vim: set ft=python:

Modified: branches/brysonda/source/cpu/cpu_test_info.cc
===================================================================
--- branches/brysonda/source/cpu/cpu_test_info.cc	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/cpu/cpu_test_info.cc	2005-07-26 14:44:40 UTC (rev 263)
@@ -25,7 +25,6 @@
   , trace_task_order(false)
   , use_random_inputs(false)
   , org_array(max_tests)
-  , m_tracer(NULL)
 {
   org_array.SetAll(NULL);
   Clear();
@@ -56,13 +55,15 @@
 }
  
 
-void cCPUTestInfo::SetTraceExecution(cHardwareTracer *tracer)
+void cCPUTestInfo::SetTraceExecution(const cString & filename)
 {
-  trace_execution = (tracer)?(true):(false);
-  m_tracer = tracer;
+  trace_execution = true;
+  trace_fp.open(filename);
+  assert (trace_fp.good() == true); // Unable to open trace file.
 }
 
 
+
 double cCPUTestInfo::GetGenotypeFitness()
 {
   if (org_array[0] != NULL) return org_array[0]->GetPhenotype().GetFitness();

Modified: branches/brysonda/source/cpu/cpu_test_info.hh
===================================================================
--- branches/brysonda/source/cpu/cpu_test_info.hh	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/cpu/cpu_test_info.hh	2005-07-26 14:44:40 UTC (rev 263)
@@ -8,6 +8,8 @@
 #ifndef CPU_TEST_INFO_HH
 #define CPU_TEST_INFO_HH
 
+#include <fstream>
+
 #ifndef CPU_DEFS_HH
 #include "cpu_defs.hh"
 #endif
@@ -18,7 +20,6 @@
 #include "tArray.hh"
 #endif
 
-class cHardwareTracer;
 class cOrganism;
 class cString;
 
@@ -32,7 +33,7 @@
   bool trace_execution;       // Should we trace this CPU?
   bool trace_task_order;      // Should we keep track of ordering of tasks?
   bool use_random_inputs;     // Should we give the organism random inputs?
-  cHardwareTracer *m_tracer;
+  std::ofstream trace_fp;
 
   // Outputs...
   bool is_viable;         // Is this organism colony forming?
@@ -43,6 +44,9 @@
 
   tArray<cOrganism *> org_array;
 
+private:
+  // disabled copy constructor.
+  cCPUTestInfo(const cCPUTestInfo &);
 public:
   cCPUTestInfo(int max_tests=TEST_CPU_GENERATIONS);
   ~cCPUTestInfo();
@@ -54,7 +58,7 @@
   void PrintThreads(bool _print=true) { print_threads = _print; }
   void TraceTaskOrder(bool _trace=true) { trace_task_order = _trace; }
   void UseRandomInputs(bool _rand=true) { use_random_inputs = _rand; }
-  void SetTraceExecution(cHardwareTracer *tracer = NULL);
+  void SetTraceExecution(const cString & filename="trace.dat");
 
   // Input Accessors
   int GetGenerationTests() const { return generation_tests; }
@@ -63,7 +67,7 @@
   bool GetTraceTaskOrder() const { return trace_task_order; }
   bool GetUseRandomInputs() const { return use_random_inputs; }
   bool GetTraceExecution() const { return trace_execution; }
-  cHardwareTracer *GetTracer() { return m_tracer; }
+  std::ofstream & GetTraceFP() { return trace_fp; }
 
 
   // Output Accessors

Modified: branches/brysonda/source/cpu/hardware_4stack.cc
===================================================================
--- branches/brysonda/source/cpu/hardware_4stack.cc	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/cpu/hardware_4stack.cc	2005-07-26 14:44:40 UTC (rev 263)
@@ -374,13 +374,8 @@
 #endif
     
     // Print the status of this CPU at each step...
-    if (m_tracer != NULL) {
-      if (cHardwareTracer_4Stack * tracer
-          = dynamic_cast<cHardwareTracer_4Stack *>(m_tracer)
-      ){
-        tracer->TraceHardware_4Stack(*this);
-      }
-    }
+    const cString & next_name = inst_set->GetName(IP().GetInst())();
+    if (trace_fp != NULL) organism->PrintStatus(*trace_fp, next_name);
     
     // Find the instruction to be executed
     const cInstruction & cur_inst = IP().GetInst();
@@ -487,14 +482,10 @@
 
   // @CAO FIX PRINTING TO INDICATE THIS IS A BONUS
   // Print the status of this CPU at each step...
-  if (m_tracer != NULL) {
-    if (cHardwareTracer_4Stack * tracer
-        = dynamic_cast<cHardwareTracer_4Stack *>(m_tracer)
-    ){
-      tracer->TraceHardware_4StackBonus(*this);
-    }
-  }
-    
+  cString next_name = cStringUtil::Stringf("%s (bonus instruction)",
+					   inst_set->GetName(inst)());
+  if (trace_fp != NULL) organism->PrintStatus(*trace_fp, next_name);
+      
   SingleProcess_ExecuteInst(inst);
 
   organism->SetRunning(prev_run_state);

Modified: branches/brysonda/source/cpu/hardware_base.cc
===================================================================
--- branches/brysonda/source/cpu/hardware_base.cc	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/cpu/hardware_base.cc	2005-07-26 14:44:40 UTC (rev 263)
@@ -17,7 +17,7 @@
   : organism(in_organism)
   , inst_set(in_inst_set)
   , viewer_lock(-1)
-  , m_tracer(NULL)
+  , trace_fp(NULL)
 {
   assert(inst_set->OK());
   assert(organism != NULL);

Modified: branches/brysonda/source/cpu/hardware_base.hh
===================================================================
--- branches/brysonda/source/cpu/hardware_base.hh	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/cpu/hardware_base.hh	2005-07-26 14:44:40 UTC (rev 263)
@@ -31,7 +31,7 @@
   int viewer_lock;            // Used if the viewer should only lock onto
                               //  one aspect of the hardware.
 
-  cHardwareTracer * m_tracer;         // Set this if you want execution traced.
+  ostream * trace_fp;         // Set this if you want execution traced.
 
   static int instance_count;
 public:
@@ -73,7 +73,7 @@
   virtual void SaveState(std::ostream & fp) = 0;
   virtual void LoadState(std::istream & fp) = 0;
 
-  void SetTrace(cHardwareTracer * tracer) { m_tracer = tracer; }
+  void SetTrace(ostream * in_fp) { trace_fp = in_fp; }
 
 
   // --------  Mutations (Must be Virtual)  --------

Modified: branches/brysonda/source/cpu/hardware_cpu.cc
===================================================================
--- branches/brysonda/source/cpu/hardware_cpu.cc	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/cpu/hardware_cpu.cc	2005-07-26 14:44:40 UTC (rev 263)
@@ -472,13 +472,9 @@
 #endif
     
     // Print the status of this CPU at each step...
-    if (m_tracer != NULL) {
-      if (cHardwareTracer_CPU * tracer
-          = dynamic_cast<cHardwareTracer_CPU *>(m_tracer)
-      ){
-        tracer->TraceHardware_CPU(*this);
-      }
-    }
+    const cString & next_name = inst_set->GetName(IP().GetInst())();
+    if (trace_fp != NULL) organism->PrintStatus(*trace_fp, next_name);
+
     
     // Find the instruction to be executed
     const cInstruction & cur_inst = IP().GetInst();
@@ -586,13 +582,9 @@
 
   // @CAO FIX PRINTING TO INDICATE THIS IS A BONUS
   // Print the status of this CPU at each step...
-  if (m_tracer != NULL) {
-    if (cHardwareTracer_CPU * tracer
-        = dynamic_cast<cHardwareTracer_CPU *>(m_tracer)
-    ){
-      tracer->TraceHardware_CPUBonus(*this);
-    }
-  }
+  cString next_name = cStringUtil::Stringf("%s (bonus instruction)",
+					   inst_set->GetName(inst)());
+  if (trace_fp != NULL) organism->PrintStatus(*trace_fp, next_name);
     
   SingleProcess_ExecuteInst(inst);
 

Modified: branches/brysonda/source/cpu/hardware_smt.cc
===================================================================
--- branches/brysonda/source/cpu/hardware_smt.cc	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/cpu/hardware_smt.cc	2005-07-26 14:44:40 UTC (rev 263)
@@ -125,18 +125,16 @@
     //30
     cInstEntry4Stack("ThreadFork",   &cHardwareSMT::Inst_ForkThread),
     //31
-    //cInstEntry4Stack("if-label",  &cHardwareSMT::Inst_IfLabel),
-    //32
     cInstEntry4Stack("Val-Inc",       &cHardwareSMT::Inst_Increment),
-    //33
+    //32
     cInstEntry4Stack("Val-Dec",       &cHardwareSMT::Inst_Decrement),
-    //34
+    //33
     cInstEntry4Stack("Val-Mod",       &cHardwareSMT::Inst_Mod),
-    //35
+    //34
     cInstEntry4Stack("ThreadKill",   &cHardwareSMT::Inst_KillThread),
-    //36
+    //35
     cInstEntry4Stack("IO", &cHardwareSMT::Inst_IO),
-    //37
+    //36
     cInstEntry4Stack("Inject", &cHardwareSMT::Inst_Inject)
   };
 	
@@ -160,16 +158,8 @@
 	const cInstruction error(255);
 	const cInstruction def(0);
 	
-  tInstLib<cHardwareSMT::tMethod> *inst_lib = new tInstLib<cHardwareSMT::tMethod>(
-                                                                                  n_size,
-                                                                                  f_size,
-                                                                                  n_names,
-                                                                                  f_names,
-                                                                                  nop_mods,
-                                                                                  functions,
-                                                                                  error,
-                                                                                  def
-                                                                                  );
+  tInstLib<cHardwareSMT::tMethod> *inst_lib =
+    new tInstLib<cHardwareSMT::tMethod>(n_size, f_size, n_names, f_names, nop_mods, functions, error, def);
 	
   cout <<
 		"<cHardwareSMT::initInstLib> debug: important post-init values:" <<endl<<
@@ -182,85 +172,64 @@
   return inst_lib;
 }
 
-cHardwareSMT::cHardwareSMT(cOrganism * in_organism, cInstSet * in_inst_set)
-: cHardwareBase(in_organism, in_inst_set)
-, memory_array(nHardwareSMT::NUM_MEMORY_SPACES)
+cHardwareSMT::cHardwareSMT(cOrganism* in_organism, cInstSet* in_inst_set)
+  : cHardwareBase(in_organism, in_inst_set), m_mem_array(nHardwareSMT::NUM_MEMORY_SPACES)
 {
-  /* FIXME:  reorganize storage of m_functions.  -- kgn */
   m_functions = s_inst_slib->GetFunctions();
-  /**/
-  inst_remainder = 0;
 	
-  for(int x=1; x<=cConfig::GetMaxCPUThreads(); x++)
-	{
-		slice_array[x] = (x-1)*cConfig::GetThreadSlicingMethod()+1;
-	}
-	
-  memory_array[0] = in_organism->GetGenome();  // Initialize memory...
-  memory_array[0].Resize(GetMemory(0).GetSize()+1);
-  memory_array[0][memory_array[0].GetSize()-1] = cInstruction();
+  m_mem_array[0] = in_organism->GetGenome();  // Initialize memory...
+  m_mem_array[0].Resize(GetMemory(0).GetSize() + 1);
+  m_mem_array[0][m_mem_array[0].GetSize() - 1] = cInstruction();
   Reset();                            // Setup the rest of the hardware...
 }
 
 
-cHardwareSMT::cHardwareSMT(const cHardwareSMT &hardware_4stack)
-: cHardwareBase(hardware_4stack.organism, hardware_4stack.inst_set)
-, m_functions(hardware_4stack.m_functions)
-, memory_array(hardware_4stack.memory_array)
-, threads(hardware_4stack.threads)
-, thread_id_chart(hardware_4stack.thread_id_chart)
-, cur_thread(hardware_4stack.cur_thread)
-, mal_active(hardware_4stack.mal_active)
-, inst_cost(hardware_4stack.inst_cost)
+cHardwareSMT::cHardwareSMT(const cHardwareSMT& hardware)
+: cHardwareBase(hardware.organism, hardware.inst_set)
+, m_functions(hardware.m_functions)
+, m_mem_array(hardware.m_mem_array)
+, m_threads(hardware.m_threads)
+, thread_id_chart(hardware.thread_id_chart)
+, m_cur_thread(hardware.m_cur_thread)
+, inst_cost(hardware.inst_cost)
 #ifdef INSTRUCTION_COSTS
-, inst_ft_cost(hardware_4stack.inst_ft_cost)
-, inst_remainder(hardware_4stack.inst_remainder)
+, inst_ft_cost(hardware.inst_ft_cost)
 #endif
 {
-  for(int i = 0; i < nHardwareSMT::NUM_GLOBAL_STACKS; i++){
-    global_stacks[i] = hardware_4stack.global_stacks[i];
+  for(int i = 0; i < nHardwareSMT::NUM_GLOBAL_STACKS; i++) {
+    m_global_stacks[i] = hardware.m_global_stacks[i];
   }
-  for(int i = 0; i < sizeof(slice_array)/sizeof(float); i++){
-    slice_array[i] = hardware_4stack.slice_array[i];
-  }
 }
 
 
 void cHardwareSMT::Recycle(cOrganism * new_organism, cInstSet * in_inst_set)
 {
   cHardwareBase::Recycle(new_organism, in_inst_set);
-  memory_array[0] = new_organism->GetGenome();
-  memory_array[0].Resize(GetMemory(0).GetSize()+1);
-  memory_array[0][memory_array[0].GetSize()-1] = cInstruction();
+  m_mem_array[0] = new_organism->GetGenome();
+  m_mem_array[0].Resize(GetMemory(0).GetSize() + 1);
+  m_mem_array[0][m_mem_array[0].GetSize()-1] = cInstruction();
   Reset();
 }
 
 
 void cHardwareSMT::Reset()
 {
-  //global_stack.Clear();
-  //thread_time_used = 0;
-	
   // Setup the memory...
   for (int i = 1; i < nHardwareSMT::NUM_MEMORY_SPACES; i++) {
-		memory_array[i].Resize(1);
-		//GetMemory(i).Replace(0, 1, cGenome(ConvertToInstruction(i)));
-		GetMemory(i)=cGenome(ConvertToInstruction(i)); 
+		m_mem_array[i].Resize(1);
+		GetMemory(i) = cGenome(ConvertToInstruction(i)); 
   }
 	
   // We want to reset to have a single thread.
-  threads.Resize(1);
+  m_threads.Resize(1);
 	
   // Reset that single thread.
-  threads[0].Reset(this, 0);
+  m_threads[0].Reset(this, 0);
   thread_id_chart = 1; // Mark only the first thread as taken...
-  cur_thread = 0;
-	
-  mal_active = false;
-	
+  m_cur_thread = 0;
+		
   // Reset all stacks (local and global)
-  for(int i = 0; i < nHardwareSMT::NUM_STACKS; i++)
-	{
+  for(int i = 0; i < nHardwareSMT::NUM_STACKS; i++) {
 		Stack(i).Clear();
 	}
 	
@@ -274,8 +243,7 @@
     inst_cost[i] = GetInstSet().GetCost(cInstruction(i));
     inst_ft_cost[i] = GetInstSet().GetFTCost(cInstruction(i));
   }
-#endif
-	
+#endif	
 }
 
 // This function processes the very next command in the genome, and is made
@@ -288,23 +256,9 @@
 	
   cPhenotype & phenotype = organism->GetPhenotype();
   phenotype.IncTimeUsed();
-  //if(organism->GetCellID()==46 && IP().GetMemSpace()==2)
-  // int x=0;
 	
-  //if (GetNumThreads() > 1) thread_time_used++;
-  //assert((GetHead(HEAD_WRITE).GetPosition() == Stack(STACK_BX).Top() ||
-  // Stack(STACK_BX).Top()==GetMemory(IP().GetMemSpace()).GetSize()-1 || 
-  // GetHead(HEAD_WRITE).GetPosition() == Stack(STACK_BX).Top()+1) &&
-  // (GetHead(HEAD_WRITE).GetMemSpace() == IP().GetMemSpace() ||
-  //  GetHead(HEAD_WRITE).GetMemSpace() == IP().GetMemSpace()+1));
-  // If we have threads turned on and we executed each thread in a single
-  // timestep, adjust the number of instructions executed accordingly.
-  //const int num_inst_exec = (cConfig::GetThreadSlicingMethod() == 1) ?
-  //  GetNumThreads() : 1;
-	
-  const int num_inst_exec = int(slice_array[GetNumThreads()]+ inst_remainder);
-  inst_remainder = slice_array[GetNumThreads()] + inst_remainder - num_inst_exec;
-  
+  const int num_inst_exec = (cConfig::GetThreadSlicingMethod() == 1) ? GetNumThreads() : 1;
+
   for (int i = 0; i < num_inst_exec; i++) {
     // Setup the hardware for the next instruction to be executed.
     NextThread();
@@ -341,17 +295,16 @@
       // we now want to move to the next instruction in the memory.
       if (AdvanceIP() == true) IP().Advance();
     } // if exec
-    
   } // Previous was executed once for each thread...
 
-// Kill creatures who have reached their max num of instructions executed
-const int max_executed = organism->GetMaxExecuted();
-if ((max_executed > 0 && phenotype.GetTimeUsed() >= max_executed)
-    || phenotype.GetToDie()) {
-  organism->Die();
-}
+  // Kill creatures who have reached their max num of instructions executed
+  const int max_executed = organism->GetMaxExecuted();
+  if ((max_executed > 0 && phenotype.GetTimeUsed() >= max_executed)
+      || phenotype.GetToDie()) {
+    organism->Die();
+  }
 
-organism->SetRunning(false);
+  organism->SetRunning(false);
 }
 
 // This method will test to see if all costs have been paid associated
@@ -441,30 +394,23 @@
   //  }
   //}
 	
-SingleProcess_ExecuteInst(inst);
+  SingleProcess_ExecuteInst(inst);
 
-organism->SetRunning(prev_run_state);
+  organism->SetRunning(prev_run_state);
 }
 
-
-void cHardwareSMT::LoadGenome(const cGenome & new_genome)
-{
-  GetMemory(0) = new_genome;
-}
-
-
 bool cHardwareSMT::OK()
 {
   bool result = true;
 	
   for(int i = 0 ; i < nHardwareSMT::NUM_MEMORY_SPACES; i++) {
-    if (!memory_array[i].OK()) result = false;
+    if (!m_mem_array[i].OK()) result = false;
   }
 	
   for (int i = 0; i < GetNumThreads(); i++) {
     for(int j=0; j < nHardwareSMT::NUM_LOCAL_STACKS; j++)
-			if (threads[i].local_stacks[j].OK() == false) result = false;
-    if (threads[i].next_label.OK() == false) result = false;
+			if (m_threads[i].local_stacks[j].OK() == false) result = false;
+    if (m_threads[i].next_label.OK() == false) result = false;
   }
 	
   return result;
@@ -561,7 +507,6 @@
   
   // Return the last line of the found label, if it was found.
   if (found_pos > 0) search_head.Set(found_pos - 1, IP().GetMemSpace());
-  //*** I THINK THIS MIGHT HAVE BEEN WRONG...CHANGED >= to >.  -law ***//
   
   // Return the found position (still at start point if not found).
   return search_head;
@@ -883,13 +828,11 @@
   //reset the memory space which was injected
   GetMemory(mem_space_used)=cGenome(ConvertToInstruction(mem_space_used)); 
 	
-  for(int x=0; x<NUM_HEADS; x++)
-	{
+  for(int x=0; x<NUM_HEADS; x++) {
 		GetHead(x).Reset(IP().GetMemSpace(), this);
 	}
 	
-  for(int x=0; x < nHardwareSMT::NUM_LOCAL_STACKS; x++)
-	{
+  for(int x=0; x < nHardwareSMT::NUM_LOCAL_STACKS; x++) {
 		Stack(x).Clear();
 	}
   
@@ -935,18 +878,18 @@
 		
     // Set instruction flags on the injected code
     for (int i = 0; i < inject_code.GetSize(); i++) {
-      memory_array[target_mem_space].FlagInjected(i) = true;
+      m_mem_array[target_mem_space].FlagInjected(i) = true;
     }
     organism->GetPhenotype().IsModified() = true;
     
     // Adjust all of the heads to take into account the new mem size.
     
-    cur_thread=GetNumThreads()-1;
+    m_cur_thread=GetNumThreads()-1;
     
-    for(int i=0; i<cur_thread; i++) {
+    for(int i=0; i<m_cur_thread; i++) {
       for(int j=0; j < NUM_HEADS; j++) {
-				if(threads[i].heads[j].GetMemSpace()==target_mem_space)
-					threads[i].heads[j].Jump(inject_code.GetSize());
+				if(m_threads[i].heads[j].GetMemSpace()==target_mem_space)
+					m_threads[i].heads[j].Jump(inject_code.GetSize());
       }
     }
     
@@ -1140,7 +1083,7 @@
 {
   for (int i = 0; i < GetNumThreads(); i++) {
     for (int j = 0; j < NUM_HEADS; j++) {
-      threads[i].heads[j].Adjust();
+      m_threads[i].heads[j].Adjust();
     }
   }
 }
@@ -1178,18 +1121,18 @@
   if (num_threads == cConfig::GetMaxCPUThreads()) return false;
 	
   // Make room for the new thread.
-  threads.Resize(num_threads + 1);
+  m_threads.Resize(num_threads + 1);
 	
   //IP().Advance();
 	
   // Initialize the new thread to the same values as the current one.
-  threads[num_threads] = threads[cur_thread]; 
+  m_threads[num_threads] = m_threads[m_cur_thread]; 
 	
   // Find the first free bit in thread_id_chart to determine the new
   // thread id.
   int new_id = 0;
   while ( (thread_id_chart >> new_id) & 1 == 1) new_id++;
-  threads[num_threads].SetID(new_id);
+  m_threads[num_threads].SetID(new_id);
   thread_id_chart |= (1 << new_id);
 	
   return true;
@@ -1208,22 +1151,22 @@
   if (GetNumThreads() == 1) return false;
 	
   // Note the current thread and set the current back one.
-  const int kill_thread = cur_thread;
+  const int kill_thread = m_cur_thread;
   PrevThread();
   
   // Turn off this bit in the thread_id_chart...
-  thread_id_chart ^= 1 << threads[kill_thread].GetID();
+  thread_id_chart ^= 1 << m_threads[kill_thread].GetID();
 	
   // Copy the last thread into the kill position
   const int last_thread = GetNumThreads() - 1;
   if (last_thread != kill_thread) {
-    threads[kill_thread] = threads[last_thread];
+    m_threads[kill_thread] = m_threads[last_thread];
   }
 	
   // Kill the thread!
-  threads.Resize(GetNumThreads() - 1);
+  m_threads.Resize(GetNumThreads() - 1);
 	
-  if (cur_thread > kill_thread) cur_thread--;
+  if (m_cur_thread > kill_thread) m_cur_thread--;
 	
   return true;
 }
@@ -1242,11 +1185,11 @@
 	
   //fp << thread_time_used  << endl;
   fp << GetNumThreads()   << endl;
-  fp << cur_thread        << endl;
+  fp << m_cur_thread        << endl;
 	
   // Threads
   for( int i = 0; i < GetNumThreads(); i++ ) {
-    threads[i].SaveState(fp);
+    m_threads[i].SaveState(fp);
   }
 }
 
@@ -1267,11 +1210,11 @@
   int num_threads;
   //fp >> thread_time_used;
   fp >> num_threads;
-  fp >> cur_thread;
+  fp >> m_cur_thread;
 	
   // Threads
   for( int i = 0; i < num_threads; i++ ){
-    threads[i].LoadState(fp);
+    m_threads[i].LoadState(fp);
   }
 }
 
@@ -1725,7 +1668,7 @@
 	    }
 			
 			//this will reset the current thread's heads and stacks.  It will 
-			//not touch any other threads or memory spaces (ie: parasites)
+			//not touch any other m_threads or memory spaces (ie: parasites)
 			else
 	    {
 	      for(int x = 0; x < NUM_HEADS; x++)
@@ -2040,7 +1983,7 @@
 	}
   else
 	{
-		threads[cur_thread].heads[HEAD_FLOW]++;
+		m_threads[m_cur_thread].heads[HEAD_FLOW]++;
 	}
   return true;
 }
@@ -2210,7 +2153,7 @@
 		{
 			for(int z=0; z<NUM_HEADS; z++)
 	    {
-	      if(threads[y].heads[z].GetMemSpace() == index)
+	      if(m_threads[y].heads[z].GetMemSpace() == index)
 					OK=false;
 	    }
 		}

Modified: branches/brysonda/source/cpu/hardware_smt.h
===================================================================
--- branches/brysonda/source/cpu/hardware_smt.h	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/cpu/hardware_smt.h	2005-07-26 14:44:40 UTC (rev 263)
@@ -52,7 +52,7 @@
 #ifdef SINGLE_IO_BUFFER   // For Single IOBuffer vs IOBuffer for each Thread
 # define IO_THREAD 0
 #else
-# define IO_THREAD cur_thread
+# define IO_THREAD m_cur_thread
 #endif
 
 /**
@@ -84,34 +84,21 @@
   static tInstLib<cHardwareSMT::tMethod>* initInstLib(void);
   tMethod* m_functions;
 private:
-    tArray<cCPUMemory> memory_array;          // Memory...
-  cCPUStack global_stacks[nHardwareSMT::NUM_GLOBAL_STACKS];
+  tArray<cCPUMemory> m_mem_array;          // Memory...
+  cCPUStack m_global_stacks[nHardwareSMT::NUM_GLOBAL_STACKS];
 	
-  tArray<cHardwareSMT_Thread> threads;
+  tArray<cHardwareSMT_Thread> m_threads;
   int thread_id_chart;
-  int cur_thread;
+  int m_cur_thread;
 	
-  // Flags...
-  bool mal_active;         // Has an allocate occured since last dividehe?
-													 //bool advance_ip;         // Should the IP advance after this instruction?
-	
   // Instruction costs...
 #ifdef INSTRUCTION_COSTS
   tArray<int> inst_cost;
   tArray<int> inst_ft_cost;
 #endif
 	
-  // Thread slicing...
-	
-	// Keeps track of the base thread slicing number for each possible number of threads
-  float slice_array[10]; //***HACK!  How do I do this right? -law
-                         //this wouldn't compile -> [cConfig::GetMaxCPUThreads()+1]***; 
-	
-  // Keeps track of fractional instructions that carry over into next update
-  float inst_remainder; 
-	
 public:
-		cHardwareSMT(cOrganism * in_organism, cInstSet * in_inst_set);
+  cHardwareSMT(cOrganism * in_organism, cInstSet * in_inst_set);
   explicit cHardwareSMT(const cHardwareSMT &);
   ~cHardwareSMT() { ; }
   void Recycle(cOrganism * new_organism, cInstSet * in_inst_set);
@@ -124,22 +111,17 @@
   bool SingleProcess_PayCosts(const cInstruction & cur_inst);
   bool SingleProcess_ExecuteInst(const cInstruction & cur_inst);
   void ProcessBonusInst(const cInstruction & inst);
-  void LoadGenome(const cGenome & new_genome);
+  void LoadGenome(const cGenome& new_genome) { GetMemory(0) = new_genome; }
 	
   // --------  Helper methods  --------
   bool OK();
   void PrintStatus(std::ostream & fp);
 	
 	
-  // --------  Flag Accessors --------
-  bool GetMalActive() const   { return mal_active; }
-	
   // --------  Stack Manipulation...  --------
-  //void StackFlip();
   inline int GetStack(int depth=0, int stack_id=-1, int in_thread=-1) const;
-  //inline void StackClear();
-  //inline void SwitchStack();
   cString GetActiveStackID(int stackID) const;
+  
   //retrieves appropriate stack
   inline cCPUStack & Stack(int stack_id); 
   inline const cCPUStack & Stack(int stack_id) const;
@@ -148,61 +130,60 @@
 	
   // --------  Head Manipulation (including IP)  --------
   inline void SetActiveHead(const int new_head)
-  { threads[cur_thread].cur_head = (UCHAR) new_head; }
+  { m_threads[m_cur_thread].cur_head = (UCHAR) new_head; }
 	
-  int GetCurHead() const { return threads[cur_thread].cur_head; }
+  int GetCurHead() const { return m_threads[m_cur_thread].cur_head; }
   
   const cHeadMultiMem & GetHead(int head_id) const
-  { return threads[cur_thread].heads[head_id]; }
+  { return m_threads[m_cur_thread].heads[head_id]; }
   cHeadMultiMem & GetHead(int head_id) 
-  { return threads[cur_thread].heads[head_id];}
+  { return m_threads[m_cur_thread].heads[head_id];}
   
   const cHeadMultiMem & GetHead(int head_id, int thread) const
-  { return threads[thread].heads[head_id]; }
+  { return m_threads[thread].heads[head_id]; }
   cHeadMultiMem & GetHead(int head_id, int thread) 
-  { return threads[thread].heads[head_id];}
+  { return m_threads[thread].heads[head_id];}
 	
   const cHeadMultiMem & GetActiveHead() const { return GetHead(GetCurHead()); }
   cHeadMultiMem & GetActiveHead() { return GetHead(GetCurHead()); }
 	
   void AdjustHeads();
 	
-  inline const cHeadMultiMem & IP() const
-	{ return threads[cur_thread].heads[HEAD_IP]; }
-  inline cHeadMultiMem & IP() { return threads[cur_thread].heads[HEAD_IP]; }
+  const cHeadMultiMem & IP() const { return m_threads[m_cur_thread].heads[HEAD_IP]; }
+  cHeadMultiMem & IP() { return m_threads[m_cur_thread].heads[HEAD_IP]; }
 	
-  inline const cHeadMultiMem & IP(int thread) const
-  { return threads[thread].heads[HEAD_IP]; }
-  inline cHeadMultiMem & IP(int thread) 
-  { return threads[thread].heads[HEAD_IP]; }
+  const cHeadMultiMem & IP(int thread) const { return m_threads[thread].heads[HEAD_IP]; }
+  cHeadMultiMem & IP(int thread) { return m_threads[thread].heads[HEAD_IP]; }
 	
 	
-  inline const bool & AdvanceIP() const
-	{ return threads[cur_thread].advance_ip; }
-  inline bool & AdvanceIP() { return threads[cur_thread].advance_ip; }
+  const bool & AdvanceIP() const { return m_threads[m_cur_thread].advance_ip; }
+  bool & AdvanceIP() { return m_threads[m_cur_thread].advance_ip; }
 	
   // --------  Label Manipulation  -------
   void ReadLabel(int max_size=MAX_LABEL_SIZE);
-  const cCodeLabel & GetLabel() const 
-	{ return threads[cur_thread].next_label; }
-  cCodeLabel & GetLabel() { return threads[cur_thread].next_label; }
-  const cCodeLabel & GetReadLabel() const
-	{ return threads[cur_thread].read_label; }
-  cCodeLabel & GetReadLabel() { return threads[cur_thread].read_label; }
+  const cCodeLabel & GetLabel() const { return m_threads[m_cur_thread].next_label; }
+  cCodeLabel & GetLabel() { return m_threads[m_cur_thread].next_label; }
+  const cCodeLabel & GetReadLabel() const { return m_threads[m_cur_thread].read_label; }
+  cCodeLabel & GetReadLabel() { return m_threads[m_cur_thread].read_label; }
 	
-	
-  // --------  Register Manipulation  --------
-  //int Register(int reg_id) const { return threads[cur_thread].reg[reg_id]; }
-  //int & Register(int reg_id) { return threads[cur_thread].reg[reg_id]; }
-	
   // --------  Memory Manipulation  --------}
-  inline cCPUMemory & GetMemory();
-  inline cCPUMemory & GetMemory(int mem_space);
-  inline const cCPUMemory & GetMemory(int mem_space) const;
-  inline const cCPUMemory & GetMemory() const;
-	
+  cCPUMemory& GetMemory() { return m_mem_array[0]; }
+  const cCPUMemory & GetMemory() const { return m_mem_array[0]; }
+  cCPUMemory & cHardwareSMT::GetMemory(int mem_space)
+  {
+    if(mem_space >= nHardwareSMT::NUM_MEMORY_SPACES)
+      mem_space %= nHardwareSMT::NUM_MEMORY_SPACES;
+    return m_mem_array[mem_space];
+  }
+  const cCPUMemory & cHardwareSMT::GetMemory(int mem_space) const
+  {
+    if(mem_space >= nHardwareSMT::NUM_MEMORY_SPACES)
+      mem_space %= nHardwareSMT::NUM_MEMORY_SPACES;
+    return m_mem_array[mem_space];
+  }
+  
   // --------  Thread Manipulation  --------
-  bool ForkThread(); // Adds a new thread based off of cur_thread.
+  bool ForkThread(); // Adds a new thread based off of m_cur_thread.
   bool KillThread(); // Kill the current thread!
   inline void PrevThread(); // Shift the current thread in use.
   inline void NextThread();
@@ -216,15 +197,13 @@
   int TestParasite() const;
 	
   // --------  Accessors  --------
-  //int GetThreadTimeUsed() const { return thread_time_used; }
-  int GetNumThreads() const     { return threads.GetSize(); }
-  int GetCurThread() const      { return cur_thread; }
-  int GetCurThreadID() const    { return threads[cur_thread].GetID(); }
+  int GetNumThreads() const     { return m_threads.GetSize(); }
+  int GetCurThread() const      { return m_cur_thread; }
+  int GetCurThreadID() const    { return m_threads[m_cur_thread].GetID(); }
 	
   int GetThreadDist() const {
     if (GetNumThreads() == 1) return 0;
-    return threads[0].heads[HEAD_IP].GetPosition() -
-      threads[1].heads[HEAD_IP].GetPosition();
+    return m_threads[0].heads[HEAD_IP].GetPosition() - m_threads[1].heads[HEAD_IP].GetPosition();
   }
 	
   // Complex label manipulation...
@@ -266,10 +245,8 @@
 	
 	
 private:
-		
-		/////////---------- Instruction Helpers ------------//////////
-		
-		int FindModifiedStack(int default_stack);
+  /////////---------- Instruction Helpers ------------//////////
+  int FindModifiedStack(int default_stack);
   int FindModifiedHead(int default_head);
   int FindComplementStack(int base_stack);
 	
@@ -289,81 +266,40 @@
   bool Inst_HeadDivideMut(double mut_multiplier=1);
 	
 public:
-		/////////---------- Instruction Library ------------//////////
-		
-		//6
-		bool Inst_ShiftR();
-  //7
+  /////////---------- Instruction Library ------------//////////
+  bool Inst_ShiftR();
   bool Inst_ShiftL();
-  //8
   bool Inst_Val_Nand();
-  //9
   bool Inst_Val_Add();
-  //10
   bool Inst_Val_Sub();
-  //11
   bool Inst_Val_Mult();
-  //12
   bool Inst_Val_Div();
-  //13
   bool Inst_SetMemory();
-  //14
   bool Inst_Divide();
-  //15
   bool Inst_HeadRead();
-  //16
   bool Inst_HeadWrite();
-  //??
   bool Inst_HeadCopy();
-  //17
   bool Inst_IfEqual();
-  //18
   bool Inst_IfNotEqual();
-  //19
   bool Inst_IfLess();
-  //20
   bool Inst_IfGreater();
-  //21
   bool Inst_HeadPush();
-  //22
   bool Inst_HeadPop();
-  //23
   bool Inst_HeadMove();
-  //24
   bool Inst_Search();
-  //25
   bool Inst_PushNext();
-  //26
   bool Inst_PushPrevious();
-  //27
   bool Inst_PushComplement();
-  //28
   bool Inst_ValDelete();
-  //29
   bool Inst_ValCopy();
-  //30
   bool Inst_ForkThread();
-  //31
   bool Inst_IfLabel();
-  //32
   bool Inst_Increment();
-  //33
   bool Inst_Decrement();
-  //34
   bool Inst_Mod();
-  //35 
   bool Inst_KillThread();
-  //36
   bool Inst_IO();
-  //37
   bool Inst_Inject();
-  
-  /*
-	 bool Inst_InjectRand();
-	 bool Inst_InjectThread();
-	 bool Inst_Repro();
-	 */
-	
 };
 
 
@@ -371,148 +307,86 @@
 //  cHardwareSMT
 //////////////////
 
-//Not used, but here to satisfy the requirements of HardwareBase
-inline const cCPUMemory & cHardwareSMT::GetMemory() const
-{
-  return memory_array[0];
-}
-
-//Not used, but here to satisfy the requirements of HardwareBase 
-inline cCPUMemory & cHardwareSMT::GetMemory()
-{
-  return memory_array[0];
-}
-
-inline const cCPUMemory & cHardwareSMT::GetMemory(int mem_space) const
-{
-  if(mem_space >= nHardwareSMT::NUM_MEMORY_SPACES)
-    mem_space %= nHardwareSMT::NUM_MEMORY_SPACES;
-  return memory_array[mem_space];
-}
-
-inline cCPUMemory & cHardwareSMT::GetMemory(int mem_space)
-{
-	if(mem_space >= nHardwareSMT::NUM_MEMORY_SPACES)
-    mem_space %= nHardwareSMT::NUM_MEMORY_SPACES;
-  return memory_array[mem_space];
-}
-
 inline void cHardwareSMT::NextThread()
 {
-  cur_thread++;
-  if (cur_thread >= GetNumThreads()) cur_thread = 0;
+  m_cur_thread++;
+  if (m_cur_thread >= GetNumThreads()) m_cur_thread = 0;
 }
 
 inline void cHardwareSMT::PrevThread()
 {
-  if (cur_thread == 0) cur_thread = GetNumThreads() - 1;
-  else cur_thread--;
+  if (m_cur_thread == 0) m_cur_thread = GetNumThreads() - 1;
+  else m_cur_thread--;
 }
 
 inline void cHardwareSMT::SetThread(int value)
 {
-  if (value>=0 && value < GetNumThreads())
-    cur_thread=value;
+  if (value>=0 && value < GetNumThreads()) m_cur_thread = value;
 }
 
 inline cInjectGenotype * cHardwareSMT::GetCurThreadOwner() 
 { 
-  return threads[cur_thread].owner; 
+  return m_threads[m_cur_thread].owner; 
 }
 
 inline cInjectGenotype * cHardwareSMT::GetThreadOwner(int thread) 
 { 
-  return threads[thread].owner; 
+  return m_threads[thread].owner; 
 }
 
 inline void cHardwareSMT::SetThreadOwner(cInjectGenotype * in_genotype)
 { 
-  threads[cur_thread].owner = in_genotype; 
+  m_threads[m_cur_thread].owner = in_genotype; 
 }
 
-/*inline void cHardwareSMT::StackFlip()
-{
-  if (threads[cur_thread].cur_stack == 0) {
-    threads[cur_thread].stack.Flip();
-  } else {
-    global_stack.Flip();
-  }
-}*/
-
 inline int cHardwareSMT::GetStack(int depth, int stack_id, int in_thread) const
 {
   if(stack_id<0 || stack_id > nHardwareSMT::NUM_STACKS) stack_id=0;
   
   if(in_thread==-1)
-    in_thread=cur_thread;
+    in_thread=m_cur_thread;
   
   return Stack(stack_id, in_thread).Get(depth);
 }
 
-//inline void cHardwareSMT::StackClear()
-//{
-
-//if (threads[cur_thread].cur_stack == 0) {
-//  threads[cur_thread].stack.Clear();
-//} else {
-//  global_stack.Clear();
-//}
-//}
-
-//inline void cHardwareSMT::SwitchStack()
-//{
-//  threads[cur_thread].cur_stack++;
-//  if (threads[cur_thread].cur_stack > 1) threads[cur_thread].cur_stack = 0;
-//}
-	
 inline cCPUStack& cHardwareSMT::Stack(int stack_id)
 {
-  if(stack_id >= nHardwareSMT::NUM_STACKS)
-	{
-		stack_id=0;
-	}
+  if(stack_id >= nHardwareSMT::NUM_STACKS) stack_id = 0;
   if(stack_id < nHardwareSMT::NUM_LOCAL_STACKS)
-    return threads[cur_thread].local_stacks[stack_id];
+    return m_threads[m_cur_thread].local_stacks[stack_id];
   else
-    return global_stacks[stack_id % nHardwareSMT::NUM_LOCAL_STACKS];
+    return m_global_stacks[stack_id % nHardwareSMT::NUM_LOCAL_STACKS];
 }
 
 inline const cCPUStack& cHardwareSMT::Stack(int stack_id) const 
 {
-  if(stack_id >= nHardwareSMT::NUM_STACKS)
-	{
-		stack_id=0;
-	}
+  if(stack_id >= nHardwareSMT::NUM_STACKS) stack_id = 0;
   if(stack_id < nHardwareSMT::NUM_LOCAL_STACKS)
-    return threads[cur_thread].local_stacks[stack_id];
+    return m_threads[m_cur_thread].local_stacks[stack_id];
   else
-    return global_stacks[stack_id % nHardwareSMT::NUM_LOCAL_STACKS];
+    return m_global_stacks[stack_id % nHardwareSMT::NUM_LOCAL_STACKS];
 }
 
 inline cCPUStack& cHardwareSMT::Stack(int stack_id, int in_thread) 
 {
-  if(stack_id >= nHardwareSMT::NUM_STACKS)
-		stack_id=0;
-  if(in_thread >= threads.GetSize())
-		in_thread=cur_thread;
+  if(stack_id >= nHardwareSMT::NUM_STACKS) stack_id = 0;
+  if(in_thread >= m_threads.GetSize()) in_thread = m_cur_thread;
 	
   if(stack_id < nHardwareSMT::NUM_LOCAL_STACKS)
-    return threads[in_thread].local_stacks[stack_id];
+    return m_threads[in_thread].local_stacks[stack_id];
   else
-    return global_stacks[stack_id % nHardwareSMT::NUM_LOCAL_STACKS];
+    return m_global_stacks[stack_id % nHardwareSMT::NUM_LOCAL_STACKS];
 }
 
 inline const cCPUStack& cHardwareSMT::Stack(int stack_id, int in_thread) const 
 {
-  if(stack_id >= nHardwareSMT::NUM_STACKS)
-		stack_id=0;
-  if(in_thread >= threads.GetSize())
-		in_thread=cur_thread;
+  if(stack_id >= nHardwareSMT::NUM_STACKS) stack_id = 0;
+  if(in_thread >= m_threads.GetSize()) in_thread = m_cur_thread;
 	
   if(stack_id < nHardwareSMT::NUM_LOCAL_STACKS)
-    return threads[in_thread].local_stacks[stack_id];
+    return m_threads[in_thread].local_stacks[stack_id];
   else
-    return global_stacks[stack_id % nHardwareSMT::NUM_LOCAL_STACKS];
+    return m_global_stacks[stack_id % nHardwareSMT::NUM_LOCAL_STACKS];
 }
 
 #endif

Modified: branches/brysonda/source/cpu/tInstLib.h
===================================================================
--- branches/brysonda/source/cpu/tInstLib.h	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/cpu/tInstLib.h	2005-07-26 14:44:40 UTC (rev 263)
@@ -22,20 +22,20 @@
 template <class MethodType> class tInstLib : public cInstLibBase {
   const size_t m_nopmods_array_size;
   const size_t m_function_array_size;
-  cString *m_nopmod_names;
-  cString *m_function_names;
-  const int *m_nopmods;
-  MethodType *m_functions;
+  cString* m_nopmod_names;
+  cString* m_function_names;
+  const int* m_nopmods;
+  MethodType* m_functions;
   const cInstruction inst_error;
   const cInstruction inst_default;
 public:
 		tInstLib(
 						 size_t nopmod_array_size,
 						 size_t function_array_size,
-						 cString *nopmod_names,
-						 cString *function_names,
-						 const int *nopmods,
-						 MethodType *functions,
+						 cString* nopmod_names,
+						 cString* function_names,
+						 const int* nopmods,
+						 MethodType* functions,
 						 const cInstruction& error,
 						 const cInstruction& def
 						 ):m_nopmods_array_size(nopmod_array_size),
@@ -47,7 +47,7 @@
 		inst_error(error),
 		inst_default(def)
   {}
-  MethodType *GetFunctions(void){ return m_functions; } 
+  MethodType* GetFunctions(void){ return m_functions; } 
   const cString &GetName(const unsigned int id) {
     assert(id < m_function_array_size);
     return m_function_names[id];

Modified: branches/brysonda/source/cpu/test_cpu.cc
===================================================================
--- branches/brysonda/source/cpu/test_cpu.cc	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/cpu/test_cpu.cc	2005-07-26 14:44:40 UTC (rev 263)
@@ -42,9 +42,9 @@
 bool cTestCPU::initialized(false);
 bool cTestCPU::d_useResources(false);
 tArray<double> cTestCPU::d_emptyDoubleArray;
+tArray<double> cTestCPU::d_resources;
 
 
-
 //////////////////////////////
 //  cTestCPU  (Static Class)
 //////////////////////////////
@@ -57,14 +57,17 @@
   inst_set = in_inst_set;
   environment = in_env;
   resource_count.SetSize(in_env->GetResourceLib().GetSize());
-  d_emptyDoubleArray.ResizeClear(in_env->GetResourceLib().GetSize());
+  //d_emptyDoubleArray.ResizeClear(in_env->GetResourceLib().GetSize());
+  //d_resources.ResizeClear(in_env->GetResourceLib().GetSize());
   SetupResources();
   test_interface = in_interface;
   initialized = true;
+
 }
 
 void cTestCPU::SetupResources(void) {
-  // Setup the resources...
+
+    // Setup the resources...
   assert(environment);
 
   const cResourceLib & resource_lib = environment->GetResourceLib();
@@ -72,6 +75,11 @@
 
   resource_count.SetSize(resource_lib.GetSize());
   d_emptyDoubleArray.ResizeClear(resource_lib.GetSize());
+  d_resources.ResizeClear(resource_lib.GetSize());
+  for(int i=0; i<resource_lib.GetSize(); i++) {
+    d_emptyDoubleArray[i] = 0.0;
+    d_resources[i] = 0.0;
+  }
   //resource_count.ResizeSpatialGrids(cConfig::GetWorldX(),
   //				    cConfig::GetWorldY());
   resource_count.ResizeSpatialGrids(1, 1);
@@ -91,8 +99,21 @@
   }
 
   return;
+
 }
 
+void cTestCPU::SetupResourceArray(const tArray<double> &resources) {
+  for(int i=0; i<d_resources.GetSize(); i++) {
+    if(i >= resources.GetSize()) {
+      d_resources[i] = 0.0;
+    } else {
+      d_resources[i] = resources[i];
+    }
+  }
+
+  return;
+}
+
 void cTestCPU::SetInstSet(cInstSet * in_inst_set)
 {
   inst_set = in_inst_set;
@@ -121,18 +142,17 @@
 
   // Prepare the inputs...
   cur_input = 0;
-  cur_receive = 0;
 
   // Determine if we're tracing and what we need to print.
-  cHardwareTracer * tracer =
-    test_info.GetTraceExecution() ? (test_info.GetTracer()) : NULL;
+  ostream * trace_fp =
+    test_info.GetTraceExecution() ? &(test_info.GetTraceFP()) : NULL;
 
   int time_used = 0;
   while (time_used < time_allocated &&
 	 organism.GetHardware().GetMemory().GetSize() &&
 	 organism.GetPhenotype().GetNumDivides() == 0) {
     time_used++;
-    organism.GetHardware().SetTrace(tracer);
+    organism.GetHardware().SetTrace(trace_fp);
     organism.GetHardware().SingleProcess();
     organism.GetHardware().SetTrace(NULL);
     //resource_count.Update(1/cConfig::GetAveTimeslice());
@@ -140,22 +160,24 @@
   }
 
   // Print out some final info in trace...
-  if (tracer != NULL) {
-    if (cHardwareTracer_TestCPU * tracer_test_cpu
-        = dynamic_cast<cHardwareTracer_TestCPU *>(tracer)
-    ){
-      tracer_test_cpu->TraceHardware_TestCPU(
-        time_used,
-        time_allocated,
-        organism.GetHardware().GetMemory().GetSize(),
-        organism.GetHardware().GetMemory().AsString(),
-        organism.ChildGenome().AsString()
-      );
+  if (trace_fp != NULL) {
+    if (time_used == time_allocated) {
+      *trace_fp << endl << "TIMEOUT: No offspring produced." << endl;
     }
+    else if (organism.GetHardware().GetMemory().GetSize() == 0) {
+      *trace_fp << endl << "ORGANISM DEATH: No offspring produced." << endl;
+    }
+    else {
+      *trace_fp << endl << "Final Memory: "
+		<< organism.GetHardware().GetMemory().AsString() << endl
+		<< "Child Memory: " << organism.ChildGenome().AsString()
+		<< endl;
+    }
   }
 
   // For now, always return true.
   return true;
+
 }
 
 
@@ -396,11 +418,16 @@
 const tArray<double> & cTestCPU::GetResources()
 {
   if(d_useResources) {
-    return resource_count.GetResources();
+    //return resource_count.GetResources();  // Changed to use my own vector
+    return d_resources;
   }
+
   return d_emptyDoubleArray;
+  //assert(resource_count != NULL);       // Original line
+  //return resource_count.GetResources();   // Original line
 }
 
+
 void cTestCPU::UpdateResources(const tArray<double> & res_change)
 {
   //resource_count.Modify(res_change);

Modified: branches/brysonda/source/cpu/test_cpu.hh
===================================================================
--- branches/brysonda/source/cpu/test_cpu.hh	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/cpu/test_cpu.hh	2005-07-26 14:44:40 UTC (rev 263)
@@ -42,6 +42,7 @@
   static cResourceCount resource_count;
   static bool d_useResources;
   static tArray<double> d_emptyDoubleArray;
+  static tArray<double> d_resources;
   
   static bool initialized;
 
@@ -84,6 +85,7 @@
 				  const int cell_id);
   static void SetResource(int id, double new_level);
   static void SetupResources(void);
+  static void SetupResourceArray(const tArray<double> &resources);
   static bool &UseResources(void) { return d_useResources; }
   static cResourceCount &GetResourceCount(void) {return resource_count;}
 };

Deleted: branches/brysonda/source/event/cPopulation_descr.h
===================================================================
--- branches/brysonda/source/event/cPopulation_descr.h	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/event/cPopulation_descr.h	2005-07-26 14:44:40 UTC (rev 263)
@@ -1,35 +0,0 @@
-/*
- *  cPopulation_descr.h
- *  Avida2
- *
- *  Created by David on 6/7/05.
- *  Copyright 2005 Michigan State University. All rights reserved.
- *
- */
-
-class cEventEntry{
-private:
-  const char* m_name;
-  const char* m_description;
-public:
-    cEventEntry( const char* name, const char* description )
-    : m_name( name ), m_description( description ) {;}
-  ~cEventEntry() {;}
-  /**
-    * @return The name of the event.
-   **/
-  const char* GetName() const { return m_name; }
-  
-  /**
-    * @return The description of the event.
-   **/
-  const char* GetDescription() const { return m_description; }
-};
-
-
-class cEventDescrs{
-public:
-  const static int num_of_events;
-  const static cEventEntry entries[];
-};
-

Modified: branches/brysonda/source/event/event_list.cc
===================================================================
--- branches/brysonda/source/event/event_list.cc	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/event/event_list.cc	2005-07-26 14:44:40 UTC (rev 263)
@@ -48,19 +48,11 @@
 {
 }
 
-cEventList::~cEventList() {
-  /*
-   XXX:  modified by kaben.  DeleteAll is equivalent.
-   */
-  //while( m_head != NULL ){
-  //  m_current = m_head;
-  //  m_head = m_head->GetNext();
-  //  delete m_head;
-  //}
+cEventList::~cEventList()
+{
   DeleteAll();
-
-delete m_factory_manager;
-delete m_triggers;
+  delete m_factory_manager;
+  delete m_triggers;
 }
 
 bool
@@ -126,7 +118,6 @@
 
 /*
  public manipulator used while rebuilding event list.
- XXX:  added by kaben.
  */
 void cEventList::DeleteAll(void){
   while( m_head != NULL ){
@@ -261,9 +252,6 @@
   }
 }
 
-/*
- XXX:  modified by kaben to stream-dump in parseable format.
- */
 void cEventList::PrintEvent(cEventListEntry * entry, ostream & os){
   assert( entry != NULL );
   switch ( entry->GetTrigger() ){

Modified: branches/brysonda/source/main/analyze.cc
===================================================================
--- branches/brysonda/source/main/analyze.cc	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/main/analyze.cc	2005-07-26 14:44:40 UTC (rev 263)
@@ -52,26 +52,23 @@
 
 using namespace std;
 
-
-
-
 //////////////
 //  cAnalyze
 //////////////
 
 cAnalyze::cAnalyze(cString filename, cEnvironment *environment)
-  : cur_batch(0)
-  , d_environment(environment)
-  , verbose(false)
-  , interactive_depth(0)
-  , inst_set(cHardwareUtil::DefaultInstSet(cConfig::GetInstFilename()))
+: cur_batch(0)
+, d_environment(environment)
+, verbose(false)
+, interactive_depth(0)
+, inst_set(cHardwareUtil::DefaultInstSet(cConfig::GetInstFilename()))
 {
   random.ResetSeed(cConfig::GetRandSeed());
-
+  
   for (int i = 0; i < MAX_BATCHES; i++) {
     batch[i].Name().Set("Batch%d", i);
   }
-
+  
   // Initialize the time oriented resource list to be just the initial
   // concentrations of the resources in the environment.  This will only
   // be changed if LOAD_RESOURCES analyze command is called.  If there is
@@ -87,14 +84,17 @@
     }
     resources.push_back(make_pair(0, r));
   }
-
+  FillResources(0);
+  
   cInitFile analyze_file(filename);
   analyze_file.Load();
   analyze_file.Compress();
   analyze_file.Close();
-
+  
   LoadCommandList(analyze_file, command_list);
   ProcessCommands(command_list);
+  
+  return;
 }
 
 cAnalyze::~cAnalyze()
@@ -111,26 +111,26 @@
 void cAnalyze::LoadOrganism(cString cur_string)
 {
   // LOAD_ORGANISM command...
-
+  
   cString filename = cur_string.PopWord();
-
+  
   cout << "Loading: " << filename << endl;
-
+  
   // Setup the genome...
   cGenome genome( cInstUtil::LoadGenome(filename, inst_set) );
-
+  
   // Construct the new genotype..
   cAnalyzeGenotype * genotype = new cAnalyzeGenotype(genome, inst_set);
-
+  
   // Determine the organism's original name -- strip off directory...
   while (filename.Find('/') != -1) filename.Pop('/');
   while (filename.Find('\\') != -1) filename.Pop('\\');
   filename.Replace(".gen", "");  // Remove the .gen from the filename.
   genotype->SetName(filename);
-
+  
   // And save it in the current batch.
   batch[cur_batch].List().PushRear(genotype);
-
+  
   // Adjust the flags on this batch
   batch[cur_batch].SetLineage(false);
   batch[cur_batch].SetAligned(false);
@@ -139,11 +139,11 @@
 void cAnalyze::LoadBasicDump(cString cur_string)
 {
   // LOAD_BASE_DUMP
-
+  
   cString filename = cur_string.PopWord();
-
+  
   cout << "Loading: " << filename << endl;
-
+  
   cInitFile input_file(filename);
   if (!input_file.IsOpen()) {
     cerr << "Error: Cannot load file: \"" << filename << "\"." << endl;
@@ -152,27 +152,27 @@
   input_file.Load();
   input_file.Compress();
   input_file.Close();
-
+  
   // Setup the genome...
-
+  
   for (int line_id = 0; line_id < input_file.GetNumLines(); line_id++) {
     cString cur_line = input_file.GetLine(line_id);
-
+    
     // Setup the genotype for this line...
     cAnalyzeGenotype * genotype =
       new cAnalyzeGenotype(cur_line.PopWord(), inst_set);
     int num_cpus = cur_line.PopWord().AsInt();
     int id_num = cur_line.PopWord().AsInt();
     cString name = cStringUtil::Stringf("org-%d", id_num);
-
+    
     genotype->SetNumCPUs(num_cpus);
     genotype->SetID(id_num);
     genotype->SetName(name);
-
+    
     // Add this genotype to the proper batch.
     batch[cur_batch].List().PushRear(genotype);
   }
-
+  
   // Adjust the flags on this batch
   batch[cur_batch].SetLineage(false);
   batch[cur_batch].SetAligned(false);
@@ -181,14 +181,14 @@
 void cAnalyze::LoadDetailDump(cString cur_string)
 {
   cout << "WARNING: This function is DEPRICATED!" << endl
-       << "It is no longer being supported; use \"LOAD\" instead." << endl;
-
+  << "It is no longer being supported; use \"LOAD\" instead." << endl;
+  
   // LOAD_DETAIL_DUMP
-
+  
   cString filename = cur_string.PopWord();
-
+  
   cout << "Loading: " << filename << endl;
-
+  
   cInitFile input_file(filename);
   if (!input_file.IsOpen()) {
     cerr << "Error: Cannot load file: \"" << filename << "\"." << endl;
@@ -197,14 +197,14 @@
   input_file.Load();
   input_file.Compress();
   input_file.Close();
-
+  
   // Setup the genome...
-
+  
   for (int line_id = 0; line_id < input_file.GetNumLines(); line_id++) {
     cString cur_line = input_file.GetLine(line_id);
-
+    
     // Setup the genotype for this line...
-
+    
     int id_num      = cur_line.PopWord().AsInt();
     int parent_id   = cur_line.PopWord().AsInt();
     int parent_dist = cur_line.PopWord().AsInt();
@@ -218,10 +218,10 @@
     int update_dead = cur_line.PopWord().AsInt();
     int depth       = cur_line.PopWord().AsInt();
     cString name = cStringUtil::Stringf("org-%d", id_num);
-
+    
     cAnalyzeGenotype * genotype =
       new cAnalyzeGenotype(cur_line.PopWord(), inst_set);
-
+    
     genotype->SetID(id_num);
     genotype->SetParentID(parent_id);
     genotype->SetParentDist(parent_dist);
@@ -235,11 +235,11 @@
     genotype->SetUpdateDead(update_dead);
     genotype->SetDepth(depth);
     genotype->SetName(name);
-
+    
     // Add this genotype to the proper batch.
     batch[cur_batch].List().PushRear(genotype);
   }
-
+  
   // Adjust the flags on this batch
   batch[cur_batch].SetLineage(false);
   batch[cur_batch].SetAligned(false);
@@ -248,41 +248,41 @@
 void cAnalyze::LoadMultiDetail(cString cur_string)
 {
   // LOAD_MULTI_DETAIL
-
+  
   int start_UD = cur_string.PopWord().AsInt();
   int step_UD = cur_string.PopWord().AsInt();
   int stop_UD = cur_string.PopWord().AsInt();
   cString data_directory = PopDirectory(cur_string, "./");
   cur_batch = cur_string.PopWord().AsInt();
-
+  
   if (step_UD == 0) {
     cerr << "Error: LOAD_MULTI_DETAIL must have a non-zero value for step."
-	 << endl;
+    << endl;
     return;
   }
-
+  
   int num_steps = (stop_UD - start_UD) / step_UD + 1;
   if (num_steps > 1000) {
     cerr << "Warning: Loading over 1000 files in LOAD_MULTI_DETAIL!"
-	 << endl;
+    << endl;
   }
-
+  
   if (verbose == true) {
     cout << "Loading in " << num_steps
-	 << " detail files from update " << start_UD
-	 << " to update " << stop_UD
-	 << endl;
+    << " detail files from update " << start_UD
+    << " to update " << stop_UD
+    << endl;
   } else {
     cout << "Running LOAD_MULTI_DETAIL" << endl;
   }
-
+  
   for (int cur_UD = start_UD; cur_UD <= stop_UD; cur_UD += step_UD) {
     cString filename = cStringUtil::Stringf("detail_pop.%d", cur_UD);
-
+    
     cout << "Loading '" << filename
-	 << "' into batch " << cur_batch
-	 << endl;
-
+      << "' into batch " << cur_batch
+      << endl;
+    
     cInitFile input_file(filename);
     if (!input_file.IsOpen()) {
       cerr << "Error: Cannot load file: \"" << filename << "\"." << endl;
@@ -293,7 +293,7 @@
     input_file.Close();
     
     // Setup the genome...
-
+    
     for (int line_id = 0; line_id < input_file.GetNumLines(); line_id++) {
       cString cur_line = input_file.GetLine(line_id);
       
@@ -314,7 +314,7 @@
       cString name = cStringUtil::Stringf("org-%d", id_num);
       
       cAnalyzeGenotype * genotype =
-	new cAnalyzeGenotype(cur_line.PopWord(), inst_set);
+        new cAnalyzeGenotype(cur_line.PopWord(), inst_set);
       
       genotype->SetID(id_num);
       genotype->SetParentID(parent_id);
@@ -345,26 +345,26 @@
 void cAnalyze::LoadSequence(cString cur_string)
 {
   // LOAD_SEQUENCE
-
+  
   static int sequence_count = 1;
   cString sequence = cur_string.PopWord();
   cString seq_name = cur_string.PopWord();
-
+  
   cout << "Loading: " << sequence << endl;
-
+  
   // Setup the genotype...
   cAnalyzeGenotype * genotype = new cAnalyzeGenotype(sequence, inst_set);
-
+  
   genotype->SetNumCPUs(1);      // Initialize to a single organism.
   if (seq_name == "") {
     seq_name = cStringUtil::Stringf("org-Seq%d", sequence_count);
   }
   genotype->SetName(seq_name);
   sequence_count++;
-
+  
   // Add this genotype to the proper batch.
   batch[cur_batch].List().PushRear(genotype);
-
+  
   // Adjust the flags on this batch
   batch[cur_batch].SetLineage(false);
   batch[cur_batch].SetAligned(false);
@@ -381,36 +381,36 @@
 void cAnalyze::LoadResources(cString cur_string)
 {
   resources.clear();
-
+  
   int words = cur_string.CountNumWords();
-
+  
   cString filename = "resource.dat";
   if(words >= 1) {
-    cString filename = cur_string.PopWord();
+    filename = cur_string.PopWord();
   }
-
+  
   cout << "Loading Resources from: " << filename << endl;
-
+  
   // Process the resource.dat, currently assuming this is the only possible
   // input file
-  ifstream resourceFile("resource.dat", ios::in);
+  ifstream resourceFile(filename, ios::in);
   assert(resourceFile);
-
+  
   // Read in each line of the resource file and process it
   char line[2048];
   while(!resourceFile.eof()) {
     resourceFile.getline(line, 2047);
     if(line[0] == '\0') { continue; }
-
+    
     // Get rid of the whitespace at the beginning of the stream, then 
     // see if the line begins with a #, if so move on to the next line.
     stringstream ss;
     ss << line; ss >> ws; if(ss.peek() == '#') { continue; }
-
+    
     // Read the update number from the stream
     int update;
     ss >> update; assert(ss.good());
-
+    
     // Read in the concentration values for the current update and put them
     // into a temporary vector.
     double x;
@@ -420,8 +420,9 @@
     // assuming a non-numeric is a comment denoting the rest of the line as
     // not informational.
     while(true) {
-      ss >> ws; ss >> x; if(!ss.good()) { ss.clear(); break; }
+      ss >> ws; ss >> x;
       tempValues.push_back(x);
+      if(!ss.good()) { ss.clear(); break; }
     }
     // Can't have no resources, so assert
     if(tempValues.empty()) { assert(0); }
@@ -431,17 +432,18 @@
     resources.push_back(make_pair(update, tempValues));
   }
   resourceFile.close();
-
+  
   return;
 }
 
 // Looks up the resource concentrations that are the closest to the
 // given update and then fill in those concentrations into the environment.
-void cAnalyze::FillResources(int update, cEnvironment &environment)
+void cAnalyze::FillResources(int update)
 {
   // There must be some resources for at least one update
-  assert(!resources.empty());
-
+  //assert(!resources.empty());
+  if(resources.empty()) { return; }
+  
   int which = -1;
   // Assuming resource vector is sorted by update, front to back
   if(update <= resources[0].first) {
@@ -453,39 +455,45 @@
     for(unsigned int i=0; i<resources.size()-1; i++) {
       if(update > resources[i+1].first) { continue; }
       if(update - resources[i].first <=
-	 resources[i+1].first - update) {
-	which = i;
+         resources[i+1].first - update) {
+        which = i;
       } else {
-	which = i + 1;
+        which = i + 1;
       }
       break;
     }
   }
   if(which < 0) { assert(0); }
-
-  cResourceLib &resLib = environment.GetResourceLib();
+  
+  //cResourceLib &resLib = environment.GetResourceLib();
   // The resources from the file and the original resources from
   // environment.cfg must be the same size.
-  assert((unsigned int)resLib.GetSize() == resources[which].second.size());
+  //assert((unsigned int)resLib.GetSize() == resources[which].second.size());
   // Set the resource concentrations to the values for the appropriate
   // update
-  for(unsigned int i=0; i<resources[which].second.size(); i++) {
-    cResource *res = resLib.GetResource(i);
-    assert(res);
-    res->SetInitial(resources[which].second[i]);
-  }
+  //for(unsigned int i=0; i<resources[which].second.size(); i++) {
+  //  cResource *res = resLib.GetResource(i);
+  //  assert(res);
+  //  res->SetInitial(resources[which].second[i]);
+  //}
+  
+tArray<double> temp(resources[which].second.size());
+for(unsigned int i=0; i<resources[which].second.size(); i++) {
+  temp[i] = resources[which].second[i];
+}
+cTestCPU::SetupResourceArray(temp);
 
-  return;
+return;
 }
 
 void cAnalyze::LoadFile(cString cur_string)
 {
   // LOAD
-
+  
   cString filename = cur_string.PopWord();
-
+  
   cout << "Loading: " << filename << endl;
-
+  
   cInitFile input_file(filename);
   if (!input_file.IsOpen()) {
     cerr << "Error: Cannot load file: \"" << filename << "\"." << endl;
@@ -495,42 +503,42 @@
   input_file.ReadHeader();
   input_file.Compress();
   input_file.Close();
-
+  
   const cString filetype = input_file.GetFiletype();
   if (filetype != "population_data") {
     cerr << "Error: Cannot load files of type \"" << filetype << "\"." << endl;
     exit(1);
   }
-
+  
   if (verbose == true) {
     cout << "Loading file of type: " << filetype << endl;
   }
-
   
+  
   // Construct a linked list of data types that can be loaded...
   tList< tDataEntryCommand<cAnalyzeGenotype> > output_list;
   tListIterator< tDataEntryCommand<cAnalyzeGenotype> > output_it(output_list);
   LoadGenotypeDataList(input_file.GetFormat(), output_list);
   bool id_inc = input_file.GetFormat().HasString("id");
-
+  
   // Setup the genome...
   cGenome default_genome(1);
   int load_count = 0;
-
+  
   for (int line_id = 0; line_id < input_file.GetNumLines(); line_id++) {
     cString cur_line = input_file.GetLine(line_id);
-
+    
     cAnalyzeGenotype * genotype =
       new cAnalyzeGenotype(default_genome, inst_set);
-
+    
     output_it.Reset();
     tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
     while ((data_command = output_it.Next()) != NULL) {
       data_command->SetTarget(genotype);
-//        genotype->SetSpecialArgs(data_command->GetArgs());
+      //        genotype->SetSpecialArgs(data_command->GetArgs());
       data_command->SetValue(cur_line.PopWord());
     }
-
+    
     // Give this genotype a name.  Base it on the ID if possible.
     if (id_inc == false) {
       cString name = cStringUtil::Stringf("org-%d", load_count++);
@@ -540,11 +548,11 @@
       cString name = cStringUtil::Stringf("org-%d", genotype->GetID());
       genotype->SetName(name);
     }
-
+    
     // Add this genotype to the proper batch.
     batch[cur_batch].List().PushRear(genotype);
   }
-
+  
   // Adjust the flags on this batch
   batch[cur_batch].SetLineage(false);
   batch[cur_batch].SetAligned(false);
@@ -557,36 +565,36 @@
 {
   // If no arguments are passed in, just find max num_cpus.
   if (cur_string.GetSize() == 0) cur_string = "num_cpus";
-
+  
   if (verbose == true) {
     cout << "Reducing batch " << cur_batch << " to genotypes: ";
   }
-
+  
   tListPlus<cAnalyzeGenotype> & gen_list = batch[cur_batch].List();
   tListPlus<cAnalyzeGenotype> found_list;
   while (cur_string.CountNumWords() > 0) {
     cString gen_desc(cur_string.PopWord());
     if (verbose) cout << gen_desc << " ";
-
+    
     // Determine by lin_type which genotype were are tracking...
     cAnalyzeGenotype * found_gen = PopGenotype(gen_desc, cur_batch);
-
+    
     if (found_gen == NULL) {
       cerr << "  Warning: genotype not found!" << endl;
       continue;
     }
-
+    
     // Save this genotype...
     found_list.Push(found_gen);
   }
   cout << endl;
-
+  
   // Delete all genotypes other than the ones found!
   while (gen_list.GetSize() > 0) delete gen_list.Pop();
-
+  
   // And fill it back in with the good stuff.
   while (found_list.GetSize() > 0) gen_list.Push(found_list.Pop());
-
+  
   // Adjust the flags on this batch
   batch[cur_batch].SetLineage(false);
   batch[cur_batch].SetAligned(false);
@@ -599,21 +607,21 @@
     cerr << "Error: At least one argument is required in FIND_ORGANISM." << endl;
     return;
   }
-
+  
   if (verbose == true) {
     cout << "Reducing batch " << cur_batch << " to organisms: " << endl;
   }
-
+  
   tListPlus<cAnalyzeGenotype> & gen_list = batch[cur_batch].List();
   tListPlus<cAnalyzeGenotype> found_list;
-
+  
   tArray<int> new_counts(gen_list.GetSize());
   new_counts.SetAll(0);
-
+  
   while (cur_string.CountNumWords() > 0) {
     cString org_desc(cur_string.PopWord());
     if (verbose) cout << org_desc << " ";
-
+    
     // Determine by org_desc which genotype were are tracking...
     if (org_desc == "random") {
       bool found = false; 
@@ -621,16 +629,16 @@
       while (found != true) {
       	int org_chosen = random.GetUInt(num_orgs);
       	cAnalyzeGenotype * found_genotype = 
-	   gen_list.FindSummedValue(org_chosen, &cAnalyzeGenotype::GetNumCPUs);
-	if ( found_genotype->GetNumCPUs() != 0 && found_genotype->GetViable()) {
-  	   found_genotype->SetNumCPUs(found_genotype->GetNumCPUs()-1);
-	   new_counts[gen_list.FindPosPtr(found_genotype)] +=1;
-	   cout << "Found genotype " << gen_list.FindPosPtr(found_genotype) << endl;
-	   found = true;
-	}
+          gen_list.FindSummedValue(org_chosen, &cAnalyzeGenotype::GetNumCPUs);
+        if ( found_genotype->GetNumCPUs() != 0 && found_genotype->GetViable()) {
+          found_genotype->SetNumCPUs(found_genotype->GetNumCPUs()-1);
+          new_counts[gen_list.FindPosPtr(found_genotype)] +=1;
+          cout << "Found genotype " << gen_list.FindPosPtr(found_genotype) << endl;
+          found = true;
+        }
       }
     }
-
+    
     // pick a random organisms, with replacement!
     if (org_desc == "randomWR") {
       bool found = false;
@@ -638,16 +646,16 @@
       while (found != true) {
         int org_chosen = random.GetUInt(num_orgs);
         cAnalyzeGenotype * found_genotype =
-           gen_list.FindSummedValue(org_chosen, &cAnalyzeGenotype::GetNumCPUs);
+          gen_list.FindSummedValue(org_chosen, &cAnalyzeGenotype::GetNumCPUs);
         if ( found_genotype->GetNumCPUs() != 0 && found_genotype->GetViable()) {
-           new_counts[gen_list.FindPosPtr(found_genotype)] +=1;
-           cout << "Found genotype " << gen_list.FindPosPtr(found_genotype) << endl;
-           found = true;
+          new_counts[gen_list.FindPosPtr(found_genotype)] +=1;
+          cout << "Found genotype " << gen_list.FindPosPtr(found_genotype) << endl;
+          found = true;
         }
       }
     }
   }
-
+  
   int pos_count = 0;
   cAnalyzeGenotype * genotype = NULL;
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
@@ -658,7 +666,7 @@
     else cout << "Genotype " << pos_count << " has " << new_counts[pos_count] << " organisms." << endl;
     pos_count++;
   }
-
+  
   // Adjust the flags on this batch
   batch[cur_batch].SetLineage(false);
   batch[cur_batch].SetAligned(false);
@@ -668,65 +676,65 @@
 {
   cString lin_type = "num_cpus";
   if (cur_string.CountNumWords() > 0) lin_type = cur_string.PopWord();
-
+  
   if (verbose == true) {
     cout << "Reducing batch " << cur_batch
-	 << " to " << lin_type << " lineage " << endl;
+    << " to " << lin_type << " lineage " << endl;
   } else cout << "Performing lineage scan..." << endl;
-
-
+  
+  
   // Determine by lin_type which genotype we are tracking...
   cAnalyzeGenotype * found_gen = PopGenotype(lin_type, cur_batch);
-
+  
   if (found_gen == NULL) {
     cerr << "  Warning: Genotype " << lin_type
-	 << " not found.  Lineage scan aborted." << endl;
+    << " not found.  Lineage scan aborted." << endl;
     return;
   }
-
+  
   // Otherwise, trace back through the id numbers to mark all of those
   // in the ancestral lineage...
-
+  
   // Construct a list of genotypes found...
-
+  
   tListPlus<cAnalyzeGenotype> found_list;
   found_list.Push(found_gen);
   int next_id = found_gen->GetParentID();
   bool found = true;
   while (found == true) {
     found = false;
-
+    
     tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
     while ((found_gen = batch_it.Next()) != NULL) {
       if (found_gen->GetID() == next_id) {
-	batch_it.Remove();
-	found_list.Push(found_gen);
-	next_id = found_gen->GetParentID();
-	found = true;
-	break;
+        batch_it.Remove();
+        found_list.Push(found_gen);
+        next_id = found_gen->GetParentID();
+        found = true;
+        break;
       }
     }
   }
-
+  
   // We now have all of the genotypes in this lineage, delete everything
   // else.
-
+  
   const int total_removed = batch[cur_batch].List().GetSize();
   while (batch[cur_batch].List().GetSize() > 0) {
     delete batch[cur_batch].List().Pop();
   }
-
+  
   // And fill it back in with the good stuff.
   int total_kept = found_list.GetSize();
   while (found_list.GetSize() > 0) {
     batch[cur_batch].List().PushRear(found_list.Pop());
   }
-
+  
   if (verbose == true) {
     cout << "  Lineage has " << total_kept << " genotypes; "
-	 << total_removed << " were removed." << endl;
+    << total_removed << " were removed." << endl;
   }
-
+  
   // Adjust the flags on this batch
   batch[cur_batch].SetLineage(true);
   batch[cur_batch].SetAligned(false);
@@ -734,12 +742,12 @@
 
 void cAnalyze::FindSexLineage(cString cur_string)
 {
-
+  
   // detemine the method for construicting a lineage 
   // by defauly, find the lineage of the final dominant
   cString lin_type = "num_cpus";
   if (cur_string.CountNumWords() > 0) lin_type = cur_string.PopWord();
-
+  
   // parent_method determins which of the two parental lineages to use
   // "rec_region_size" : 
   //		"mother" (dominant parent) is the parent contributing
@@ -748,61 +756,61 @@
   //		"mother" (dominant parent) is the longer parent 
   cString parent_method = "rec_region_size";
   if (cur_string.CountNumWords() > 0) parent_method = cur_string.PopWord();
-
+  
   if (verbose == true) {
     cout << "Reducing batch " << cur_batch
-	 << " to " << lin_type << " sexual lineage " 
-	 << " using " << parent_method << " criteria." << endl;
+    << " to " << lin_type << " sexual lineage " 
+    << " using " << parent_method << " criteria." << endl;
   } else cout << "Performing sexual lineage scan..." << endl;
-
-
+  
+  
   // Determine by lin_type which genotype we are tracking...
   cAnalyzeGenotype * found_gen = PopGenotype(lin_type, cur_batch);
-
+  
   cAnalyzeGenotype * found_dad;
   cAnalyzeGenotype * found_mom;
   cAnalyzeGenotype * found_temp;
-
+  
   if (found_gen == NULL) {
     cerr << "  Warning: Genotype " << lin_type
-	 << " not found.  Sexual lineage scan aborted." << endl;
+    << " not found.  Sexual lineage scan aborted." << endl;
     return;
   }
-
+  
   // Otherwise, trace back through the id numbers to mark all of those
   // in the ancestral lineage...
-
+  
   // Construct a list of genotypes found...
-
+  
   tListPlus<cAnalyzeGenotype> found_list;
   found_list.Push(found_gen);
   int next_id1 = found_gen->GetParentID();
   int next_id2 = found_gen->GetParent2ID();
-
+  
   bool found_m = true;
   bool found_d = true;
-
+  
   while (found_m == true & found_d == true) {
-
+    
     //cout << "Searching for mom=" << next_id1
     //	 << " and dad=" << next_id2 << endl;
     found_m = false;
     found_d = false;
-
+    
     // Look for the father first....
     tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
     batch_it.Reset();
     while ((found_dad = batch_it.Next()) != NULL) {
       // Check if the father is found...
       if (found_dad->GetID() == next_id2) {
-	//cout << "Found dad!" << endl;
-	batch_it.Remove();
-	found_list.Push(found_dad);
-	found_d = true; 
-	break;
+        //cout << "Found dad!" << endl;
+        batch_it.Remove();
+        found_list.Push(found_dad);
+        found_d = true; 
+        break;
       }
     }
-
+    
     // dad may have already been found, check the find list!
     if (found_d == false) {
       tListIterator<cAnalyzeGenotype> found_it(found_list);
@@ -814,74 +822,74 @@
         }
       }
     } 
-
+    
     // Next, look for the mother...
     batch_it.Reset();
     while ((found_mom = batch_it.Next()) != NULL) {
       if (found_mom->GetID() == next_id1) {
-	//cout << "Found mom!" << endl;
-	batch_it.Remove();
-	found_list.Push(found_mom);
-	// if finding lineages by parental length, may have to swap 
-	if (parent_method == "genome_size" & 
-	       found_mom->GetLength() < found_dad->GetLength()) { 
-	  //cout << "Swapping parents!" << endl;
-	  found_temp = found_mom; 
-	  found_mom = found_dad; 
-	  found_dad = found_temp; 
-	} 	
-	next_id1 = found_mom->GetParentID();
-	next_id2 = found_mom->GetParent2ID();
-	found_m = true;
-	break;
+        //cout << "Found mom!" << endl;
+        batch_it.Remove();
+        found_list.Push(found_mom);
+        // if finding lineages by parental length, may have to swap 
+        if (parent_method == "genome_size" & 
+            found_mom->GetLength() < found_dad->GetLength()) { 
+          //cout << "Swapping parents!" << endl;
+          found_temp = found_mom; 
+          found_mom = found_dad; 
+          found_dad = found_temp; 
+        } 	
+        next_id1 = found_mom->GetParentID();
+        next_id2 = found_mom->GetParent2ID();
+        found_m = true;
+        break;
       }
     }
-
+    
     // If the mother was not found, it may already have been placed in the
     // found list as a father... 
     if (found_m == false) {
       tListIterator<cAnalyzeGenotype> found_it(found_list);
       while ((found_mom = found_it.Next()) != NULL) {
-	if (found_mom->GetID() == next_id1) {
-	  //cout << "Found mom as dad!" << endl;
-	  // Don't move to found list, since its already there, but update
-	  // to the next ids.
-	  // if finding lineages by parental length, may have to swap 
+        if (found_mom->GetID() == next_id1) {
+          //cout << "Found mom as dad!" << endl;
+          // Don't move to found list, since its already there, but update
+          // to the next ids.
+          // if finding lineages by parental length, may have to swap 
           if (parent_method == "genome_size" & 
               found_mom->GetLength() < found_dad->GetLength()) {
- 	    //cout << "Swapping parents!" << endl;
+            //cout << "Swapping parents!" << endl;
             found_temp = found_mom; 
             found_mom = found_dad;  
             found_dad = found_temp;
           }
-	  next_id1 = found_mom->GetParentID();
-	  next_id2 = found_mom->GetParent2ID();
-	  found_m = true;
-	  break;
-	}
+          next_id1 = found_mom->GetParentID();
+          next_id2 = found_mom->GetParent2ID();
+          found_m = true;
+          break;
+        }
       }
     }    
   }
-
+  
   // We now have all of the genotypes in this lineage, delete everything
   // else.
-
+  
   const int total_removed = batch[cur_batch].List().GetSize();
   while (batch[cur_batch].List().GetSize() > 0) {
     delete batch[cur_batch].List().Pop();
   }
-
+  
   // And fill it back in with the good stuff.
   int total_kept = found_list.GetSize();
   while (found_list.GetSize() > 0) {
     batch[cur_batch].List().PushRear(found_list.Pop());
   }
-
+  
   if (verbose == true) {
     cout << "  Sexual lineage has " << total_kept << " genotypes; "
-	 << total_removed << " were removed." << endl;
+    << total_removed << " were removed." << endl;
   }
-
+  
   // Adjust the flags on this batch
   batch[cur_batch].SetLineage(false);
   batch[cur_batch].SetAligned(false);
@@ -893,68 +901,68 @@
     cerr << "  Warning: No clade specified for FIND_CLADE.  Aborting." << endl;
     return;
   }
-
+  
   cString clade_type( cur_string.PopWord() );
-
+  
   if (verbose == true) {
     cout << "Reducing batch " << cur_batch
-	 << " to clade " << clade_type << "." << endl;
+    << " to clade " << clade_type << "." << endl;
   } else cout << "Performing clade scan..." << endl;
-
-
+  
+  
   // Determine by clade_type which genotype we are tracking...
   cAnalyzeGenotype * found_gen = PopGenotype(clade_type, cur_batch);
-
+  
   if (found_gen == NULL) {
     cerr << "  Warning: Ancestral genotype " << clade_type
-	 << " not found.  Clade scan aborted." << endl;
+    << " not found.  Clade scan aborted." << endl;
     return;
   }
-
+  
   // Do this the brute force way... scan for one step at a time.
-
+  
   // Construct a list of genotypes found...
-
+  
   tListPlus<cAnalyzeGenotype> found_list; // Found and finished.
   tListPlus<cAnalyzeGenotype> scan_list;  // Found, but need to scan for children.
   scan_list.Push(found_gen);
-
+  
   // Keep going as long as there is something in the scan list...
   while (scan_list.GetSize() > 0) {
     // Move the next genotype from the scan list to the found_list.
     found_gen = scan_list.Pop();
     int parent_id = found_gen->GetID();
     found_list.Push(found_gen);
-
+    
     // Seach for all of the children of this genotype...
     tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
     while ((found_gen = batch_it.Next()) != NULL) {
       // If we found a child, place it into the scan list.
       if (found_gen->GetParentID() == parent_id) {
-	batch_it.Remove();
-	scan_list.Push(found_gen);
+        batch_it.Remove();
+        scan_list.Push(found_gen);
       }
     }
   }
-
+  
   // We now have all of the genotypes in this clade, delete everything else.
-
+  
   const int total_removed = batch[cur_batch].List().GetSize();
   while (batch[cur_batch].List().GetSize() > 0) {
     delete batch[cur_batch].List().Pop();
   }
-
+  
   // And fill it back in with the good stuff.
   int total_kept = found_list.GetSize();
   while (found_list.GetSize() > 0) {
     batch[cur_batch].List().PushRear(found_list.Pop());
   }
-
+  
   if (verbose == true) {
     cout << "  Clade has " << total_kept << " genotypes; "
-	 << total_removed << " were removed." << endl;
+    << total_removed << " were removed." << endl;
   }
-
+  
   // Adjust the flags on this batch
   batch[cur_batch].SetLineage(false);
   batch[cur_batch].SetAligned(false);
@@ -964,42 +972,42 @@
 {
   double fraction = cur_string.PopWord().AsDouble();
   int init_genotypes = batch[cur_batch].List().GetSize();
-
+  
   double test_viable = 0; 
   if (cur_string.GetSize() > 0) {
-     test_viable = cur_string.PopWord().AsDouble();
+    test_viable = cur_string.PopWord().AsDouble();
   }
-
+  
   if (verbose == true) {
     cout << "Sampling " << fraction << " organisms from batch "
-	 << cur_batch << "." << endl;
+    << cur_batch << "." << endl;
   }
   else cout << "Sampling Organisms..." << endl;
-
+  
   int old_total = 0;
   int new_total = 0;
-
+  
   cAnalyzeGenotype * genotype = NULL;
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-
+  
   // of only interested in viables, remove them first. 
   if (test_viable==1) {
     while ((genotype = batch_it.Next()) != NULL) {
       if ((genotype->GetViable())==0) { 
-	batch_it.Remove();
+        batch_it.Remove();
         delete genotype;
       } 
     } 
   } 
-
+  
   batch_it.Reset();
-
+  
   while ((genotype = batch_it.Next()) != NULL) {
     const int old_count = genotype->GetNumCPUs();
     const int new_count = random.GetRandBinomial(old_count, fraction);
     old_total += old_count;
     new_total += new_count;
-
+    
     if (new_count == 0) {
       batch_it.Remove();
       delete genotype;
@@ -1007,16 +1015,16 @@
       genotype->SetNumCPUs(new_count);
     }
   }
-
+  
   int num_genotypes = batch[cur_batch].List().GetSize();
   if (verbose) {
     cout << "  Removed " << old_total - new_total
-	 << " organisms (" << init_genotypes - num_genotypes
-	 << " genotypes); " << new_total
-	 << " orgs (" << num_genotypes << " gens) remaining."
-	 << endl;
+    << " organisms (" << init_genotypes - num_genotypes
+    << " genotypes); " << new_total
+    << " orgs (" << num_genotypes << " gens) remaining."
+    << endl;
   }
-
+  
   // Adjust the flags on this batch
   batch[cur_batch].SetLineage(false);
   batch[cur_batch].SetAligned(false);
@@ -1027,22 +1035,22 @@
 {
   double fraction = cur_string.PopWord().AsDouble();
   int init_genotypes = batch[cur_batch].List().GetSize();
-
+  
   double test_viable = 0;
   if (cur_string.GetSize() > 0) {
-     test_viable = cur_string.PopWord().AsDouble();
+    test_viable = cur_string.PopWord().AsDouble();
   }
-
+  
   if (verbose == true) {
     cout << "Sampling " << fraction << " genotypes from batch "
-	 << cur_batch << "." << endl;
+    << cur_batch << "." << endl;
   }
   else cout << "Sampling Genotypes..." << endl;
-
+  
   double frac_remove = 1.0 - fraction;
-
+  
   cAnalyzeGenotype * genotype = NULL;
-
+  
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   while ((genotype = batch_it.Next()) != NULL) {
     if (random.P(frac_remove) || ((genotype->GetViable())==0 && test_viable==1) ) {
@@ -1050,14 +1058,14 @@
       delete genotype;
     }
   }
-
+  
   int num_genotypes = batch[cur_batch].List().GetSize();
   if (verbose == true) {
     cout << "  Removed " << init_genotypes - num_genotypes
-	 << " genotypes; " << num_genotypes << " remaining."
-	 << endl;
+    << " genotypes; " << num_genotypes << " remaining."
+    << endl;
   }
-
+  
   // Adjust the flags on this batch
   batch[cur_batch].SetLineage(false);
   batch[cur_batch].SetAligned(false);
@@ -1068,11 +1076,11 @@
   const int num_kept = cur_string.PopWord().AsInt();
   const int num_genotypes = batch[cur_batch].List().GetSize();
   const int num_removed = num_genotypes - num_kept;
-
+  
   for (int i = 0; i < num_removed; i++) {
     delete batch[cur_batch].List().PopRear();
   }
-
+  
   // Adjust the flags on this batch
   // batch[cur_batch].SetLineage(false); // Should not destroy a lineage...
   batch[cur_batch].SetAligned(false);
@@ -1086,22 +1094,22 @@
 {
   if (verbose == true) cout << "Printing batch " << cur_batch << endl;
   else cout << "Printing organisms..." << endl;
-
+  
   cString directory = PopDirectory(cur_string, "genebank/");
-
+  
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   cAnalyzeGenotype * genotype = NULL;
   while ((genotype = batch_it.Next()) != NULL) {
     cString filename(directory);
-
+    
     if (cur_string.GetSize() > 0) {
-         filename += cur_string.PopWord();
+      filename += cur_string.PopWord();
     }
     else { 
-       filename += genotype->GetName();
-       filename += ".gen";
+      filename += genotype->GetName();
+      filename += ".gen";
     }
-
+    
     cTestUtil::PrintGenome(genotype->GetGenome(), filename);
     if (verbose) cout << "Printing: " << filename << endl;
   }
@@ -1111,13 +1119,13 @@
 {
   if (verbose == true) cout << "Tracing batch " << cur_batch << endl;
   else cout << "Tracing organisms..." << endl;
-
+  
   int words = cur_string.CountNumWords();
-
+  
   cString dir = cur_string.PopWord();
   cString defaultDirectory = "genebank/";
   cString directory = PopDirectory(dir, defaultDirectory);
-
+  
   int useResources = 0;
   if(words >= 2) {
     useResources = cur_string.PopWord().AsInt();
@@ -1126,57 +1134,45 @@
       useResources = 0;
     }
   }
-  if(useResources) {
-    assert(d_environment);
-  }
-
+  
   bool backupUsage;
-  cResourceCount originalResourceCount;
-  cEnvironment *backupEnvironment;
+  tArray<double> backupResources;
+  
   if(useResources) {
+    // Backup test cpu data
     backupUsage = cTestCPU::UseResources();
-    originalResourceCount = cTestCPU::GetResourceCount();
-    backupEnvironment = cTestCPU::GetEnvironment();
-
-    cTestCPU::SetEnvironment(d_environment);
-    cTestCPU::SetupResources();
+    backupResources = cTestCPU::GetResources();
+    
     cTestCPU::UseResources() = true;
   }
-
+  
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   cAnalyzeGenotype * genotype = NULL;
   while ((genotype = batch_it.Next()) != NULL) {
     cString filename(directory);
     filename += genotype->GetName();
     filename += ".trace";
-
+    
     if (genotype->GetGenome().GetSize() == 0) {
       break;
     }
-
-    // Build the hardware status printer for tracing.
-    ofstream trace_fp;
-    trace_fp.open(filename);
-    assert (trace_fp.good() == true); // Unable to open trace file.
-    cHardwareStatusPrinter trace_printer(trace_fp);
-
+    
     // Build the test info for printing.
     cCPUTestInfo test_info;
     test_info.TestThreads();
-    test_info.SetTraceExecution(&trace_printer);
-
+    test_info.SetTraceExecution(filename);
+    
     cTestCPU::TestGenome(test_info, genotype->GetGenome());
-
+    
     if (verbose) cout << "  Tracing: " << filename << endl;
-    trace_fp.close();
   }
-
+  
   if(useResources) {
-    cTestCPU::SetEnvironment(backupEnvironment);
-    cTestCPU::GetResourceCount() = originalResourceCount;
+    // Set the test cpu back to the state it was in before we messed with it
     cTestCPU::UseResources() = backupUsage;
+    cTestCPU::SetupResourceArray(backupResources);
   }
-
+  
   return;
 }
 
@@ -1184,13 +1180,13 @@
 {
   if (verbose == true) cout << "Printing tasks in batch " << cur_batch << endl;
   else cout << "Printing tasks..." << endl;
-
+  
   // Load in the variables...
   cString filename("tasks.dat");
   if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-
+  
   ofstream & fp = data_file_manager.GetOFStream(filename);
-
+  
   // Loop through all of the genotypes in this batch...
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   cAnalyzeGenotype * genotype = NULL;
@@ -1205,22 +1201,22 @@
 {
   if (verbose == true) cout << "Detailing batch " << cur_batch << endl;
   else cout << "Detailing..." << endl;
-
+  
   // Load in the variables...
   cString filename("detail.dat");
   if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-
+  
   // Construct a linked list of details needed...
   tList< tDataEntryCommand<cAnalyzeGenotype> > output_list;
   tListIterator< tDataEntryCommand<cAnalyzeGenotype> > output_it(output_list);
   LoadGenotypeDataList(cur_string, output_list);
-
+  
   // Determine the file type...
   int file_type = FILE_TYPE_TEXT;
   cString file_extension(filename);
   while (file_extension.Find('.') != -1) file_extension.Pop('.');
   if (file_extension == "html") file_type = FILE_TYPE_HTML;
-
+  
   // Setup the file...
   if (filename == "cout") {
     CommandDetail_Header(cout, file_type, output_it);
@@ -1230,7 +1226,7 @@
     CommandDetail_Header(fp, file_type, output_it);
     CommandDetail_Body(fp, file_type, output_it);
   }
-
+  
   // And clean up...
   while (output_list.GetSize() != 0) delete output_list.Pop();
 }
@@ -1239,9 +1235,9 @@
 void cAnalyze::CommandDetailTimeline(cString cur_string)
 {
   if (verbose == true) cout << "Detailing batch "
-         << cur_batch << " based on time" << endl;
+    << cur_batch << " based on time" << endl;
   else cout << "Detailing..." << endl;
-
+  
   // Load in the variables...
   cString filename("detail_timeline.dat");
   int time_step = 100;
@@ -1249,23 +1245,23 @@
   if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
   if (cur_string.GetSize() != 0) time_step = cur_string.PopWord().AsInt();
   if (cur_string.GetSize() != 0) max_time = cur_string.PopWord().AsInt();
-
+  
   if (verbose == true) {
     cout << "  Time step = " << time_step << endl
-  << "  Max time = " << max_time << endl;
+    << "  Max time = " << max_time << endl;
   }
-
+  
   // Construct a linked list of details needed...
   tList< tDataEntryCommand<cAnalyzeGenotype> > output_list;
   tListIterator< tDataEntryCommand<cAnalyzeGenotype> > output_it(output_list);
   LoadGenotypeDataList(cur_string, output_list);
-
+  
   // Determine the file type...
   int file_type = FILE_TYPE_TEXT;
   cString file_extension(filename);
   while (file_extension.Find('.') != -1) file_extension.Pop('.');
   if (file_extension == "html") file_type = FILE_TYPE_HTML;
-
+  
   // Setup the file...
   if (filename == "cout") {
     CommandDetail_Header(cout, file_type, output_it, time_step);
@@ -1275,15 +1271,15 @@
     CommandDetail_Header(fp, file_type, output_it, time_step);
     CommandDetail_Body(fp, file_type, output_it, time_step, max_time);
   }
-
+  
   // And clean up...
   while (output_list.GetSize() != 0) delete output_list.Pop();
 }
 
 
 void cAnalyze::CommandDetail_Header(ostream & fp, int format_type,
-	    tListIterator< tDataEntryCommand<cAnalyzeGenotype> > & output_it,
-	    int time_step)
+                                    tListIterator< tDataEntryCommand<cAnalyzeGenotype> > & output_it,
+                                    int time_step)
 {
   // Write out the header on the file
   if (format_type == FILE_TYPE_TEXT) {
@@ -1295,7 +1291,7 @@
       fp << entry_name << " ";
     }
     fp << endl << endl;
-
+    
     // Give the more human-readable legend.
     fp << "# Legend:" << endl;
     int count = 0;
@@ -1307,39 +1303,39 @@
     fp << endl;
   } else { // if (format_type == FILE_TYPE_HTML) {
     fp << "<html>" << endl
-       << "<body bgcolor=\"#FFFFFF\"" << endl
-       << " text=\"#000000\"" << endl
-       << " link=\"#0000AA\"" << endl
-       << " alink=\"#0000FF\"" << endl
-       << " vlink=\"#000044\">" << endl
-       << endl
-       << "<h1 align=center>Run " << batch[cur_batch].Name() << endl
-       << endl
-       << "<center>" << endl
-       << "<table border=1 cellpadding=2><tr>" << endl;
-
+    << "<body bgcolor=\"#FFFFFF\"" << endl
+    << " text=\"#000000\"" << endl
+    << " link=\"#0000AA\"" << endl
+    << " alink=\"#0000FF\"" << endl
+    << " vlink=\"#000044\">" << endl
+    << endl
+    << "<h1 align=center>Run " << batch[cur_batch].Name() << endl
+    << endl
+    << "<center>" << endl
+    << "<table border=1 cellpadding=2><tr>" << endl;
+    
     if (time_step > 0) fp << "<th bgcolor=\"#AAAAFF\">Update ";
     while (output_it.Next() != NULL) {
       const cString & entry_desc = output_it.Get()->GetDesc();
       fp << "<th bgcolor=\"#AAAAFF\">" << entry_desc << " ";
     }
     fp << "</tr>" << endl;
-
+    
   }
+  
+  }
 
-}
 
-
 void cAnalyze::CommandDetail_Body(ostream & fp, int format_type,
-	    tListIterator< tDataEntryCommand<cAnalyzeGenotype> > & output_it,
-	    int time_step, int max_time)
+                                  tListIterator< tDataEntryCommand<cAnalyzeGenotype> > & output_it,
+                                  int time_step, int max_time)
 {
   // Loop through all of the genotypes in this batch...
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   cAnalyzeGenotype * cur_genotype = batch_it.Next();
   cAnalyzeGenotype * next_genotype = batch_it.Next();
   cAnalyzeGenotype * prev_genotype = NULL;
-
+  
   int cur_time = 0;
   while (cur_genotype != NULL && cur_time <= max_time) {
     output_it.Reset();
@@ -1351,31 +1347,31 @@
     else if (time_step > 0) {  // TEXT file, printing times...
       fp << cur_time << " ";
     }
-
+    
     while ((data_command = output_it.Next()) != NULL) {
       data_command->SetTarget(cur_genotype);
       cur_genotype->SetSpecialArgs(data_command->GetArgs());
       if (format_type == FILE_TYPE_HTML) {
-	int compare = 0;
+        int compare = 0;
         if (prev_genotype) {
           prev_genotype->SetSpecialArgs(data_command->GetArgs());
           compare = data_command->Compare(prev_genotype);
-	}
-	data_command->HTMLPrint(fp, compare);
+        }
+        data_command->HTMLPrint(fp, compare);
       }
       else {  // if (format_type == FILE_TYPE_TEXT) {
-	fp << data_command->GetEntry() << " ";
+        fp << data_command->GetEntry() << " ";
       }
-    }
+      }
     if (format_type == FILE_TYPE_HTML) fp << "</tr>";
     fp << endl;
-
+    
     cur_time += time_step;
     if (time_step > 0) {
       while (next_genotype && next_genotype->GetUpdateBorn() < cur_time) {
-       prev_genotype = cur_genotype;
-       cur_genotype = next_genotype;
-       next_genotype = batch_it.Next();
+        prev_genotype = cur_genotype;
+        cur_genotype = next_genotype;
+        next_genotype = batch_it.Next();
       }
     }
     else {
@@ -1385,25 +1381,25 @@
       cur_genotype = next_genotype;
       next_genotype = batch_it.Next();
     }
-
-  }
-
+    
+    }
+  
   // If in HTML mode, we need to end the file...
   if (format_type == FILE_TYPE_HTML) {
     fp << "</table>" << endl
-       << "</center>" << endl;
+    << "</center>" << endl;
   }
-}
+  }
 
 void cAnalyze::CommandDetailAverage_Body(ostream & fp, int num_outputs,
-	    tListIterator< tDataEntryCommand<cAnalyzeGenotype> > & output_it)
+                                         tListIterator< tDataEntryCommand<cAnalyzeGenotype> > & output_it)
 {
   // Loop through all of the genotypes in this batch...
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   cAnalyzeGenotype * cur_genotype = batch_it.Next();
   cAnalyzeGenotype * next_genotype = batch_it.Next();
   cAnalyzeGenotype * prev_genotype = NULL;
-
+  
   tArray<cDoubleSum> output_counts(num_outputs);
   for (int i = 0; i < num_outputs; i++) { output_counts[i].Clear();} 
   int count; 
@@ -1419,16 +1415,16 @@
       } 	
       count++;
     }
-
+    
     prev_genotype = cur_genotype;
     cur_genotype = next_genotype;
     next_genotype = batch_it.Next();
   }
-    fp << batch[cur_batch].Name() << " "; 
-    for (int i = 0; i < num_outputs; i++) {  
-	fp << output_counts[i].Average() << " ";
-    } 
-    fp << endl;   
+  fp << batch[cur_batch].Name() << " "; 
+  for (int i = 0; i < num_outputs; i++) {  
+    fp << output_counts[i].Average() << " ";
+  } 
+  fp << endl;   
 }
 
 void cAnalyze::CommandDetailAverage(cString cur_string) 
@@ -1447,17 +1443,17 @@
   
   // check if file is already in use.
   bool file_active = data_file_manager.IsOpen(filename);
-
+  
   ofstream & fp = data_file_manager.GetOFStream(filename);
-
+  
   // if it's a new file print out the header
   if (file_active == false) {
-     CommandDetail_Header(fp, FILE_TYPE_TEXT, output_it);
+    CommandDetail_Header(fp, FILE_TYPE_TEXT, output_it);
   } 
   CommandDetailAverage_Body(fp, cur_string.CountNumWords(), output_it);
-
+  
   while (output_list.GetSize() != 0) delete output_list.Pop();
-
+  
 } 
 
 void cAnalyze::CommandDetailBatches(cString cur_string)
@@ -1467,26 +1463,26 @@
   cString filename("detail_batch.dat");
   if (cur_string.GetSize() != 0) keyword = cur_string.PopWord();
   if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-
+  
   if (verbose == true) cout << "Detailing batches for " << keyword << endl;
   else cout << "Detailing Batches..." << endl;
-
+  
   // Scan the functions list for the keyword we need...
   SetupGenotypeDataList();
   tListIterator< tDataEntryBase<cAnalyzeGenotype> >
     output_it(genotype_data_list);
-
+  
   // Divide up the keyword into its acrual entry and its arguments...
   cString cur_args = keyword;
   cString cur_entry = cur_args.Pop(':');
-
+  
   // Find its associated command...
   tDataEntryCommand<cAnalyzeGenotype> * cur_command = NULL;
   bool found = false;
   while (output_it.Next() != NULL) {
     if (output_it.Get()->GetName() == cur_entry) {
       cur_command = new tDataEntryCommand<cAnalyzeGenotype>
-	(output_it.Get(), cur_args);
+      (output_it.Get(), cur_args);
       found = true;
       break;
     }
@@ -1495,115 +1491,115 @@
     cout << "Error: Unknown data type: " << cur_entry << endl;
     return;
   }
-
-
+  
+  
   // Determine the file type...
   int file_type = FILE_TYPE_TEXT;
   cString file_extension(filename);
   while (file_extension.Find('.') != -1) file_extension.Pop('.');
   if (file_extension == "html") file_type = FILE_TYPE_HTML;
-
+  
   ofstream & fp = data_file_manager.GetOFStream(filename);
-
+  
   // Write out the header on the file
   if (file_type == FILE_TYPE_TEXT) {
     fp << "#filetype batch_data" << endl
-       << "#format batch_id " << keyword << endl
-       << endl;
-
+    << "#format batch_id " << keyword << endl
+    << endl;
+    
     // Give the more human-readable legend.
     fp << "# Legend:" << endl
-       << "#  Column 1 = Batch ID" << endl
-       << "#  Remaining entries: " << cur_command->GetDesc() << endl
-       << endl;
-
+      << "#  Column 1 = Batch ID" << endl
+      << "#  Remaining entries: " << cur_command->GetDesc() << endl
+      << endl;
+    
   } else { // if (file_type == FILE_TYPE_HTML) {
     fp << "<html>" << endl
-       << "<body bgcolor=\"#FFFFFF\"" << endl
-       << " text=\"#000000\"" << endl
-       << " link=\"#0000AA\"" << endl
-       << " alink=\"#0000FF\"" << endl
-       << " vlink=\"#000044\">" << endl
-       << endl
-       << "<h1 align=center> Distribution of " << cur_command->GetDesc()
-       << endl << endl
-       << "<center>" << endl
-       << "<table border=1 cellpadding=2>" << endl
-       << "<tr><th bgcolor=\"#AAAAFF\">" << cur_command->GetDesc() << "</tr>"
-       << endl;
+    << "<body bgcolor=\"#FFFFFF\"" << endl
+    << " text=\"#000000\"" << endl
+    << " link=\"#0000AA\"" << endl
+    << " alink=\"#0000FF\"" << endl
+    << " vlink=\"#000044\">" << endl
+    << endl
+    << "<h1 align=center> Distribution of " << cur_command->GetDesc()
+    << endl << endl
+    << "<center>" << endl
+    << "<table border=1 cellpadding=2>" << endl
+    << "<tr><th bgcolor=\"#AAAAFF\">" << cur_command->GetDesc() << "</tr>"
+    << endl;
   }
-
-
+  
+  
   // Loop through all of the batches...
   for (int i = 0; i < MAX_BATCHES; i++) {
     if (batch[i].List().GetSize() == 0) continue;
-
+    
     if (file_type == FILE_TYPE_HTML) fp << "<tr><td>";
     fp << i << " ";
-  
+    
     tListIterator<cAnalyzeGenotype> batch_it(batch[i].List());
     cAnalyzeGenotype * genotype = NULL;
     while ((genotype = batch_it.Next()) != NULL) {
       output_it.Reset();
       if (file_type == FILE_TYPE_HTML) fp << "<td>";
-
+      
       cur_command->SetTarget(genotype);
       genotype->SetSpecialArgs(cur_command->GetArgs());
       if (file_type == FILE_TYPE_HTML) {
-	cur_command->HTMLPrint(fp, 0);
+        cur_command->HTMLPrint(fp, 0);
       }
       else {  // if (file_type == FILE_TYPE_TEXT) {
-	fp << cur_command->GetEntry() << " ";
+        fp << cur_command->GetEntry() << " ";
       }
-    }
+      }
     if (file_type == FILE_TYPE_HTML) fp << "</tr>";
     fp << endl;
-  }
-
+    }
+  
   // If in HTML mode, we need to end the file...
   if (file_type == FILE_TYPE_HTML) {
     fp << "</table>" << endl
-       << "</center>" << endl;
+    << "</center>" << endl;
   }
   
   delete cur_command;
-}
+  }
 
 
 
 void cAnalyze::CommandDetailIndex(cString cur_string)
 {
   cout << "Creating a Detail Index..." << endl;
-
+  
   // A filename and min and max batches must be included.
   if (cur_string.CountNumWords() < 3) {
     cerr << "Error: must include filename, and min and max batch numbers."
-	 << endl;
+    << endl;
     exit(1);
   }
-
+  
   // Load in the variables...
   cString filename(cur_string.PopWord());
   int min_batch = cur_string.PopWord().AsInt();
   int max_batch = cur_string.PopWord().AsInt();
-
+  
   if (max_batch < min_batch) {
     cerr << "Error: min_batch=" << min_batch
-	 << ", max_batch=" << max_batch << "  (incorrect order?)" << endl;
+    << ", max_batch=" << max_batch << "  (incorrect order?)" << endl;
     exit(1);
   }
-
+  
   // Construct a linked list of details needed...
   tList< tDataEntryBase<cAnalyzeGenotype> > output_list;
   tListIterator< tDataEntryBase<cAnalyzeGenotype> > output_it(output_list);
-
+  
   // For the moment, just put everything into the output list.
   SetupGenotypeDataList();
-
+  
   // If no args were given, load all of the stats.
   if (cur_string.CountNumWords() == 0) {
     tListIterator< tDataEntryBase<cAnalyzeGenotype> >
-      genotype_data_it(genotype_data_list);
+    genotype_data_it(genotype_data_list);
     while (genotype_data_it.Next() != NULL) {
       output_list.PushRear(genotype_data_it.Get());
     }
@@ -1614,51 +1610,51 @@
       // Setup the next entry
       cString cur_entry = cur_string.PopWord();
       bool found_entry = false;
-
+      
       // Scan the genotype data list for the current entry
       tListIterator< tDataEntryBase<cAnalyzeGenotype> >
-	genotype_data_it(genotype_data_list);
-
+        genotype_data_it(genotype_data_list);
+      
       while (genotype_data_it.Next() != NULL) {
-	if (genotype_data_it.Get()->GetName() == cur_entry) {
-	  output_list.PushRear(genotype_data_it.Get());
-	  found_entry = true;
-	  break;
-	}
+        if (genotype_data_it.Get()->GetName() == cur_entry) {
+          output_list.PushRear(genotype_data_it.Get());
+          found_entry = true;
+          break;
+        }
       }
-
+      
       // If the entry was not found, give a warning.
       if (found_entry == false) {
-	int best_match = 1000;
-	cString best_entry;
-
-	genotype_data_it.Reset();
-	while (genotype_data_it.Next() != NULL) {
-	  const cString & test_str = genotype_data_it.Get()->GetName();
-	  const int test_dist = cStringUtil::EditDistance(test_str, cur_entry);
-	  if (test_dist < best_match) {
-	    best_match = test_dist;
-	    best_entry = test_str;
-	  }
-	}	
-
-	cerr << "Warning: Format entry \"" << cur_entry
-	     << "\" not found.  Best match is \""
-	     << best_entry << "\"." << endl;
+        int best_match = 1000;
+        cString best_entry;
+        
+        genotype_data_it.Reset();
+        while (genotype_data_it.Next() != NULL) {
+          const cString & test_str = genotype_data_it.Get()->GetName();
+          const int test_dist = cStringUtil::EditDistance(test_str, cur_entry);
+          if (test_dist < best_match) {
+            best_match = test_dist;
+            best_entry = test_str;
+          }
+        }	
+        
+        cerr << "Warning: Format entry \"" << cur_entry
+          << "\" not found.  Best match is \""
+          << best_entry << "\"." << endl;
       }
-
+      
     }
   }
-
+  
   // Setup the file...
   ofstream fp;
   fp.open(filename);
-
+  
   // Determine the file type...
   int file_type = FILE_TYPE_TEXT;
   while (filename.Find('.') != -1) filename.Pop('.'); // Grab only extension
   if (filename == "html") file_type = FILE_TYPE_HTML;
-
+  
   // Write out the header on the file
   if (file_type == FILE_TYPE_TEXT) {
     fp << "#filetype genotype_data" << endl;
@@ -1668,7 +1664,7 @@
       fp << entry_name << " ";
     }
     fp << endl << endl;
-
+    
     // Give the more human-readable legend.
     fp << "# Legend:" << endl;
     fp << "# 1: Batch Name" << endl;
@@ -1680,26 +1676,26 @@
     fp << endl;
   } else { // if (file_type == FILE_TYPE_HTML) {
     fp << "<html>" << endl
-       << "<body bgcolor=\"#FFFFFF\"" << endl
-       << " text=\"#000000\"" << endl
-       << " link=\"#0000AA\"" << endl
-       << " alink=\"#0000FF\"" << endl
-       << " vlink=\"#000044\">" << endl
-       << endl
-       << "<h1 align=center>Batch Index" << endl
-       << endl
-       << "<center>" << endl
-       << "<table border=1 cellpadding=2><tr>" << endl;
-
+    << "<body bgcolor=\"#FFFFFF\"" << endl
+    << " text=\"#000000\"" << endl
+    << " link=\"#0000AA\"" << endl
+    << " alink=\"#0000FF\"" << endl
+    << " vlink=\"#000044\">" << endl
+    << endl
+    << "<h1 align=center>Batch Index" << endl
+    << endl
+    << "<center>" << endl
+    << "<table border=1 cellpadding=2><tr>" << endl;
+    
     fp << "<th bgcolor=\"#AAAAFF\">Batch ";
     while (output_it.Next() != NULL) {
       const cString & entry_desc = output_it.Get()->GetDesc();
       fp << "<th bgcolor=\"#AAAAFF\">" << entry_desc << " ";
     }
     fp << "</tr>" << endl;
-
+    
   }
-
+  
   // Loop through all of the batchs...
   for (int batch_id = min_batch; batch_id <= max_batch; batch_id++) {
     cAnalyzeGenotype * genotype = batch[batch_id].List().GetFirst();
@@ -1709,33 +1705,33 @@
     const cString & batch_name = batch[batch_id].Name();
     if (file_type == FILE_TYPE_HTML) {
       fp << "<tr><th><a href=lineage." << batch_name << ".html>"
-	 << batch_name << "</a> ";
+      << batch_name << "</a> ";
     }
     else {
       fp << batch_name << " ";
     }
-
+    
     while ((data_entry = output_it.Next()) != NULL) {
       data_entry->SetTarget(genotype);
       if (file_type == FILE_TYPE_HTML) {
-	fp << "<td align=center><a href=\""
-	   << data_entry->GetName() << "." << batch_name << ".png\">"
-	   << *data_entry << "</a> ";
+        fp << "<td align=center><a href=\""
+        << data_entry->GetName() << "." << batch_name << ".png\">"
+        << *data_entry << "</a> ";
       }
       else {  // if (file_type == FILE_TYPE_TEXT) {
-	fp << *data_entry << " ";
+        fp << *data_entry << " ";
       }
-    }
+      }
     if (file_type == FILE_TYPE_HTML) fp << "</tr>";
     fp << endl;
-  }
-
+    }
+  
   // If in HTML mode, we need to end the file...
   if (file_type == FILE_TYPE_HTML) {
     fp << "</table>" << endl
-       << "</center>" << endl;
+    << "</center>" << endl;
   }
-}
+  }
 
 
 ///// Population Analysis Commands ////
@@ -1743,16 +1739,16 @@
 void cAnalyze::CommandPrintPhenotypes(cString cur_string)
 {
   if (verbose == true) cout << "Printing phenotypes in batch "
-			    << cur_batch << endl;
+    << cur_batch << endl;
   else cout << "Printing phenotypes..." << endl;
-
+  
   // Load in the variables...
   cString filename("phenotype.dat");
   if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-
+  
   // Make sure we have at least one genotype...
   if (batch[cur_batch].List().GetSize() == 0) return;
-
+  
   // Setup the phenotype categories...
   const int num_tasks = batch[cur_batch].List().GetFirst()->GetNumTasks();
   const int num_phenotypes = 1 << (num_tasks + 1);
@@ -1760,12 +1756,12 @@
   tArray<int> genotype_counts(num_phenotypes);
   tArray<double> total_length(num_phenotypes);
   tArray<double> total_gest(num_phenotypes);
-
+  
   phenotype_counts.SetAll(0);
   genotype_counts.SetAll(0);
   total_length.SetAll(0.0);
   total_gest.SetAll(0.0);
-
+  
   // Loop through all of the genotypes in this batch...
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   cAnalyzeGenotype * genotype = NULL;
@@ -1780,40 +1776,40 @@
     total_length[phen_id] += genotype->GetNumCPUs() * genotype->GetLength();
     total_gest[phen_id] += genotype->GetNumCPUs() * genotype->GetGestTime();
   }
-
+  
   // Print out the results...
   
   ofstream & fp = data_file_manager.GetOFStream(filename);
-
+  
   fp << "# 1: Number of organisms of this phenotype" << endl
-     << "# 2: Number of genotypes of this phenotye" << endl
-     << "# 3: Average Genome Length" << endl
-     << "# 4: Average Gestation Time" << endl
-     << "# 5: Viability of Phenotype" << endl
-     << "# 6+: Tasks performed in this phenotype" << endl
-     << endl;
-
+    << "# 2: Number of genotypes of this phenotye" << endl
+    << "# 3: Average Genome Length" << endl
+    << "# 4: Average Gestation Time" << endl
+    << "# 5: Viability of Phenotype" << endl
+    << "# 6+: Tasks performed in this phenotype" << endl
+    << endl;
+  
   // @CAO Lets do this inefficiently for the moment, but print out the
   // phenotypes in order.
-
+  
   while (true) {
     // Find the next phenotype to print...
     int max_count = phenotype_counts[0];
     int max_position = 0;
     for (int i = 0; i < num_phenotypes; i++) {
       if (phenotype_counts[i] > max_count) {
-	max_count = phenotype_counts[i];
-	max_position = i;
+        max_count = phenotype_counts[i];
+        max_position = i;
       }
     }
-
+    
     if (max_count == 0) break; // we're done!
-
+    
     fp << phenotype_counts[max_position] << " "
-       << genotype_counts[max_position] << " "
-       << total_length[max_position] / phenotype_counts[max_position] << " "
-       << total_gest[max_position] / phenotype_counts[max_position] << " "
-       << (max_position & 1) << "  ";
+      << genotype_counts[max_position] << " "
+      << total_length[max_position] / phenotype_counts[max_position] << " "
+      << total_gest[max_position] / phenotype_counts[max_position] << " "
+      << (max_position & 1) << "  ";
     for (int i = 1; i <= num_tasks; i++) {
       if ((max_position >> i) & 1 > 0) fp << "1 ";
       else fp << "0 ";
@@ -1821,7 +1817,7 @@
     fp << endl;
     phenotype_counts[max_position] = 0;
   }
-
+  
   fp.close();
 }
 
@@ -1830,16 +1826,16 @@
 void cAnalyze::CommandPrintDiversity(cString cur_string)
 {
   if (verbose == true) cout << "Printing diversity data for batch "
-			    << cur_batch << endl;
+    << cur_batch << endl;
   else cout << "Printing diversity data..." << endl;
-
+  
   // Load in the variables...
   cString filename("diversity.dat");
   if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-
+  
   // Make sure we have at least one genotype...
   if (batch[cur_batch].List().GetSize() == 0) return;
-
+  
   // Setup the task categories...
   const int num_tasks = batch[cur_batch].List().GetFirst()->GetNumTasks();
   tArray<int> task_count(num_tasks);
@@ -1848,7 +1844,7 @@
   tArray<double> task_site_entropy(num_tasks);
   task_count.SetAll(0);
   task_gen_count.SetAll(0);
-
+  
   // We must determine the average hamming distance between genotypes in
   // this batch that perform each task.  Levenstein distance would be ideal,
   // but takes a while, so we'll do it this way first.  For the calculations,
@@ -1857,28 +1853,28 @@
   const int num_insts = inst_set.GetSize();
   const int max_length = BatchUtil_GetMaxLength();
   tMatrix<int> inst_freq(max_length, num_insts+1);
-
+  
   for (int task_id = 0; task_id < num_tasks; task_id++) {
     inst_freq.SetAll(0);
-
+    
     // Loop through all genotypes, singling out those that do current task...
     tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
     cAnalyzeGenotype * genotype = NULL;
     while ((genotype = batch_it.Next()) != NULL) {
       if (genotype->GetTaskCount(task_id) == 0) continue;
-
+      
       const cGenome & genome = genotype->GetGenome();
       const int num_cpus = genotype->GetNumCPUs();
       task_count[task_id] += num_cpus;
       task_gen_count[task_id]++;
       for (int i = 0; i < genotype->GetLength(); i++) {
-	inst_freq( i, genome[i].GetOp() ) += num_cpus;
+        inst_freq( i, genome[i].GetOp() ) += num_cpus;
       }
       for (int i = genotype->GetLength(); i < max_length; i++) {
-	inst_freq(i, num_insts) += num_cpus; // Entry for "past genome end"
+        inst_freq(i, num_insts) += num_cpus; // Entry for "past genome end"
       }
     }
-
+    
     // Analyze the data for this entry...
     const int cur_count = task_count[task_id];
     const int total_pairs = cur_count * (cur_count - 1) / 2;
@@ -1887,28 +1883,28 @@
     for (int pos = 0; pos < max_length; pos++) {
       // Calculate distance component...
       for (int inst1 = 0; inst1 < num_insts; inst1++) {
-	if (inst_freq(pos, inst1) == 0) continue;
-	for (int inst2 = inst1+1; inst2 <= num_insts; inst2++) {
-	  total_dist += inst_freq(pos, inst1) * inst_freq(pos, inst2);
-	}
+        if (inst_freq(pos, inst1) == 0) continue;
+        for (int inst2 = inst1+1; inst2 <= num_insts; inst2++) {
+          total_dist += inst_freq(pos, inst1) * inst_freq(pos, inst2);
+        }
       }
-
+      
       // Calculate entropy component...
       for (int i = 0; i <= num_insts; i++) {
-	const int cur_freq = inst_freq(pos, i);
-	if (cur_freq == 0) continue;
-	const double p = ((double) cur_freq) / (double) cur_count;
-	total_ent -= p * log(p);
+        const int cur_freq = inst_freq(pos, i);
+        if (cur_freq == 0) continue;
+        const double p = ((double) cur_freq) / (double) cur_count;
+        total_ent -= p * log(p);
       }
     }
-
+    
     task_gen_dist[task_id] = ((double) total_dist) / (double) total_pairs;
     task_site_entropy[task_id] = total_ent;
   }
-
+  
   // Print out the results...
   cDataFile & df = data_file_manager.Get(filename);
-
+  
   for (int i = 0; i < num_tasks; i++) {
     df.Write(i,                    "# 1: Task ID");
     df.Write(task_count[i],        "# 2: Number of organisms performing task");
@@ -1924,7 +1920,7 @@
 {
   if (verbose == true) cout << "Landscaping batch " << cur_batch << endl;
   else cout << "Landscapping..." << endl;
-
+  
   // Load in the variables...
   cString filename;
   if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
@@ -1932,7 +1928,7 @@
   if (cur_string.GetSize() != 0) dist = cur_string.PopWord().AsInt();
   int num_test = 0;
   if (cur_string.GetSize() != 0) num_test=cur_string.PopWord().AsInt();
-
+  
   // If we're given a file, write to it.
   ofstream & fp = data_file_manager.GetOFStream(filename);
   
@@ -1943,7 +1939,6 @@
     cLandscape landscape(genotype->GetGenome(), inst_set);
     if (num_test == 0) landscape.Process(dist);
     else landscape.RandomProcess(num_test,dist,num_test,num_test*2);
-
     landscape.PrintStats(fp);
   }
 }
@@ -1952,13 +1947,13 @@
 {
   if (verbose == true) cout << "Epistasis on " << cur_batch << endl;
   else cout << "Calculating epistasis values..." << endl;
-
+  
   // Load in the variables...
   cString filename;
   if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
   int test_num = 1;
   if (cur_string.GetSize() != 0) test_num = cur_string.PopWord().AsInt();
-
+  
   // If we're given a file, write to it.
   ofstream & fp = data_file_manager.GetOFStream(filename);
   
@@ -1973,53 +1968,207 @@
   }
 }
 
+double cAnalyze::AnalyzeEntropy(cAnalyzeGenotype * genotype, double mu) 
+{
+  double entropy = 0.0;
+  
+  // Calculate the stats for the genotype we're working with ...
+  genotype->Recalculate();
+  const int num_insts = inst_set.GetSize();
+  const int num_lines = genotype->GetLength();
+  const cGenome & base_genome = genotype->GetGenome();
+  cGenome mod_genome(base_genome);
+  double base_fitness = genotype->GetFitness();
+  
+  // Loop through all the lines of code, testing all mutations...
+  tArray<double> test_fitness(num_insts);
+  tArray<double> prob(num_insts);
+  for (int line_no = 0; line_no < num_lines; line_no ++) {
+    int cur_inst = base_genome[line_no].GetOp();
+    
+    // Test fitness of each mutant.
+    for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) {
+      mod_genome[line_no].SetOp(mod_inst);
+      cAnalyzeGenotype test_genotype(mod_genome, inst_set);
+      test_genotype.Recalculate();
+      // Ajust fitness ...
+      if (test_genotype.GetFitness() <= base_fitness) {
+        test_fitness[mod_inst] = test_genotype.GetFitness();
+      } else {
+        test_fitness[mod_inst] = base_fitness;
+      }
+    }
+    
+    // Calculate probabilities at mut-sel balance
+    double w_bar = 1;
+    
+    // Normalize fitness values, assert if they are all zero
+    double maxFitness = 0.0;
+    for(int i=0; i<num_insts; i++) {
+      if(test_fitness[i] > maxFitness) {
+        maxFitness = test_fitness[i];
+      }
+    }
+    
+    if(maxFitness > 0) {
+      for(int i=0; i<num_insts; i++) {
+        test_fitness[i] /= maxFitness;
+      }
+    } else {
+      cout << "All zero fitness, ERROR." << endl;
+      return -1.0;
+    }
+    
+    while(1) {
+      double sum = 0.0;
+      for (int mod_inst = 0; mod_inst < num_insts; mod_inst ++) {
+        prob[mod_inst] = (mu * w_bar) / 
+        ((double)num_insts * 
+         (w_bar + test_fitness[mod_inst] * mu - test_fitness[mod_inst]));
+        sum = sum + prob[mod_inst];
+      }
+      if ((sum-1.0)*(sum-1.0) <= 0.0001) 
+        break;
+      else
+        w_bar = w_bar - 0.000001;
+    }
+    
+    // Calculate entropy ...
+    double this_entropy = 0.0;
+    for (int i = 0; i < num_insts; i ++) {
+      this_entropy += prob[i] * log((double) 1.0/prob[i]) / log ((double) num_insts);
+    }
+    entropy += this_entropy;
+    
+    // Reset the mod_genome back to the original sequence.
+    mod_genome[line_no].SetOp(cur_inst);
+  }
+  return entropy;
+}
+
+double cAnalyze::AnalyzeEntropyGivenParent(cAnalyzeGenotype * genotype,
+                                           cAnalyzeGenotype * parent, double mut_rate)
+{
+  double entropy = 0.0;
+  
+  // Calculate the stats for the genotype we're working with ...
+  genotype->Recalculate();
+  const int num_insts = inst_set.GetSize();
+  const int num_lines = genotype->GetLength();
+  const cGenome & base_genome = genotype->GetGenome();
+  cGenome mod_genome(base_genome);
+  double base_fitness = genotype->GetFitness();
+  
+  // Loop through all the lines of code, testing all mutations ...
+  tArray<double> test_fitness(num_insts);
+  tArray<double> prob(num_insts);
+  for (int line_no = 0; line_no < num_lines; line_no ++) {
+    int cur_inst = base_genome[line_no].GetOp();
+    
+    // Test fitness of each mutant.
+    for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) {
+      mod_genome[line_no].SetOp(mod_inst);
+      cAnalyzeGenotype test_genotype(mod_genome, inst_set);
+      test_genotype.Recalculate();
+      test_fitness[mod_inst] = test_genotype.GetFitness();
+    }
+    
+    // Calculate probabilities at mut-sel balance
+    double w_bar = 1;
+    
+    // Normalize fitness values, assert if they are all zero
+    double maxFitness = 0.0;
+    for(int i=0; i<num_insts; i++) {
+      if(test_fitness[i] > maxFitness) {
+        maxFitness = test_fitness[i];
+      }
+    }
+    
+    if(maxFitness > 0) {
+      for(int i=0; i<num_insts; i++) {
+        test_fitness[i] /= maxFitness;
+      }
+    } else {
+      cout << "All zero fitness, ERROR." << endl;
+      return -1.0;
+    }
+    
+    while(1) {
+      double sum = 0.0;
+      for (int mod_inst = 0; mod_inst < num_insts; mod_inst ++) {
+        prob[mod_inst] = (mut_rate * w_bar) / 
+        ((double)num_insts * 
+         (w_bar + test_fitness[mod_inst] * mut_rate - test_fitness[mod_inst]));
+        sum = sum + prob[mod_inst];
+      }
+      if ((sum-1.0)*(sum-1.0) <= 0.0001) 
+        break;
+      else
+        w_bar = w_bar - 0.000001;
+    }
+    
+    // Calculate entropy ...
+    double this_entropy = 0.0;
+    this_entropy -= (1-mut_rate)*log(1-mut_rate)/log(static_cast<double>(num_insts));
+    for (int i = 0; i < num_insts; i ++) {
+      prob[i] = prob[i] * mut_rate;
+      this_entropy += prob[i] * log(static_cast<double>(1.0/prob[i])) / log (static_cast<double>(num_insts));
+    }
+    entropy += this_entropy;
+    
+    // Reset the mod_genome back to the base_genome.
+    mod_genome[line_no].SetOp(cur_inst);
+  }
+  return entropy;
+}
+
 void cAnalyze::CommandFitnessMatrix(cString cur_string)
 {
   if (verbose == true) cout << "Calculating fitness matrix for batch " << cur_batch << endl;
   else cout << "Calculating fitness matrix..." << endl;
-
+  
   cout << "Warning: considering only first genotype of the batch!" << endl;
-
+  
   // Load in the variables...
   int depth_limit = 4;
   if (cur_string.GetSize() != 0) depth_limit = cur_string.PopWord().AsInt();
-
+  
   double fitness_threshold_ratio = .9;
   if (cur_string.GetSize() != 0) fitness_threshold_ratio = cur_string.PopWord().AsDouble();
-
+  
   int ham_thresh  = 1;
   if (cur_string.GetSize() != 0) ham_thresh = cur_string.PopWord().AsInt();
-
+  
   double error_rate_min = 0.005;
   if (cur_string.GetSize() != 0) error_rate_min = cur_string.PopWord().AsDouble();
-
+  
   double error_rate_max = 0.05;
   if (cur_string.GetSize() != 0) error_rate_max = cur_string.PopWord().AsDouble();
-
+  
   double error_rate_step = 0.005;
   if (cur_string.GetSize() != 0) error_rate_step = cur_string.PopWord().AsDouble();
-
+  
   double vect_fmax = 1.1;
   if (cur_string.GetSize() != 0) vect_fmax = cur_string.PopWord().AsDouble();
-
+  
   double vect_fstep = .1;
   if (cur_string.GetSize() != 0) vect_fstep = cur_string.PopWord().AsDouble();
-
+  
   int diag_iters = 200;
   if (cur_string.GetSize() != 0) diag_iters = cur_string.PopWord().AsInt();
-
+  
   int write_ham_vector = 0;
   if (cur_string.GetSize() != 0) write_ham_vector = cur_string.PopWord().AsInt();
-
+  
   int write_full_vector = 0;
   if (cur_string.GetSize() != 0) write_full_vector = cur_string.PopWord().AsInt();
-
+  
   // Consider only the first genotypes in this batch...
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   cAnalyzeGenotype * genotype = batch_it.Next();
-
+  
   cFitnessMatrix matrix( 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 );
 }
 
@@ -2027,24 +2176,24 @@
 void cAnalyze::CommandMapTasks(cString cur_string)
 {
   cout << "Constructing genotype-phenotype maps..." << endl;
-
+  
   // Load in the variables...
   cString directory = PopDirectory(cur_string, "phenotype/");
   int print_mode = 0;   // 0=Normal, 1=Boolean results
   int file_type = FILE_TYPE_TEXT;
-
+  
   // HTML special flags...
   bool link_maps = false;  // Should muliple maps be linked together?
   bool link_insts = false; // Should links be made to instruction descs?
-
+  
   // Collect any other format information needed...
   tList< tDataEntryCommand<cAnalyzeGenotype> > output_list;
   tListIterator< tDataEntryCommand<cAnalyzeGenotype> > output_it(output_list);
-
+  
   cStringList arg_list(cur_string);
-
+  
   cout << "Found " << arg_list.GetSize() << " args." << endl;
-
+  
   // Check for some command specific variables.
   if (arg_list.PopString("0") != "") print_mode = 0;
   if (arg_list.PopString("1") != "") print_mode = 1;
@@ -2052,15 +2201,15 @@
   if (arg_list.PopString("html") != "") file_type = FILE_TYPE_HTML;
   if (arg_list.PopString("link_maps") != "") link_maps = true;
   if (arg_list.PopString("link_insts") != "") link_insts = true;
-
+  
   cout << "There are " << arg_list.GetSize() << " column args." << endl;
-
+  
   LoadGenotypeDataList(arg_list, output_list);
-
+  
   cout << "Args are loaded." << endl;
-
+  
   const int num_cols = output_list.GetSize();
-
+  
   // Give some information in verbose mode.
   if (verbose == true) {
     cout << "  outputing as ";
@@ -2074,23 +2223,23 @@
       cout << "." << endl;
     }
     cout << "  Format: ";
-
+    
     output_it.Reset();
     while (output_it.Next() != NULL) {
       cout << output_it.Get()->GetName() << " ";
     }
     cout << endl;
-  }
-
-
+    }
+  
+  
   ///////////////////////////////////////////////////////
   // Loop through all of the genotypes in this batch...
-
+  
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   cAnalyzeGenotype * genotype = NULL;
   while ((genotype = batch_it.Next()) != NULL) {
     if (verbose == true) cout << "  Mapping " << genotype->GetName() << endl;
-
+    
     // Construct this filename...
     cString filename;
     if (file_type == FILE_TYPE_TEXT) {
@@ -2099,71 +2248,71 @@
       filename.Set("%stasksites.%s.html", directory(), genotype->GetName()());
     }
     ofstream fp(filename());
-
+    
     // Construct linked filenames...
     cString next_file("");
     cString prev_file("");
     if (link_maps == true) {
       // Check the next genotype on the list...
       if (batch_it.Next() != NULL) {
-	next_file.Set("tasksites.%s.html", batch_it.Get()->GetName()());
+        next_file.Set("tasksites.%s.html", batch_it.Get()->GetName()());
       }
       batch_it.Prev();  // Put the list back where it was...
-
+      
       // Check the previous genotype on the list...
       if (batch_it.Prev() != NULL) {
-	prev_file.Set("tasksites.%s.html", batch_it.Get()->GetName()());
+        prev_file.Set("tasksites.%s.html", batch_it.Get()->GetName()());
       }
       batch_it.Next();  // Put the list back where it was...
     }
-
+    
     // Calculate the stats for the genotype we're working with...
     genotype->Recalculate();
-
+    
     // Headers...
     if (file_type == FILE_TYPE_TEXT) {
       fp << "-1 "  << batch[cur_batch].Name() << " "
-	 << genotype->GetID() << " ";
-
+      << genotype->GetID() << " ";
+      
       tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
       while ((data_command = output_it.Next()) != NULL) {
-	data_command->SetTarget(genotype);
-	fp << data_command->GetEntry() << " ";
+        data_command->SetTarget(genotype);
+        fp << data_command->GetEntry() << " ";
       }
       fp << endl;
-
+      
     } else { // if (file_type == FILE_TYPE_HTML) {
-      // Mark file as html
+             // Mark file as html
       fp << "<html>" << endl;
-
+      
       // Setup any javascript macros needed...
       fp << "<head>" << endl;
       if (link_insts == true) {
-	fp << "<script language=\"javascript\">" << endl
-	   << "function Inst(inst_name)" << endl
-	   << "{" << endl
-	   << "var filename = \"help.\" + inst_name + \".html\";" << endl
-	   << "newwin = window.open(filename, 'Instruction', "
-	   << "'toolbar=0,status=0,location=0,directories=0,menubar=0,"
-	   << "scrollbars=1,height=150,width=300');" << endl
-	   << "newwin.focus();" << endl
-	   << "}" << endl
-	   << "</script>" << endl;
+        fp << "<script language=\"javascript\">" << endl
+        << "function Inst(inst_name)" << endl
+        << "{" << endl
+        << "var filename = \"help.\" + inst_name + \".html\";" << endl
+        << "newwin = window.open(filename, 'Instruction', "
+        << "'toolbar=0,status=0,location=0,directories=0,menubar=0,"
+        << "scrollbars=1,height=150,width=300');" << endl
+        << "newwin.focus();" << endl
+        << "}" << endl
+        << "</script>" << endl;
       }
       fp << "</head>" << endl;
-
+      
       // Setup the body...
       fp << "<body bgcolor=\"#FFFFFF\"" << endl
-	 << " text=\"#000000\"" << endl
-	 << " link=\"#0000AA\"" << endl
-	 << " alink=\"#0000FF\"" << endl
-	 << " vlink=\"#000044\">" << endl
-	 << endl
-	 << "<h1 align=center>Run " << batch[cur_batch].Name()
-	 << ", ID " << genotype->GetID() << "</h1>" << endl
-	 << "<center>" << endl
-	 << endl;
-
+        << " text=\"#000000\"" << endl
+        << " link=\"#0000AA\"" << endl
+        << " alink=\"#0000FF\"" << endl
+        << " vlink=\"#000044\">" << endl
+        << endl
+        << "<h1 align=center>Run " << batch[cur_batch].Name()
+        << ", ID " << genotype->GetID() << "</h1>" << endl
+        << "<center>" << endl
+        << endl;
+      
       // Links?
       fp << "<table width=90%><tr><td align=left>";
       if (prev_file != "") fp << "<a href=\"" << prev_file << "\">Prev</a>";
@@ -2172,41 +2321,41 @@
       if (next_file != "") fp << "<a href=\"" << next_file << "\">Next</a>";
       else fp << "&nbsp;";
       fp << "</tr></table>" << endl;
-
+      
       // The table
       fp << "<table border=1 cellpadding=2>" << endl;
-
+      
       // The headings...///
       fp << "<tr><td colspan=3> ";
       output_it.Reset();
       while (output_it.Next() != NULL) {
-	fp << "<th>" << output_it.Get()->GetDesc() << " ";
+        fp << "<th>" << output_it.Get()->GetDesc() << " ";
       }
       fp << "</tr>" << endl;
-
+      
       // The base creature...
       fp << "<tr><th colspan=3>Base Creature";
       tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
       cAnalyzeGenotype null_genotype("a", inst_set);
       while ((data_command = output_it.Next()) != NULL) {
-	data_command->SetTarget(genotype);
-	genotype->SetSpecialArgs(data_command->GetArgs());
-	if (data_command->Compare(&null_genotype) > 0) {
-	  fp << "<th bgcolor=\"#00FF00\">";
-	}
-	else  fp << "<th bgcolor=\"#FF0000\">";
-
-	if (data_command->HasArg("blank") == true) fp << "&nbsp;" << " ";
-	else fp << data_command->GetEntry() << " ";
+        data_command->SetTarget(genotype);
+        genotype->SetSpecialArgs(data_command->GetArgs());
+        if (data_command->Compare(&null_genotype) > 0) {
+          fp << "<th bgcolor=\"#00FF00\">";
+        }
+        else  fp << "<th bgcolor=\"#FF0000\">";
+        
+        if (data_command->HasArg("blank") == true) fp << "&nbsp;" << " ";
+        else fp << data_command->GetEntry() << " ";
       }
       fp << "</tr>" << endl;
     }
-
-
+    
+    
     const int max_line = genotype->GetLength();
     const cGenome & base_genome = genotype->GetGenome();
     cGenome mod_genome(base_genome);
-
+    
     // Keep track of the number of failues/successes for attributes...
     int * col_pass_count = new int[num_cols];
     int * col_fail_count = new int[num_cols];
@@ -2214,7 +2363,7 @@
       col_pass_count[i] = 0;
       col_fail_count[i] = 0;
     }
-
+    
     cInstSet map_inst_set(inst_set);
     // Locate instruction corresponding to "NULL" in the instruction library.
     {
@@ -2232,128 +2381,128 @@
       map_inst_set.Add2(inst_lib_null_inst.GetOp());
     }
     const cInstruction null_inst = map_inst_set.GetInst("NULL");
-
+    
     // Loop through all the lines of code, testing the removal of each.
     for (int line_num = 0; line_num < max_line; line_num++) {
       int cur_inst = base_genome[line_num].GetOp();
       char cur_symbol = base_genome[line_num].GetSymbol();
-
+      
       mod_genome[line_num] = null_inst;
       cAnalyzeGenotype test_genotype(mod_genome, map_inst_set);
       test_genotype.Recalculate();
-
+      
       if (file_type == FILE_TYPE_HTML) fp << "<tr><td align=right>";
       fp << (line_num + 1) << " ";
       if (file_type == FILE_TYPE_HTML) fp << "<td align=center>";
       fp << cur_symbol << " ";
       if (file_type == FILE_TYPE_HTML) fp << "<td align=center>";
       if (link_insts == true) {
-	fp << "<a href=\"javascript:Inst('"
-	   << map_inst_set.GetName(cur_inst)
-	   << "')\">";
+        fp << "<a href=\"javascript:Inst('"
+        << map_inst_set.GetName(cur_inst)
+        << "')\">";
       }
       fp << map_inst_set.GetName(cur_inst) << " ";
       if (link_insts == true) fp << "</a>";
-
-
+      
+      
       // Print the individual columns...
       output_it.Reset();
       tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
       int cur_col = 0;
       while ((data_command = output_it.Next()) != NULL) {
-	data_command->SetTarget(&test_genotype);
-	test_genotype.SetSpecialArgs(data_command->GetArgs());
-	int compare = data_command->Compare(genotype);
-	if (file_type == FILE_TYPE_HTML) {
-	  data_command->HTMLPrint(fp, compare,
-				  !(data_command->HasArg("blank")));
-	} 
-	else fp << data_command->GetEntry() << " ";
-
-	if (compare == -2) col_fail_count[cur_col]++;
-	else if (compare == 2) col_pass_count[cur_col]++;
-	cur_col++;
+        data_command->SetTarget(&test_genotype);
+        test_genotype.SetSpecialArgs(data_command->GetArgs());
+        int compare = data_command->Compare(genotype);
+        if (file_type == FILE_TYPE_HTML) {
+          data_command->HTMLPrint(fp, compare,
+                                  !(data_command->HasArg("blank")));
+        } 
+        else fp << data_command->GetEntry() << " ";
+        
+        if (compare == -2) col_fail_count[cur_col]++;
+        else if (compare == 2) col_pass_count[cur_col]++;
+        cur_col++;
       }
       if (file_type == FILE_TYPE_HTML) fp << "</tr>";
       fp << endl;
-
+      
       // Reset the mod_genome back to the original sequence.
       mod_genome[line_num].SetOp(cur_inst);
     }
-
-
+    
+    
     // Construct the final line of the table with all totals...
     if (file_type == FILE_TYPE_HTML) {
       fp << "<tr><th colspan=3>Totals";
-
+      
       for (int i = 0; i < num_cols; i++) {
-	if (col_pass_count[i] > 0) {
-	  fp << "<th bgcolor=\"#00FF00\">" << col_pass_count[i];
-	}
-	else if (col_fail_count[i] > 0) {
-	  fp << "<th bgcolor=\"#FF0000\">" << col_fail_count[i];
-	}
-	else fp << "<th>0";
+        if (col_pass_count[i] > 0) {
+          fp << "<th bgcolor=\"#00FF00\">" << col_pass_count[i];
+        }
+        else if (col_fail_count[i] > 0) {
+          fp << "<th bgcolor=\"#FF0000\">" << col_fail_count[i];
+        }
+        else fp << "<th>0";
       }
       fp << "</tr>" << endl;
-
+      
       // And close everything up...
       fp << "</table>" << endl
-	 << "</center>" << endl;
+        << "</center>" << endl;
     }
-
+    
     delete [] col_pass_count;
     delete [] col_fail_count;
+    
+    }
+    }
 
-  }
-}
-
 void cAnalyze::CommandAverageModularity(cString cur_string)
 {
   cout << "Average Modularity calculations" << endl;
-
+  
   // Load in the variables...
   cString filename = cur_string.PopWord();
-//    cString filename = "average.dat";
-
+  //    cString filename = "average.dat";
+  
   int print_mode = 0;   // 0=Normal, 1=Boolean results
-
+  
   // Collect any other format information needed...
   tList< tDataEntryCommand<cAnalyzeGenotype> > output_list;
   tListIterator< tDataEntryCommand<cAnalyzeGenotype> > output_it(output_list);
-
+  
   cStringList arg_list(cur_string);
-
+  
   cout << "Found " << arg_list.GetSize() << " args." << endl;
-
+  
   // Check for some command specific variables.
   if (arg_list.PopString("0") != "") print_mode = 0;
   if (arg_list.PopString("1") != "") print_mode = 1;
-
+  
   cout << "There are " << arg_list.GetSize() << " column args." << endl;
-
+  
   LoadGenotypeDataList(arg_list, output_list);
-
+  
   cout << "Args are loaded." << endl;
-
+  
   const int num_cols = output_list.GetSize();
-
+  
   // Give some information in verbose mode.
   if (verbose == true) {
     cout << "  outputing as ";
     if (print_mode == 1) cout << "boolean ";
-      cout << "text files." << endl;
+    cout << "text files." << endl;
     cout << "  Format: ";
-
+    
     output_it.Reset();
     while (output_it.Next() != NULL) {
       cout << output_it.Get()->GetName() << " ";
     }
     cout << endl;
   }
-
-    ofstream & fp = data_file_manager.GetOFStream(filename);
-
+  
+  ofstream & fp = data_file_manager.GetOFStream(filename);
+  
   // printing the headers
   // not done by default since many dumps may be analyzed at the same time
   // and results would be put in the same file
@@ -2374,280 +2523,280 @@
     fp << "# 37-45: average task length (distance from first to last inst used)" << endl;
     fp << endl;
     return;
-}        
-
+  }        
+  
   // initialize various variables used in calculations
-
-    int num_orgs = 0;		// number of organisms in the dump
-
-    double  av_length = 0; 	// average organism length
-    double  av_task = 0; 	// average # of tasks done
-    double  av_inst = 0; 	// average # instructions used in tasks
-    double  av_inst_len = 0; 	// proportion of sites used for tasks
-    double  av_site_task = 0; 	// average number of sites per task
-    double  av_task_site = 0;   // average number of tasks per site
-    double  av_t_s_norm = 0;	// average number of tasks per site per task
-    double  av_task_overlap = 0; // average overlap between tasks
-
-    // average StDev in positions used for a task
-    tArray<double> std_task_position(num_cols);
-    std_task_position.SetAll(0.0);
-    
-    // # of organisms actually doing a task
-    tArray<double> org_task(num_cols);
-    org_task.SetAll(0.0);
-
-    // av. # of sites necessary for each of the tasks
-    tArray<double> av_num_inst(num_cols);
-    av_num_inst.SetAll(0.0);
-    
-    // number of sites involved in 0-9 tasks 
-    tArray<double> av_inst_task(num_cols+1);
-    av_inst_task.SetAll(0.0);
-
-    // av. # task length (distance from first to last site used)
-    tArray<double> av_task_length(num_cols);
-    av_task_length.SetAll(0.0);
-
-    
+  
+  int num_orgs = 0;		// number of organisms in the dump
+  
+  double  av_length = 0; 	// average organism length
+  double  av_task = 0; 	// average # of tasks done
+  double  av_inst = 0; 	// average # instructions used in tasks
+  double  av_inst_len = 0; 	// proportion of sites used for tasks
+  double  av_site_task = 0; 	// average number of sites per task
+  double  av_task_site = 0;   // average number of tasks per site
+  double  av_t_s_norm = 0;	// average number of tasks per site per task
+  double  av_task_overlap = 0; // average overlap between tasks
+  
+  // average StDev in positions used for a task
+  tArray<double> std_task_position(num_cols);
+  std_task_position.SetAll(0.0);
+  
+  // # of organisms actually doing a task
+  tArray<double> org_task(num_cols);
+  org_task.SetAll(0.0);
+  
+  // av. # of sites necessary for each of the tasks
+  tArray<double> av_num_inst(num_cols);
+  av_num_inst.SetAll(0.0);
+  
+  // number of sites involved in 0-9 tasks 
+  tArray<double> av_inst_task(num_cols+1);
+  av_inst_task.SetAll(0.0);
+  
+  // av. # task length (distance from first to last site used)
+  tArray<double> av_task_length(num_cols);
+  av_task_length.SetAll(0.0);
+  
+  
   ///////////////////////////////////////////////////////
   // Loop through all of the genotypes in this batch...
   ///////////////////////////////////////////////////////
-
+  
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   cAnalyzeGenotype * genotype = NULL;
-
+  
   // would like to test oly the viable ones, but they can be non-viable
   // and still reproduce and do tasks
   // while ((genotype = batch_it.Next()) != NULL && genotype->GetViable()) {
   while ((genotype = batch_it.Next()) != NULL) {
-
+    
     int num_cpus = genotype->GetNumCPUs();
-
+    
     if (verbose == true) cout << "  Mapping " << genotype->GetName() << endl;
- 
+    
     // Calculate the stats for the genotype we're working with...
     genotype->Recalculate();
-
+    
     // Check if the organism does any tasks. 
     int does_tasks = 0;
     for (int i = 0; i < num_cols; i++) {
       if (genotype->GetTaskCount(i) > 0)  does_tasks = 1;
     }
-
-   // Don't calculate the modularity if the organism doesn't reproduce
-   // i.e. if the fitness is 0 
-   if (genotype->GetFitness() != 0 && does_tasks != 0) {
-    num_orgs = num_orgs + num_cpus;
-
-    const int max_line = genotype->GetLength();
-    const cGenome & base_genome = genotype->GetGenome();
-    cGenome mod_genome(base_genome);
-
-    // Create and initialize the modularity matrix
-    tMatrix<int> mod_matrix(num_cols, max_line);
-    mod_matrix.SetAll(0);
-
-    // Create and initialize the task overalp matrix
-    tMatrix<int> task_overlap(num_cols, num_cols);
-    task_overlap.SetAll(0);
-
-    // Create an initialize the counters for modularity
-    tArray<int> num_task(max_line); // number of tasks instruction is used in
-    tArray<int> num_inst(num_cols); // number of instructions involved in a task
-    tArray<int> sum(num_cols); 	    // helps with StDev calculations
-    tArray<int> sumsq(num_cols);    // helps with StDev calculations
-    tArray<int> inst_task(num_cols+1); // # of inst's involved in 0,1,2,3... tasks
-    tArray<int> task_length(num_cols);    // ditance between first and last inst involved in a task
-
-    num_task.SetAll(0);
-    num_inst.SetAll(0);
-    sum.SetAll(0);
-    sumsq.SetAll(0);
-    inst_task.SetAll(0);
-    task_length.SetAll(0);
-
-    int total_task = 0;        // total number of tasks done
-    int total_inst = 0;        // total number of instructions involved in tasks
-    int total_all = 0;         // sum of mod_matrix
-    double sum_task_overlap = 0;// task overlap for for this geneome
-
-    cInstSet map_inst_set(inst_set);
-
-    // Locate instruction corresponding to "NULL" in the instruction library.
-    {
-      const cInstruction inst_lib_null_inst = map_inst_set.GetInstLib()->GetInst("NULL");
-      if(inst_lib_null_inst == map_inst_set.GetInstLib()->GetInstError()){
-        cout << "<cAnalyze::CommandMapTasks> got error:" << endl;
-        cout << " --- instruction \"NULL\" isn't in the instruction library;" << endl;
-        cout << " --- get somebody to map a function to \"NULL\" in the library." << endl;
-        cout << " --- (probably to class method \"cHardware-of-some-type::initInstLib\"" << endl;
-        cout << " --- in file named \"cpu/hardware-of-some-type.cc\".)" << endl;
-        cout << " --- bailing-out." << endl;
-        exit(1);
-      }
-      // Add mapping to located instruction. 
-      map_inst_set.Add2(inst_lib_null_inst.GetOp());
-    }
-    const cInstruction null_inst = map_inst_set.GetInst("NULL");
-
-    // Loop through all the lines of code, testing the removal of each.
-    for (int line_num = 0; line_num < max_line; line_num++) {
-      int cur_inst = base_genome[line_num].GetOp();
-
-      mod_genome[line_num] = null_inst;
-      cAnalyzeGenotype test_genotype(mod_genome, map_inst_set);
-      cAnalyzeGenotype old_genotype(base_genome, map_inst_set);
-      test_genotype.Recalculate();
-
-      // Print the individual columns...
-      output_it.Reset();
-      tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
-      int cur_col = 0;
-      while ((data_command = output_it.Next()) != NULL) {
-	data_command->SetTarget(&test_genotype);
-	test_genotype.SetSpecialArgs(data_command->GetArgs());
-        // This is done so that under 'binary' option it marks
-        // the task as being influenced by the mutation iff
-        // it is completely knocked out, not just decreased
-        genotype->SetSpecialArgs(data_command->GetArgs());
-
-	int compare = data_command->Compare(genotype);
-
-	// If knocking out an instruction stops the expression of a
-	// particular task, mark that in the modularity matrix
-	// and add it to two counts
-	// Only do the checking if the test_genotype replicate, i.e.
-	// if it's fitness is not zeros
-
-	if (compare < 0  && test_genotype.GetFitness() != 0) {
-		mod_matrix(cur_col,line_num) = 1;
-		num_inst[cur_col]++;
-		num_task[line_num]++;
-	}
-	cur_col++;
-      }
-
-      // Reset the mod_genome back to the original sequence.
-      mod_genome[line_num].SetOp(cur_inst);
-    } // end of genotype-phenotype mapping for a single organism
     
-    for (int i = 0; i < num_cols; i++) {if (num_inst[i] != 0) total_task++;}
-    for (int i = 0; i < max_line; i++) {if (num_task[i] != 0) total_inst++;}
-    for (int i = 0; i < num_cols; i++) {total_all = total_all + num_inst[i];}
-
-    // Add the values to the av_ variables, used for calculating the average
-    // in order to weigh them by abundance, multiply everything by num_cpus
-
-    av_length = av_length + max_line*num_cpus;
-    av_task = av_task + total_task*num_cpus;
-    av_inst = av_inst + total_inst*num_cpus;
-    av_inst_len = av_inst_len + (double) total_inst*num_cpus/max_line;
-
-    if (total_task !=0)  av_site_task = av_site_task + num_cpus * (double) total_all/total_task; 
-    if (total_inst !=0)  av_task_site = av_task_site + num_cpus * (double) total_all/total_inst; 
-    if (total_inst !=0 && total_task !=0) {
-	av_t_s_norm = av_t_s_norm + num_cpus * (double) total_all/(total_inst*total_task); 
-    }
-
-    for (int i = 0; i < num_cols; i++) { 
-	if (num_inst[i] > 0) {
-		av_num_inst[i] = av_num_inst[i] + num_inst[i] * num_cpus;
-		org_task[i] = org_task[i] + num_cpus;   // count how many are actually doing the task
-	}
-    }	
-
-    // calculate average task overlap
-    // first construct num_task x num_task matrix with number of sites overlapping
-    for (int i = 0; i < max_line; i++) {
-        for (int j = 0; j < num_cols; j++) {
-           for (int k = j; k < num_cols; k++) {
-               if (mod_matrix(j,i)>0 && mod_matrix(k,i)>0) {
-                       task_overlap(j,k)++;
-                       if (j!=k) task_overlap(k,j)++;
-               }               
-           }
-       }
-    }
-
-    // go though the task_overlap matrix, add and average everything up. 
-    if (total_task > 1) {
-       for (int i = 0; i < num_cols; i++) {
-          double overlap_per_task = 0;                 
+    // Don't calculate the modularity if the organism doesn't reproduce
+    // i.e. if the fitness is 0 
+    if (genotype->GetFitness() != 0 && does_tasks != 0) {
+      num_orgs = num_orgs + num_cpus;
+      
+      const int max_line = genotype->GetLength();
+      const cGenome & base_genome = genotype->GetGenome();
+      cGenome mod_genome(base_genome);
+      
+      // Create and initialize the modularity matrix
+      tMatrix<int> mod_matrix(num_cols, max_line);
+      mod_matrix.SetAll(0);
+      
+      // Create and initialize the task overalp matrix
+      tMatrix<int> task_overlap(num_cols, num_cols);
+      task_overlap.SetAll(0);
+      
+      // Create an initialize the counters for modularity
+      tArray<int> num_task(max_line); // number of tasks instruction is used in
+      tArray<int> num_inst(num_cols); // number of instructions involved in a task
+      tArray<int> sum(num_cols); 	    // helps with StDev calculations
+      tArray<int> sumsq(num_cols);    // helps with StDev calculations
+      tArray<int> inst_task(num_cols+1); // # of inst's involved in 0,1,2,3... tasks
+      tArray<int> task_length(num_cols);    // ditance between first and last inst involved in a task
+      
+      num_task.SetAll(0);
+      num_inst.SetAll(0);
+      sum.SetAll(0);
+      sumsq.SetAll(0);
+      inst_task.SetAll(0);
+      task_length.SetAll(0);
+      
+      int total_task = 0;        // total number of tasks done
+      int total_inst = 0;        // total number of instructions involved in tasks
+      int total_all = 0;         // sum of mod_matrix
+      double sum_task_overlap = 0;// task overlap for for this geneome
+        
+        cInstSet map_inst_set(inst_set);
+        
+        // Locate instruction corresponding to "NULL" in the instruction library.
+        {
+          const cInstruction inst_lib_null_inst = map_inst_set.GetInstLib()->GetInst("NULL");
+          if(inst_lib_null_inst == map_inst_set.GetInstLib()->GetInstError()){
+            cout << "<cAnalyze::CommandMapTasks> got error:" << endl;
+            cout << " --- instruction \"NULL\" isn't in the instruction library;" << endl;
+            cout << " --- get somebody to map a function to \"NULL\" in the library." << endl;
+            cout << " --- (probably to class method \"cHardware-of-some-type::initInstLib\"" << endl;
+            cout << " --- in file named \"cpu/hardware-of-some-type.cc\".)" << endl;
+            cout << " --- bailing-out." << endl;
+            exit(1);
+          }
+          // Add mapping to located instruction. 
+          map_inst_set.Add2(inst_lib_null_inst.GetOp());
+        }
+        const cInstruction null_inst = map_inst_set.GetInst("NULL");
+        
+        // Loop through all the lines of code, testing the removal of each.
+        for (int line_num = 0; line_num < max_line; line_num++) {
+          int cur_inst = base_genome[line_num].GetOp();
+          
+          mod_genome[line_num] = null_inst;
+          cAnalyzeGenotype test_genotype(mod_genome, map_inst_set);
+          cAnalyzeGenotype old_genotype(base_genome, map_inst_set);
+          test_genotype.Recalculate();
+          
+          // Print the individual columns...
+          output_it.Reset();
+          tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
+          int cur_col = 0;
+          while ((data_command = output_it.Next()) != NULL) {
+            data_command->SetTarget(&test_genotype);
+            test_genotype.SetSpecialArgs(data_command->GetArgs());
+            // This is done so that under 'binary' option it marks
+            // the task as being influenced by the mutation iff
+            // it is completely knocked out, not just decreased
+            genotype->SetSpecialArgs(data_command->GetArgs());
+            
+            int compare = data_command->Compare(genotype);
+            
+            // If knocking out an instruction stops the expression of a
+            // particular task, mark that in the modularity matrix
+            // and add it to two counts
+            // Only do the checking if the test_genotype replicate, i.e.
+            // if it's fitness is not zeros
+            
+            if (compare < 0  && test_genotype.GetFitness() != 0) {
+              mod_matrix(cur_col,line_num) = 1;
+              num_inst[cur_col]++;
+              num_task[line_num]++;
+            }
+            cur_col++;
+          }
+          
+          // Reset the mod_genome back to the original sequence.
+          mod_genome[line_num].SetOp(cur_inst);
+        } // end of genotype-phenotype mapping for a single organism
+        
+        for (int i = 0; i < num_cols; i++) {if (num_inst[i] != 0) total_task++;}
+        for (int i = 0; i < max_line; i++) {if (num_task[i] != 0) total_inst++;}
+        for (int i = 0; i < num_cols; i++) {total_all = total_all + num_inst[i];}
+        
+        // Add the values to the av_ variables, used for calculating the average
+        // in order to weigh them by abundance, multiply everything by num_cpus
+        
+        av_length = av_length + max_line*num_cpus;
+        av_task = av_task + total_task*num_cpus;
+        av_inst = av_inst + total_inst*num_cpus;
+        av_inst_len = av_inst_len + (double) total_inst*num_cpus/max_line;
+        
+        if (total_task !=0)  av_site_task = av_site_task + num_cpus * (double) total_all/total_task; 
+        if (total_inst !=0)  av_task_site = av_task_site + num_cpus * (double) total_all/total_inst; 
+        if (total_inst !=0 && total_task !=0) {
+          av_t_s_norm = av_t_s_norm + num_cpus * (double) total_all/(total_inst*total_task); 
+        }
+        
+        for (int i = 0; i < num_cols; i++) { 
+          if (num_inst[i] > 0) {
+            av_num_inst[i] = av_num_inst[i] + num_inst[i] * num_cpus;
+            org_task[i] = org_task[i] + num_cpus;   // count how many are actually doing the task
+          }
+        }	
+        
+        // calculate average task overlap
+        // first construct num_task x num_task matrix with number of sites overlapping
+        for (int i = 0; i < max_line; i++) {
           for (int j = 0; j < num_cols; j++) {
-               if (i!=j) {overlap_per_task = overlap_per_task + task_overlap(i,j);}
+            for (int k = j; k < num_cols; k++) {
+              if (mod_matrix(j,i)>0 && mod_matrix(k,i)>0) {
+                task_overlap(j,k)++;
+                if (j!=k) task_overlap(k,j)++;
+              }               
+            }
           }
-          if (task_overlap(i,i) !=0){
+        }
+        
+        // go though the task_overlap matrix, add and average everything up. 
+        if (total_task > 1) {
+          for (int i = 0; i < num_cols; i++) {
+            double overlap_per_task = 0;                 
+            for (int j = 0; j < num_cols; j++) {
+              if (i!=j) {overlap_per_task = overlap_per_task + task_overlap(i,j);}
+            }
+            if (task_overlap(i,i) !=0){
               sum_task_overlap = sum_task_overlap + overlap_per_task / (task_overlap(i,i) * (total_task-1));   
+            }
           }
-       }
-    }
-
-    // now, divide that by number of tasks done and add to the grand sum, weigthed by num_cpus 
-    if (total_task!=0) {
-       av_task_overlap = av_task_overlap + num_cpus * (double) sum_task_overlap/total_task ;
-}
-    // calculate the first/last postion of a task, the task "spread"
-    // starting from the top look for the fist command that matters for a task
-
-    for (int i = 0; i < num_cols; i++) { 
-       int j = 0; 
-       while (j < max_line) {
+        }
+        
+        // now, divide that by number of tasks done and add to the grand sum, weigthed by num_cpus 
+        if (total_task!=0) {
+          av_task_overlap = av_task_overlap + num_cpus * (double) sum_task_overlap/total_task ;
+        }
+        // calculate the first/last postion of a task, the task "spread"
+        // starting from the top look for the fist command that matters for a task
+        
+        for (int i = 0; i < num_cols; i++) { 
+          int j = 0; 
+          while (j < max_line) {
             if (mod_matrix(i,j) > 0 && task_length[i] == 0 ) {
-               task_length[i] = j;
-               break;
+              task_length[i] = j;
+              break;
             }
             j++;
-       }
-     }
-
-    // starting frm the bottom look for the last command that matters for a task
-    // and substract it from the first to get the task length
-    // add one in order to account for both the beginning and the end instruction
-    for (int i = 0; i < num_cols; i++) { 
-       int j = max_line - 1; 
-       while (j > -1) {
+          }
+        }
+        
+        // starting frm the bottom look for the last command that matters for a task
+        // and substract it from the first to get the task length
+        // add one in order to account for both the beginning and the end instruction
+        for (int i = 0; i < num_cols; i++) { 
+          int j = max_line - 1; 
+          while (j > -1) {
             if (mod_matrix(i,j) > 0) {
-               task_length[i] = j - task_length[i] + 1;
-               break;
+              task_length[i] = j - task_length[i] + 1;
+              break;
             }
             j--;
-       }
+          }
+        }
+        // add the task lengths to the average for the batch
+        // weigthed by the number of cpus for that genotype 
+        for (int i = 0; i < num_cols; i++) { 
+          av_task_length[i] = av_task_length[i] +  num_cpus * task_length[i];
+        }
+        
+        // calculate the Standard Deviation in the mean position of the task
+        for (int i = 0; i < num_cols; i++) { 
+          for (int j = 0; j < max_line; j++) { 
+            if (mod_matrix(i,j)>0) sum[i] = sum[i] + j;
+          }		
+        }
+        
+        double temp = 0;
+        for (int i = 0; i < num_cols; i++) {
+          if (num_inst[i]>1) { 
+            double av_sum = sum[i]/num_inst[i];
+            for (int j = 0; j < max_line; j++) {
+              if (mod_matrix(i,j)>0) temp = (av_sum - j)*(av_sum - j);
+            }
+            std_task_position[i] = std_task_position[i] + sqrt(temp/(num_inst[i]-1))*num_cpus;
+          } 
+        } 
+        
+        for (int i = 0; i < max_line; i++) { inst_task[num_task[i]]++ ;}
+        for (int i = 0; i < num_cols+1; i++) { av_inst_task[i] = av_inst_task[i] + inst_task[i] * num_cpus;}
+        
     }
-   // add the task lengths to the average for the batch
-   // weigthed by the number of cpus for that genotype 
-   for (int i = 0; i < num_cols; i++) { 
-       av_task_length[i] = av_task_length[i] +  num_cpus * task_length[i];
-   }
-
-    // calculate the Standard Deviation in the mean position of the task
-    for (int i = 0; i < num_cols; i++) { 
-	for (int j = 0; j < max_line; j++) { 
-		if (mod_matrix(i,j)>0) sum[i] = sum[i] + j;
-	}		
-    }
-
-    double temp = 0;
-    for (int i = 0; i < num_cols; i++) {
-	if (num_inst[i]>1) { 
-		double av_sum = sum[i]/num_inst[i];
-		for (int j = 0; j < max_line; j++) {
-			if (mod_matrix(i,j)>0) temp = (av_sum - j)*(av_sum - j);
-		}
-		std_task_position[i] = std_task_position[i] + sqrt(temp/(num_inst[i]-1))*num_cpus;
-	} 
-    } 
-
-    for (int i = 0; i < max_line; i++) { inst_task[num_task[i]]++ ;}
-    for (int i = 0; i < num_cols+1; i++) { av_inst_task[i] = av_inst_task[i] + inst_task[i] * num_cpus;}
-
-   }
   }  // this is the end of the loop going though all the organisms
-
- // make sure there are some organisms doing task in this batch
- // if not, return all zeros
-
- if (num_orgs != 0) { 
+  
+  // make sure there are some organisms doing task in this batch
+  // if not, return all zeros
+  
+  if (num_orgs != 0) { 
     fp << (double) av_length/num_orgs  << " ";  	// 1: average length
     fp << (double) av_task/num_orgs << " ";		// 2: av. number of tasks done
     fp << (double) av_inst/num_orgs << " ";		// 3: av. number of sites used for tasks
@@ -2657,57 +2806,57 @@
     fp << (double) av_t_s_norm/num_orgs << " ";		// 7: av. number of tasks per site per task
     fp << (double) 1 - av_task_overlap/num_orgs << " ";        // 8: av. proportion of a task that DOESN'T overlap
     for (int i = 0; i < num_cols; i++) {
-	if (org_task[i] > 0) fp << std_task_position[i]/org_task[i]  << " ";
-        else fp << 0 << " ";
+      if (org_task[i] > 0) fp << std_task_position[i]/org_task[i]  << " ";
+      else fp << 0 << " ";
     }
     for (int i = 0; i < num_cols; i++) {
-        if (org_task[i] > 0) fp << (double) av_num_inst[i]/org_task[i]  << " ";
-        else fp << 0 << " ";
+      if (org_task[i] > 0) fp << (double) av_num_inst[i]/org_task[i]  << " ";
+      else fp << 0 << " ";
     }
     for (int i = 0; i < num_cols+1; i++) { fp << (double) av_inst_task[i]/num_orgs  << " ";}
     for (int i = 0; i < num_cols; i++) { fp << (double) av_task_length[i]/num_orgs  << " ";}
     fp << endl;
-    }
-
- else {
+  }
+  
+  else {
     for (int i = 0; i < 8+4*num_cols+1; i++) {fp << "0 ";}
     fp << endl;
- }
-}
+  }
+  }
 
 
 void cAnalyze::CommandMapMutations(cString cur_string)
 {
   cout << "Constructing genome mutations maps..." << endl;
-
+  
   // Load in the variables...
   cString directory = PopDirectory(cur_string, "mutations/");
   int file_type = FILE_TYPE_TEXT;
-
+  
   cStringList arg_list(cur_string);
-
+  
   // Check for some command specific variables.
   if (arg_list.PopString("text") != "") file_type = FILE_TYPE_TEXT;
   if (arg_list.PopString("html") != "") file_type = FILE_TYPE_HTML;
-
+  
   // Give some information in verbose mode.
   if (verbose == true) {
     cout << "  outputing as ";
     if (file_type == FILE_TYPE_TEXT) cout << "text files." << endl;
     else cout << "HTML files." << endl;
   }
-
-
+  
+  
   ///////////////////////////////////////////////////////
   // Loop through all of the genotypes in this batch...
-
+  
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   cAnalyzeGenotype * genotype = NULL;
   while ((genotype = batch_it.Next()) != NULL) {
     if (verbose == true) {
       cout << "  Creating mutation map for " << genotype->GetName() << endl;
     }
-
+    
     // Construct this filename...
     cString filename;
     if (file_type == FILE_TYPE_TEXT) {
@@ -2716,18 +2865,18 @@
       filename.Set("%smut_map.%s.html", directory(), genotype->GetName()());
     }
     ofstream fp(filename());
-
+    
     // Calculate the stats for the genotype we're working with...
     genotype->Recalculate();
     const double base_fitness = genotype->GetFitness();
     const int num_insts = inst_set.GetSize();
-
+    
     // Headers...
     if (file_type == FILE_TYPE_TEXT) {
       fp << "# 1: Genome instruction ID (pre-mutation)" << endl;
       for (int i = 0; i < num_insts; i++) {
-	fp << "# " << i+1 <<": Fit if mutated to '"
-	   << inst_set.GetName(i) << "'" << endl;
+        fp << "# " << i+1 <<": Fit if mutated to '"
+        << inst_set.GetName(i) << "'" << endl;
       }
       fp << "# " << num_insts + 2 << ": Knockout" << endl;
       fp << "# " << num_insts + 3 << ": Fraction Lethal" << endl;
@@ -2738,30 +2887,30 @@
       fp << "# " << num_insts + 8 << ": Expected Entropy" << endl;
       fp << "# " << num_insts + 9 << ": Original Instruction Name" << endl;
       fp << endl;
-
+      
     } else { // if (file_type == FILE_TYPE_HTML) {
-      // Mark file as html
+             // Mark file as html
       fp << "<html>" << endl;
-
+      
       // Setup the body...
       fp << "<body bgcolor=\"#FFFFFF\"" << endl
-	 << " text=\"#000000\"" << endl
-	 << " link=\"#0000AA\"" << endl
-	 << " alink=\"#0000FF\"" << endl
-	 << " vlink=\"#000044\">" << endl
-	 << endl
-	 << "<h1 align=center>Mutation Map for Run " << batch[cur_batch].Name()
-	 << ", ID " << genotype->GetID() << "</h1>" << endl
-	 << "<center>" << endl
-	 << endl;
-
+        << " text=\"#000000\"" << endl
+        << " link=\"#0000AA\"" << endl
+        << " alink=\"#0000FF\"" << endl
+        << " vlink=\"#000044\">" << endl
+        << endl
+        << "<h1 align=center>Mutation Map for Run " << batch[cur_batch].Name()
+        << ", ID " << genotype->GetID() << "</h1>" << endl
+        << "<center>" << endl
+        << endl;
+      
       // The main chart...
       fp << "<table border=1 cellpadding=2>" << endl;
-
+      
       // The headings...///
       fp << "<tr><th>Genome ";
       for (int i = 0; i < num_insts; i++) {
-	fp << "<th>" << inst_set.GetName(i) << " ";
+        fp << "<th>" << inst_set.GetName(i) << " ";
       }
       fp << "<th>Knockout ";
       fp << "<th>Frac. Lethal ";
@@ -2772,17 +2921,17 @@
       fp << "<th>Expected Entropy ";
       fp << "</tr>" << endl << endl;
     }
-
+    
     const int max_line = genotype->GetLength();
     const cGenome & base_genome = genotype->GetGenome();
     cGenome mod_genome(base_genome);
-
+    
     // Keep track of the number of mutations in each category...
     int total_dead = 0, total_neg = 0, total_neut = 0, total_pos = 0;
     double total_fitness = 0.0;
     tArray<double> col_fitness(num_insts + 1);
     col_fitness.SetAll(0.0);
-
+    
     // Build an empty instruction into the an instruction library.
     cInstSet map_inst_set(inst_set);
     // Locate instruction corresponding to "NULL" in the instruction library.
@@ -2801,22 +2950,22 @@
       map_inst_set.Add2(inst_lib_null_inst.GetOp());
     }
     const cInstruction null_inst = map_inst_set.GetInst("NULL");
-
+    
     cString color_string;  // For coloring cells...
-
+    
     // Loop through all the lines of code, testing all mutations...
     for (int line_num = 0; line_num < max_line; line_num++) {
       int cur_inst = base_genome[line_num].GetOp();
       char cur_symbol = base_genome[line_num].GetSymbol();
       int row_dead = 0, row_neg = 0, row_neut = 0, row_pos = 0;
       double row_fitness = 0.0;
-
+      
       // Column 1... the original instruction in the geneome.
       if (file_type == FILE_TYPE_HTML) {
-	fp << "<tr><td align=right>" << inst_set.GetName(cur_inst)
-	   << " (" << cur_symbol << ") ";
+        fp << "<tr><td align=right>" << inst_set.GetName(cur_inst)
+        << " (" << cur_symbol << ") ";
       } else {
-	fp << cur_inst << " ";
+        fp << cur_inst << " ";
       }
       
       // Columns 2 to D+1 (the possible mutations)
@@ -2836,7 +2985,7 @@
           row_fitness += test_fitness;
           total_fitness += test_fitness;
           col_fitness[mod_inst] += test_fitness;
-
+          
           // Categorize this mutation...
           if (test_fitness == 1.0) {           // Neutral Mutation...
             row_neut++;
@@ -2855,7 +3004,7 @@
             total_pos++;
             if (file_type == FILE_TYPE_HTML) color_string = "#00FF00";
           }
-
+          
           // Write out this cell...
           if (file_type == FILE_TYPE_HTML) {
             fp << "<th bgcolor=\"" << color_string << "\">";
@@ -2863,44 +3012,44 @@
           fp << test_fitness << " ";
         }
       }
-
+      
       // Column: Knockout
       mod_genome[line_num] = null_inst;
       cAnalyzeGenotype test_genotype(mod_genome, map_inst_set);
       test_genotype.Recalculate();
       const double test_fitness = test_genotype.GetFitness() / base_fitness;
       col_fitness[num_insts] += test_fitness;
-
+      
       // Categorize this mutation if its in HTML mode (color only)...
       if (file_type == FILE_TYPE_HTML) {
         if (test_fitness == 1.0) color_string = "#FFFFFF";
         else if (test_fitness == 0.0) color_string = "#FF0000";
         else if (test_fitness < 1.0) color_string = "#FFFF00";
         else color_string = "#00FF00";
-
+        
         fp << "<th bgcolor=\"" << color_string << "\">";
       }
-
+      
       fp << test_fitness << " ";
-
+      
       // Fraction Columns...
       if (file_type == FILE_TYPE_HTML) fp << "<th bgcolor=\"#FF0000\">";
       fp << (double) row_dead / (double) (num_insts-1) << " ";
-
+      
       if (file_type == FILE_TYPE_HTML) fp << "<th bgcolor=\"#FFFF00\">";
       fp << (double) row_neg / (double) (num_insts-1) << " ";
-
+      
       if (file_type == FILE_TYPE_HTML) fp << "<th bgcolor=\"#FFFFFF\">";
       fp << (double) row_neut / (double) (num_insts-1) << " ";
-
+      
       if (file_type == FILE_TYPE_HTML) fp << "<th bgcolor=\"#00FF00\">";
       fp << (double) row_pos / (double) (num_insts-1) << " ";
-
-
+      
+      
       // Column: Average Fitness
       if (file_type == FILE_TYPE_HTML) fp << "<th>";
       fp << row_fitness / (double) (num_insts-1) << " ";
-
+      
       // Column: Expected Entropy  @CAO Implement!
       if (file_type == FILE_TYPE_HTML) fp << "<th>";
       fp << 0.0 << " ";
@@ -2908,21 +3057,21 @@
       // End this row...
       if (file_type == FILE_TYPE_HTML) fp << "</tr>";
       fp << endl;
-
+      
       // Reset the mod_genome back to the original sequence.
       mod_genome[line_num].SetOp(cur_inst);
     }
-
-
+    
+    
     // Construct the final line of the table with all totals...
     if (file_type == FILE_TYPE_HTML) {
       fp << "<tr><th>Totals";
       
       // Instructions + Knockout
       for (int i = 0; i <= num_insts; i++) {
-	fp << "<th>" << col_fitness[i] / max_line << " ";
+        fp << "<th>" << col_fitness[i] / max_line << " ";
       }
-
+      
       int total_tests = max_line * (num_insts-1);
       fp << "<th>" << (double) total_dead / (double) total_tests << " ";
       fp << "<th>" << (double) total_neg / (double) total_tests << " ";
@@ -2930,30 +3079,30 @@
       fp << "<th>" << (double) total_pos / (double) total_tests << " ";
       fp << "<th>" << total_fitness / (double) total_tests << " ";
       fp << "<th>" << 0.0 << " ";
-
-
+      
+      
       // And close everything up...
       fp << "</table>" << endl
-	 << "</center>" << endl;
+        << "</center>" << endl;
     }
+    
+    }
+    }
 
-  }
-}
 
-
 void cAnalyze::CommandMapDepth(cString cur_string)
 {
   cout << "Constructing depth map..." << endl;
-
+  
   cString filename("depth_map.dat");
   if (cur_string.GetSize() != 0) filename = cur_string.PopWord();  
-
+  
   int min_batch = 0;
   int max_batch = cur_batch - 1;
-
+  
   if (cur_string.GetSize() != 0) min_batch = cur_string.PopWord().AsInt();
   if (cur_string.GetSize() != 0) max_batch = cur_string.PopWord().AsInt();
-
+  
   // First, scan all of the batches to find the maximum depth.
   int max_depth = -1;
   cAnalyzeGenotype * genotype;
@@ -2963,11 +3112,11 @@
       if (genotype->GetDepth() > max_depth) max_depth = genotype->GetDepth();
     }
   }
-
+  
   cout << "max_depth = " << max_depth << endl;
-
+  
   ofstream & fp = data_file_manager.GetOFStream(filename);
-
+  
   cout << "Output to " << filename << endl;
   tArray<int> depth_array(max_depth+1);
   for (cur_batch = min_batch; cur_batch <= max_batch; cur_batch++) {
@@ -2978,7 +3127,7 @@
       const int cur_count = genotype->GetNumCPUs();
       depth_array[cur_depth] += cur_count;
     }
-
+    
     for (int i = 0; i <= max_depth; i++) {
       fp << depth_array[i] << " ";
     }
@@ -2990,33 +3139,33 @@
 {
   cString filename("hamming.dat");
   if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-
+  
   int batch1 = PopBatch(cur_string.PopWord());
   int batch2 = PopBatch(cur_string.PopWord());
-
+  
   // We want batch2 to be the larger one for efficiency...
   if (batch[batch1].List().GetSize() > batch[batch2].List().GetSize()) {
     int tmp = batch1;  batch1 = batch2;  batch2 = tmp;
   }
-
+  
   if (verbose == false) {
     cout << "Calculating Hamming Distance... ";
     cout.flush();
   } else {
     cout << "Calculating Hamming Distance between batches "
-	 << batch1 << " and " << batch2 << endl;
+    << batch1 << " and " << batch2 << endl;
     cout.flush();
   }
-
+  
   // Setup some variables;
   cAnalyzeGenotype * genotype1 = NULL;
   cAnalyzeGenotype * genotype2 = NULL;
   int total_dist = 0;
   int total_count = 0;
-
+  
   tListIterator<cAnalyzeGenotype> list1_it(batch[batch1].List());
   tListIterator<cAnalyzeGenotype> list2_it(batch[batch2].List());
-
+  
   while ((genotype1 = list1_it.Next()) != NULL) {
     list2_it.Reset();
     while ((genotype2 = list2_it.Next()) != NULL) {
@@ -3024,28 +3173,28 @@
       const int count1 = genotype1->GetNumCPUs();
       const int count2 = genotype2->GetNumCPUs();
       const int num_pairs = (genotype1 == genotype2) ?
-	((count1 - 1) * (count2 - 1)) : (count1 * count2);
+        ((count1 - 1) * (count2 - 1)) : (count1 * count2);
       if (num_pairs == 0) continue;
-
+      
       // And do the tests...
       const int dist =
-	cGenomeUtil::FindHammingDistance(genotype1->GetGenome(),
-					 genotype2->GetGenome());
+        cGenomeUtil::FindHammingDistance(genotype1->GetGenome(),
+                                         genotype2->GetGenome());
       total_dist += dist * num_pairs;
       total_count += num_pairs;
     }
   }
-
-
+  
+  
   // Calculate the final answer
   double ave_dist = (double) total_dist / (double) total_count;
   cout << " ave distance = " << ave_dist << endl;
-
+  
   cDataFile & df = data_file_manager.Get(filename);
-
+  
   df.WriteComment( "Hamming distance information" );
   df.WriteTimeStamp();  
-
+  
   df.Write(batch[batch1].Name(), "Name of First Batch");
   df.Write(batch[batch2].Name(), "Name of Second Batch");
   df.Write(ave_dist,             "Average Hamming Distance");
@@ -3057,33 +3206,33 @@
 {
   cString filename("lev.dat");
   if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-
+  
   int batch1 = PopBatch(cur_string.PopWord());
   int batch2 = PopBatch(cur_string.PopWord());
-
+  
   // We want batch2 to be the larger one for efficiency...
   if (batch[batch1].List().GetSize() > batch[batch2].List().GetSize()) {
     int tmp = batch1;  batch1 = batch2;  batch2 = tmp;
   }
-
+  
   if (verbose == false) {
     cout << "Calculating Levenstein Distance... ";
     cout.flush();
   } else {
     cout << "Calculating Levenstein Distance between batch "
-	 << batch1 << " and " << batch2 << endl;
+    << batch1 << " and " << batch2 << endl;
     cout.flush();
   }
-
+  
   // Setup some variables;
   cAnalyzeGenotype * genotype1 = NULL;
   cAnalyzeGenotype * genotype2 = NULL;
   int total_dist = 0;
   int total_count = 0;
-
+  
   tListIterator<cAnalyzeGenotype> list1_it(batch[batch1].List());
   tListIterator<cAnalyzeGenotype> list2_it(batch[batch2].List());
-
+  
   // Loop through all of the genotypes in each batch...
   while ((genotype1 = list1_it.Next()) != NULL) {
     list2_it.Reset();
@@ -3092,26 +3241,26 @@
       const int count1 = genotype1->GetNumCPUs();
       const int count2 = genotype2->GetNumCPUs();
       const int num_pairs = (genotype1 == genotype2) ?
-	((count1 - 1) * (count2 - 1)) : (count1 * count2);
+        ((count1 - 1) * (count2 - 1)) : (count1 * count2);
       if (num_pairs == 0) continue;
-
+      
       // And do the tests...
       const int dist = cGenomeUtil::FindEditDistance(genotype1->GetGenome(),
-						     genotype2->GetGenome());
+                                                     genotype2->GetGenome());
       total_dist += dist * num_pairs;
       total_count += num_pairs;
     }
   }
-
+  
   // Calculate the final answer
   double ave_dist = (double) total_dist / (double) total_count;
   cout << " ave distance = " << ave_dist << endl;
-
+  
   cDataFile & df = data_file_manager.Get(filename);
-
+  
   df.WriteComment( "Levenstein distance information" );
   df.WriteTimeStamp();  
-
+  
   df.Write(batch[batch1].Name(), "Name of First Batch");
   df.Write(batch[batch2].Name(), "Name of Second Batch");
   df.Write(ave_dist,             "Average Levenstein Distance");
@@ -3123,29 +3272,29 @@
 {
   cString filename("species.dat");
   if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-
+  
   int batch1 = PopBatch(cur_string.PopWord());
   int batch2 = PopBatch(cur_string.PopWord());
   int num_compare = PopBatch(cur_string.PopWord());
-
+  
   // We want batch2 to be the larger one for efficiency...
   if (batch[batch1].List().GetSize() > batch[batch2].List().GetSize()) {
     int tmp = batch1;  batch1 = batch2;  batch2 = tmp;
   }
-
+  
   if (verbose == false) cout << "Calculating Species Distance... " << endl;
   else cout << "Calculating Species Distance between batch "
-	    << batch1 << " and " << batch2 << endl;
-
+    << batch1 << " and " << batch2 << endl;
+  
   // Setup some variables;
   cAnalyzeGenotype * genotype1 = NULL;
   cAnalyzeGenotype * genotype2 = NULL;
   int total_fail = 0;
   int total_count = 0;
-
+  
   tListIterator<cAnalyzeGenotype> list1_it(batch[batch1].List());
   tListIterator<cAnalyzeGenotype> list2_it(batch[batch2].List());
-
+  
   // Loop through all of the genotypes in each batch...
   while ((genotype1 = list1_it.Next()) != NULL) {
     list2_it.Reset();
@@ -3157,89 +3306,89 @@
       int fail_count = 0;
       bool cross1_viable = true;
       bool cross2_viable = true;
-
-
+      
+      
       if (genotype1 == genotype2) {
-	 total_count += num_pairs * 2 * num_compare;
+        total_count += num_pairs * 2 * num_compare;
       }
       else {	
-      assert(num_compare!=0);
-      // And do the tests...
-      for (int iter=1; iter < num_compare; iter++) {
-        cCPUMemory test_genome0 = genotype1->GetGenome(); 
-	cCPUMemory test_genome1 = genotype2->GetGenome(); 
-
-        double start_frac = g_random.GetDouble();
-  	double end_frac = g_random.GetDouble();
-  	if (start_frac > end_frac) nFunctions::Swap(start_frac, end_frac);
-
-  	int start0 = (int) (start_frac * (double) test_genome0.GetSize());
-  	int end0   = (int) (end_frac * (double) test_genome0.GetSize());
-  	int start1 = (int) (start_frac * (double) test_genome1.GetSize());
-  	int end1   = (int) (end_frac * (double) test_genome1.GetSize());
-	assert( start0 >= 0  &&  start0 < test_genome0.GetSize() );
-	assert( end0   >= 0  &&  end0   < test_genome0.GetSize() );
-   	assert( start1 >= 0  &&  start1 < test_genome1.GetSize() );
-   	assert( end1   >= 0  &&  end1   < test_genome1.GetSize() );
-   
-   	// Calculate size of sections crossing over...    
-   	int size0 = end0 - start0;
-   	int size1 = end1 - start1;
-    
-   	int new_size0 = test_genome0.GetSize() - size0 + size1;   
-   	int new_size1 = test_genome1.GetSize() - size1 + size0;
-     
-   	// Don't Crossover if offspring will be illegal!!!
-   	if (new_size0 < MIN_CREATURE_SIZE || new_size0 > MAX_CREATURE_SIZE || 
-	    new_size1 < MIN_CREATURE_SIZE || new_size1 > MAX_CREATURE_SIZE) { 
-	   fail_count +=2; 
-	   break; 
-	} 
-   
-  	if (size0 > 0 && size1 > 0) {
-     	   cGenome cross0 = cGenomeUtil::Crop(test_genome0, start0, end0);
-     	   cGenome cross1 = cGenomeUtil::Crop(test_genome1, start1, end1);
-     	   test_genome0.Replace(start0, size0, cross1);
-     	   test_genome1.Replace(start1, size1, cross0);
-   	}
-   	else if (size0 > 0) {
-   	  cGenome cross0 = cGenomeUtil::Crop(test_genome0, start0, end0);
-   	  test_genome1.Replace(start1, size1, cross0);
-   	}
-   	else if (size1 > 0) {
-   	  cGenome cross1 = cGenomeUtil::Crop(test_genome1, start1, end1);
-   	  test_genome0.Replace(start0, size0, cross1);
-   	}
-
-  	cCPUTestInfo test_info;
-
-      	// Run each side, and determine viability...
-      	cTestCPU::TestGenome(test_info, test_genome0);
-      	cross1_viable = test_info.IsViable();
-  
-	cTestCPU::TestGenome(test_info, test_genome1);
-      	cross2_viable = test_info.IsViable();
-  
-    	if (cross1_viable == false) fail_count++;   
-    	if (cross2_viable == false) fail_count++;
+        assert(num_compare!=0);
+        // And do the tests...
+        for (int iter=1; iter < num_compare; iter++) {
+          cCPUMemory test_genome0 = genotype1->GetGenome(); 
+          cCPUMemory test_genome1 = genotype2->GetGenome(); 
+          
+          double start_frac = g_random.GetDouble();
+          double end_frac = g_random.GetDouble();
+          if (start_frac > end_frac) nFunctions::Swap(start_frac, end_frac);
+          
+          int start0 = (int) (start_frac * (double) test_genome0.GetSize());
+          int end0   = (int) (end_frac * (double) test_genome0.GetSize());
+          int start1 = (int) (start_frac * (double) test_genome1.GetSize());
+          int end1   = (int) (end_frac * (double) test_genome1.GetSize());
+          assert( start0 >= 0  &&  start0 < test_genome0.GetSize() );
+          assert( end0   >= 0  &&  end0   < test_genome0.GetSize() );
+          assert( start1 >= 0  &&  start1 < test_genome1.GetSize() );
+          assert( end1   >= 0  &&  end1   < test_genome1.GetSize() );
+          
+          // Calculate size of sections crossing over...    
+          int size0 = end0 - start0;
+          int size1 = end1 - start1;
+          
+          int new_size0 = test_genome0.GetSize() - size0 + size1;   
+          int new_size1 = test_genome1.GetSize() - size1 + size0;
+          
+          // Don't Crossover if offspring will be illegal!!!
+          if (new_size0 < MIN_CREATURE_SIZE || new_size0 > MAX_CREATURE_SIZE || 
+              new_size1 < MIN_CREATURE_SIZE || new_size1 > MAX_CREATURE_SIZE) { 
+            fail_count +=2; 
+            break; 
+          } 
+          
+          if (size0 > 0 && size1 > 0) {
+            cGenome cross0 = cGenomeUtil::Crop(test_genome0, start0, end0);
+            cGenome cross1 = cGenomeUtil::Crop(test_genome1, start1, end1);
+            test_genome0.Replace(start0, size0, cross1);
+            test_genome1.Replace(start1, size1, cross0);
+          }
+          else if (size0 > 0) {
+            cGenome cross0 = cGenomeUtil::Crop(test_genome0, start0, end0);
+            test_genome1.Replace(start1, size1, cross0);
+          }
+          else if (size1 > 0) {
+            cGenome cross1 = cGenomeUtil::Crop(test_genome1, start1, end1);
+            test_genome0.Replace(start0, size0, cross1);
+          }
+          
+          cCPUTestInfo test_info;
+          
+          // Run each side, and determine viability...
+          cTestCPU::TestGenome(test_info, test_genome0);
+          cross1_viable = test_info.IsViable();
+          
+          cTestCPU::TestGenome(test_info, test_genome1);
+          cross2_viable = test_info.IsViable();
+          
+          if (cross1_viable == false) fail_count++;   
+          if (cross2_viable == false) fail_count++;
+        }
+        
+        total_fail += fail_count * num_pairs;
+        total_count += num_pairs * 2 * num_compare;
       }
-
-      total_fail += fail_count * num_pairs;
-      total_count += num_pairs * 2 * num_compare;
-      }
     }
   }
   // Calculate the final answer
   double ave_dist = (double) total_fail / (double) total_count;
   cout << "  ave distance = " << ave_dist
-       << " in " << total_count
-       << " tests." << endl; 
-
+    << " in " << total_count
+    << " tests." << endl; 
+  
   cDataFile & df = data_file_manager.Get(filename);
-
+  
   df.WriteComment( "Species information" );
   df.WriteTimeStamp();  
-
+  
   df.Write(batch[batch1].Name(), "Name of First Batch");
   df.Write(batch[batch2].Name(), "Name of Second Batch");
   df.Write(ave_dist,             "Average Species Distance");
@@ -3253,94 +3402,94 @@
   int batch2 = PopBatch(cur_string.PopWord());
   int batch3 = PopBatch(cur_string.PopWord());
   int num_compare = PopBatch(cur_string.PopWord());
-
+  
   // We want batch2 to be the larger one for efficiency...
   if (batch[batch1].List().GetSize() > batch[batch2].List().GetSize()) {
     int tmp = batch1;  batch1 = batch2;  batch2 = tmp;
   }
-
+  
   if (verbose == false) cout << "Creating recombinants...  " << endl;
   else cout << "Creating recombinants between batch "
-	    << batch1 << " and " << batch2 << endl;
-
+    << batch1 << " and " << batch2 << endl;
+  
   // Setup some variables;
   cAnalyzeGenotype * genotype1 = NULL;
   cAnalyzeGenotype * genotype2 = NULL;
-
+  
   tListIterator<cAnalyzeGenotype> list1_it(batch[batch1].List());
   tListIterator<cAnalyzeGenotype> list2_it(batch[batch2].List());
-
+  
   // Loop through all of the genotypes in each batch...
   while ((genotype1 = list1_it.Next()) != NULL) {
     list2_it.Reset();
     while ((genotype2 = list2_it.Next()) != NULL) {
       // Determine the counts...
       int fail_count = 0;
-
-
+      
+      
       assert(num_compare!=0);
       // And do the tests...
-      for (int iter=0; iter < num_compare; iter++) {
+      for (int iter=1; iter < num_compare; iter++) {
         cCPUMemory test_genome0 = genotype1->GetGenome(); 
-	cCPUMemory test_genome1 = genotype2->GetGenome(); 
-
+        cCPUMemory test_genome1 = genotype2->GetGenome(); 
+        
         double start_frac = g_random.GetDouble();
-  	double end_frac = g_random.GetDouble();
-  	if (start_frac > end_frac) nFunctions::Swap(start_frac, end_frac);
-
-  	int start0 = (int) (start_frac * (double) test_genome0.GetSize());
-  	int end0   = (int) (end_frac * (double) test_genome0.GetSize());
-  	int start1 = (int) (start_frac * (double) test_genome1.GetSize());
-  	int end1   = (int) (end_frac * (double) test_genome1.GetSize());
-	assert( start0 >= 0  &&  start0 < test_genome0.GetSize() );
-	assert( end0   >= 0  &&  end0   < test_genome0.GetSize() );
-   	assert( start1 >= 0  &&  start1 < test_genome1.GetSize() );
-   	assert( end1   >= 0  &&  end1   < test_genome1.GetSize() );
-   
-   	// Calculate size of sections crossing over...    
-   	int size0 = end0 - start0;
-   	int size1 = end1 - start1;
-    
-   	int new_size0 = test_genome0.GetSize() - size0 + size1;   
-   	int new_size1 = test_genome1.GetSize() - size1 + size0;
-     
-   	// Don't Crossover if offspring will be illegal!!!
-   	if (new_size0 < MIN_CREATURE_SIZE || new_size0 > MAX_CREATURE_SIZE || 
-	    new_size1 < MIN_CREATURE_SIZE || new_size1 > MAX_CREATURE_SIZE) { 
-	   fail_count +=2; 
-	   break; 
-	} 
-   
-  	if (size0 > 0 && size1 > 0) {
-     	   cGenome cross0 = cGenomeUtil::Crop(test_genome0, start0, end0);
-     	   cGenome cross1 = cGenomeUtil::Crop(test_genome1, start1, end1);
-     	   test_genome0.Replace(start0, size0, cross1);
-     	   test_genome1.Replace(start1, size1, cross0);
-   	}
-   	else if (size0 > 0) {
-   	  cGenome cross0 = cGenomeUtil::Crop(test_genome0, start0, end0);
-   	  test_genome1.Replace(start1, size1, cross0);
-   	}
-   	else if (size1 > 0) {
-   	  cGenome cross1 = cGenomeUtil::Crop(test_genome1, start1, end1);
-   	  test_genome0.Replace(start0, size0, cross1);
-   	}
-
-	cAnalyzeGenotype * new_genotype0 = new cAnalyzeGenotype(test_genome0, inst_set); 
-	cAnalyzeGenotype * new_genotype1 = new cAnalyzeGenotype(test_genome1, inst_set); 
-	new_genotype0->SetNumCPUs(1); 
-	new_genotype1->SetNumCPUs(1); 
+        double end_frac = g_random.GetDouble();
+        if (start_frac > end_frac) nFunctions::Swap(start_frac, end_frac);
+        
+        int start0 = (int) (start_frac * (double) test_genome0.GetSize());
+        int end0   = (int) (end_frac * (double) test_genome0.GetSize());
+        int start1 = (int) (start_frac * (double) test_genome1.GetSize());
+        int end1   = (int) (end_frac * (double) test_genome1.GetSize());
+        assert( start0 >= 0  &&  start0 < test_genome0.GetSize() );
+        assert( end0   >= 0  &&  end0   < test_genome0.GetSize() );
+        assert( start1 >= 0  &&  start1 < test_genome1.GetSize() );
+        assert( end1   >= 0  &&  end1   < test_genome1.GetSize() );
+        
+        // Calculate size of sections crossing over...    
+        int size0 = end0 - start0;
+        int size1 = end1 - start1;
+        
+        int new_size0 = test_genome0.GetSize() - size0 + size1;   
+        int new_size1 = test_genome1.GetSize() - size1 + size0;
+        
+        // Don't Crossover if offspring will be illegal!!!
+        if (new_size0 < MIN_CREATURE_SIZE || new_size0 > MAX_CREATURE_SIZE || 
+            new_size1 < MIN_CREATURE_SIZE || new_size1 > MAX_CREATURE_SIZE) { 
+          fail_count +=2; 
+          break; 
+        } 
+        
+        if (size0 > 0 && size1 > 0) {
+          cGenome cross0 = cGenomeUtil::Crop(test_genome0, start0, end0);
+          cGenome cross1 = cGenomeUtil::Crop(test_genome1, start1, end1);
+          test_genome0.Replace(start0, size0, cross1);
+          test_genome1.Replace(start1, size1, cross0);
+        }
+        else if (size0 > 0) {
+          cGenome cross0 = cGenomeUtil::Crop(test_genome0, start0, end0);
+          test_genome1.Replace(start1, size1, cross0);
+        }
+        else if (size1 > 0) {
+          cGenome cross1 = cGenomeUtil::Crop(test_genome1, start1, end1);
+          test_genome0.Replace(start0, size0, cross1);
+        }
+        
+        cAnalyzeGenotype * new_genotype0 = new cAnalyzeGenotype(test_genome0, inst_set); 
+        cAnalyzeGenotype * new_genotype1 = new cAnalyzeGenotype(test_genome1, inst_set); 
+        new_genotype0->SetNumCPUs(1); 
+        new_genotype1->SetNumCPUs(1); 
         new_genotype0->SetID(0);
         new_genotype1->SetID(0);
         new_genotype0->SetName("noname");
         new_genotype1->SetName("noname");
-
-	batch[batch3].List().PushRear(new_genotype0);
-	batch[batch3].List().PushRear(new_genotype1); 
-
-	//batch[batch3].List().PushRear(new cAnalyzeGenotype(test_genome0, inst_set));
-	//batch[batch3].List().PushRear(new cAnalyzeGenotype(test_genome1, inst_set));
-
+        
+        batch[batch3].List().PushRear(new_genotype0);
+        batch[batch3].List().PushRear(new_genotype1); 
+        
+        //batch[batch3].List().PushRear(new cAnalyzeGenotype(test_genome0, inst_set));
+        //batch[batch3].List().PushRear(new cAnalyzeGenotype(test_genome1, inst_set));
+        
       }
     }
   }
@@ -3350,20 +3499,20 @@
 {
   // Align does not need any args yet.
   (void) cur_string;
-
+  
   cout << "Aligning sequences..." << endl;
-
+  
   if (batch[cur_batch].IsLineage() == false && verbose == true) {
     cerr << "  Warning: sequences may not be a consecutive lineage."
-	 << endl;
+    << endl;
   }
-
+  
   // Create an array of all the sequences we need to align.
   tListPlus<cAnalyzeGenotype> & glist = batch[cur_batch].List();
   tListIterator<cAnalyzeGenotype> batch_it(glist);
   const int num_sequences = glist.GetSize();
   cString * sequences = new cString[num_sequences];
-
+  
   // Move through each sequence an update it.
   batch_it.Reset();
   cString diff_info;
@@ -3373,7 +3522,7 @@
     // Track of the number of insertions and deletions to shift properly.
     int num_ins = 0;
     int num_del = 0;
-
+    
     // Compare each string to the previous.
     cStringUtil::EditDistance(sequences[i], sequences[i-1], diff_info, '_');
     while (diff_info.GetSize() != 0) {
@@ -3381,42 +3530,170 @@
       const char mut_type = cur_mut[0];
       cur_mut.ClipFront(1); cur_mut.ClipEnd(1);
       int position = cur_mut.AsInt();
-
+      
       // Nothing to do with Mutations
       if (mut_type == 'M') continue;
-
+      
       // Handle insertions...
       if (mut_type == 'I') {
-	// Loop back and insert an '_' into all previous sequences.
-	for (int j = 0; j < i; j++) {
-	  sequences[j].Insert('_', position + num_del);
-	}
-	num_ins++;
+        // Loop back and insert an '_' into all previous sequences.
+        for (int j = 0; j < i; j++) {
+          sequences[j].Insert('_', position + num_del);
+        }
+        num_ins++;
       }
-
+      
       // Handle Deletions...
       else if (mut_type == 'D') {
-	// Insert '_' into the current sequence at the point of deletions.
-	sequences[i].Insert("_", position + num_ins);
-	num_del++;
+        // Insert '_' into the current sequence at the point of deletions.
+        sequences[i].Insert("_", position + num_ins);
+        num_del++;
       }
-
+      
     }
   }
-
+  
   batch_it.Reset();
   for (int i = 0; i < num_sequences; i++) {
     batch_it.Next()->SetAlignedSequence(sequences[i]);
   }
-
+  
   // Cleanup
   delete [] sequences;
-
+  
   // Adjust the flags on this batch
   // batch[cur_batch].SetLineage(false);
   batch[cur_batch].SetAligned(true);
 }
 
+// Now this command do not consider changing environment 
+// and only work for lineage and fixed-length runs.
+void cAnalyze::AnalyzeNewInfo(cString cur_string)
+{
+  cout << "Analyze new information in child about environment ..." << endl;
+  
+  // Load in the variables
+  int words = cur_string.CountNumWords();
+  if (words < 1) {
+    cout << "This command requires mutation rate, skipping." << endl;
+    return;
+  }
+  
+  // Get the mutation rate ...
+  double mu = cur_string.PopWord().AsDouble();
+  
+  // Create the directory using the string given as the second argument
+  cString dir = cur_string.PopWord();
+  cString defaultDir = "newinfo/";
+  cString directory = PopDirectory(dir, defaultDir);
+  
+  ///////////////////////////////////////////////////////
+  // Loop through all of the genotypes in this batch...
+  
+  cString newinfo_fn;
+  ofstream newinfo_fp;
+  if (batch[cur_batch].IsLineage() == true) {
+    newinfo_fn.Set("%s%s.newinfo.dat", directory(), "lineage");
+    newinfo_fp.open(newinfo_fn);
+  } else {
+    cout << "This command requires the lineage in the batch, skipping.\n";
+    return;
+  }
+  newinfo_fp << "# Legend:" << endl;
+  newinfo_fp << "# 1:Child Genotype ID" << endl;
+  newinfo_fp << "# 2:Parent Genotype ID" << endl;
+  newinfo_fp << "# 3:New Information about Environment given Parent" << endl; 
+  
+  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
+  cAnalyzeGenotype * parent_genotype = batch_it.Next();
+  if (parent_genotype == NULL) {
+    newinfo_fp.close();
+    return;
+  }
+  cAnalyzeGenotype * child_genotype = NULL;
+  
+  while ((child_genotype = batch_it.Next()) != NULL) {
+    assert( parent_genotype->GetLength() == child_genotype->GetLength() );
+    
+    if (verbose == true) {
+      cout << endl << "Analyze new information for " << child_genotype->GetName() << endl;
+    }
+    
+    // 1.
+    // Analyze the information between parent and child ...
+    // H(C) = all insts are equally probably = 1
+    // H(C|P) = -(1-u)log(1-u)-26*(u/26)*log(u/26)
+    // I(C:P) = H(C)-H(C|P)
+    const int num_insts = inst_set.GetSize();
+    const int num_lines = child_genotype->GetLength();
+    double H_C = 1;
+    double H_C_P = -(1-mu)*log(1-mu)/log(static_cast<double>(num_insts))
+      -(num_insts)*(mu/(num_insts))*log(mu/(num_insts))/log(static_cast<double>(num_insts));
+    double I_CP = (H_C - H_C_P) * num_lines;
+    if (verbose) {
+      cout << "I(C:P) =  H(C) - H(C|P) = (" << H_C << " - " <<  H_C_P << ") * 100 = " 
+      << I_CP << endl;
+    }
+    
+    // 2.
+    // Analyze the information between parent and child given the environment.
+    // H(C|E)
+    // H(C|PE) = -(1-u)log(1-u)
+    //           -u distributed among 26 insts according to mut/sel balance 
+    // I(C:P|E) = H(C|E)-H(C|PE)
+    double H_C_E = AnalyzeEntropy(child_genotype, mu);
+    if (H_C_E < 0) {
+      cout << "Cannot calculate the entropy of genotype " << child_genotype->GetID();
+      cout << " given environment. Error." << endl;
+      return;
+    }
+    double H_C_PE = AnalyzeEntropyGivenParent(child_genotype, parent_genotype, mu);
+    if (H_C_PE < 0) {
+      cout << "Cannot calculate the entropy of genotype " << child_genotype->GetID();
+      cout << " given parent and environment. Error." << endl;
+    }
+    
+    double I_CP_E = H_C_E - H_C_PE;
+    if (verbose) {
+      cout << "I(C:P|E) = H(C|E) - H(C|PE) = " << H_C_E << " - " << H_C_PE << 
+      " = " << I_CP_E << endl;
+    }
+    
+    // 3.
+    // Information among parent, child and environment.
+    // I(C:P:E) = I(C:P)-I(C:P|E)
+    double I_CPE = I_CP -I_CP_E;
+    if (verbose) {
+      cout << "I(C:P:E) = I(C:P) - I(C:P|E) = " << I_CP << " - " << I_CP_E << 
+      " = " << I_CPE << endl;
+    }
+    
+    // 4.
+    // New information child about environment given parent.
+    // I(C:E|P) = I(C:E)-I(C:P:E)
+    double I_CE = (double)child_genotype->GetLength() - H_C_E;
+    double I_CE_P = I_CE - I_CPE;
+    if (verbose) {
+      cout << "I(C:E|P) = I(C:E) - I(C:P:E) = " << I_CE << " - " << I_CPE << 
+      " = " << I_CE_P << endl;
+    }
+    
+    // Write information to file ...
+    newinfo_fp << child_genotype->GetID() << " ";
+    newinfo_fp << parent_genotype->GetID() << " ";
+    newinfo_fp << I_CE_P << endl;
+    
+    if (verbose) {
+      cout << child_genotype->GetID() << " ";
+      cout << parent_genotype->GetID() << " ";
+      cout << I_CE_P << endl;
+    }
+    parent_genotype = child_genotype;
+  }
+  
+  newinfo_fp.close();
+  return;
+}
 
 void cAnalyze::WriteClone(cString cur_string)
 {
@@ -3426,18 +3703,18 @@
   if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
   if (cur_string.GetSize() != 0) num_cells = cur_string.PopWord().AsInt();
   
-
+  
   ofstream & fp = data_file_manager.GetOFStream(filename);
-
+  
   // Start up again at update zero...
   fp << "0 ";
-
+  
   // Setup the genebank sizes of lists to all be zero.
   fp << MAX_CREATURE_SIZE << " ";
   for (int i = 0; i < MAX_CREATURE_SIZE; i++) {
     fp << "0 ";
   }
-
+  
   // Save the individual genotypes
   fp << batch[cur_batch].List().GetSize() << " ";
   
@@ -3448,27 +3725,27 @@
     org_count += genotype->GetNumCPUs();
     const int length = genotype->GetLength();
     const cGenome & genome = genotype->GetGenome();
-
+    
     fp << genotype->GetID() << " "
-       << length << " ";
-
+      << length << " ";
+    
     for (int i = 0; i < length; i++) {
       fp << genome[i].GetOp() << " ";
     }
   }
-
+  
   // Write out the current state of the grid.
   
   if (num_cells == 0) num_cells = org_count;
   fp << num_cells << " ";
-
+  
   batch_it.Reset();
   while ((genotype = batch_it.Next()) != NULL) {
     for (int i = 0; i < genotype->GetNumCPUs(); i++) {
       fp << genotype->GetID() << " ";
     }
   }
-
+  
   // Fill out the remainder of the grid with -1
   for (int i = org_count; i < num_cells; i++) {
     fp << "-1 ";
@@ -3487,7 +3764,7 @@
   if (cur_string.GetSize() != 0) lineage = cur_string.PopWord().AsInt();
   
   ofstream & fp = data_file_manager.GetOFStream(filename);
-
+  
   int org_count = 0;
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   cAnalyzeGenotype * genotype = NULL;
@@ -3495,14 +3772,14 @@
     const int cur_count = genotype->GetNumCPUs();
     org_count += cur_count;
     const cGenome & genome = genotype->GetGenome();
-
+    
     fp << "u 0 inject_sequence "
-       << genome.AsString() << " "
-       << start_cell << " "
-       << start_cell + cur_count << " "
-       << genotype->GetMerit() << " "
-       << lineage << " "
-       << endl;
+      << genome.AsString() << " "
+      << start_cell << " "
+      << start_cell + cur_count << " "
+      << genotype->GetMerit() << " "
+      << lineage << " "
+      << endl;
     start_cell += cur_count;
   }
 }
@@ -3511,7 +3788,7 @@
 void cAnalyze::WriteCompetition(cString cur_string)
 {
   cout << "Writing Competition events..." << endl;
-
+  
   // Load in the variables...
   int join_UD = 0;
   double start_merit = 50000;
@@ -3520,10 +3797,10 @@
   int batch_B = cur_batch;
   int grid_side = -1;
   int lineage = 0;
-
+  
   // Make sure we have reasonable default batches.
   if (cur_batch == 0) { batch_A = 0; batch_B = 1; }
-
+  
   if (cur_string.GetSize() != 0) join_UD = cur_string.PopWord().AsInt();
   if (cur_string.GetSize() != 0) start_merit = cur_string.PopWord().AsDouble();
   if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
@@ -3531,7 +3808,7 @@
   if (cur_string.GetSize() != 0) batch_B = cur_string.PopWord().AsInt();
   if (cur_string.GetSize() != 0) grid_side = cur_string.PopWord().AsInt();
   if (cur_string.GetSize() != 0) lineage = cur_string.PopWord().AsInt();
-
+  
   // Check inputs...
   if (join_UD < 0) join_UD = 0;
   if (batch_A < 0 || batch_B < 0) {
@@ -3540,40 +3817,40 @@
   }
   
   ofstream & fp = data_file_manager.GetOFStream(filename);
-
+  
   // Count the number of organisms in each batch...
   cAnalyzeGenotype * genotype = NULL;
-
+  
   int org_count_A = 0;
   tListIterator<cAnalyzeGenotype> batchA_it(batch[batch_A].List());
   while ((genotype = batchA_it.Next()) != NULL) {
     org_count_A += genotype->GetNumCPUs();
   }
-
+  
   int org_count_B = 0;
   tListIterator<cAnalyzeGenotype> batchB_it(batch[batch_B].List());
   while ((genotype = batchB_it.Next()) != NULL) {
     org_count_B += genotype->GetNumCPUs();
   }
-
+  
   int max_count = Max(org_count_A, org_count_B);
   if (max_count > 10000) {
     cout << "Warning: more than 10,000 organisms in sub-population!" << endl;
   }
-
+  
   if (grid_side <= 0) {
     for (grid_side = 5; grid_side < 100; grid_side += 5) {
       if (grid_side * grid_side >= max_count) break;
     }
     if (verbose == true) {
       cout << "...assuming population size "
-	   << grid_side << "x" << grid_side << "." << endl;
+      << grid_side << "x" << grid_side << "." << endl;
     }
   }
-
-
+  
+  
   int pop_size = grid_side * grid_side;
-
+  
   int inject_pos = 0;
   while ((genotype = batchA_it.Next()) != NULL) {
     const int cur_count = genotype->GetNumCPUs();
@@ -3581,15 +3858,15 @@
     double cur_merit = start_merit;
     if (cur_merit < 0) cur_merit = genotype->GetMerit();
     fp << "u 0 inject_sequence "
-       << genome.AsString() << " "
-       << inject_pos << " "
-       << inject_pos + cur_count << " "
-       << cur_merit << " "
-       << lineage << " "
-       << endl;
+      << genome.AsString() << " "
+      << inject_pos << " "
+      << inject_pos + cur_count << " "
+      << cur_merit << " "
+      << lineage << " "
+      << endl;
     inject_pos += cur_count;
   }
-
+  
   inject_pos = pop_size;
   while ((genotype = batchB_it.Next()) != NULL) {
     const int cur_count = genotype->GetNumCPUs();
@@ -3597,15 +3874,15 @@
     double cur_merit = start_merit;
     if (cur_merit < 0) cur_merit = genotype->GetMerit();
     fp << "u 0 inject_sequence "
-       << genome.AsString() << " "
-       << inject_pos << " "
-       << inject_pos + cur_count << " "
-       << cur_merit << " "
-       << lineage+1 << " "
-       << endl;
+      << genome.AsString() << " "
+      << inject_pos << " "
+      << inject_pos + cur_count << " "
+      << cur_merit << " "
+      << lineage+1 << " "
+      << endl;
     inject_pos += cur_count;
   }
-
+  
   fp << "u 0 sever_grid_row" << grid_side << endl;
   fp << "u " << join_UD << " join_grid_row " << grid_side << endl;
 }
@@ -3614,29 +3891,29 @@
 void cAnalyze::AnalyzeMuts(cString cur_string)
 {
   cout << "Analyzing Mutations" << endl;
-
+  
   // Make sure we have everything we need.
   if (batch[cur_batch].IsAligned() == false) {
     cout << "  ERROR: sequences not aligned." << endl;
     return;
   }
-
+  
   // Setup variables...
   cString filename("analyze_muts.dat");
   bool all_combos = false;
   if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
   if (cur_string.GetSize() != 0) all_combos = cur_string.PopWord().AsInt();
-
+  
   tListPlus<cAnalyzeGenotype> & gen_list = batch[cur_batch].List();
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-
+  
   const int num_sequences = gen_list.GetSize();
   const int sequence_length =
     gen_list.GetFirst()->GetAlignedSequence().GetSize();
   cString * sequences = new cString[num_sequences];
   int * mut_count = new int[sequence_length];
   for (int i = 0; i < sequence_length; i++) mut_count[i] = 0;
-
+  
   // Load in the sequences
   batch_it.Reset();
   int count = 0;
@@ -3644,7 +3921,7 @@
     sequences[count] = batch_it.Get()->GetAlignedSequence();
     count++;
   }
-
+  
   // Count the number of changes at each site...
   for (int i = 1; i < num_sequences; i++) {       // For each pair...
     cString & seq1 = sequences[i-1];
@@ -3653,11 +3930,11 @@
       if (seq1[j] != seq2[j]) mut_count[j]++;
     }
   }
-
+  
   // Grab the two strings we're actively going to be working with.
   cString & first_seq = sequences[0];
   cString & last_seq = sequences[num_sequences - 1];
-
+  
   // Print out the header...
   ofstream & fp = data_file_manager.GetOFStream(filename);
   fp << "# " << sequences[0] << endl;
@@ -3675,12 +3952,12 @@
     else fp << "^";
   }
   fp << endl << endl;
-
+  
   // Count the number of diffs between the two strings we're interested in.
   const int total_diffs = cStringUtil::Distance(first_seq, last_seq);
   if (verbose) cout << "  " << total_diffs << " mutations being tested."
-		    << endl;
-
+    << endl;
+  
   // Locate each difference.
   int * mut_positions = new int[total_diffs];
   int cur_mut = 0;
@@ -3690,7 +3967,7 @@
       cur_mut++;
     }
   }
-
+  
   // The number of mutations we need to deal with will tell us how much
   // we can attempt to do. (@CAO should be able to overide defaults)
   bool scan_combos = true;  // Scan all possible combos of mutations?
@@ -3699,12 +3976,12 @@
   if (total_diffs > 30) scan_combos = false;
   if (total_diffs > 20) detail_muts = false;
   if (total_diffs > 10) print_all = false;
-
+  
   // Start moving through the difference combinations...
   if (scan_combos) {
     const int total_combos = 1 << total_diffs;
     cout << "  Scanning through " << total_combos << " combos." << endl;
-
+    
     double * total_fitness = new double[total_diffs + 1];
     double * total_sqr_fitness = new double[total_diffs + 1];
     double * max_fitness = new double[total_diffs + 1];
@@ -3716,68 +3993,68 @@
       max_fitness[i] = 0.0;
       test_count[i] = 0;
     }
-
+    
     // Loop through all of the combos...
     const int combo_step = total_combos / 79;
     for (int combo_id = 0; combo_id < total_combos; combo_id++) {
       if (combo_id % combo_step == 0) {
-	cout << '.';
-	cout.flush();
+        cout << '.';
+        cout.flush();
       }
       // Start at the first sequence and add needed changes...
       cString test_sequence = first_seq;
       int diff_count = 0;
       for (int mut_id = 0; mut_id < total_diffs; mut_id++) {
-	if ((combo_id >> mut_id) & 1) {
-	  const int cur_pos = mut_positions[mut_id];
-	  test_sequence[cur_pos] = last_seq.GetData()[cur_pos];
-	  diff_count++;
-	}
+        if ((combo_id >> mut_id) & 1) {
+          const int cur_pos = mut_positions[mut_id];
+          test_sequence[cur_pos] = last_seq.GetData()[cur_pos];
+          diff_count++;
+        }
       }
-
+      
       // Determine the fitness of the current sequence...
       cGenome test_genome(test_sequence);
       cCPUTestInfo test_info;
       test_info.TestThreads();
       cTestCPU::TestGenome(test_info, test_genome);
       const double fitness = test_info.GetGenotypeFitness();
-
+      
       //cAnalyzeGenotype test_genotype(test_sequence);
       //test_genotype.Recalculate();
       //const double fitness = test_genotype.GetFitness();
-
+      
       total_fitness[diff_count] += fitness;
       total_sqr_fitness[diff_count] += fitness * fitness;
       if (fitness > max_fitness[diff_count]) {
-	max_fitness[diff_count] = fitness;
-	max_sequence[diff_count] = test_sequence;
-//  	cout << endl
-//  	     << max_sequence[diff_count] << " "
-//  	     << test_info.GetGenotypeMerit() << " "
-//  	     << fitness << " "
-//  	     << combo_id << endl;
+        max_fitness[diff_count] = fitness;
+        max_sequence[diff_count] = test_sequence;
+        //  	cout << endl
+        //  	     << max_sequence[diff_count] << " "
+        //  	     << test_info.GetGenotypeMerit() << " "
+        //  	     << fitness << " "
+        //  	     << combo_id << endl;
       }
       test_count[diff_count]++;
     }
-
+    
     // Output the results...
-
+    
     for (int i = 0; i <= total_diffs; i++) {
       cAnalyzeGenotype max_genotype(max_sequence[i], inst_set);
       max_genotype.Recalculate();
       fp << i                                         << " "  //  1
-	 << test_count[i]                             << " "  //  2
-	 << total_fitness[i] / (double) test_count[i] << " "  //  3
-	 << max_fitness[i]                            << " "  //  4
-	 << max_genotype.GetMerit()                   << " "  //  5
-	 << max_genotype.GetGestTime()                << " "  //  6
-	 << max_genotype.GetLength()                  << " "  //  7
-	 << max_genotype.GetCopyLength()              << " "  //  8
-	 << max_genotype.GetExeLength()               << " "; //  9
+        << test_count[i]                             << " "  //  2
+        << total_fitness[i] / (double) test_count[i] << " "  //  3
+        << max_fitness[i]                            << " "  //  4
+        << max_genotype.GetMerit()                   << " "  //  5
+        << max_genotype.GetGestTime()                << " "  //  6
+        << max_genotype.GetLength()                  << " "  //  7
+        << max_genotype.GetCopyLength()              << " "  //  8
+        << max_genotype.GetExeLength()               << " "; //  9
       max_genotype.PrintTasks(fp, 3,12);
       fp << max_sequence[i] << endl;
     }
-
+    
     // Cleanup
     delete [] total_fitness;
     delete [] total_sqr_fitness;
@@ -3788,10 +4065,10 @@
   // If we can't scan through all combos, give wanring.
   else {
     cerr << "  Warning: too many mutations (" << total_diffs
-	 << ") to scan through combos." << endl;
+    << ") to scan through combos." << endl;
   }
-
-
+  
+  
   // Cleanup...
   delete [] sequences;
   delete [] mut_count;
@@ -3804,64 +4081,64 @@
     cout << "Analyzing Instructions in batch " << cur_batch << endl;
   }
   else cout << "Analyzeing Instructions..." << endl;
-
+  
   // Load in the variables...
   cString filename("inst_analyze.dat");
   if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
   const int num_insts = inst_set.GetSize();
-
+  
   // Setup the file...
   ofstream fp(filename);
-
+  
   // Determine the file type...
   int file_type = FILE_TYPE_TEXT;
   while (filename.Find('.') != -1) filename.Pop('.');
   if (filename == "html") file_type = FILE_TYPE_HTML;
-
+  
   // If we're in HTML mode, setup the header...
   if (file_type == FILE_TYPE_HTML) {
     // Document header...
     fp << "<html>" << endl
-       << "<body bgcolor=\"#FFFFFF\"" << endl
-       << " text=\"#000000\"" << endl
-       << " link=\"#0000AA\"" << endl
-       << " alink=\"#0000FF\"" << endl
-       << " vlink=\"#000044\">" << endl
-       << endl
-       << "<h1 align=center>Instruction Chart: "
-       << batch[cur_batch].Name() << endl
-       << "<br><br>" << endl
-       << endl;
-
+    << "<body bgcolor=\"#FFFFFF\"" << endl
+    << " text=\"#000000\"" << endl
+    << " link=\"#0000AA\"" << endl
+    << " alink=\"#0000FF\"" << endl
+    << " vlink=\"#000044\">" << endl
+    << endl
+    << "<h1 align=center>Instruction Chart: "
+    << batch[cur_batch].Name() << endl
+    << "<br><br>" << endl
+    << endl;
+    
     // Instruction key...
     const int num_cols = 6;
     const int num_rows = ((num_insts - 1) / num_cols) + 1;
     fp << "<table border=2 cellpadding=3>" << endl
-       << "<tr bgcolor=\"#AAAAFF\"><th colspan=6>Instruction Set Legend</tr>"
-       << endl;
+      << "<tr bgcolor=\"#AAAAFF\"><th colspan=6>Instruction Set Legend</tr>"
+      << endl;
     for (int i = 0; i < num_rows; i++) {
       fp << "<tr>";
       for (int j = 0; j < num_cols; j++) {
-	const int inst_id = i + j * num_rows;
-	if (inst_id < num_insts) {
-	  cInstruction cur_inst(inst_id);
-	  fp << "<td><b>" << cur_inst.GetSymbol() << "</b> : "
-	     << inst_set.GetName(inst_id) << " ";
-	}
-	else {
-	  fp << "<td>&nbsp; ";
-	}
+        const int inst_id = i + j * num_rows;
+        if (inst_id < num_insts) {
+          cInstruction cur_inst(inst_id);
+          fp << "<td><b>" << cur_inst.GetSymbol() << "</b> : "
+            << inst_set.GetName(inst_id) << " ";
+        }
+        else {
+          fp << "<td>&nbsp; ";
+        }
       }
       fp << "</tr>" << endl;
     }
     fp << "</table>" << endl
-       << "<br><br><br>" << endl;
-
+      << "<br><br><br>" << endl;
+    
     // Main table header...
     fp << "<center>" << endl
-       << "<table border=1 cellpadding=2>" << endl
-       << "<tr><th bgcolor=\"#AAAAFF\">Run # <th bgcolor=\"#AAAAFF\">Length"
-       << endl;
+      << "<table border=1 cellpadding=2>" << endl
+      << "<tr><th bgcolor=\"#AAAAFF\">Run # <th bgcolor=\"#AAAAFF\">Length"
+      << endl;
     for (int i = 0; i < num_insts; i++) {
       cInstruction cur_inst(i);
       fp << "<th bgcolor=\"#AAAAFF\">" << cur_inst.GetSymbol() << " ";
@@ -3876,16 +4153,16 @@
     }
     fp << endl;
   }
-
+  
   // Figure out how often we expect each instruction to appear...
   const double exp_freq = 1.0 / (double) num_insts;
   const double min_freq = exp_freq * 0.5;
   const double max_freq = exp_freq * 2.0;
-
+  
   double total_length = 0.0;
   tArray<double> total_freq(num_insts);
   for (int i = 0; i < num_insts; i++) total_freq[i] = 0.0;
-
+  
   // Loop through all of the genotypes in this batch...
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   cAnalyzeGenotype * genotype = NULL;
@@ -3893,14 +4170,14 @@
     // Setup for counting...
     tArray<int> inst_bin(num_insts);
     for (int i = 0; i < num_insts; i++) inst_bin[i] = 0;
-
+    
     // Count it up!
     const int genome_size = genotype->GetLength();
     for (int i = 0; i < genome_size; i++) {
       const int inst_id = genotype->GetGenome()[i].GetOp();
       inst_bin[inst_id]++;
     }
-
+    
     // Print it out...
     if (file_type == FILE_TYPE_HTML) fp << "<tr><th>";
     fp << genotype->GetName() << " ";
@@ -3911,17 +4188,17 @@
       const double inst_freq = ((double) inst_bin[i]) / (double) genome_size;
       total_freq[i] += inst_freq;
       if (file_type == FILE_TYPE_HTML) {
-	if (inst_freq == 0.0) fp << "<td bgcolor=\"FFAAAA\">";
-	else if (inst_freq < min_freq) fp << "<td bgcolor=\"FFFFAA\">";
-	else if (inst_freq < max_freq) fp << "<td bgcolor=\"AAAAFF\">";
-	else fp << "<td bgcolor=\"AAFFAA\">";
+        if (inst_freq == 0.0) fp << "<td bgcolor=\"FFAAAA\">";
+        else if (inst_freq < min_freq) fp << "<td bgcolor=\"FFFFAA\">";
+        else if (inst_freq < max_freq) fp << "<td bgcolor=\"AAAAFF\">";
+        else fp << "<td bgcolor=\"AAFFAA\">";
       }
       fp << cStringUtil::Stringf("%04.3f", inst_freq) << " ";
     }
     if (file_type == FILE_TYPE_HTML) fp << "</tr>";
     fp << endl;
   }
-
+  
   if (file_type == FILE_TYPE_HTML) {
     int num_genomes = batch[cur_batch].List().GetSize();
     fp << "<tr><th>Average <th>" << total_length / num_genomes << " ";
@@ -3934,9 +4211,9 @@
       fp << cStringUtil::Stringf("%04.3f", inst_freq) << " ";
     }
     fp << "</tr>" << endl
-       << "</table></center>" << endl;
+      << "</table></center>" << endl;
   }
-}
+  }
 
 void cAnalyze::AnalyzeInstPop(cString cur_string)
 {
@@ -3944,37 +4221,37 @@
     cout << "Analyzing Instructions in batch " << cur_batch << endl;
   }
   else cout << "Analyzeing Instructions..." << endl;
-
+  
   // Load in the variables...
   cString filename("inst_analyze.dat");
   if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
   const int num_insts = inst_set.GetSize();
-
+  
   // Setup the file...
   ofstream fp(filename);
-
-    for (int i = 0; i < num_insts; i++) {
-      cInstruction cur_inst(i);
-      fp << cur_inst.GetSymbol() << ":" << inst_set.GetName(i) << " ";
-    }
-    fp << endl;
-
+  
+  for (int i = 0; i < num_insts; i++) {
+    cInstruction cur_inst(i);
+    fp << cur_inst.GetSymbol() << ":" << inst_set.GetName(i) << " ";
+  }
+  fp << endl;
+  
   double total_length = 0.0;
   tArray<double> total_freq(num_insts);
   for (int i = 0; i < num_insts; i++) total_freq[i] = 0.0;
   int num_orgs = 0; 
-
+  
   // Loop through all of the genotypes in this batch...
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   cAnalyzeGenotype * genotype = NULL;
   while ((genotype = batch_it.Next()) != NULL) {
-
+    
     num_orgs++; 
-
+    
     // Setup for counting...
     tArray<int> inst_bin(num_insts);
     for (int i = 0; i < num_insts; i++) inst_bin[i] = 0;
-
+    
     // Count it up!
     const int genome_size = genotype->GetLength();
     for (int i = 0; i < genome_size; i++) {
@@ -3988,12 +4265,12 @@
     }
   }
   // Print it out...
-//    fp << total_length/num_orgs  << " ";
-    for (int i = 0; i < num_insts; i++) {
-      fp << cStringUtil::Stringf("%04.3f", total_freq[i]/num_orgs) << " ";
-    }
-    fp << endl;
-
+  //    fp << total_length/num_orgs  << " ";
+  for (int i = 0; i < num_insts; i++) {
+    fp << cStringUtil::Stringf("%04.3f", total_freq[i]/num_orgs) << " ";
+  }
+  fp << endl;
+  
 }
 
 void cAnalyze::AnalyzeBranching(cString cur_string)
@@ -4002,11 +4279,11 @@
     cout << "Analyzing branching patterns in batch " << cur_batch << endl;
   }
   else cout << "Analyzeing Branches..." << endl;
-
+  
   // Load in the variables...
   cString filename("branch_analyze.dat");
   if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-
+  
   // Setup the file...
   ofstream fp(filename);
   
@@ -4020,19 +4297,19 @@
     cout << "Analyzing mutation traceback in batch " << cur_batch << endl;
   }
   else cout << "Analyzing mutation traceback..." << endl;
-
+  
   // This works best on lineages, so warn if we don't have one.
   if (batch[cur_batch].IsLineage() == false && verbose == true) {
     cerr << "  Warning: trying to traceback mutations outside of lineage."
-	 << endl;
+    << endl;
   }
-
+  
   if (batch[cur_batch].List().GetSize() == 0) {
     cerr << "Error: Trying to traceback mutations with no genotypes in batch."
-	 << endl;
+    << endl;
     return;
   }
-
+  
   // Make sure all genotypes are the same length.
   int size = -1;
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
@@ -4045,18 +4322,18 @@
       return;
     }
   }
-
+  
   // Setup variables...
   cString filename("analyze_traceback.dat");
   if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-
+  
   // Setup a genome to store the previous values before mutations.
   tArray<int> prev_inst(size);
   prev_inst.SetAll(-1);  // -1 indicates never changed.
-
+  
   // Open the output file...
   ofstream fp(filename);
-
+  
   // Loop through all of the genotypes again, testing mutation reversions.
   cAnalyzeGenotype * prev_genotype = batch_it.Next();
   while ((genotype = batch_it.Next()) != NULL) {
@@ -4064,16 +4341,16 @@
     // Check to see if any sites have changed...
     for (int i = 0; i < size; i++) {
       if (genotype->GetGenome()[i] != prev_genotype->GetGenome()[i]) {
-	prev_inst[i] = prev_genotype->GetGenome()[i].GetOp();
+        prev_inst[i] = prev_genotype->GetGenome()[i].GetOp();
       }
     }
-
+    
     // Next, determine the fraction of mutations that are currently adaptive.
     int num_beneficial = 0;
     int num_neutral = 0;
     int num_detrimental = 0;
     int num_static = 0;      // Sites that were never mutated.
-
+    
     cGenome test_genome = genotype->GetGenome();
     cCPUTestInfo test_info;
     cTestCPU::TestGenome(test_info, test_genome);
@@ -4082,23 +4359,23 @@
     for (int i = 0; i < size; i++) {
       if (prev_inst[i] == -1) num_static++;
       else {
-	test_genome[i].SetOp(prev_inst[i]);
-	cTestCPU::TestGenome(test_info, test_genome);
-	const double cur_fitness = test_info.GetGenotypeFitness();
-	if (cur_fitness > base_fitness) num_detrimental++;
-	else if (cur_fitness < base_fitness) num_beneficial++;
-	else num_neutral++;
-	test_genome[i] = genotype->GetGenome()[i];
+        test_genome[i].SetOp(prev_inst[i]);
+        cTestCPU::TestGenome(test_info, test_genome);
+        const double cur_fitness = test_info.GetGenotypeFitness();
+        if (cur_fitness > base_fitness) num_detrimental++;
+        else if (cur_fitness < base_fitness) num_beneficial++;
+        else num_neutral++;
+        test_genome[i] = genotype->GetGenome()[i];
       }      
     }
-
+    
     fp << genotype->GetDepth() << " "
-       << num_beneficial << " "
-       << num_neutral << " "
-       << num_detrimental << " "
-       << num_static << " "
-       << endl;
-
+      << num_beneficial << " "
+      << num_neutral << " "
+      << num_detrimental << " "
+      << num_static << " "
+      << endl;
+    
     prev_genotype = genotype;
   }
 }
@@ -4106,7 +4383,7 @@
 void cAnalyze::AnalyzeComplexity(cString cur_string)
 {
   cout << "Analyzing genome complexity..." << endl;
-
+  
   // Load in the variables...
   // This command requires at least on arguement
   int words = cur_string.CountNumWords();
@@ -4114,15 +4391,15 @@
     cout << "AnalyzeComplexity has no parameters, skipping." << endl;
     return;
   }
-
+  
   // Get the mutation rate arguement
   double mut_rate = cur_string.PopWord().AsDouble();
-
+  
   // Create the directory using the string given as the second arguement
   cString dir = cur_string.PopWord();
   cString defaultDirectory = "complexity/";
   cString directory = PopDirectory(dir, defaultDirectory);
-
+  
   // Default for usage of resources is false
   int useResources = 0;
   // resource usage flag is an optional arguement, but is always the 3rd arg
@@ -4133,11 +4410,7 @@
       useResources = 0;
     }
   }
-  // It is an error to use resources, but have no environment
-  if(useResources) {
-    assert(d_environment);
-  }
-
+  
   // Batch frequency begins with the first organism, but then skips that 
   // amount ahead in the batch.  It defaults to 1, so that default analyzes
   // all the organisms in the batch.  It is always the 4th arg.
@@ -4148,31 +4421,27 @@
       batchFrequency = 1;
     }
   }
-
+  
   // These are used to backup the state of the environment and resource_count
   // for the test cpu, and will be reset to their original values at the end
   bool backupUsage;
-  cEnvironment *originalEnvironment;
-  cResourceCount originalResourceCount;
-
+  tArray<double> backupResources;
+  
   if(useResources) {
     // Backup test cpu data
     backupUsage = cTestCPU::UseResources();
-    originalEnvironment = cTestCPU::GetEnvironment();
-    originalResourceCount = cTestCPU::GetResourceCount();
-
-    // Set the test cpu up with our environment and tell it to use resources
-    cTestCPU::SetEnvironment(d_environment);
-    cTestCPU::SetupResources();
+    backupResources = cTestCPU::GetResources();
+    
     cTestCPU::UseResources() = true;
   }
-
+  
   ///////////////////////////////////////////////////////
   // Loop through all of the genotypes in this batch...
-
+  
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   cAnalyzeGenotype * genotype = NULL;
-
+  
+  
   bool islineage = false;
   cString lineage_filename;
   ofstream lineage_fp;
@@ -4187,7 +4456,7 @@
     non_lineage_fp.open(non_lineage_file);
     islineage = false;
   }
-
+  
   while ((genotype = batch_it.Next()) != NULL) {
     if (verbose == true) {
       cout << "  Analyzing complexity for " << genotype->GetName() << endl;
@@ -4202,24 +4471,21 @@
     } else {
       non_lineage_fp << genotype->GetID() << " ";
     }
-
+    
+    int updateBorn = -1;
     if(useResources) {
-      int updateBorn = genotype->GetUpdateBorn();
-
-      cEnvironment *env = cTestCPU::GetEnvironment();
-      assert(env);
-      FillResources(updateBorn, *env);
-      cTestCPU::SetupResources();
+      updateBorn = genotype->GetUpdateBorn();
+      FillResources(updateBorn);
     }
-
+    
     // Calculate the stats for the genotype we're working with ...
     genotype->Recalculate();
+    cout << genotype->GetFitness() << endl;
     const int num_insts = inst_set.GetSize();
-
     const int max_line = genotype->GetLength();
     const cGenome & base_genome = genotype->GetGenome();
     cGenome mod_genome(base_genome);
-
+    
     // Loop through all the lines of code, testing all mutations...
     tArray<double> test_fitness(num_insts);
     tArray<double> prob(num_insts);
@@ -4234,47 +4500,47 @@
       for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) {
         mod_genome[line_num].SetOp(mod_inst);
         cAnalyzeGenotype test_genotype(mod_genome, inst_set);
-	test_genotype.Recalculate();
+        test_genotype.Recalculate();
         test_fitness[mod_inst] = test_genotype.GetFitness();
       }
-
+      
       // Ajust fitness
       double cur_inst_fitness = test_fitness[cur_inst];
       for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) {
-	if (test_fitness[mod_inst] > cur_inst_fitness)
-	  test_fitness[mod_inst] = cur_inst_fitness;
+        if (test_fitness[mod_inst] > cur_inst_fitness)
+          test_fitness[mod_inst] = cur_inst_fitness;
         test_fitness[mod_inst] = test_fitness[mod_inst] / cur_inst_fitness;
       }
       
       // Calculate probabilities at mut-sel balance
       double w_bar = 1;
-
+      
       // Normalize fitness values, assert if they are all zero
       double maxFitness = 0.0;
       for(int i=0; i<num_insts; i++) {
-	if(test_fitness[i] > maxFitness) {
-	  maxFitness = test_fitness[i];
-	}
+        if(test_fitness[i] > maxFitness) {
+          maxFitness = test_fitness[i];
+        }
       }
-
+      
       if(maxFitness > 0) {
-	for(int i=0; i<num_insts; i++) {
-	  test_fitness[i] /= maxFitness;
-	}
+        for(int i=0; i<num_insts; i++) {
+          test_fitness[i] /= maxFitness;
+        }
       } else {
-	fp << "All zero fitness, ERROR." << endl;
-	continue;
+        fp << "All zero fitness, ERROR." << endl;
+        continue;
       }
-
+      
       while(1) {
         double sum = 0.0;
         for (int mod_inst = 0; mod_inst < num_insts; mod_inst ++) {
           prob[mod_inst] = (mut_rate * w_bar) /
-	                   ((double)num_insts * (w_bar + test_fitness[mod_inst] * mut_rate - test_fitness[mod_inst]));
+          ((double)num_insts * (w_bar + test_fitness[mod_inst] * mut_rate - test_fitness[mod_inst]));
           sum = sum + prob[mod_inst];
         }
         if ((sum-1.0)*(sum-1.0) <= 0.0001) 
-	  break;
+          break;
         else
           w_bar = w_bar - 0.000001;
       }
@@ -4282,21 +4548,21 @@
       for (int mod_inst = 0; mod_inst < num_insts; mod_inst ++) {
         fp << prob[mod_inst] << " ";
       }
-
+      
       // Calculate complexity
       double entropy = 0;
       for (int i = 0; i < num_insts; i ++) {
-	entropy += prob[i] * log((double) 1.0/prob[i]) / log ((double) num_insts);
+        entropy += prob[i] * log((double) 1.0/prob[i]) / log ((double) num_insts);
       }
       double complexity = 1 - entropy;
       fp << complexity << endl;
-
+      
       if (islineage) {
-	lineage_fp << complexity << " ";
+        lineage_fp << complexity << " ";
       } else {
-	non_lineage_fp << complexity << " ";
+        non_lineage_fp << complexity << " ";
       }
-
+      
       // Reset the mod_genome back to the original sequence.
       mod_genome[line_num].SetOp(cur_inst);
     }
@@ -4306,14 +4572,14 @@
     } else {
       non_lineage_fp << endl;
     }
-
+    
     // Always grabs the first one
     // Skip i-1 times, so that the beginning of the loop will grab the ith one
     // where i is the batchFrequency
     for(int count=0; genotype != NULL && count < batchFrequency - 1; count++) {
       genotype = batch_it.Next();
       if(genotype != NULL && verbose == true) {
-	cout << "Skipping: " << genotype->GetName() << endl;
+        cout << "Skipping: " << genotype->GetName() << endl;
       }
     }
     if(genotype == NULL) { break; }
@@ -4323,14 +4589,13 @@
   } else {
     non_lineage_fp.close();
   }
-
+  
   if(useResources) {
     // Set the test cpu back to the state it was in before we messed with it
     cTestCPU::UseResources() = backupUsage;
-    cTestCPU::SetEnvironment(originalEnvironment);
-    cTestCPU::GetResourceCount() = originalResourceCount;
+    cTestCPU::SetupResourceArray(backupResources);
   }
-
+  
   return;
 }
 
@@ -4343,67 +4608,67 @@
   //int sample_size = cur_string.PopWord().AsInt();
   cString directory = PopDirectory(cur_string, "pop_complexity/");
   cString file = cur_string;
-
+  
   // Get sample index...
   /*if (sample_size > batch_size) {
     cout << " Sample size is greater than batch size." << endl;
-    return;
+  return;
   }
-  int *index_array;
-  int *flag_array;
-  index_array = (int*) malloc (batch_size*sizeof(int));
-  flag_array = (int*) malloc (batch_size*sizeof(int));
-  for (int i=0; i<batch_size; i++) {
-    index_array[i] = i;
-    flag_array[i] = 0;
-  }
-  int max_num = batch_size;
-  cRandom random;
-  for (int i=0; i<sample_size; i++) {
-    int index = random.GetUInt(max_num);
-    flag_array[index_array[index]] = 1;
-    index_array[index] = index_array[max_num-1];
-    max_num--;
-    }*/
-
+int *index_array;
+int *flag_array;
+index_array = (int*) malloc (batch_size*sizeof(int));
+flag_array = (int*) malloc (batch_size*sizeof(int));
+for (int i=0; i<batch_size; i++) {
+  index_array[i] = i;
+  flag_array[i] = 0;
+}
+int max_num = batch_size;
+cRandom random;
+for (int i=0; i<sample_size; i++) {
+  int index = random.GetUInt(max_num);
+  flag_array[index_array[index]] = 1;
+  index_array[index] = index_array[max_num-1];
+  max_num--;
+}*/
+  
   // Construct filename...
   cString filename;
   filename.Set("%spop%s.complexity.dat", directory(), file());
   ofstream fp(filename());
-
+  
   //////////////////////////////////////////////////////////
   // Loop through all of the genotypes in this batch ...
-
+  
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   cAnalyzeGenotype * genotype = NULL;
-
- 
+  
+  
   genotype = batch_it.Next();
-
-
+  
+  
   if (genotype == NULL) return;
   int seq_length = genotype->GetLength();
   const int num_insts = inst_set.GetSize();
   tMatrix<int> inst_stat(seq_length, num_insts);
-
+  
   // Initializing inst_stat ...
   for (int line_num = 0; line_num < seq_length; line_num ++) 
     for (int inst_num = 0; inst_num < num_insts; inst_num ++) 
       inst_stat(line_num, inst_num) = 0;
-
+  
   int num_cpus = 0;
   int actural_samples = 0;
   while (genotype != NULL) {
     num_cpus = genotype->GetNumCPUs();
     const cGenome & base_genome = genotype->GetGenome();
     for (int i=0; i<num_cpus; i++) {   // Stat on every organism with same genotype.
-      //if (flag_array[organism_index] == 0) {
-      //organism_index++;
-      //continue;
-      //}
+                                       //if (flag_array[organism_index] == 0) {
+                                       //organism_index++;
+                                       //continue;
+                                       //}
       for (int line_num = 0; line_num < seq_length; line_num ++) {
-	int cur_inst = base_genome[line_num].GetOp();
-	inst_stat(line_num, cur_inst) ++;
+        int cur_inst = base_genome[line_num].GetOp();
+        inst_stat(line_num, cur_inst) ++;
       }
       //organism_index++;
       actural_samples++;
@@ -4413,30 +4678,30 @@
 
 
 
-  // Calculate complexity
-  for (int line_num = 0; line_num < seq_length; line_num ++) {
-    double entropy = 0.0;
-    for (int inst_num = 0; inst_num < num_insts; inst_num ++) {
-      if (inst_stat(line_num, inst_num) == 0) continue;
-      float prob = (float) (inst_stat(line_num, inst_num)) / (float) (actural_samples);
-      entropy += prob * log((double) 1.0/prob) / log((double) num_insts);
-    }
-    double complexity = 1 - entropy;
-    fp << complexity << " ";
-  };
-  fp << endl;
-  fp.close();
-  //free(index_array);
-  //free(flag_array);
-  return;
+// Calculate complexity
+for (int line_num = 0; line_num < seq_length; line_num ++) {
+  double entropy = 0.0;
+  for (int inst_num = 0; inst_num < num_insts; inst_num ++) {
+    if (inst_stat(line_num, inst_num) == 0) continue;
+    float prob = (float) (inst_stat(line_num, inst_num)) / (float) (actural_samples);
+    entropy += prob * log((double) 1.0/prob) / log((double) num_insts);
+  }
+  double complexity = 1 - entropy;
+  fp << complexity << " ";
+};
+fp << endl;
+fp.close();
+//free(index_array);
+//free(flag_array);
+return;
 }
 
 
 void cAnalyze::EnvironmentSetup(cString cur_string)
 {
   cout << "Running environment command: " << endl
-       << "  " << cur_string << endl;
-
+  << "  " << cur_string << endl;
+  
   cTestCPU::GetEnvironment()->LoadLine(cur_string);
 }
 
@@ -4444,26 +4709,26 @@
 void cAnalyze::CommandHelpfile(cString cur_string)
 {
   cout << "Printing helpfiles in: " << cur_string << endl;
-
+  
   cHelpManager help_control;
   if (verbose == true) help_control.SetVerbose();
   while (cur_string.GetSize() > 0) {
     help_control.LoadFile(cur_string.PopWord());
   }
-
+  
   help_control.PrintHTML();
 }
 
 void cAnalyze::CommandDocfile(cString cur_string)
 {
   cout << "Printing documentation files in: " << cur_string << endl;
-
+  
   cHelpManager help_control;
   if (verbose == true) help_control.SetVerbose();
   while (cur_string.GetSize() > 0) {
     help_control.LoadFile(cur_string.PopWord());
   }
-
+  
   help_control.PrintHTML();
 }
 
@@ -4474,15 +4739,15 @@
 void cAnalyze::VarSet(cString cur_string)
 {
   cString var = cur_string.PopWord();
-
+  
   if (cur_string.GetSize() == 0) {
     cerr << "Error: No variable provided in SET command" << endl;
     return;
   }
-
+  
   cString & cur_variable = GetVariable(var);
   cur_variable = cur_string.PopWord();
-
+  
   if (verbose == true) {
     cout << "Setting " << var << " to " << cur_variable << endl;
   }
@@ -4509,7 +4774,7 @@
     if (verbose) cout << "  Warning: No name given in NAME_BATCH!" << endl;
     return;
   }
-
+  
   batch[cur_batch].Name() = cur_string.PopWord();
 }
 
@@ -4519,31 +4784,31 @@
     if (verbose) cout << "  Warning: No tag given in TAG_BATCH!" << endl;
     return;
   }
-
+  
   if (verbose == true) {
     cout << "Tagging batch " << cur_batch
-	 << " with tag '" << cur_string << "'" << endl;
+    << " with tag '" << cur_string << "'" << endl;
   }
-
+  
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   cAnalyzeGenotype * genotype = NULL;
   while ((genotype = batch_it.Next()) != NULL) {
     genotype->SetTag(cur_string);
   }
-
+  
 }
 
 void cAnalyze::BatchPurge(cString cur_string)
 {
   int batch_id = cur_batch;
   if (cur_string.CountNumWords() > 0) batch_id = cur_string.PopWord().AsInt();
-
+  
   if (verbose) cout << "Purging batch " << batch_id << endl;
-
+  
   while (batch[batch_id].List().GetSize() > 0) {
     delete batch[batch_id].List().Pop();
   }
-
+  
   batch[batch_id].SetLineage(false);
   batch[batch_id].SetAligned(false);
 }
@@ -4555,22 +4820,22 @@
     exit(1);
   }
   int batch_from = cur_string.PopWord().AsInt();
-
+  
   int batch_to = cur_batch;
   if (cur_string.GetSize() > 0) batch_to = cur_string.PopWord().AsInt();
-
+  
   if (verbose == true) {
     cout << "Duplicating from batch " << batch_from
-	 << " to batch " << batch_to << "." << endl;
+    << " to batch " << batch_to << "." << endl;
   }
-
+  
   tListIterator<cAnalyzeGenotype> batch_from_it(batch[batch_from].List());
   cAnalyzeGenotype * genotype = NULL;
   while ((genotype = batch_from_it.Next()) != NULL) {
     cAnalyzeGenotype * new_genotype = new cAnalyzeGenotype(*genotype);
     batch[batch_to].List().PushRear(new_genotype);
   }
-
+  
   batch[batch_to].SetLineage(false);
   batch[batch_to].SetAligned(false);
 }
@@ -4586,52 +4851,58 @@
       useResources = 0;
     }
   }
-  if(useResources) {
-    assert(d_environment);
-  }
-
+  
   bool backupUsage;
-  cResourceCount originalResourceCount;
-  cEnvironment *backupEnvironment;
+  tArray<double> backupResources;
+  
   if(useResources) {
+    // Backup test cpu data
     backupUsage = cTestCPU::UseResources();
-    originalResourceCount = cTestCPU::GetResourceCount();
-    backupEnvironment = cTestCPU::GetEnvironment();
-
-    cTestCPU::SetEnvironment(d_environment);
-    cTestCPU::SetupResources();
+    backupResources = cTestCPU::GetResources();
+    
     cTestCPU::UseResources() = true;
   }
-
+  
   if (verbose == true) {
     cout << "Running batch " << cur_batch << " through test CPUs..." << endl;
   } else cout << "Running through test CPUs..." << endl;
-
+  
   if (verbose == true && batch[cur_batch].IsLineage() == false) {
     cerr << "  Warning: batch may not be a linege; "
-	 << "parent and ancestor distances may not be correct" << endl;
+    << "parent and ancestor distances may not be correct" << endl;
   }
-
+  
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   cAnalyzeGenotype * genotype = NULL;
   cAnalyzeGenotype * last_genotype = NULL;
   while ((genotype = batch_it.Next()) != NULL) {
+    
+    // If use resources, load proper resource according to update_born
+    int updateBorn = -1;
+    if(useResources) {
+      updateBorn = genotype->GetUpdateBorn();
+      FillResources(updateBorn);
+    }
+    
     // If the previous genotype was the parent of this one, pass in a pointer
     // to it for improved recalculate (such as distance to parent, etc.)
+    if (verbose == true) {
+      PrintTestCPUResources("");
+    }
     if (last_genotype != NULL &&
-	genotype->GetParentID() == last_genotype->GetID()) {
+        genotype->GetParentID() == last_genotype->GetID()) {
       genotype->Recalculate(last_genotype);
     }
     else genotype->Recalculate();
     last_genotype = genotype;
   }
-
+  
   if(useResources) {
-    cTestCPU::SetEnvironment(backupEnvironment);
-    cTestCPU::GetResourceCount() = originalResourceCount;
+    // Set the test cpu back to the state it was in before we messed with it
     cTestCPU::UseResources() = backupUsage;
+    cTestCPU::SetupResourceArray(backupResources);
   }
-
+  
   return;
 }
 
@@ -4639,9 +4910,9 @@
 {
   if (verbose == false) cout << "Renaming organisms..." << endl;
   else cout << "Renaming organisms in batch " << cur_batch << endl;
-
+  
   // If a number is given with rename, start at that number...
-
+  
   int id_num = cur_string.PopWord().AsInt();
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   cAnalyzeGenotype * genotype = NULL;
@@ -4657,16 +4928,16 @@
 {
   // No Args needed...
   (void) cur_string;
-
+  
   cout << "Status Report:" << endl;
   for (int i = 0; i < MAX_BATCHES; i++) {
     if (i == cur_batch || batch[i].List().GetSize() > 0) {
       cout << "  Batch " << i << " -- "
-	   << batch[i].List().GetSize() << " genotypes.";
+      << batch[i].List().GetSize() << " genotypes.";
       if (i == cur_batch) cout << "  <current>";
       if (batch[i].IsLineage() == true) cout << "  <lineage>";
       if (batch[i].IsAligned() == true) cout << "  <aligned>";
-
+      
       cout << endl;
     }
   }
@@ -4681,7 +4952,7 @@
 {
   // No Args needed...
   (void) cur_string;
-
+  
   if (verbose == false) {
     cout << "Using verbose log messages..." << endl;
     verbose = true;
@@ -4695,12 +4966,12 @@
 {
   while (cur_string.GetSize() > 0) {
     cString filename = cur_string.PopWord();
-
+    
     cInitFile include_file(filename);
     include_file.Load();
     include_file.Compress();
     include_file.Close();
-
+    
     tList<cAnalyzeCommand> include_list;
     LoadCommandList(include_file, include_list);
     ProcessCommands(include_list);
@@ -4710,7 +4981,7 @@
 void cAnalyze::CommandSystem(cString cur_string)
 {
   cout << "Running System Command: " << cur_string << endl;
-
+  
   system(cur_string());
 }
 
@@ -4718,7 +4989,7 @@
 {
   // No Args needed...
   (void) cur_string;
-
+  
   RunInteractive();
 }
 
@@ -4727,42 +4998,41 @@
   cout << "TestCPU is using resources: ";
   cout << cTestCPU::UseResources() << endl;
   cout << "Resources currently in TestCPU: ";
-  const cResourceCount &resources = cTestCPU::GetResourceCount();
-  const tArray<double> &quantity = resources.ReadResources();
+  const tArray<double> &quantity = cTestCPU::GetResources();
   for(int i=0; i<quantity.GetSize(); i++) {
     cout << quantity.ElementAt(i) << " ";
   }
   cout << endl;
-
+  
   return;
 }
 
 void cAnalyze::FunctionCreate(cString cur_string,
-			      tList<cAnalyzeCommand> & clist)
+                              tList<cAnalyzeCommand> & clist)
 {
   int num_args = cur_string.CountNumWords();
   if (num_args < 1) {
     cerr << "Error: Must provide function name when creating function.";
     exit(1);
   }
-
+  
   cString fun_name = cur_string.PopWord();
   fun_name.ToUpper();
-
+  
   if (FindAnalyzeCommandDef(fun_name) != NULL) {
     cerr << "Error: Cannot create function '" << fun_name
-	 << "'; already exists." << endl;
+    << "'; already exists." << endl;
     exit(1);
   }
-
+  
   if (verbose) cout << "Creating function: " << fun_name << endl;
-
+  
   // Create the new function...
   cAnalyzeFunction * new_function = new cAnalyzeFunction(fun_name);
   while (clist.GetSize() > 0) {
     new_function->GetCommandList()->PushRear(clist.Pop());
   }
-
+  
   // Save the function on the new list...
   function_list.PushRear(new_function);
 }
@@ -4773,7 +5043,7 @@
     cout << "Running function: " << fun_name << endl;
     // << " with args: " << args << endl;
   }
-
+  
   // Find the function we're about to run...
   cAnalyzeFunction * found_function = NULL;
   tListIterator<cAnalyzeFunction> function_it(function_list);
@@ -4783,27 +5053,27 @@
       break;
     }
   }
-
+  
   // If we were unable to find the command we're looking for, return false.
   if (found_function == NULL) return false;
-
+  
   // Back up the local variables
   cString backup_arg_vars[10];
   cString backup_local_vars[26];
   for (int i = 0; i < 10; i++) backup_arg_vars[i] = arg_variables[i];
   for (int i = 0; i < 26; i++) backup_local_vars[i] = local_variables[i];
-
+  
   // Set the arg variables to the passed-in args...
   arg_variables[0] = fun_name;
   for (int i = 1; i < 10; i++) arg_variables[i] = args.PopWord();
   for (int i = 0; i < 26; i++) local_variables[i] = "";
-
+  
   ProcessCommands(*(found_function->GetCommandList()));
-
+  
   // Restore the local variables
   for (int i = 0; i < 10; i++) arg_variables[i] = backup_arg_vars[i];
   for (int i = 0; i < 26; i++) local_variables[i] = backup_local_vars[i];
-
+  
   return true;
 }
 
@@ -4811,9 +5081,9 @@
 int cAnalyze::BatchUtil_GetMaxLength(int batch_id)
 {
   if (batch_id < 0) batch_id = cur_batch;
-
+  
   int max_length = 0;
-
+  
   tListIterator<cAnalyzeGenotype> batch_it(batch[batch_id].List());
   cAnalyzeGenotype * genotype = NULL;
   while ((genotype = batch_it.Next()) != NULL) {
@@ -4825,24 +5095,24 @@
 
 
 void cAnalyze::CommandForeach(cString cur_string,
-			      tList<cAnalyzeCommand> & clist)
+                              tList<cAnalyzeCommand> & clist)
 {
   if (verbose) cout << "Initiating Foreach loop..." << endl;
-
+  
   cString var = cur_string.PopWord();
   int num_args = cur_string.CountNumWords();
-
+  
   cString & cur_variable = GetVariable(var);
-
+  
   for (int i = 0; i < num_args; i++) {
     cur_variable = cur_string.PopWord();
-
+    
     if (verbose == true) {
       cout << "Foreach: setting " << var << " to " << cur_variable << endl;
     }
     ProcessCommands(clist);
   }
-
+  
   if (verbose == true) {
     cout << "Ending Foreach on " << var << endl;
   }
@@ -4850,48 +5120,48 @@
 
 
 void cAnalyze::CommandForRange(cString cur_string,
-			      tList<cAnalyzeCommand> & clist)
+                               tList<cAnalyzeCommand> & clist)
 {
   if (verbose) cout << "Initiating FORRANGE loop..." << endl;
-
+  
   int num_args = cur_string.CountNumWords();
   if (num_args < 3) {
     cerr << "  Error: Must give variable, min and max with FORRANGE!"
-	 << endl;
+    << endl;
     exit(1);
   }
-
+  
   cString var = cur_string.PopWord();
   double min_val = cur_string.PopWord().AsDouble();
   double max_val = cur_string.PopWord().AsDouble();
   double step_val = 1.0;
   if (num_args >=4 ) step_val = cur_string.PopWord().AsDouble();
-
+  
   cString & cur_variable = GetVariable(var);
-
+  
   // Seperate out all ints from not all ints...
   if (min_val == (double) ((int) min_val) &&
       max_val == (double) ((int) max_val) &&
       step_val == (double) ((int) step_val)) {
     for (int i = (int) min_val; i <= (int) max_val; i += (int) step_val) {
       cur_variable.Set("%d", i);
-
+      
       if (verbose == true) {
-	cout << "FORRANGE: setting " << var << " to " << cur_variable << endl;
+        cout << "FORRANGE: setting " << var << " to " << cur_variable << endl;
       }
       ProcessCommands(clist);
     }
   } else {
     for (double i = min_val; i <= max_val; i += step_val) {
       cur_variable.Set("%f", i);
-
+      
       if (verbose == true) {
-	cout << "FORRANGE: setting " << var << " to " << cur_variable << endl;
+        cout << "FORRANGE: setting " << var << " to " << cur_variable << endl;
       }
       ProcessCommands(clist);
     }
   }
-
+  
   if (verbose == true) {
     cout << "Ending FORRANGE on " << var << endl;
   }
@@ -4901,30 +5171,30 @@
 ///////////////////  Private Methods ///////////////////////////
 
 cString cAnalyze::PopDirectory(cString & in_string,
-			       const cString & default_dir)
+                               const cString & default_dir)
 {
   // Determing the directory name
   cString directory(default_dir);
   if (in_string.GetSize() != 0) directory = in_string.PopWord();
-
+  
   // Make sure the directory ends in a slash.  If not, add one.
   int last_pos = directory.GetSize() - 1;
   if (directory[last_pos] != '/' && directory[last_pos] != '\\') {
     directory += '/';
   }
-
+  
   // Make sure the directory exists.
   FILE *fp = fopen ( directory(), "r" );
   if ( fp == 0 ){
     if ( errno == ENOENT ){
       cerr << "Directory '" << directory
-	   << "' does not exist.  Creating..." << endl;
+      << "' does not exist.  Creating..." << endl;
       if ( mkdir( directory(), (S_IRWXU|S_IRWXG|S_IRWXO) ) )
-	cerr << " Error creating '" << directory << "'" << endl;
+        cerr << " Error creating '" << directory << "'" << endl;
     }
     else cerr << " Error opening '" << directory << "'" << endl;
   }
-
+  
   return directory;
 }
 
@@ -4934,7 +5204,7 @@
   if (in_string.GetSize() != 0 && in_string != "current") {
     batch = in_string.AsInt();
   }
-
+  
   return batch;
 }
 
@@ -4943,7 +5213,7 @@
   if (batch_id == -1) batch_id = cur_batch;
   tListPlus<cAnalyzeGenotype> & gen_list = batch[batch_id].List();
   gen_desc.ToLower();
-
+  
   cAnalyzeGenotype * found_gen = NULL;
   if (gen_desc == "num_cpus")
     found_gen = gen_list.PopIntMax(&cAnalyzeGenotype::GetNumCPUs);
@@ -4955,7 +5225,7 @@
     found_gen = gen_list.PopDoubleMax(&cAnalyzeGenotype::GetFitness);
   else if (gen_desc.IsNumeric(0))
     found_gen = gen_list.PopIntValue(&cAnalyzeGenotype::GetID,
-				     gen_desc.AsInt());
+                                     gen_desc.AsInt());
   else if (gen_desc == "random") {
     int gen_pos = random.GetUInt(gen_list.GetSize());
     found_gen = gen_list.PopPos(gen_pos);
@@ -4964,7 +5234,7 @@
     cout << "  Error: unknown type " << gen_desc << endl;
     exit(1);
   }
-
+  
   return found_gen;
 }
 
@@ -4976,7 +5246,7 @@
     cerr << "Error: Illegal variable " << var << " being used." << endl;
     exit(1);
   }
-
+  
   if (var.IsLowerLetter(0) == true) {
     int var_id = (int) (var[0] - 'a');
     return variables[var_id];
@@ -4992,13 +5262,13 @@
 
 
 void cAnalyze::LoadCommandList(cInitFile & init_file,
-			       tList<cAnalyzeCommand> & clist)
+                               tList<cAnalyzeCommand> & clist)
 {
   while (init_file.GetLineNum() < init_file.GetNumLines()) {
     cString cur_string = init_file.GetNextLine();
     cString command = cur_string.PopWord();
     command.ToUpper();
-
+    
     cAnalyzeCommand * cur_command;
     cAnalyzeCommandDefBase * command_def = FindAnalyzeCommandDef(command);
     if (command == "END") {
@@ -5014,7 +5284,7 @@
       // This is a normal command...
       cur_command = new cAnalyzeCommand(command, cur_string);
     }
-
+    
     clist.PushRear(cur_command);
   }
 }
@@ -5033,7 +5303,7 @@
     cString cur_input(text_input);
     cString command = cur_input.PopWord();
     command.ToUpper();
-
+    
     cAnalyzeCommand * cur_command;
     cAnalyzeCommandDefBase * command_def = FindAnalyzeCommandDef(command);
     if (command == "END") {
@@ -5049,7 +5319,7 @@
       // This is a normal command...
       cur_command = new cAnalyzeCommand(command, cur_input);
     }
-
+    
     clist.PushRear(cur_command);
   }
   interactive_depth--;
@@ -5064,7 +5334,7 @@
     char varlet = args[pos+1];
     cString varname("$");
     varname += varlet;
-
+    
     // Determine the variable and act on it.
     int varsize = 0;
     if (varlet == '$') {
@@ -5100,9 +5370,9 @@
     cString command = cur_command->GetCommand();
     cString args = cur_command->GetArgs();
     PreProcessArgs(args);
-
+    
     cAnalyzeCommandDefBase * command_fun = FindAnalyzeCommandDef(command);
-
+    
     if (command_fun != NULL) command_fun->Run(this, args, *cur_command);
     else if (FunctionRun(command, args) == true) {
       // Found a defined function by this name.
@@ -5111,176 +5381,176 @@
       cerr << "Error: Unknown analysis keyword '" << command << "'." << endl;
       exit(1);
     }
-
+    
   }
 }
 
 void cAnalyze::SetupGenotypeDataList()
 {
   if (genotype_data_list.GetSize() != 0) return; // List already setup.
-
+  
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, bool>
-       ("viable",      "Is Viable (0/1)", &cAnalyzeGenotype::GetViable,
-	&cAnalyzeGenotype::SetViable));
+                              ("viable",      "Is Viable (0/1)", &cAnalyzeGenotype::GetViable,
+                               &cAnalyzeGenotype::SetViable));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-       ("id",          "Genome ID",       &cAnalyzeGenotype::GetID,
-	&cAnalyzeGenotype::SetID));
+                              ("id",          "Genome ID",       &cAnalyzeGenotype::GetID,
+                               &cAnalyzeGenotype::SetID));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, const cString &>
-       ("tag",         "Genotype Tag",    &cAnalyzeGenotype::GetTag,
-	&cAnalyzeGenotype::SetTag,
-	&cAnalyzeGenotype::CompareNULL, "(none)", ""));
+                              ("tag",         "Genotype Tag",    &cAnalyzeGenotype::GetTag,
+                               &cAnalyzeGenotype::SetTag,
+                               &cAnalyzeGenotype::CompareNULL, "(none)", ""));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-       ("parent_id",   "Parent ID",       &cAnalyzeGenotype::GetParentID,
-	&cAnalyzeGenotype::SetParentID));
+                              ("parent_id",   "Parent ID",       &cAnalyzeGenotype::GetParentID,
+                               &cAnalyzeGenotype::SetParentID));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-       ("parent2_id",  "Second Parent ID (for sexual genotypes)",
-	&cAnalyzeGenotype::GetParent2ID, &cAnalyzeGenotype::SetParent2ID));
+                              ("parent2_id",  "Second Parent ID (for sexual genotypes)",
+                               &cAnalyzeGenotype::GetParent2ID, &cAnalyzeGenotype::SetParent2ID));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-       ("parent_dist", "Parent Distance", &cAnalyzeGenotype::GetParentDist,
-	&cAnalyzeGenotype::SetParentDist));
+                              ("parent_dist", "Parent Distance", &cAnalyzeGenotype::GetParentDist,
+                               &cAnalyzeGenotype::SetParentDist));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-       ("ancestor_dist","Ancestor Distance",&cAnalyzeGenotype::GetAncestorDist,
-	&cAnalyzeGenotype::SetAncestorDist));
+                              ("ancestor_dist","Ancestor Distance",&cAnalyzeGenotype::GetAncestorDist,
+                               &cAnalyzeGenotype::SetAncestorDist));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-       ("lineage", "Unique Lineage Label",&cAnalyzeGenotype::GetLineageLabel,
-	&cAnalyzeGenotype::SetLineageLabel));
+                              ("lineage", "Unique Lineage Label",&cAnalyzeGenotype::GetLineageLabel,
+                               &cAnalyzeGenotype::SetLineageLabel));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-       ("num_cpus",    "Number of CPUs",  &cAnalyzeGenotype::GetNumCPUs,
-	&cAnalyzeGenotype::SetNumCPUs));
+                              ("num_cpus",    "Number of CPUs",  &cAnalyzeGenotype::GetNumCPUs,
+                               &cAnalyzeGenotype::SetNumCPUs));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-       ("total_cpus",  "Total CPUs Ever", &cAnalyzeGenotype::GetTotalCPUs,
-	&cAnalyzeGenotype::SetTotalCPUs));
+                              ("total_cpus",  "Total CPUs Ever", &cAnalyzeGenotype::GetTotalCPUs,
+                               &cAnalyzeGenotype::SetTotalCPUs));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-       ("length",      "Genome Length",   &cAnalyzeGenotype::GetLength,
-	&cAnalyzeGenotype::SetLength, &cAnalyzeGenotype::CompareLength));
+                              ("length",      "Genome Length",   &cAnalyzeGenotype::GetLength,
+                               &cAnalyzeGenotype::SetLength, &cAnalyzeGenotype::CompareLength));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-       ("copy_length", "Copied Length",   &cAnalyzeGenotype::GetCopyLength,
-	&cAnalyzeGenotype::SetCopyLength));
+                              ("copy_length", "Copied Length",   &cAnalyzeGenotype::GetCopyLength,
+                               &cAnalyzeGenotype::SetCopyLength));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-       ("exe_length",  "Executed Length", &cAnalyzeGenotype::GetExeLength,
-	&cAnalyzeGenotype::SetExeLength));
+                              ("exe_length",  "Executed Length", &cAnalyzeGenotype::GetExeLength,
+                               &cAnalyzeGenotype::SetExeLength));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-       ("merit",       "Merit",           &cAnalyzeGenotype::GetMerit,
-	&cAnalyzeGenotype::SetMerit, &cAnalyzeGenotype::CompareMerit));
+                              ("merit",       "Merit",           &cAnalyzeGenotype::GetMerit,
+                               &cAnalyzeGenotype::SetMerit, &cAnalyzeGenotype::CompareMerit));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-       ("comp_merit",  "Computational Merit", &cAnalyzeGenotype::GetCompMerit,
-	(void (cAnalyzeGenotype::*)(double)) NULL, &cAnalyzeGenotype::CompareCompMerit));
+                              ("comp_merit",  "Computational Merit", &cAnalyzeGenotype::GetCompMerit,
+                               (void (cAnalyzeGenotype::*)(double)) NULL, &cAnalyzeGenotype::CompareCompMerit));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-       ("comp_merit_ratio", "Computational Merit Ratio",
-	&cAnalyzeGenotype::GetCompMeritRatio,
-	(void (cAnalyzeGenotype::*)(double)) NULL,
-	&cAnalyzeGenotype::CompareCompMerit));
+                              ("comp_merit_ratio", "Computational Merit Ratio",
+                               &cAnalyzeGenotype::GetCompMeritRatio,
+                               (void (cAnalyzeGenotype::*)(double)) NULL,
+                               &cAnalyzeGenotype::CompareCompMerit));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-       ("gest_time",   "Gestation Time",  &cAnalyzeGenotype::GetGestTime,
-	&cAnalyzeGenotype::SetGestTime,
-	&cAnalyzeGenotype::CompareGestTime, "Inf."));
+                              ("gest_time",   "Gestation Time",  &cAnalyzeGenotype::GetGestTime,
+                               &cAnalyzeGenotype::SetGestTime,
+                               &cAnalyzeGenotype::CompareGestTime, "Inf."));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-       ("efficiency",  "Rep. Efficiency", &cAnalyzeGenotype::GetEfficiency,
-	(void (cAnalyzeGenotype::*)(double)) NULL,
-	&cAnalyzeGenotype::CompareEfficiency));
+                              ("efficiency",  "Rep. Efficiency", &cAnalyzeGenotype::GetEfficiency,
+                               (void (cAnalyzeGenotype::*)(double)) NULL,
+                               &cAnalyzeGenotype::CompareEfficiency));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-       ("efficiency_ratio", "Rep. Efficiency Ratio",
-	&cAnalyzeGenotype::GetEfficiencyRatio,
-	(void (cAnalyzeGenotype::*)(double)) NULL,
-	&cAnalyzeGenotype::CompareEfficiency));
+                              ("efficiency_ratio", "Rep. Efficiency Ratio",
+                               &cAnalyzeGenotype::GetEfficiencyRatio,
+                               (void (cAnalyzeGenotype::*)(double)) NULL,
+                               &cAnalyzeGenotype::CompareEfficiency));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-       ("fitness",     "Fitness",         &cAnalyzeGenotype::GetFitness,
-	&cAnalyzeGenotype::SetFitness, &cAnalyzeGenotype::CompareFitness));
+                              ("fitness",     "Fitness",         &cAnalyzeGenotype::GetFitness,
+                               &cAnalyzeGenotype::SetFitness, &cAnalyzeGenotype::CompareFitness));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-       ("div_type",     "Divide Type",         &cAnalyzeGenotype::GetDivType,
-	&cAnalyzeGenotype::SetDivType));
+                              ("div_type",     "Divide Type",         &cAnalyzeGenotype::GetDivType,
+                               &cAnalyzeGenotype::SetDivType));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-       ("fitness_ratio", "Fitness Ratio", &cAnalyzeGenotype::GetFitnessRatio,
-	(void (cAnalyzeGenotype::*)(double)) NULL,
-	&cAnalyzeGenotype::CompareFitness));
+                              ("fitness_ratio", "Fitness Ratio", &cAnalyzeGenotype::GetFitnessRatio,
+                               (void (cAnalyzeGenotype::*)(double)) NULL,
+                               &cAnalyzeGenotype::CompareFitness));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-       ("update_born", "Update Born",     &cAnalyzeGenotype::GetUpdateBorn,
-	&cAnalyzeGenotype::SetUpdateBorn));
+                              ("update_born", "Update Born",     &cAnalyzeGenotype::GetUpdateBorn,
+                               &cAnalyzeGenotype::SetUpdateBorn));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-       ("update_dead", "Update Dead",     &cAnalyzeGenotype::GetUpdateDead,
-	&cAnalyzeGenotype::SetUpdateDead));
+                              ("update_dead", "Update Dead",     &cAnalyzeGenotype::GetUpdateDead,
+                               &cAnalyzeGenotype::SetUpdateDead));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-       ("depth",       "Tree Depth",      &cAnalyzeGenotype::GetDepth,
-	&cAnalyzeGenotype::SetDepth));
+                              ("depth",       "Tree Depth",      &cAnalyzeGenotype::GetDepth,
+                               &cAnalyzeGenotype::SetDepth));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-       ("frac_dead",   "Fraction Mutations Lethal",
-	&cAnalyzeGenotype::GetFracDead,
-	(void (cAnalyzeGenotype::*)(double)) NULL));
+                              ("frac_dead",   "Fraction Mutations Lethal",
+                               &cAnalyzeGenotype::GetFracDead,
+                               (void (cAnalyzeGenotype::*)(double)) NULL));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-       ("frac_neg",   "Fraction Mutations Detrimental",
-	&cAnalyzeGenotype::GetFracNeg,
-	(void (cAnalyzeGenotype::*)(double)) NULL));
+                              ("frac_neg",   "Fraction Mutations Detrimental",
+                               &cAnalyzeGenotype::GetFracNeg,
+                               (void (cAnalyzeGenotype::*)(double)) NULL));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-       ("frac_neut",   "Fraction Mutations Neutral",
-	&cAnalyzeGenotype::GetFracNeut,
-	(void (cAnalyzeGenotype::*)(double)) NULL));
+                              ("frac_neut",   "Fraction Mutations Neutral",
+                               &cAnalyzeGenotype::GetFracNeut,
+                               (void (cAnalyzeGenotype::*)(double)) NULL));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-       ("frac_pos",   "Fraction Mutations Beneficial",
-	&cAnalyzeGenotype::GetFracPos,
-	(void (cAnalyzeGenotype::*)(double)) NULL));
+                              ("frac_pos",   "Fraction Mutations Beneficial",
+                               &cAnalyzeGenotype::GetFracPos,
+                               (void (cAnalyzeGenotype::*)(double)) NULL));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, const cString &>
-       ("parent_muts", "Mutations from Parent",
-	&cAnalyzeGenotype::GetParentMuts, &cAnalyzeGenotype::SetParentMuts,
-	&cAnalyzeGenotype::CompareNULL, "(none)", ""));
+                              ("parent_muts", "Mutations from Parent",
+                               &cAnalyzeGenotype::GetParentMuts, &cAnalyzeGenotype::SetParentMuts,
+                               &cAnalyzeGenotype::CompareNULL, "(none)", ""));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, const cString &>
-       ("task_order", "Task Performance Order",
-	&cAnalyzeGenotype::GetTaskOrder, &cAnalyzeGenotype::SetTaskOrder,
-	&cAnalyzeGenotype::CompareNULL, "(none)", ""));
+                              ("task_order", "Task Performance Order",
+                               &cAnalyzeGenotype::GetTaskOrder, &cAnalyzeGenotype::SetTaskOrder,
+                               &cAnalyzeGenotype::CompareNULL, "(none)", ""));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, cString>
-       ("sequence",    "Genome Sequence",
-	&cAnalyzeGenotype::GetSequence, &cAnalyzeGenotype::SetSequence, 
-	&cAnalyzeGenotype::CompareNULL, "(N/A)", ""));
+                              ("sequence",    "Genome Sequence",
+                               &cAnalyzeGenotype::GetSequence, &cAnalyzeGenotype::SetSequence, 
+                               &cAnalyzeGenotype::CompareNULL, "(N/A)", ""));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, const cString &>
-       ("alignment",   "Aligned Sequence",
-	&cAnalyzeGenotype::GetAlignedSequence,
-	&cAnalyzeGenotype::SetAlignedSequence,
-	&cAnalyzeGenotype::CompareNULL, "(N/A)", ""));
-
+                              ("alignment",   "Aligned Sequence",
+                               &cAnalyzeGenotype::GetAlignedSequence,
+                               &cAnalyzeGenotype::SetAlignedSequence,
+                               &cAnalyzeGenotype::CompareNULL, "(N/A)", ""));
+  
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, cString>
-       ("task_list",    "List of all tasks performed",
-	&cAnalyzeGenotype::GetTaskList,
-	(void (cAnalyzeGenotype::*)(cString)) NULL,
-	&cAnalyzeGenotype::CompareNULL, "(N/A)", ""));
-
+                              ("task_list",    "List of all tasks performed",
+                               &cAnalyzeGenotype::GetTaskList,
+                               (void (cAnalyzeGenotype::*)(cString)) NULL,
+                               &cAnalyzeGenotype::CompareNULL, "(N/A)", ""));
+  
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, cString>
-       ("link.tasksites", "Phenotype Map", &cAnalyzeGenotype::GetMapLink,
-	(void (cAnalyzeGenotype::*)(cString)) NULL));
+                              ("link.tasksites", "Phenotype Map", &cAnalyzeGenotype::GetMapLink,
+                               (void (cAnalyzeGenotype::*)(cString)) NULL));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, cString>
-       ("html.sequence",  "Genome Sequence",
-	&cAnalyzeGenotype::GetHTMLSequence,
-	(void (cAnalyzeGenotype::*)(cString)) NULL,
-	&cAnalyzeGenotype::CompareNULL, "(N/A)", ""));
-
+                              ("html.sequence",  "Genome Sequence",
+                               &cAnalyzeGenotype::GetHTMLSequence,
+                               (void (cAnalyzeGenotype::*)(cString)) NULL,
+                               &cAnalyzeGenotype::CompareNULL, "(N/A)", ""));
+  
   const cTaskLib & task_lib = cTestCPU::GetEnvironment()->GetTaskLib();
   for (int i = 0; i < task_lib.GetSize(); i++) {
     cString t_name, t_desc;
     t_name.Set("task.%d", i);
     t_desc = task_lib.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
   // "population_data_list", but for the moment we're going to put them
   // here so that we only need to worry about a single system to load and
   // save genotype information.
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-       ("update",       "Update Output",
-	&cAnalyzeGenotype::GetUpdateDead, &cAnalyzeGenotype::SetUpdateDead));
+                              ("update",       "Update Output",
+                               &cAnalyzeGenotype::GetUpdateDead, &cAnalyzeGenotype::SetUpdateDead));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-       ("dom_num_cpus", "Number of Dominant Organisms",
-	&cAnalyzeGenotype::GetNumCPUs, &cAnalyzeGenotype::SetNumCPUs));
+                              ("dom_num_cpus", "Number of Dominant Organisms",
+                               &cAnalyzeGenotype::GetNumCPUs, &cAnalyzeGenotype::SetNumCPUs));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-       ("dom_depth",    "Tree Depth of Dominant Genotype",
-	&cAnalyzeGenotype::GetDepth, &cAnalyzeGenotype::SetDepth));
+                              ("dom_depth",    "Tree Depth of Dominant Genotype",
+                               &cAnalyzeGenotype::GetDepth, &cAnalyzeGenotype::SetDepth));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-       ("dom_id",       "Dominant Genotype ID",
-	&cAnalyzeGenotype::GetID, &cAnalyzeGenotype::SetID));
+                              ("dom_id",       "Dominant Genotype ID",
+                               &cAnalyzeGenotype::GetID, &cAnalyzeGenotype::SetID));
   genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, cString>
-       ("dom_sequence", "Dominant Genotype Sequence",
-	&cAnalyzeGenotype::GetSequence, &cAnalyzeGenotype::SetSequence, 
-	&cAnalyzeGenotype::CompareNULL, "(N/A)", ""));
+                              ("dom_sequence", "Dominant Genotype Sequence",
+                               &cAnalyzeGenotype::GetSequence, &cAnalyzeGenotype::SetSequence, 
+                               &cAnalyzeGenotype::CompareNULL, "(N/A)", ""));
 }
 
 
@@ -5288,18 +5558,18 @@
 // format....
 
 void cAnalyze::LoadGenotypeDataList(cStringList arg_list,
-       tList< tDataEntryCommand<cAnalyzeGenotype> > & output_list)
+                                    tList< tDataEntryCommand<cAnalyzeGenotype> > & output_list)
 {
   // For the moment, just put everything into the output list.
   SetupGenotypeDataList();
-
+  
   // If no args were given, load all of the stats.
   if (arg_list.GetSize() == 0) {
     tListIterator< tDataEntryBase<cAnalyzeGenotype> >
-      genotype_data_it(genotype_data_list);
+    genotype_data_it(genotype_data_list);
     while (genotype_data_it.Next() != (void *) NULL) {
       tDataEntryCommand<cAnalyzeGenotype> * entry_command =
-	new tDataEntryCommand<cAnalyzeGenotype>(genotype_data_it.Get());
+      new tDataEntryCommand<cAnalyzeGenotype>(genotype_data_it.Get());
       output_list.PushRear(entry_command);
     }
   }
@@ -5310,55 +5580,55 @@
       cString cur_args = arg_list.Pop();
       cString cur_entry = cur_args.Pop(':');
       bool found_entry = false;
-
+      
       // Scan the genotype data list for the current entry
       tListIterator< tDataEntryBase<cAnalyzeGenotype> >
-	genotype_data_it(genotype_data_list);
-
+        genotype_data_it(genotype_data_list);
+      
       while (genotype_data_it.Next() != (void *) NULL) {
-	if (genotype_data_it.Get()->GetName() == cur_entry) {
-	  tDataEntryCommand<cAnalyzeGenotype> * entry_command =
-	    new tDataEntryCommand<cAnalyzeGenotype>
-	    (genotype_data_it.Get(), cur_args);
-	  output_list.PushRear(entry_command);
-	  found_entry = true;
-	  break;
-	}
+        if (genotype_data_it.Get()->GetName() == cur_entry) {
+          tDataEntryCommand<cAnalyzeGenotype> * entry_command =
+          new tDataEntryCommand<cAnalyzeGenotype>
+          (genotype_data_it.Get(), cur_args);
+          output_list.PushRear(entry_command);
+          found_entry = true;
+          break;
+        }
       }
-
+      
       // If the entry was not found, give a warning.
       if (found_entry == false) {
-	int best_match = 1000;
-	cString best_entry;
-
-	genotype_data_it.Reset();
-	while (genotype_data_it.Next() != (void *) NULL) {
-	  const cString & test_str = genotype_data_it.Get()->GetName();
-	  const int test_dist = cStringUtil::EditDistance(test_str, cur_entry);
-	  if (test_dist < best_match) {
-	    best_match = test_dist;
-	    best_entry = test_str;
-	  }
-	}	
-
-	cerr << "Warning: Format entry \"" << cur_entry
-	     << "\" not found.  Best match is \""
-	     << best_entry << "\"." << endl;
+        int best_match = 1000;
+        cString best_entry;
+        
+        genotype_data_it.Reset();
+        while (genotype_data_it.Next() != (void *) NULL) {
+          const cString & test_str = genotype_data_it.Get()->GetName();
+          const int test_dist = cStringUtil::EditDistance(test_str, cur_entry);
+          if (test_dist < best_match) {
+            best_match = test_dist;
+            best_entry = test_str;
+          }
+        }	
+        
+        cerr << "Warning: Format entry \"" << cur_entry
+          << "\" not found.  Best match is \""
+          << best_entry << "\"." << endl;
       }
-
+      
     }
   }
 }
 
 
 void cAnalyze::AddLibraryDef(const cString & name,
-			     void (cAnalyze::*_fun)(cString))
+                             void (cAnalyze::*_fun)(cString))
 {
   command_lib.PushRear(new cAnalyzeCommandDef(name, _fun));
 }
 
 void cAnalyze::AddLibraryDef(const cString & name,
-	  void (cAnalyze::*_fun)(cString, tList<cAnalyzeCommand> &))
+                             void (cAnalyze::*_fun)(cString, tList<cAnalyzeCommand> &))
 {
   command_lib.PushRear(new cAnalyzeFlowCommandDef(name, _fun));
 }
@@ -5366,7 +5636,7 @@
 void cAnalyze::SetupCommandDefLibrary()
 {
   if (command_lib.GetSize() != 0) return; // Library already setup.
-
+  
   AddLibraryDef("LOAD_ORGANISM", &cAnalyze::LoadOrganism);
   AddLibraryDef("LOAD_BASE_DUMP", &cAnalyze::LoadBasicDump);
   AddLibraryDef("LOAD_DETAIL_DUMP", &cAnalyze::LoadDetailDump);
@@ -5375,8 +5645,8 @@
   AddLibraryDef("LOAD_DOMINANT", &cAnalyze::LoadDominant);
   AddLibraryDef("LOAD_RESOURCES", &cAnalyze::LoadResources);
   AddLibraryDef("LOAD", &cAnalyze::LoadFile);
-
-    // Reduction commands...
+  
+  // Reduction commands...
   AddLibraryDef("FIND_GENOTYPE", &cAnalyze::FindGenotype);
   AddLibraryDef("FIND_ORGANISM", &cAnalyze::FindOrganism);
   AddLibraryDef("FIND_LINEAGE", &cAnalyze::FindLineage);
@@ -5385,7 +5655,7 @@
   AddLibraryDef("SAMPLE_ORGANISMS", &cAnalyze::SampleOrganisms);
   AddLibraryDef("SAMPLE_GENOTYPES", &cAnalyze::SampleGenotypes);
   AddLibraryDef("KEEP_TOP", &cAnalyze::KeepTopGenotypes);
-
+  
   // Direct output commands...
   AddLibraryDef("PRINT", &cAnalyze::CommandPrint);
   AddLibraryDef("TRACE", &cAnalyze::CommandTrace);
@@ -5395,11 +5665,11 @@
   AddLibraryDef("DETAIL_BATCHES", &cAnalyze::CommandDetailBatches);
   AddLibraryDef("DETAIL_AVERAGE", &cAnalyze::CommandDetailAverage);
   AddLibraryDef("DETAIL_INDEX", &cAnalyze::CommandDetailIndex);
-
+  
   // Population analysis commands...
   AddLibraryDef("PRINT_PHENOTYPES", &cAnalyze::CommandPrintPhenotypes);
   AddLibraryDef("PRINT_DIVERSITY", &cAnalyze::CommandPrintDiversity);
-
+  
   // Individual organism analysis...
   AddLibraryDef("LANDSCAPE", &cAnalyze::CommandLandscape);
   AddLibraryDef("FITNESS_MATRIX", &cAnalyze::CommandFitnessMatrix);
@@ -5416,30 +5686,31 @@
   AddLibraryDef("LEVENSTEIN", &cAnalyze::CommandLevenstein);
   AddLibraryDef("SPECIES", &cAnalyze::CommandSpecies);
   AddLibraryDef("RECOMBINE", &cAnalyze::CommandRecombine);
-
+  
   // Lineage analysis commands...
   AddLibraryDef("ALIGN", &cAnalyze::CommandAlign);
-
+  AddLibraryDef("ANALYZE_NEWINFO", &cAnalyze::AnalyzeNewInfo);
+  
   // Build input files for avida...
   AddLibraryDef("WRITE_CLONE", &cAnalyze::WriteClone);
   AddLibraryDef("WRITE_INJECT_EVENTS", &cAnalyze::WriteInjectEvents);
   AddLibraryDef("WRITE_COMPETITION", &cAnalyze::WriteCompetition);
-
+  
   // Automated analysis
   AddLibraryDef("ANALYZE_MUTS", &cAnalyze::AnalyzeMuts);
   AddLibraryDef("ANALYZE_INSTRUCTIONS", &cAnalyze::AnalyzeInstructions);
   AddLibraryDef("ANALYZE_INST_POP", &cAnalyze::AnalyzeInstPop);
   AddLibraryDef("ANALYZE_BRANCHING", &cAnalyze::AnalyzeBranching);
   AddLibraryDef("ANALYZE_MUTATION_TRACEBACK",
-		&cAnalyze::AnalyzeMutationTraceback);
+                &cAnalyze::AnalyzeMutationTraceback);
   AddLibraryDef("ANALYZE_EPISTASIS", &cAnalyze::AnalyzeEpistasis);
-
+  
   // Environment manipulation
   AddLibraryDef("ENVIRONMENT", &cAnalyze::EnvironmentSetup);
-
+  
   // Documantation...
   AddLibraryDef("HELPFILE", &cAnalyze::CommandHelpfile);
-
+  
   // Control commands...
   AddLibraryDef("SET", &cAnalyze::VarSet);
   AddLibraryDef("SET_BATCH", &cAnalyze::BatchSet);
@@ -5456,11 +5727,11 @@
   AddLibraryDef("SYSTEM", &cAnalyze::CommandSystem);
   AddLibraryDef("INTERACTIVE", &cAnalyze::CommandInteractive);
   AddLibraryDef("PRINT_TEST_CPU_RESOURCES", &cAnalyze::PrintTestCPUResources);
-
-    // Functions...
+  
+  // Functions...
   AddLibraryDef("FUNCTION", &cAnalyze::FunctionCreate);
-
-    // Flow commands...
+  
+  // Flow commands...
   AddLibraryDef("FOREACH", &cAnalyze::CommandForeach);
   AddLibraryDef("FORRANGE", &cAnalyze::CommandForRange);
 }
@@ -5468,19 +5739,19 @@
 cAnalyzeCommandDefBase * cAnalyze::FindAnalyzeCommandDef(const cString & name)
 {
   SetupCommandDefLibrary();
-
+  
   tListIterator<cAnalyzeCommandDefBase> lib_it(command_lib);
   while (lib_it.Next() != (void *) NULL) {
     if (lib_it.Get()->GetName() == name) break;
   }
-
+  
   return lib_it.Get();
 }
 
 void cAnalyze::RunInteractive()
 {
   cout << "Entering interactive mode..." << endl;
-
+  
   char text_input[2048];
   while (true) {
     cout << ">> ";
@@ -5489,7 +5760,7 @@
     cString cur_input(text_input);
     cString command = cur_input.PopWord();
     command.ToUpper();
-
+    
     cAnalyzeCommand * cur_command;
     cAnalyzeCommandDefBase * command_def = FindAnalyzeCommandDef(command);
     if (command == "") {
@@ -5509,18 +5780,18 @@
       // This is a normal command...
       cur_command = new cAnalyzeCommand(command, cur_input);
     }
-
+    
     cString args = cur_command->GetArgs();
     PreProcessArgs(args);
-
+    
     cAnalyzeCommandDefBase * command_fun = FindAnalyzeCommandDef(command);
-
+    
     // First check for built-in functions...
     if (command_fun != NULL) command_fun->Run(this, args, *cur_command);
-
+    
     // Then for user defined functions
     else if (FunctionRun(command, args) == true) { }
-
+    
     // Otherwise, give an error.
     else cerr << "Error: Unknown command '" << command << "'." << endl;
   }

Modified: branches/brysonda/source/main/analyze.hh
===================================================================
--- branches/brysonda/source/main/analyze.hh	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/main/analyze.hh	2005-07-26 14:44:40 UTC (rev 263)
@@ -167,6 +167,7 @@
 
   // Lineage Analysis Commands...
   void CommandAlign(cString cur_string);
+  void AnalyzeNewInfo(cString cur_string);   
 
   // Build Input Files for Avida
   void WriteClone(cString cur_string);
@@ -182,6 +183,9 @@
   void AnalyzeComplexity(cString cur_string);
   void AnalyzePopComplexity(cString cur_string);
   void AnalyzeEpistasis(cString cur_string);
+  double AnalyzeEntropy(cAnalyzeGenotype * genotype, double mut_rate);
+  double AnalyzeEntropyGivenParent(cAnalyzeGenotype * genotype, 
+				   cAnalyzeGenotype * parent, double mut_rate);
 
   // Environment Manipulation
   void EnvironmentSetup(cString cur_string);
@@ -211,12 +215,15 @@
   void FunctionCreate(cString cur_string, tList<cAnalyzeCommand> & clist);
   // Looks up the resource concentrations that are the closest to the
   // given update and then fill in those concentrations into the environment.
-  void FillResources(int update, cEnvironment &environment);
+  void FillResources(int update);
 
   // Flow Control...
   void CommandForeach(cString cur_string, tList<cAnalyzeCommand> & clist);
   void CommandForRange(cString cur_string, tList<cAnalyzeCommand> & clist);
 
+private:
+  // disabled copy constructor.
+  cAnalyze(const cAnalyze &);
 public:
   cAnalyze(cString filename, cEnvironment* = NULL);
   ~cAnalyze();

Modified: branches/brysonda/source/main/analyze_command.hh
===================================================================
--- branches/brysonda/source/main/analyze_command.hh	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/main/analyze_command.hh	2005-07-26 14:44:40 UTC (rev 263)
@@ -21,6 +21,9 @@
 protected:
   cString command;
   cString args;
+private:
+  // disabled copy constructor.
+  cAnalyzeCommand(const cAnalyzeCommand &);
 public:
   cAnalyzeCommand(const cString & _command, const cString & _args)
     : command(_command), args(_args) { command.ToUpper(); }

Modified: branches/brysonda/source/main/analyze_function.hh
===================================================================
--- branches/brysonda/source/main/analyze_function.hh	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/main/analyze_function.hh	2005-07-26 14:44:40 UTC (rev 263)
@@ -28,6 +28,9 @@
 private:
   cString name;
   tList<cAnalyzeCommand> command_list;
+private:
+  // disabled copy constructor.
+  cAnalyzeFunction(const cAnalyzeFunction &);
 public:
   cAnalyzeFunction(const cString & _name) : name(_name) { ; }
   ~cAnalyzeFunction() { 

Modified: branches/brysonda/source/main/avida_triggers.hh
===================================================================
--- branches/brysonda/source/main/avida_triggers.hh	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/main/avida_triggers.hh	2005-07-26 14:44:40 UTC (rev 263)
@@ -22,6 +22,9 @@
 class cAvidaTriggers : public cEventTriggers {
 private:
   cStats & stats;
+private:
+  // disabled copy constructor.
+  cAvidaTriggers(const cAvidaTriggers &);
 public:
   cAvidaTriggers(cStats & _stats) : stats(_stats) { ; }
   double GetUpdate() const { return (double) stats.GetUpdate(); }

Modified: branches/brysonda/source/main/config.cc
===================================================================
--- branches/brysonda/source/main/config.cc	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/main/config.cc	2005-07-26 14:44:40 UTC (rev 263)
@@ -11,123 +11,6 @@
 #include "genesis.hh"
 #include "tools.hh"
 
-#include "cPopulation_descr.h" // declarations and definitions
-//include "cPopulation_descr.ci" // for event documentation
-const cEventEntry cEventDescrs::entries[] = {
-  cEventEntry( "exit", "Ends the Avida run immediately.\n" ),
-  cEventEntry( "exit_if_generation_greater_than", "Ends the Avida run when the current generation exceeds the\nmaximum generation given as parameter.\n\nParameters:\nmax generation (int)\n  The generation at which the run should be stopped.\n" ),
-  cEventEntry( "exit_if_update_greater_than", "Ends the Avida run when the current update exceeds the\nmaximum update given as parameter.\n\nParameters:\nmax update (int)\n  The update at which the run should be stopped.\n" ),
-  cEventEntry( "exit_if_ave_lineage_label_smaller", "Halts the avida run if the current average lineage label is smaller\nthan the value given as parameter.\n\nParameters:\nlineage_label_crit_value (int)\n  The critical value to which the average lineage label is compared.\n" ),
-  cEventEntry( "exit_if_ave_lineage_label_larger", "Halts the avida run if the current average lineage label is larger\nthan the value given as parameter.\n\nParameters:\nlineage_label_crit_value (int)\n  The critical value to which the average lineage label is compared.\n" ),
-  cEventEntry( "echo", "Writes out a message. If no message is given, average update and\ngeneration are written out.\n\nParameters:\nmessage (string)\n" ),
-  cEventEntry( "print_data", "Output user-defined data from the cStats object...\n\nParameters:\nfilename (string)\n  The name of the data file.\nformat\n  A comma-seperated list of statistics to output.\n" ),
-  cEventEntry( "print_average_data", "Output various average quantities into datafile.\n\nParameters:\nfilename (string) default: average.dat\n  The name of the data file.\n" ),
-  cEventEntry( "print_error_data", "Prints out various data related to statistical errors.\n\nParameters:\nfilename (string) default: error.dat\n  The name of the data file.\n" ),
-  cEventEntry( "print_variance_data", "Prints out various variances.\n\nParameters:\nfilename (string) default: variance.dat\n  The name of the data file.\n" ),
-  cEventEntry( "print_dominant_data", "Output various quantities related to the dominant organism.\n\nParameters:\nfilename (string) default: dominant.dat\n  The name of the data file.\n" ),
-  cEventEntry( "print_stats_data", "Output various statistical quantities.\n\nParameters:\nfilename (string) default: stats.dat\n  The name of the data file.\n" ),
-  cEventEntry( "print_count_data", "Output various counts, such as number of organisms etc.\n\nParameters:\nfilename (string) default: count.dat\n  The name of the data file.\n" ),
-  cEventEntry( "print_totals_data", "Various total numbers.\n\nParameters:\nfilename (string) default: totals.dat\n  The name of the data file.\n" ),
-  cEventEntry( "print_tasks_data", "Output the number of times the various tasks have been performed in the\nlast update.\n\nParameters:\nfilename (string) default: tasks.dat\n  The name of the data file.\n" ),
-  cEventEntry( "print_tasks_exe_data", "\n" ),
-  cEventEntry( "print_resource_data", "\n" ),
-  cEventEntry( "print_time_data", "Output time related data, such as update, generation, etc.\n\nParameters:\nfilename (string) default: time.dat\n  The name of the data file.\n" ),
-  cEventEntry( "print_mutation_data", "\n" ),
-  cEventEntry( "print_mutation_rate_data", "(regular and log) statistics about individual copy\nrates (aver, stdev, skew, cur).\nonly when mutation rate is set per organism.\n" ),
-  cEventEntry( "print_divide_mut_data", "(regular and log) statistics about individual, per site,\ndivide mutation rates (aver, stdev, skew, cur).\nwith multiple divide instuction set.\n" ),
-  cEventEntry( "print_dom_parasite_data", "Output various quantities related to the dominant parasite.\n\nParameters:\nfilename (string) default: parasite.dat\n  The name of the data file.\n" ),
-  cEventEntry( "print_instruction_data", "of the by-organisms counts of what instructions they _successfully_\nbeteween birth and divide. Prior to their first divide, organisms\nvalues for their parents.\n" ),
-  cEventEntry( "print_instruction_abundance_histogram", "Appends a line containing the bulk count (abundance) of\neach instruction in the population onto a file.\n\nParameters:\nfilename (string) default: \"instruction_histogram.dat\"\n\n" ),
-  cEventEntry( "print_depth_histogram", "\n" ),
-  cEventEntry( "print_genotype_abundance_histogram", "Writes out a genotype abundance histogram.\n\nParameters:\nfilename (string) default: genotype_abundance_histogram.dat\n  The name of the file into which the histogram is written.\n" ),
-  cEventEntry( "print_species_abundance_histogram", "Writes out a species abundance histogram.\n\nParameters:\nfilename (string) default: species_abundance_histogram.dat\n  The name of the file into which the histogram is written.\n" ),
-  cEventEntry( "print_lineage_totals", "\n" ),
-  cEventEntry( "print_lineage_counts", "\n" ),
-  cEventEntry( "print_dom", "Write the currently dominant genotype to disk.\n\nParameters:\nfilename (string)\n  The name under which the genotype should be saved. If no\n  filename is given, the genotype is saved into the directory\n  genebank, under the name that the genebank has associated with\n  this genotype.\n" ),
-  cEventEntry( "parasite_debug", "\n" ),
-  cEventEntry( "print_dom_parasite", "Write the currently dominant injected genotype to disk.\n\nParameters:\nfilename (string)\n  The name under which the genotype should be saved. If no\n  filename is given, the genotype is saved into the directory\n  genebank, under the name that the genebank has associated with\n  this genotype.\n" ),
-  cEventEntry( "print_genotype_map", "write a matrix of genotype ID's to a file (matlab format)\n" ),
-  cEventEntry( "print_number_phenotypes", "file with number of phenotypes based on tasks executed\nthis update.  Executing a task any numbers of times is considered\nsame as executing it once.\n" ),
-  cEventEntry( "print_phenotype_status", "merit status for all the organisms in the population.\nfor testing/debuging. \n" ),
-  cEventEntry( "save_population", "Saves the full state of the population.\n\nParameters:\nfilename (string) default: save_pop.*\n  The name of the file into which the population should\n  be saved. If it is not given, then the name 'save_pop.*'\n  is used, with '*' replaced by the current update.\n" ),
-  cEventEntry( "load_population", "Loads the full state of the population.\n\nParameters:\nfilename (string)\n  The name of the file to open.\n" ),
-  cEventEntry( "save_clone", "\n" ),
-  cEventEntry( "load_clone", "\n" ),
-  cEventEntry( "load_dump_file", "Sets up a population based on a dump file such as written out by\ndetail_pop. It is also possible to append a history file to the dump\nfile, in order to preserve the history of a previous run.\n" ),
-  cEventEntry( "dump_pop", "Writes out a line of data for each genotype in the current population. The\nline contains the genome as string, the number of organisms of that genotype,\nand the genotype ID.\n\nParameters:\nfilename (string) default: \"dump.<update>\"\n  The name of the file into which the population dump should be written.\n" ),
-  cEventEntry( "print_genotypes", "This is a new version of \"detail_pop\" or \"historic_dump\".  It allows you to\noutput one line per genotype in memory where you get to choose what data\nshould be included.\n\nParameters\ndata_fields (string)\n  This must be a comma separated string of all data you wish to output.\n  Options include: id, parent_id, parent2_id (for sex), parent_dist,\n      num_cpus, total_cpus, length, merit, gest_time, fitness, update_born,\n      update_dead, depth, lineage, sequence\nhistoric (int) default: 0\n  How many updates back of history should we include (-1 = all)\nfilename (string) default: \"genotypes-<update>.dat\"\n  The name of the file into which the population dump should be written.\n" ),
-  cEventEntry( "detail_pop", "Like dump_pop, but more detailed data is written out.\n\nParameters:\nfilename (string) default: \"detail_pop.<update>\"\n  The name of the file into which the population dump should be written.\n" ),
-  cEventEntry( "detail_sex_pop", "Like detail_pop, but for sexual populations. \nInfo for both parents is writen out.\n\nParameters:\nfilename (string) default: \"detail_pop.<update>\"\n  The name of the file into which the population dump should be written.\n" ),
-  cEventEntry( "detail_parasite_pop", "Like dump_pop, but more detailed data is written out.\n\nParameters:\nfilename (string) default: \"detail_pop.<update>\"\n  The name of the file into which the population dump should be written.\n" ),
-  cEventEntry( "dump_historic_pop", "Similar to detail_pop. However, only genotypes that are not in the\ncurrent population anymore are included. Genotypes that are not in\nthe line of descent of any of the current genotypes to the ultimate\nancestor are excluded.\n\nParameters:\nback_dist (int) default: -1\n  How many updates back should we print?  -1 goes forever.  Use the\n  distance to the last dump historic if you only want a \"diff\".\nfilename (string) default: \"historic_dump.<update>\"\n  The name of the file into which the historic dump should be written.\n" ),
-  cEventEntry( "dump_historic_sex_pop", "Similar to dump_historic_pop, but for sexual populations. \nID of both parents is writen out. \n\nParameters:\nfilename (string) default: \"historic_dump.<update>\"\n  The name of the file into which the historic dump should be written.\n" ),
-  cEventEntry( "dump_memory", "Dump the current memory state of all CPUs to a file.\n" ),
-  cEventEntry( "inject", "Injects a single organism into the population.\n\nParameters:\nfilename (string)\n  The filename of the genotype to load. If this is left empty, or the keyword\n  \"START_CREATURE\" is given, than the genotype specified in the genesis\n  file under \"START_CREATURE\" is used.\ncell ID (integer) default: 0\n  The grid-point into which the organism should be placed.\nmerit (double) default: -1\n  The initial merit of the organism. If set to -1, this is ignored.\nlineage label (integer) default: 0\n  An integer that marks all descendants of this organism.\nneutral metric (double) default: 0\n  A double value that randomly drifts over time.\n" ),
-  cEventEntry( "inject_all", "Injects identical organisms into all cells of the population.\n\nParameters:\nfilename (string)\n  The filename of the genotype to load. If this is left empty, or the keyword\n  \"START_CREATURE\" is given, than the genotype specified in the genesis\n  file under \"START_CREATURE\" is used.\nmerit (double) default: -1\n  The initial merit of the organism. If set to -1, this is ignored.\nlineage label (integer) default: 0\n  An integer that marks all descendants of this organism.\nneutral metric (double) default: 0\n  A double value that randomly drifts over time.\n" ),
-  cEventEntry( "inject_range", "Injects identical organisms into a range of cells of the population.\n\nParameters:\nfilename (string)\n  The filename of the genotype to load. If this is left empty, or the keyword\n  \"START_CREATURE\" is given, than the genotype specified in the genesis\n  file under \"START_CREATURE\" is used.\nstart_cell (int)\n  First cell to inject into.\nstop_cell (int)\n  First cell *not* to inject into.\nmerit (double) default: -1\n  The initial merit of the organism. If set to -1, this is ignored.\nlineage label (integer) default: 0\n  An integer that marks all descendants of this organism.\nneutral metric (double) default: 0\n  A double value that randomly drifts over time.\n\nExample:\n  inject_range creature.gen 0 10\n\nWill inject 10 organisms into cells 0 through 9.\n" ),
-  cEventEntry( "inject_sequence", "Injects identical organisms into a range of cells of the population.\n\nParameters:\nsequence (string)\n  The genome sequence for this organism.  This is a mandatory argument.\nstart_cell (int)\n  First cell to inject into.\nstop_cell (int)\n  First cell *not* to inject into.\nmerit (double) default: -1\n  The initial merit of the organism. If set to -1, this is ignored.\nlineage label (integer) default: 0\n  An integer that marks all descendants of this organism.\nneutral metric (double) default: 0\n  A double value that randomly drifts over time.\n\nExample:\n  inject_range ckdfhgklsahnfsaggdsgajfg 0 10 100\n\nWill inject 10 organisms into cells 0 through 9 with a merit of 100.\n" ),
-  cEventEntry( "inject_random", "Injects a randomly generated genome into the population.\n\nParameters:\nlength (integer) [required]\n  Number of instructions in the randomly generated genome.\ncell ID (integer) default: -1\n  The grid-point into which the genome should be placed.  Default is random.\nmerit (double) default: -1\n  The initial merit of the organism. If set to -1, this is ignored.\nlineage label (integer) default: 0\n  An integer that marks all descendants of this organism.\nneutral metric (double) default: 0\n  A double value that randomly drifts over time.\n" ),
-  cEventEntry( "inject_range_parasite", "Injects identical organisms into a range of cells of the population.\n\nParameters:\nfilename (string)\n  The filename of the genotype to load. If this is left empty, or the keyword\n  \"START_CREATURE\" is given, than the genotype specified in the genesis\n  file under \"START_CREATURE\" is used.\nstart_cell (int)\n  First cell to inject into.\nstop_cell (int)\n  First cell *not* to inject into.\nmerit (double) default: -1\n  The initial merit of the organism. If set to -1, this is ignored.\nlineage label (integer) default: 0\n  An integer that marks all descendants of this organism.\nneutral metric (double) default: 0\n  A double value that randomly drifts over time.\n\nExample:\n  inject_range creature.gen 0 10\n\nWill inject 10 organisms into cells 0 through 9.\n" ),
-  cEventEntry( "inject_range_pair", "Injects identical organisms into a range of cells of the population.\n\nParameters:\nfilename (string)\n  The filename of the genotype to load. If this is left empty, or the keyword\n  \"START_CREATURE\" is given, than the genotype specified in the genesis\n  file under \"START_CREATURE\" is used.\nstart_cell (int)\n  First cell to inject into.\nstop_cell (int)\n  First cell *not* to inject into.\nmerit (double) default: -1\n  The initial merit of the organism. If set to -1, this is ignored.\nlineage label (integer) default: 0\n  An integer that marks all descendants of this organism.\nneutral metric (double) default: 0\n  A double value that randomly drifts over time.\n\nExample:\n  inject_range creature.gen 0 10\n\nWill inject 10 organisms into cells 0 through 9.\n" ),
-  cEventEntry( "zero_muts", "This event will set all mutation rates to zero...\n" ),
-  cEventEntry( "mod_copy_mut", "\n" ),
-  cEventEntry( "mod_div_mut", "\n" ),
-  cEventEntry( "set_copy_mut", "\n" ),
-  cEventEntry( "mod_point_mut", "\n" ),
-  cEventEntry( "set_point_mut", "\n" ),
-  cEventEntry( "calc_landscape", "\n" ),
-  cEventEntry( "predict_w_landscape", "\n" ),
-  cEventEntry( "predict_nu_landscape", "\n" ),
-  cEventEntry( "sample_landscape", "\n" ),
-  cEventEntry( "random_landscape", "\n" ),
-  cEventEntry( "analyze_landscape", "\n" ),
-  cEventEntry( "pairtest_landscape", "If sample_size = 0, pairtest the full landscape.\n" ),
-  cEventEntry( "test_dom", "\n" ),
-  cEventEntry( "analyze_population", "\n" ),
-  cEventEntry( "print_detailed_fitness_data", "\n" ),
-  cEventEntry( "print_genetic_distance_data", "\n" ),
-  cEventEntry( "genetic_distance_pop_dump", "\n" ),
-  cEventEntry( "task_snapshot", "\n" ),
-  cEventEntry( "print_viable_tasks_data", "\n" ),
-  cEventEntry( "apocalypse", "Randomly removes a certain proportion of the population.\n\nParameters:\nremoval probability (double) default: 0.9\n  The probability with which a single organism is removed.\n" ),
-  cEventEntry( "kill_rectangle", "Kills all cell in a rectangle.\n\nParameters:\ncell [X1][Y1][x2][Y2] (integer) default: 0\n  The start and stoping grid-points into which the organism should\nkilled.\n" ),
-  cEventEntry( "rate_kill", "Randomly removes a certain proportion of the population.\nIn principle, this event does the same thing as the apocalypse event.\nHowever, instead of a probability, here one has to specify a rate. The\nrate has the same unit as fitness. So if the average fitness is 20000,\nthen you remove 50% of the population on every update with a removal rate\nof 10000.\n\nParameters:\nremoval rate (double)\n  The rate at which organisms are removed.\n" ),
-  cEventEntry( "serial_transfer", "This event does again the same thing as apocalypse. However, now\nthe number of organisms to be retained can be specified\nexactly. Also, it is possible to specify whether any of these\norganisms may be dead or not.\n\nParameters:\ntransfer size (int) default: 1\n  The number of organisms to retain. If there are fewer living\n  organisms than the specified transfer size, then all living\n  organisms are retained.\nignore deads (int) default: 1\n  When set to 1, only living organisms are retained. Otherwise,\n  every type of organism can be retained.\n" ),
-  cEventEntry( "hillclimb", "Does a hill climb with the dominant genotype.\n" ),
-  cEventEntry( "hillclimb_neut", "\n" ),
-  cEventEntry( "hillclimb_rand", "\n" ),
-  cEventEntry( "compete_demes", "Compete all of the demes using a basic genetic algorithm approach. Fitness\nof each deme is determined differently depending on the competition_type: \n0: deme fitness = 1 (control, random deme selection)\n1: deme fitness = number of births since last competition (default) \n2: deme fitness = average organism fitness at the current update\n3: deme fitness = average mutation rate at the current update\nMerit can optionally be passed in.\n" ),
-  cEventEntry( "reset_demes", "Designed to serve as a control for the compete_demes. Each deme is \ncopied into itself and the parameters reset. \n" ),
-  cEventEntry( "print_deme_stats", "Print stats about individual demes\n" ),
-  cEventEntry( "copy_deme", "Takes two numbers as arguments and copies the contents of the first deme\nlisted into the second.\n" ),
-  cEventEntry( "calc_consensus", "Calculates the consensus sequence.\n\nParameters:\nlines saved (integer) default: 0\n   ???\n" ),
-  cEventEntry( "test_size_change_robustness", "\n" ),
-  cEventEntry( "test_threads", "\n" ),
-  cEventEntry( "print_threads", "\n" ),
-  cEventEntry( "dump_fitness_grid", "Writes out all fitness values of the organisms currently in the\npopulation.\n\nThe output file is called \"fgrid.*.out\", where '*' is replaced by the\nnumber of the current update.\n" ),
-  cEventEntry( "dump_genotype_grid", "Writes out all genotype id values of the organisms currently in the\npopulation.\n\nThe output file is called \"idgrid.*.out\", where '*' is replaced by the\nnumber of the current update.\n" ),
-  cEventEntry( "dump_task_grid", "Writes out a grid of tasks done by each organism\nTasks are encoded as a binary string first, and then converted into a\nbase 10 number \n" ),
-  cEventEntry( "dump_donor_grid", "Writes out the grid of donor organisms in the population\n\nThe output file is called \"donor_grid.*.out\", where '*' is replaced by the\nnumber of the current update.\n" ),
-  cEventEntry( "dump_receiver_grid", "Writes out the grid of organisms which received merit in the population\n\nThe output file is called \"receiver_grid.*.out\", where '*' is replaced by the\nnumber of the current update.\n" ),
-  cEventEntry( "print_tree_depths", "Reconstruction of phylogenetic trees.\n" ),
-  cEventEntry( "sever_grid_col", "Remove the connections between cells along a column in an avida grid.\nArguments:\n col_id:  indicates the number of columns to the left of the cut.\n          default (or -1) = cut population in half\n min_row: First row to start cutting from\n          default = 0\n max_row: Last row to cut to\n          default (or -1) = last row in population.\n" ),
-  cEventEntry( "sever_grid_row", "Remove the connections between cells along a column in an avida grid.\nArguments:\n row_id:  indicates the number of rows above the cut.\n          default (or -1) = cut population in half\n min_col: First row to start cutting from\n          default = 0\n max_col: Last row to cut to\n          default (or -1) = last row in population.\n" ),
-  cEventEntry( "join_grid_col", "Join the connections between cells along a column in an avida grid.\nArguments:\n col_id:  indicates the number of columns to the left of the joining.\n          default (or -1) = join population halves.\n min_row: First row to start joining from\n          default = 0\n max_row: Last row to join to\n          default (or -1) = last row in population.\n" ),
-  cEventEntry( "join_grid_row", "Remove the connections between cells along a column in an avida grid.\nArguments:\n row_id:  indicates the number of rows abovef the cut.\n          default (or -1) = cut population in half\n min_col: First row to start cutting from\n          default = 0\n max_col: Last row to cut to\n          default (or -1) = last row in population.\n" ),
-  cEventEntry( "connect_cells", "Connects a pair of specified cells.\nArguments:\n cellA_x, cellA_y, cellB_x, cellB_y\n" ),
-  cEventEntry( "disconnect_cells", "Connects a pair of specified cells.\nArguments:\n cellA_x, cellA_y, cellB_x, cellB_y\n" ),
-  cEventEntry( "inject_resource", "Inject (add) a specified amount of a specified resource.\n" ),
-  cEventEntry( "set_resource", "Set the resource amount to a specific level\n" ),
-  cEventEntry( "inject_scaled_resource", "Inject (add) a specified amount of a specified resource, scaled by\nthe current average merit divided by the average time slice.\n" ),
-  cEventEntry( "outflow_scaled_resource", "Removes a specified percentage of a specified resource, scaled by\nthe current average merit divided by the average time slice.\n" ),
-  cEventEntry( "set_reaction_value", "Set the value associated with a reaction to a specific level\n" ),
-  cEventEntry( "set_reaction_value_mult", "Change the value of the reaction by multiplying it with the imput number\n" ) };
-
-const int cEventDescrs::num_of_events = 108;
-
-// end cPopulation_descr.ci
-
-
 using namespace std;
 
 tList<cConfig::cConfigGroup> cConfig::group_list;
@@ -237,242 +120,242 @@
   // Start with the Architecture variables...
   cConfigGroup * arch_group = new cConfigGroup("Architecture Variables");
   group_list.PushRear(arch_group);
-
+  
   arch_group->Add(max_updates, "-1", "MAX_UPDATES",
-		  "Maximum updates to run experiment (-1 = no limit)");
+                  "Maximum updates to run experiment (-1 = no limit)");
   arch_group->Add(max_generations, "-1", "MAX_GENERATIONS",
-		  "Maximum generations to run experiment (-1 = no limit)");
+                  "Maximum generations to run experiment (-1 = no limit)");
   arch_group->Add(end_condition_mode, "0", "END_CONDITION_MODE",
-		  "End run when ...\n0 = MAX_UPDATES _OR_ MAX_GENERATIONS is reached\n1 = MAX_UPDATES _AND_ MAX_GENERATIONS is reached");
+                  "End run when ...\n0 = MAX_UPDATES _OR_ MAX_GENERATIONS is reached\n1 = MAX_UPDATES _AND_ MAX_GENERATIONS is reached");
   arch_group->Add(world_x, "100", "WORLD-X",
-		  "Width of the Avida world");
+                  "Width of the Avida world");
   arch_group->Add(world_y, "100", "WORLD-Y",
-		  "Height of the Avida world");
+                  "Height of the Avida world");
   arch_group->Add(world_geometry, "2", "WORLD_GEOMETRY",
-		  "1 = Bounded Grid\n2 = Torus");
+                  "1 = Bounded Grid\n2 = Torus");
   arch_group->Add(num_demes, "0", "NUM_DEMES",
-		  "Number of independed groups in the population; 0=off");
+                  "Number of independed groups in the population; 0=off");
   arch_group->Add(rand_seed, "0", "RANDOM_SEED",
-		  "Random number seed (0 for based on time)");
+                  "Random number seed (0 for based on time)");
   arch_group->Add(hardware_type, "0", "HARDWARE_TYPE",
-		  "0 = Original CPUs\n1 = New, Stack-based CPUs");
-
+                  "0 = Original CPUs\n1 = New, Stack-based CPUs");
+  
   // Configuration file group.
   cConfigGroup * file_group = new cConfigGroup("Configuration Files");
   group_list.PushRear(file_group);
-
+  
   file_group->Add(default_dir, DEFAULT_DIR, "DEFAULT_DIR",
-		  "Directory in which config files are found");
+                  "Directory in which config files are found");
   file_group->Add(inst_filename, "inst_set.default", "INST_SET",
-		  "File containing instruction set");
+                  "File containing instruction set");
   file_group->Add(event_filename, "events.cfg", "EVENT_FILE",
-		  "File containing list of events during run");
+                  "File containing list of events during run");
   file_group->Add(analyze_filename, "analyze.cfg", "ANALYZE_FILE",
-		  "File used for analysis mode");
+                  "File used for analysis mode");
   file_group->Add(env_filename, "environment.cfg", "ENVIRONMENT_FILE",
-		  "File that describes the environment");
+                  "File that describes the environment");
   file_group->Add(start_creature, "organism.default", "START_CREATURE",
-		  "Organism to seed the soup");
-
+                  "Organism to seed the soup");
+  
   // Reproduction group.
   cConfigGroup * repro_group = new cConfigGroup("Birth and Death");
   group_list.PushRear(repro_group);
-
+  
   repro_group->Add(birth_method, "4", "BIRTH_METHOD",
-		   "0 = Replace random organism in neighborhood\n1 = Replace oldest organism in neighborhood\n2 = Replace largest Age/Merit in neighborhood\n3 = Place only in empty cells in neighborhood\n4 = Replace random from population (Mass Action)\n5 = Replace oldest in entire population (like Tierra)\n6 = Replace random within deme");
+                   "0 = Replace random organism in neighborhood\n1 = Replace oldest organism in neighborhood\n2 = Replace largest Age/Merit in neighborhood\n3 = Place only in empty cells in neighborhood\n4 = Replace random from population (Mass Action)\n5 = Replace oldest in entire population (like Tierra)\n6 = Replace random within deme");
   repro_group->Add(prefer_empty, "1", "PREFER_EMPTY",
-		   "Are empty cells given preference in offsping placement?");
+                   "Are empty cells given preference in offsping placement?");
   repro_group->Add(death_method, "0", "DEATH_METHOD",
-		   "0 = Never die of old age.\n1 = Die when inst executed = AGE_LIMIT (+deviation)\n2 = Die when inst executed = length*AGE_LIMIT (+dev)");
+                   "0 = Never die of old age.\n1 = Die when inst executed = AGE_LIMIT (+deviation)\n2 = Die when inst executed = length*AGE_LIMIT (+dev)");
   repro_group->Add(age_limit, "5000", "AGE_LIMIT",
-		   "Modifies DEATH_METHOD");
+                   "Modifies DEATH_METHOD");
   repro_group->Add(age_deviation, "0", "AGE_DEVIATION",
-		   "Creates a distribution around AGE_LIMIT");
+                   "Creates a distribution around AGE_LIMIT");
   repro_group->Add(alloc_method, "0", "ALLOC_METHOD",
-		   "0 = Allocated space is set to default instruction.\n1 = Set to section of dead genome (Necrophilia)\n2 = Allocated space is set to random instruction.");
+                   "0 = Allocated space is set to default instruction.\n1 = Set to section of dead genome (Necrophilia)\n2 = Allocated space is set to random instruction.");
   repro_group->Add(divide_method, "1", "DIVIDE_METHOD",
-		   "0 = Divide leaves state of mother untouched.\n1 = Divide resets state of mother (after the divide, we have 2 children)\n2 = Divide resets state of current thread only(does not touch possible parasite threads)");
+                   "0 = Divide leaves state of mother untouched.\n1 = Divide resets state of mother (after the divide, we have 2 children)\n2 = Divide resets state of current thread only(does not touch possible parasite threads)");
   repro_group->Add(generation_inc_method, "1", "GENERATION_INC_METHOD",
-		   "0 = Only the generation of the child is\n    increased on divide.\n1 = Both the generation of the mother and child are\n    increased on divide (good with DIVIDE_METHOD 1).");
+                   "0 = Only the generation of the child is\n    increased on divide.\n1 = Both the generation of the mother and child are\n    increased on divide (good with DIVIDE_METHOD 1).");
   repro_group->Add(recomb_prob, "1", "RECOMBINATION_PROB",
-		   "probability that recombination will happen when div-sex is used");
+                   "probability that recombination will happen when div-sex is used");
   repro_group->Add(num_modules, "0", "MODULE_NUM",
-		   "number of modules in the genome");
+                   "number of modules in the genome");
   repro_group->Add(cont_rec_regs, "1", "CONT_REC_REGS",
-		   "are (modular) recombination regions continuous");
+                   "are (modular) recombination regions continuous");
   repro_group->Add(corespond_rec_regs, "1", "CORESPOND_REC_REGS",
-		   "are (modular) recombination regions swapped at random or with corresponding ones, by location");
+                   "are (modular) recombination regions swapped at random or with corresponding ones, by location");
   repro_group->Add(two_fold_cost_sex, "0", "TWO_FOLD_COST_SEX",
-		   "1 = only one recombined offspring is born.\n2 = both offspring are born");
+                   "1 = only one recombined offspring is born.\n2 = both offspring are born");
   repro_group->Add(same_length_sex, "0", "SAME_LENGTH_SEX",
-		   "0 = recombine with any genome\n1 = only recombine w/ same length");
-
-
+                   "0 = recombine with any genome\n1 = only recombine w/ same length");
+  
+  
   // Divide Restrictions Group.
   cConfigGroup * div_group = new cConfigGroup("Divide Restrictions");
   group_list.PushRear(div_group);
-
+  
   div_group->Add(child_size_range, "2.0", "CHILD_SIZE_RANGE",
-		 "Maximal differential between child and parent sizes.");
+                 "Maximal differential between child and parent sizes.");
   div_group->Add(min_copied_lines, "0.5", "MIN_COPIED_LINES",
-		 "Code fraction which must be copied before divide.");
+                 "Code fraction which must be copied before divide.");
   div_group->Add(min_exe_lines, "0.5", "MIN_EXE_LINES",
-		 "Code fraction which must be executed before divide.");
+                 "Code fraction which must be executed before divide.");
   div_group->Add(require_allocate, "1", "REQUIRE_ALLOCATE",
-		 "Is a an allocate required before a divide? (0/1)");
+                 "Is a an allocate required before a divide? (0/1)");
   div_group->Add(required_task, "-1", "REQUIRED_TASK",
-		 "Task ID required for successful divide.");
-  div_group->Add(immunity_task, "-1", "REQUIRED_TASK",
-		 "Task providing immunity from the required task.");
+                 "Task ID required for successful divide.");
+  div_group->Add(immunity_task, "-1", "IMMUNITY_TASK",
+                 "Task providing immunity from the required task.");
   div_group->Add(required_reaction, "-1", "REQUIRED_REACTION",
-		 "Reaction ID required for successful divide.");
+                 "Reaction ID required for successful divide.");
   div_group->Add(die_prob, "0", "DIE_PROB",
-		 "probability of death when 'die' instruction is executed"); 
-
-
-
+                 "probability of death when 'die' instruction is executed"); 
+  
+  
+  
   // Mutations Group
   cConfigGroup * muts_group = new cConfigGroup("Mutations");
   group_list.PushRear(muts_group);
-
+  
   muts_group->Add(point_mut_prob, "0.0", "POINT_MUT_PROB",
-		  "Mutation rate (per-location per update)");
+                  "Mutation rate (per-location per update)");
   muts_group->Add(copy_mut_prob, "0.0075", "COPY_MUT_PROB",
-		  "Mutation rate (per copy)");
+                  "Mutation rate (per copy)");
   muts_group->Add(ins_mut_prob, "0.0", "INS_MUT_PROB",
-		  "Insertion rate (per site, applied on divide)");
+                  "Insertion rate (per site, applied on divide)");
   muts_group->Add(del_mut_prob, "0.0", "DEL_MUT_PROB",
-		  "Deletion rate (per site, applied on divide)");
+                  "Deletion rate (per site, applied on divide)");
   muts_group->Add(div_mut_prob, "0.0", "DIV_MUT_PROB",
-		  "Mutation rate (per site, applied on divide)");
+                  "Mutation rate (per site, applied on divide)");
   muts_group->Add(divide_mut_prob, "0.0", "DIVIDE_MUT_PROB",
-		  "Mutation rate (per divide)");
+                  "Mutation rate (per divide)");
   muts_group->Add(divide_ins_prob, "0.05", "DIVIDE_INS_PROB",
-		  "Insertion rate (per divide)");
+                  "Insertion rate (per divide)");
   muts_group->Add(divide_del_prob, "0.05", "DIVIDE_DEL_PROB",
-		  "Deletion rate (per divide)");
+                  "Deletion rate (per divide)");
   muts_group->Add(parent_mut_prob, "0.0", "PARENT_MUT_PROB",
-		  "Per-site, in parent, on divide");
+                  "Per-site, in parent, on divide");
   muts_group->Add(special_mut_line, "-1", "SPECIAL_MUT_LINE",
                   "If this is >= 0, ONLY this line is mutated");
-
-
+  
+  
   // Mutation reversions group
   cConfigGroup * rev_group = new cConfigGroup("Mutation Reversion");
   rev_group->SetComment("These slow down avida a lot, and should be set to 0.0 normally.");
   group_list.PushRear(rev_group);
-
+  
   rev_group->Add(revert_fatal, "0.0", "REVERT_FATAL",
-		 "Should any mutations be reverted on birth?");
+                 "Should any mutations be reverted on birth?");
   rev_group->Add(revert_neg, "0.0", "REVERT_DETRIMENTAL",
-		 "  0.0 to 1.0; Probability of reversion.");
+                 "  0.0 to 1.0; Probability of reversion.");
   rev_group->Add(revert_neut, "0.0", "REVERT_NEUTRAL",
-		 "");
+                 "");
   rev_group->Add(revert_pos, "0.0", "REVERT_BENEFICIAL",
-		 "");
+                 "");
   rev_group->Add(sterilize_fatal, "0.0", "STERILIZE_FATAL",
-		 "Should any mutations clear (kill) the organism?");
+                 "Should any mutations clear (kill) the organism?");
   rev_group->Add(sterilize_neg, "0.0", "STERILIZE_DETRIMENTAL",
-		 "  0.0 to 1.0; Probability of reset.");
+                 "  0.0 to 1.0; Probability of reset.");
   rev_group->Add(sterilize_neut, "0.0", "STERILIZE_NEUTRAL",
-		 "");
+                 "");
   rev_group->Add(sterilize_pos, "0.0", "STERILIZE_BENEFICIAL",
-		 "");
+                 "");
   rev_group->Add(fail_implicit, "0", "FAIL_IMPLICIT",
-               "Should copies that failed *not* due to mutations\nbe eliminated?");
-
+                 "Should copies that failed *not* due to mutations\nbe eliminated?");
+  
   // Time slicing group
   cConfigGroup * time_group = new cConfigGroup("Time Slicing");
   group_list.PushRear(time_group);
-
+  
   time_group->Add(ave_time_slice, "30", "AVE_TIME_SLICE",
-		  "Ave number of insts per org per update");
+                  "Ave number of insts per org per update");
   time_group->Add(slicing_method, "2", "SLICING_METHOD",
-		  "0 = CONSTANT: all organisms get default...\n1 = PROBABILISTIC: Run _prob_ proportional to merit.\n2 = INTEGRATED: Perfectly integrated deterministic.");
+                  "0 = CONSTANT: all organisms get default...\n1 = PROBABILISTIC: Run _prob_ proportional to merit.\n2 = INTEGRATED: Perfectly integrated deterministic.");
   time_group->Add(size_merit_method, "0", "SIZE_MERIT_METHOD",
-		  "0 = off (merit is independent of size)\n1 = Merit proportional to copied size\n2 = Merit prop. to executed size\n3 = Merit prop. to full size\n4 = Merit prop. to min of executed or copied size\n5 = Merit prop. to sqrt of the minimum size");
+                  "0 = off (merit is independent of size)\n1 = Merit proportional to copied size\n2 = Merit prop. to executed size\n3 = Merit prop. to full size\n4 = Merit prop. to min of executed or copied size\n5 = Merit prop. to sqrt of the minimum size");
   time_group->Add(task_merit_method, "1", "TASK_MERIT_METHOD",
-		  "0 = No task bonuses\n1 = Bonus just equals the task bonus");
+                  "0 = No task bonuses\n1 = Bonus just equals the task bonus");
   time_group->Add(max_cpu_threads, "1", "MAX_CPU_THREADS",
-		  "Number of Threads a CPU can spawn");
+                  "Number of Threads a CPU can spawn");
   time_group->Add(thread_slicing_method, "0", "THREAD_SLICING_METHOD",
-		  "Formula for and organism's thread slicing -> 1 + (num_organism_threads-1) * THREAD_SLICING_METHOD.\n0 = One thread executed per time slice.\n1 = All threads executed each time slice.\n");
+                  "Formula for and organism's thread slicing -> 1 + (num_organism_threads-1) * THREAD_SLICING_METHOD.\n0 = One thread executed per time slice.\n1 = All threads executed each time slice.\n");
   time_group->Add(max_label_exe_size, "1", "MAX_LABEL_EXE_SIZE",
-		  "Max nops marked as executed when labels are used");
+                  "Max nops marked as executed when labels are used");
   time_group->Add(base_size_merit, "100", "BASE_SIZE_MERIT",
-		  "Base merit when size is *not* used");
+                  "Base merit when size is *not* used");
   time_group->Add(default_bonus, "1", "DEFAULT_BONUS",
-		  "The bonus an organism gets before it has completed any tasks");
+                  "The bonus an organism gets before it has completed any tasks");
   time_group->Add(merit_time, "0", "MERIT_TIME",
-		  "0 = Merit Calculated when task completed\n1 = Merit Calculated on Divide");
+                  "0 = Merit Calculated when task completed\n1 = Merit Calculated on Divide");
   time_group->Add(merit_given, "0.0", "MERIT_GIVEN",
-		  "Fraction of merit donated with 'donate' command");
+                  "Fraction of merit donated with 'donate' command");
   time_group->Add(merit_received, "0.0", "MERIT_RECEIVED",
-		  "Multiplier of merit given with 'donate' command");
+                  "Multiplier of merit given with 'donate' command");
   time_group->Add(max_donate_kin_distance, "-1", "MAX_DONATE_KIN_DIST",
-		  "Limit on distance of relation for donate; -1=no max");
+                  "Limit on distance of relation for donate; -1=no max");
   time_group->Add(max_donate_edit_distance, "-1", "MAX_DONATE_EDIT_DIST",
-		  "Limit on genetic (edit) distance for donate; -1=no max");
+                  "Limit on genetic (edit) distance for donate; -1=no max");
   time_group->Add(max_donates, "1000000", "MAX_DONATES",
-		  "Limit on number of donates organisms are allowed.");
-
-
+                  "Limit on number of donates organisms are allowed.");
+  
+  
   // Geneology group
   cConfigGroup * gen_group = new cConfigGroup("Geneology");
   group_list.PushRear(gen_group);
-
+  
   gen_group->Add(track_main_lineage, "0", "TRACK_MAIN_LINEAGE",
-		 "Keep all ancestors of the active population?\n0=no, 1=yes, 2=yes,w/sexual population");
+                 "Keep all ancestors of the active population?\n0=no, 1=yes, 2=yes,w/sexual population");
   gen_group->Add(threshold, "3", "THRESHOLD",
-		 "Number of organisms in a genotype needed for it\n  to be considered viable.");
+                 "Number of organisms in a genotype needed for it\n  to be considered viable.");
   gen_group->Add(genotype_print, "0", "GENOTYPE_PRINT",
-		 "0/1 (off/on) Print out all threshold genotypes?");
+                 "0/1 (off/on) Print out all threshold genotypes?");
   gen_group->Add(genotype_print_dom, "0", "GENOTYPE_PRINT_DOM",
-		 "Print out a genotype if it stays dominant for\n  this many updates. (0 = off)");
+                 "Print out a genotype if it stays dominant for\n  this many updates. (0 = off)");
   gen_group->Add(species_threshold, "2", "SPECIES_THRESHOLD",
-		 "max failure count for organisms to be same species");
+                 "max failure count for organisms to be same species");
   gen_group->Add(species_recording, "0", "SPECIES_RECORDING",
-		 "1 = full, 2 = limited search (parent only)");
+                 "1 = full, 2 = limited search (parent only)");
   gen_group->Add(species_print, "0", "SPECIES_PRINT",
-		 "0/1 (off/on) Print out all species?");
+                 "0/1 (off/on) Print out all species?");
   gen_group->Add(test_cpu_time_mod, "20", "TEST_CPU_TIME_MOD",
-		 "Time allocated in test CPUs (multiple of length)");
-
-
+                 "Time allocated in test CPUs (multiple of length)");
+  
+  
   // Log Files group
   cConfigGroup * log_group = new cConfigGroup("Log Files");
   group_list.PushRear(log_group);
-
+  
   log_group->Add(log_creatures, "0", "LOG_CREATURES",
-		 "0/1 (off/on) toggle to print file.");
+                 "0/1 (off/on) toggle to print file.");
   log_group->Add(log_genotypes, "0", "LOG_GENOTYPES",
-		 "0 = off, 1 = print ALL, 2 = print threshold ONLY.");
+                 "0 = off, 1 = print ALL, 2 = print threshold ONLY.");
   log_group->Add(log_threshold, "0", "LOG_THRESHOLD",
-		 "0/1 (off/on) toggle to print file.");
+                 "0/1 (off/on) toggle to print file.");
   log_group->Add(log_species, "0", "LOG_SPECIES",
-		 "0/1 (off/on) toggle to print file.");
+                 "0/1 (off/on) toggle to print file.");
   log_group->Add(log_landscape, "0", "LOG_LANDSCAPE",
-		 "0/1 (off/on) toggle to print file.");
-
-
+                 "0/1 (off/on) toggle to print file.");
+  
+  
   // Viewer group
   cConfigGroup * view_group = new cConfigGroup("Viewer Settings");
   group_list.PushRear(view_group);
-
+  
   view_group->Add(view_mode, "0", "VIEW_MODE",
-		  "Initial viewer screen");
-
+                  "Initial viewer screen");
+  
   // Lineages group
   cConfigGroup * lin_group = new cConfigGroup("Lineage");
   lin_group->SetComment("NOTE: This should probably be called \"Clade\"\nThis one can slow down avida a lot. It is used to get an idea of how\noften an advantageous mutation arises, and where it goes afterwards.\nLineage creation options are.  Works only when LOG_LINEAGES is set to 1.\n  0 = manual creation (on inject, use successive integers as lineage labels).\n  1 = when a child's (potential) fitness is higher than that of its parent.\n  2 = when a child's (potential) fitness is higher than max in population.\n  3 = when a child's (potential) fitness is higher than max in dom. lineage\n*and* the child is in the dominant lineage, or (2)\n  4 = when a child's (potential) fitness is higher than max in dom. lineage\n(and that of its own lineage)\n  5 = same as child's (potential) fitness is higher than that of the\n      currently dominant organism, and also than that of any organism\n      currently in the same lineage.\n  6 = when a child's (potential) fitness is higher th!
 an any organism\n      currently in the same lineage.\n  7 = when a child's (potential) fitness is higher than that of any\n      organism in its line of descent");
-
+  
   group_list.PushRear(lin_group);
-
+  
   lin_group->Add(log_lineages, "0", "LOG_LINEAGES",
-		 "");
+                 "");
   lin_group->Add(lineage_creation_method, "0", "LINEAGE_CREATION_METHOD",
-		 "");
-
+                 "");
+  
 }
 
 void cConfig::Setup(cGenesis & genesis)
@@ -482,22 +365,22 @@
   g_random.ResetSeed(rand_seed);
   if( rand_seed != g_random.GetSeed() ) cout << " -> " << g_random.GetSeed();
   cout << endl;
-
+  
   tListIterator<cConfigGroup> group_it(group_list);
   cConfigGroup * cur_group;
   while ((cur_group = group_it.Next()) != NULL) {
     cur_group->LoadValues(genesis);
   }
-
+  
   /***
-   * Handle any special modifications to any of the variables now that
-   * they've been loaded.
-   ***/
-
+    * Handle any special modifications to any of the variables now that
+    * they've been loaded.
+    ***/
+  
   // The default directory should end in a '/'.
   char dir_tail = default_dir[default_dir.GetSize() - 1];
   if (dir_tail != '\\' && dir_tail != '/') default_dir += "/";
-
+  
   // Determine if any variables were set that require test CPUs to be run
   // at every divide.
   test_on_divide = false;
@@ -505,20 +388,20 @@
       (revert_pos > 0.0) || (fail_implicit > 0)) {
     test_on_divide = true;
   }
-
+  
   test_sterilize = false;
   if ((sterilize_fatal > 0.0) || (sterilize_neg > 0.0) ||
       (sterilize_neut > 0.0) || (sterilize_pos > 0.0)) {
     test_sterilize = true;
   }
-
+  
   // Determine if we are only logging threshold genotypes...
   log_threshold_only = false;
   if (log_genotypes > 1) log_threshold_only = true;
-
+  
   // Warn if there are settings in the genesis file that have not been read.
   genesis.WarnUnused();
-
+  
   // Test printing... @CAO
   //  PrintGenesis("genesis.test");
 }
@@ -526,15 +409,15 @@
 void cConfig::Setup(int argc, char * argv[])
 {
   /***
-   * Load all of the variables from genesis.
-   ***/
-
+  * Load all of the variables from genesis.
+  ***/
+  
   default_dir = DEFAULT_DIR;
-
+  
   cGenesis genesis;
   genesis.SetVerbose();
   ProcessConfiguration(argc, argv, genesis);
-
+  
   Setup(genesis);
 }
 
@@ -542,7 +425,7 @@
 {
 #ifdef PLATFORM_WINDOWS
   OSVERSIONINFO	osVersion;
-
+  
   SetFileApisToOEM();             // use console character set for files
   memset (&osVersion, 0, sizeof (osVersion));
   osVersion.dwOSVersionInfoSize = sizeof (osVersion);
@@ -553,10 +436,10 @@
     //  mode).
     if (!SetConsoleCP (GetOEMCP()))        // and for Console input
       cerr << "WARNING: Unable to set input character set, rc="
-	   << GetLastError() << endl;
+        << GetLastError() << endl;
     if (!SetConsoleOutputCP (GetOEMCP()))  // and for Console output
       cerr << "WARNING: Unable to set output character set, rc="
-	   << GetLastError() << endl;
+        << GetLastError() << endl;
   }
 #endif
 }
@@ -564,64 +447,64 @@
 void cConfig::PrintGenesis(const cString & filename)
 {
   ofstream fp(filename);
-
+  
   // Print out the generic header, including the version ID.
   fp << "#############################################################################" << endl
-     << "# This file includes all the basic run-time defines for avida." << endl
-     << "# For more information, see doc/genesis.html" << endl
-     << "#############################################################################" << endl
-     << endl
-     << "VERSION_ID " << VERSION << "   # Do not change this value."
-     << endl;
-
+    << "# This file includes all the basic run-time defines for avida." << endl
+    << "# For more information, see doc/genesis.html" << endl
+    << "#############################################################################" << endl
+    << endl
+    << "VERSION_ID " << VERSION << "   # Do not change this value."
+    << endl;
+  
   // Loop through the groups, and print out all of the variables.
-
+  
   tListIterator<cConfigGroup> group_it(group_list);
   cConfigGroup * cur_group;
   while ((cur_group = group_it.Next()) != NULL) {
     // Print out the group name...
     fp << endl;
     fp << "### " << cur_group->GetName() << " ###" << endl;
-
+    
     // If we have a comment about the current group, include it.
     for (int i = 0; i < cur_group->GetComment().GetSize(); i++) {
       fp << "# " << cur_group->GetComment().GetLine(i) << endl;
     }
-
+    
     // Print out everything for this group...
     tListIterator<cConfigEntryBase> entry_it(cur_group->GetEntries());
     cConfigEntryBase * cur_entry;
-
+    
     // First, figure out the widest entry so we know where to put comments.
     int max_width = 0;
     while ((cur_entry = entry_it.Next()) != NULL) {
       int cur_width = cur_entry->GetTag().GetSize() +
-	cur_entry->GetDefault().GetSize() + 1;
+      cur_entry->GetDefault().GetSize() + 1;
       if (cur_width > max_width) max_width = cur_width;
     }
-
+    
     // Now, make a second pass printing everything.
     entry_it.Reset();
     while ((cur_entry = entry_it.Next()) != NULL) {
       int cur_width = cur_entry->GetTag().GetSize() +
- 	cur_entry->GetDefault().GetSize() + 1;
+      cur_entry->GetDefault().GetSize() + 1;
       // Print the variable and its setting...
       fp << cur_entry->GetTag() << " " << cur_entry->GetDefault();
-
+      
       // Print some spaces before the description.
       for (int i = cur_width; i < max_width; i++) fp << " ";
-
+      
       // Print the first line of the description.
       if (cur_entry->GetDesc().GetSize() == 0) {
-	fp << "  # " << endl;
+        fp << "  # " << endl;
       } else {
-	fp << "  # " << cur_entry->GetDesc().GetLine(0) << endl;
+        fp << "  # " << cur_entry->GetDesc().GetLine(0) << endl;
       }
-
+      
       // Print the remaining lines of a description.
       for (int i = 1; i < cur_entry->GetDesc().GetSize(); i++) {
-	for (int j = 0; j < max_width; j++) fp << " ";
-	fp << "  # " << cur_entry->GetDesc().GetLine(i) << endl;
+        for (int j = 0; j < max_width; j++) fp << " ";
+        fp << "  # " << cur_entry->GetDesc().GetLine(i) << endl;
       }
     }
   }
@@ -651,19 +534,19 @@
 {
   const cString default_filename = "genesis";
   genesis_filename = default_filename;
-
+  
   int arg_num = 1;              // Argument number being looked at.
   analyze_mode = false;         // Initialize analyze_mode tp be off.
   primitive_mode = false;       // Initialize primitive_mode tp be off.
   interactive_analyze = false;  // Don't start analyze interactively either.
-
+  
   // Load all of the args into string objects for ease of access.
   cString * args = new cString[argc];
   for (int i = 0; i < argc; i++) args[i] = argv[i];
-
-
+  
+  
   // -genesis option
-
+  
   if (argc > 1 && (args[1] == "-g" || args[1] == "-genesis")) {
     if (argc < 3) {
       cerr << "Need filename for genesis file used." << endl;
@@ -672,75 +555,70 @@
     genesis_filename = args[2];
     arg_num += 2;
   }
-
-
+  
+  
   // Open and verify the genesis file.
-
+  
   genesis.Open(genesis_filename);
-
+  
   // If we failed to open the genesis file, and we are using the default,
   // try creating it.
   if (genesis.IsOpen() == false && genesis_filename == default_filename) {
     cerr << "Warning: Unable to find file '" << genesis_filename
- 	 << "'.  Creating." << endl;
+    << "'.  Creating." << endl;
     PrintGenesis(genesis_filename);
     genesis.Open(genesis_filename);
   }
-
+  
   cString version_id = genesis.ReadString("VERSION_ID", "Unknown");
   if (genesis.IsOpen() == true && version_id != VERSION) {
     cerr << "/  WARNING   WARNING   WARNING   WARNING   WARNING  \\" << endl
-	 << "|   Using incorrect genesis file.                   |" << endl
-	 << "|   Version needed = \"" << VERSION
-	 << "\".  Version used = \"" << version_id() << "\"   |" << endl
-	 << "\\  WARNING   WARNING   WARNING   WARNING   WARNING  /" << endl
-	 << endl;
+    << "|   Using incorrect genesis file.                   |" << endl
+    << "|   Version needed = \"" << VERSION
+    << "\".  Version used = \"" << version_id() << "\"   |" << endl
+    << "\\  WARNING   WARNING   WARNING   WARNING   WARNING  /" << endl
+    << endl;
   }
-
+  
   // Then scan through and process the rest of the args.
-
+  
   while (arg_num < argc || genesis.IsOpen() == false) {
     cString cur_arg = genesis.IsOpen() ? static_cast<cString>( args[arg_num] )
-		      : static_cast<cString>( "--help" );
-
+    : static_cast<cString>( "--help" );
+    
     // Test against the possible inputs.
     if (cur_arg == "-events" || cur_arg == "-e") {
       cout << "Known events:" << endl;
-      for ( int i=0; i<cEventDescrs::num_of_events; i++ ){
-	cout << "-----  "
-	     << cEventDescrs::entries[i].GetName()
-	     << "  -----" << endl;
-	cout << cEventDescrs::entries[i].GetDescription() << endl;
-      }
+      // DDD - Should print out events here
       exit(0);
     }
     else if (cur_arg == "--help" || cur_arg == "-help" ||
-	cur_arg == "-h"     || genesis.IsOpen() == false) {
+             cur_arg == "-h"     || genesis.IsOpen() == false) {
       cout << "Options:"<<endl
-	   << "  -g[enesis] <filename> Set genesis file to be <filename>"<<endl
-	   << "  -h[elp]               Help on options (this listing)"<<endl
-	   << "  -e[vents]             Print a list of all known events"<< endl
-	   << "  -s[eed] <value>       Set random seed to <value>"<<endl
-	   << "  -viewer <value>       Sets Viewer to <value>"<<endl
-	   << "  -v[ersion]            Prints the version number"<<endl
-	   << "  -set <name> <value>   Overide the genesis file"<<endl
-	   << "  -l[oad] <filename>    Load a clone file"<<endl
-	   << "  -loadpop <filename>   Load a saved population file (precedence over load)"<<endl
-	   << "  -a[nalyze]            Process analyze.cfg instead of normal run."<<endl
-	   << "  -i[nteractive]        Run analyze mode interactively."
-	// << "  -p[rimitive]          Overide viewer to be primitive."<<endl
-	   << endl;
-	
+      << "  -g[enesis] <filename> Set genesis file to be <filename>"<<endl
+      << "  -h[elp]               Help on options (this listing)"<<endl
+      << "  -e[vents]             Print a list of all known events"<< endl
+      << "  -s[eed] <value>       Set random seed to <value>"<<endl
+      << "  -viewer <value>       Sets Viewer to <value>"<<endl
+      << "  -v[ersion]            Prints the version number"<<endl
+      << "  -set <name> <value>   Overide the genesis file"<<endl
+      << "  -l[oad] <filename>    Load a clone file"<<endl
+      << "  -loadpop <filename>   Load a saved population file (precedence over load)"<<endl
+      << "  -a[nalyze]            Process analyze.cfg instead of normal run."<<endl
+      << "  -i[nteractive]        Run analyze mode interactively."
+      // << "  -p[rimitive]          Overide viewer to be primitive."<<endl
+      << endl;
+      
       exit(0);
     }
     else if (cur_arg == "-seed" || cur_arg == "-s") {
       int in_seed = 0;
       if (arg_num + 1 == argc || args[arg_num + 1][0] == '-') {
-	cerr<<"Must include a number as the random seed!"<<endl;
-	exit(0);
+        cerr<<"Must include a number as the random seed!"<<endl;
+        exit(0);
       } else {
-	arg_num++;  if (arg_num < argc) cur_arg = args[arg_num];
-	in_seed = cur_arg.AsInt();
+        arg_num++;  if (arg_num < argc) cur_arg = args[arg_num];
+        in_seed = cur_arg.AsInt();
       }
       genesis.AddInput("RANDOM_SEED", in_seed);
     } else if (cur_arg == "-analyze" || cur_arg == "-a") {
@@ -752,19 +630,19 @@
       primitive_mode = true;
     } else if (cur_arg == "-load" || cur_arg == "-l") {
       if (arg_num + 1 == argc || args[arg_num + 1][0] == '-') {
-	cerr<<"Must include a filename to load from"<<endl;
-	exit(0);
+        cerr<<"Must include a filename to load from"<<endl;
+        exit(0);
       } else {
-	arg_num++;  if (arg_num < argc) cur_arg = args[arg_num];
-	clone_filename = cur_arg;
+        arg_num++;  if (arg_num < argc) cur_arg = args[arg_num];
+        clone_filename = cur_arg;
       }
     } else if (cur_arg == "-loadpop" || cur_arg == "-lp") {
       if (arg_num + 1 == argc || args[arg_num + 1][0] == '-') {
-	cerr<<"Must include a filename to load from"<<endl;
-	exit(0);
+        cerr<<"Must include a filename to load from"<<endl;
+        exit(0);
       } else {
-	arg_num++;  if (arg_num < argc) cur_arg = args[arg_num];
-	load_pop_filename = cur_arg;
+        arg_num++;  if (arg_num < argc) cur_arg = args[arg_num];
+        load_pop_filename = cur_arg;
       }
     } else if (cur_arg == "-version" || cur_arg == "-v") {
       cout << " by Charles Ofria" << endl;
@@ -773,8 +651,8 @@
       exit(0);
     } else if (cur_arg == "-set") {
       if (arg_num + 1 == argc || arg_num + 2 == argc) {
-	cerr << "'-set' option must be followed by name and value" << endl;
-	exit(0);
+        cerr << "'-set' option must be followed by name and value" << endl;
+        exit(0);
       }
       arg_num++;  if (arg_num < argc) cur_arg = args[arg_num];
       cString name(cur_arg);
@@ -782,18 +660,18 @@
       cString value(cur_arg);
       cout << "SET " << name() << " = " << value() << endl;
       genesis.AddInput(name(), value());
-
+      
     } else if (cur_arg == "-g" || cur_arg == "-genesis") {
       cerr << "Error: -g[enesis] option must be listed first." << endl;
       exit(0);
     } else {
       cerr << "Unknown Option: " << argv[arg_num] << endl
-	   << "Type: \"" << argv[0] << " -h\" for a full option list." << endl;
+      << "Type: \"" << argv[0] << " -h\" for a full option list." << endl;
       exit(0);
     }
-
+    
     arg_num++;  if (arg_num < argc) cur_arg = args[arg_num];
   }
-
+  
   delete [] args;
 }

Modified: branches/brysonda/source/main/environment.cc
===================================================================
--- branches/brysonda/source/main/environment.cc	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/main/environment.cc	2005-07-26 14:44:40 UTC (rev 263)
@@ -643,6 +643,7 @@
 
 bool cEnvironment::Load(const cString & filename)
 {
+  cerr << "--- ENVIRONMENT SETUP ---" << endl;
   cerr << "ENV: Loading file '" << filename << "'." << endl;
 
   cInitFile infile(filename);
@@ -673,6 +674,8 @@
     }
   }
 
+  cerr << "--- FINISHED ENVIRONMENT SETUP---" << endl;
+
   return true;
 }
 

Modified: branches/brysonda/source/main/environment.hh
===================================================================
--- branches/brysonda/source/main/environment.hh	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/main/environment.hh	2005-07-26 14:44:40 UTC (rev 263)
@@ -84,6 +84,9 @@
 		   const tArray<double> & resource_count,
 		   const double task_quality,
 		   cReactionResult & result) const;
+private:
+  // disabled copy constructor.
+  cEnvironment(const cEnvironment &);
 public:
   cEnvironment();
   // cEnvironment(const cString & filename);

Modified: branches/brysonda/source/main/genebank.hh
===================================================================
--- branches/brysonda/source/main/genebank.hh	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/main/genebank.hh	2005-07-26 14:44:40 UTC (rev 263)
@@ -45,6 +45,9 @@
 private:
   cString GetLabel(int in_size, int in_num);
 
+private:
+  // disabled copy constructor.
+  cGenebank(const cGenebank &);
 public:
   cGenebank(cStats & _stats);
   ~cGenebank();

Modified: branches/brysonda/source/main/genotype_batch.hh
===================================================================
--- branches/brysonda/source/main/genotype_batch.hh	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/main/genotype_batch.hh	2005-07-26 14:44:40 UTC (rev 263)
@@ -27,6 +27,9 @@
   cString name;
   bool is_lineage;
   bool is_aligned;
+private:
+  // disabled copy constructor.
+  cGenotypeBatch(const cGenotypeBatch &);
 public:
   cGenotypeBatch() : name(""), is_lineage(false), is_aligned(false) { ; }
   ~cGenotypeBatch() { ; }

Modified: branches/brysonda/source/main/landscape.hh
===================================================================
--- branches/brysonda/source/main/landscape.hh	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/main/landscape.hh	2005-07-26 14:44:40 UTC (rev 263)
@@ -93,6 +93,9 @@
 
   double TestMutPair(cGenome & mod_genome, int line1, int line2,
     const cInstruction & mut1, const cInstruction & mut2, std::ostream & fp);
+private:
+  // disabled copy constructor.
+  cLandscape(const cLandscape &);
 public:
   cLandscape(const cGenome & in_genome, const cInstSet & in_inst_set);
   ~cLandscape();

Modified: branches/brysonda/source/main/organism.cc
===================================================================
--- branches/brysonda/source/main/organism.cc	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/main/organism.cc	2005-07-26 14:44:40 UTC (rev 263)
@@ -244,6 +244,8 @@
   // Make sure required task (if any) has been performed...
   const int required_task = cConfig::GetRequiredTask();
   const int immunity_task = cConfig::GetImmunityTask();
+//cout << "req=" << required_task << "," <<phenotype.GetCurTaskCount()[required_task]<< " "; 
+//cout << "im=" << immunity_task << "," <<phenotype.GetCurTaskCount()[immunity_task]<< endl; 
   if (required_task != -1 &&
       phenotype.GetCurTaskCount()[required_task] == 0) { 
     if (immunity_task==-1 || 

Modified: branches/brysonda/source/main/phenotype.cc
===================================================================
--- branches/brysonda/source/main/phenotype.cc	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/main/phenotype.cc	2005-07-26 14:44:40 UTC (rev 263)
@@ -245,8 +245,6 @@
   assert(time_used > 0);
   assert(initialized == true);
 
-  double pre_reset_merit = merit.GetDouble(); 
-  
   // Update these values as needed...
   int cur_merit_base = CalcSizeMerit(genome_length,copied_size,executed_size);
   merit = cur_merit_base * cur_bonus;
@@ -330,8 +328,6 @@
   assert(time_used > 0);
   assert(initialized == true);
 
-  double pre_reset_merit = merit.GetDouble(); 
-
   // Update these values as needed...
   int cur_merit_base = CalcSizeMerit(genome_length,copied_size,executed_size);
   merit           = cur_merit_base * cur_bonus;

Modified: branches/brysonda/source/main/population.cc
===================================================================
--- branches/brysonda/source/main/population.cc	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/main/population.cc	2005-07-26 14:44:40 UTC (rev 263)
@@ -1188,9 +1188,17 @@
   int min_genome_length = INT_MAX;
 
   for (int i = 0; i < cell_array.GetSize(); i++) {
+
     // Only look at cells with organisms in them.
-    if (cell_array[i].IsOccupied() == false) continue;
 
+    if (cell_array[i].IsOccupied() == false) {
+
+      // Genotype map needs zero for all non-occupied cells
+
+      stats.SetGenoMapElement(i, 0);
+      continue;
+    }
+
     cOrganism * organism = cell_array[i].GetOrganism();
     const cPhenotype & phenotype = organism->GetPhenotype();
     const cMerit cur_merit = phenotype.GetMerit();

Modified: branches/brysonda/source/main/reaction.hh
===================================================================
--- branches/brysonda/source/main/reaction.hh	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/main/reaction.hh	2005-07-26 14:44:40 UTC (rev 263)
@@ -29,6 +29,9 @@
   tList<cReactionProcess> process_list;
   tList<cReactionRequisite> requisite_list;
   bool active;
+private:
+  // disabled copy constructor.
+  cReaction(const cReaction &);
 public:
   cReaction(const cString & _name, int _id);
   ~cReaction();

Modified: branches/brysonda/source/main/reaction_requisite.hh
===================================================================
--- branches/brysonda/source/main/reaction_requisite.hh	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/main/reaction_requisite.hh	2005-07-26 14:44:40 UTC (rev 263)
@@ -19,6 +19,9 @@
   tList<cReaction> prior_noreaction_list;
   int min_task_count;
   int max_task_count;
+private:
+  // disabled copy constructor.
+  cReactionRequisite(const cReactionRequisite &);
 public:
   cReactionRequisite();
   ~cReactionRequisite();

Modified: branches/brysonda/source/main/task_lib.cc
===================================================================
--- branches/brysonda/source/main/task_lib.cc	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/main/task_lib.cc	2005-07-26 14:44:40 UTC (rev 263)
@@ -1669,7 +1669,6 @@
 double cTaskLib::Task_CommEcho() const
 {
   const int test_output = output_buffer[0];
-  const int num_buffs = other_input_buffers.GetSize();
 
   tListIterator<tBuffer<int> > buff_it(other_input_buffers);  
 

Modified: branches/brysonda/source/main/task_lib.hh
===================================================================
--- branches/brysonda/source/main/task_lib.hh	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/main/task_lib.hh	2005-07-26 14:44:40 UTC (rev 263)
@@ -43,6 +43,9 @@
 		  REQ_NEIGHBOR_OUTPUT=2, 
 		  UNUSED_REQ_C=4,
 		  UNUSED_REQ_D=8 };
+private:
+  // disabled copy constructor.
+  cTaskLib(const cTaskLib &);
 public:
   cTaskLib();
   ~cTaskLib();

Modified: branches/brysonda/source/python/AvidaGui2/pyAnalyzeControlsView.ui
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyAnalyzeControlsView.ui	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyAnalyzeControlsView.ui	2005-07-26 14:44:40 UTC (rev 263)
@@ -44,7 +44,7 @@
         </spacer>
         <widget class="QToolButton">
             <property name="name">
-                <cstring>toolButton23</cstring>
+                <cstring>m_rewind_btn</cstring>
             </property>
             <property name="text">
                 <string></string>
@@ -55,11 +55,11 @@
         </widget>
         <widget class="QWidgetStack">
             <property name="name">
-                <cstring>widgetStack3</cstring>
+                <cstring>m_widget_stack</cstring>
             </property>
             <widget class="QWidget">
                 <property name="name">
-                    <cstring>WStackPage</cstring>
+                    <cstring>m_play_page</cstring>
                 </property>
                 <attribute name="id">
                     <number>0</number>
@@ -76,7 +76,7 @@
                     </property>
                     <widget class="QToolButton">
                         <property name="name">
-                            <cstring>toolButton19</cstring>
+                            <cstring>m_play_btn</cstring>
                         </property>
                         <property name="text">
                             <string></string>
@@ -92,7 +92,7 @@
             </widget>
             <widget class="QWidget">
                 <property name="name">
-                    <cstring>WStackPage</cstring>
+                    <cstring>m_pause_page</cstring>
                 </property>
                 <attribute name="id">
                     <number>1</number>
@@ -109,7 +109,7 @@
                     </property>
                     <widget class="QToolButton">
                         <property name="name">
-                            <cstring>toolButton20</cstring>
+                            <cstring>m_pause_btn</cstring>
                         </property>
                         <property name="text">
                             <string></string>
@@ -126,7 +126,7 @@
         </widget>
         <widget class="QToolButton">
             <property name="name">
-                <cstring>toolButton24</cstring>
+                <cstring>m_cue_btn</cstring>
             </property>
             <property name="text">
                 <string></string>

Modified: branches/brysonda/source/python/AvidaGui2/pyAvida.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyAvida.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyAvida.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -132,9 +132,10 @@
       pass
 
   def doStepAvidaSlot(self, cell_id):
-    print("doStepAvidaSlot")
+    print("pyAvida.doStepAvidaSlot() ...")
 
   def doCloseAvidaSlot(self):
+    print("pyAvida.doCloseAvidaSlot() ...")
     self.m_avida_threaded_driver.doExit()
     if self.m_avida_threaded_driver.m_thread.isAlive():
       self.m_avida_threaded_driver.m_thread.join()

Modified: branches/brysonda/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyEduWorkspaceCtrl.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyEduWorkspaceCtrl.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -238,24 +238,20 @@
     if self.startStatus:
       self.m_session_mdl.m_session_mdtr.emit(
         PYSIGNAL("fromLiveCtrlStartAvidaSig"), ())
-      print "send start signal"
     else:
       self.m_session_mdl.m_session_mdtr.emit(
         PYSIGNAL("fromLiveCtrlPauseAvidaSig"), ())
-      print "send pause signal"
     
   def setAvidaSlot(self, avida):
     print "pyEduWorkspaceCtrl.setAvidaSlot() ..."
     old_avida = self.m_avida
     self.m_avida = avida
     if old_avida:
-      print "pyEduWorkspaceCtrl.setAvidaSlot() disconnecting old_avida ..."
       self.disconnect(
         old_avida.m_avida_thread_mdtr, PYSIGNAL("AvidaUpdatedSig"),
         self.avidaUpdatedSlot)
       del old_avida
     if self.m_avida:
-      print "pyEduWorkspaceCtrl.setAvidaSlot() connecting self.m_avida ..."
       self.connect(
         self.m_avida.m_avida_thread_mdtr, PYSIGNAL("AvidaUpdatedSig"),
         self.avidaUpdatedSlot)
@@ -274,11 +270,28 @@
     self.startStatus = False
     
   def startQuitProcessSlot(self):
-    m_quit_avida_ed = pyQuitDialogCtrl()
-    quit_return = m_quit_avida_ed.showDialog()
-    if quit_return == m_quit_avida_ed.QuitFlag:
+
+    # Be sure that the session is paused before quitting (to reduce confusion
+    # if the user decides to save before quiting)
+
+    self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("doPauseAvidaSig"), ())
+
+
+    # Check if there unsaved petri dishes if there are ask the user if they 
+    # want to save them, just quit the program or cancel the quit.  If there
+    # are no unsaved populations just quit.
+    # (actually only works with one population will need to expand to
+    # two populations in the future)
+
+    print "BDB: self.m_one_population_ctrl.m_session_mdl.saved_full_dish = " + str(self.m_one_population_ctrl.m_session_mdl.saved_full_dish)
+    print "BDB: self.m_one_population_ctrl.m_session_mdl.new_full_dish = " + str(self.m_one_population_ctrl.m_session_mdl.new_full_dish)
+    if (not self.m_one_population_ctrl.m_session_mdl.saved_full_dish and
+        not self.m_one_population_ctrl.m_session_mdl.new_full_dish):
+      m_quit_avida_ed = pyQuitDialogCtrl()
+      quit_return = m_quit_avida_ed.showDialog()
+      if quit_return == m_quit_avida_ed.QuitFlag:
+        self.emit(PYSIGNAL("quitAvidaPhaseIISig"), ())
+      elif quit_return == m_quit_avida_ed.FreezeQuitFlag:
+        self.m_one_population_ctrl.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("freezeDishPhaseISig"), (False, True, ))
+    else:
       self.emit(PYSIGNAL("quitAvidaPhaseIISig"), ())
-    elif quit_return == m_quit_avida_ed.FreezeQuitFlag:
-      print "at pyEduWorkspaceCtrl:startQuitProcessSlot emited FreezeDishPhaseISig"
-      self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("FreezeDishPhaseISig"), (False, True, ))
-

Copied: branches/brysonda/source/python/AvidaGui2/pyFreezeOrganismCtrl.py (from rev 262, trunk/source/python/AvidaGui2/pyFreezeOrganismCtrl.py)

Copied: branches/brysonda/source/python/AvidaGui2/pyFreezeOrganismView.ui (from rev 262, trunk/source/python/AvidaGui2/pyFreezeOrganismView.ui)

Modified: branches/brysonda/source/python/AvidaGui2/pyFreezerCtrl.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyFreezerCtrl.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyFreezerCtrl.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -4,6 +4,8 @@
 from qt import *
 from pyFreezerView import pyFreezerView
 from pyReadFreezer import pyReadFreezer
+from pyWriteToFreezer import pyWriteToFreezer
+from pyFreezeOrganismCtrl import pyFreezeOrganismCtrl
 import os.path
 
 class pyFreezerCtrl(pyFreezerView):
@@ -14,21 +16,15 @@
     self.connect(self.m_list_view, 
       SIGNAL("doubleClicked(QListViewItem*, const QPoint &, int)"),
       self.clicked_itemSlot)
-    # self.connect(self.m_list_view, 
-    #   SIGNAL("clicked(QListViewItem*, const QPoint &, int )"),
-    #   self.clicked_itemSlot)
     self.connect(self.m_list_view, 
       SIGNAL("pressed(QListViewItem*, const QPoint &, int )"),
       self.pressed_itemSlot)
-    self.setAcceptDrops(1)
 
   def construct(self, session_mdl):
     self.m_session_mdl = session_mdl
     self.connect(self.m_session_mdl.m_session_mdtr,
       PYSIGNAL("doRefreshFreezerInventorySig"),
       self.createFreezerIndexSlot)
-    self.connect(self, PYSIGNAL("freezerItemDoubleClicked"),
-      self.m_session_mdl.m_session_mdtr, PYSIGNAL("freezerItemDoubleClicked"))
     self.createFreezerIndexSlot()
 
 
@@ -65,7 +61,8 @@
         tmp_item = QListViewItem(organism_item)
         tmp_item.setText(0,organism_name)
 
-# if mouse is pressed on list item prepare its info to be dragged        
+  # if mouse is pressed on list item prepare its info to be dragged        
+
   def pressed_itemSlot(self, item):
 
     if item != None and item.depth() > 0:
@@ -121,15 +118,35 @@
   class itemDrag(QTextDrag):
     def __init__(self, item_name, parent=None, name=None):
         QStoredDrag.__init__(self, 'item name (QString)', parent, name)
+        print "setting up itemDrag, my parent is"
+        print parent
         self.setText(item_name)
 
-  def dropEvent( self, e ):
+  def dropEvent( self, e):
     freezer_item_name = QString()
     print "dropEvent in freezer"
+    if e.source() is self:
+      return
     if ( QTextDrag.decode( e, freezer_item_name ) ) : #freezer_item_name is a string...the file name 
-      if os.path.exists(str(freezer_item_name)) == False:
-        print "that was not a valid path (1)" 
-      else: 
-        self.emit(PYSIGNAL("petriDishDroppedInPopViewSig"), (e,))
+      print freezer_item_name
+      if freezer_item_name[:9] == 'organism.':
+        freezer_item_name = freezer_item_name[9:] 
+        self.FreezeOrganismSlot(freezer_item_name)
+      else:
+        print "that was not an organism"      
+    
+  def FreezeOrganismSlot(self, freezer_item_name, 
+      send_reset_signal = False, send_quit_signal = False):
+    print "freezer_item_name"
+    print freezer_item_name
+    tmp_dict = {1:freezer_item_name}
+#    tmp_dict["SETTINGS"] = self.Form2Dictio`nary()
+    m_pop_up_organism_file_name = pyFreezeOrganismCtrl()
+    file_name = m_pop_up_organism_file_name.showDialog(self.m_session_mdl.m_current_freezer)
 
-
+    file_name_len = len(file_name.rstrip())
+    if (file_name_len > 0):
+      freezer_file = pyWriteToFreezer(tmp_dict, file_name)
+    
+    self.m_session_mdl.m_session_mdtr.emit(
+      PYSIGNAL("doRefreshFreezerInventorySig"), ())

Modified: branches/brysonda/source/python/AvidaGui2/pyFreezerView.ui
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyFreezerView.ui	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyFreezerView.ui	2005-07-26 14:44:40 UTC (rev 263)
@@ -83,7 +83,7 @@
                 </font>
             </property>
             <property name="acceptDrops">
-                <bool>true</bool>
+                <bool>false</bool>
             </property>
             <property name="frameShape">
                 <enum>StyledPanel</enum>

Modified: branches/brysonda/source/python/AvidaGui2/pyGradientScaleCtrl.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyGradientScaleCtrl.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyGradientScaleCtrl.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -12,10 +12,14 @@
   def construct(self, session_mdl):
     self.m_session_mdl = session_mdl
     self.m_avida = None
+    self.m_current_map_mode_name = None
     self.connect(
       self.m_session_mdl.m_session_mdtr, PYSIGNAL("setAvidaSig"),
       self.setAvidaSlot)
+    self.connect(self.m_session_mdl.m_session_mdtr,
+       PYSIGNAL("mapModeChangedSig"), self.setMapModeSlot)
 
+
   def setAvidaSlot(self, avida):
     print "pyGradientScaleCtrl.setAvidaSlot() ..."
     old_avida = self.m_avida
@@ -32,5 +36,18 @@
         self.m_avida.m_avida_thread_mdtr, PYSIGNAL("AvidaUpdatedSig"),
         self.avidaUpdatedSlot)
 
+  def setMapModeSlot(self,index):
+    self.m_current_map_mode_name = index
+
   def avidaUpdatedSlot(self):
     pass
+
+  def destruct(self):
+    print "*** called pyGradientScaleCtrl.py:destruct ***"
+    self.m_avida = None
+    self.disconnect(
+      self.m_session_mdl.m_session_mdtr, PYSIGNAL("setAvidaSig"),
+      self.setAvidaSlot)
+    self.m_session_mdl = None
+  
+

Modified: branches/brysonda/source/python/AvidaGui2/pyGradientScaleView.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyGradientScaleView.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyGradientScaleView.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+ # -*- coding: utf-8 -*-
 
 # Original form implementation generated from reading ui file 
 # '/Users/kaben/Projects/Software/Avida/svn/avida2/trunk/source/python/AvidaGui2/pyGradientScaleView.ui'
@@ -22,6 +22,7 @@
   s_empty_text_width = 0
   s_off_scale_text_width = 0
   s_label_text_width = 0
+  s_map_mode_name_label_width = 100
   s_text_height = 0
 
   def __init__(self,parent = None,name = None,fl = 0):
@@ -49,7 +50,14 @@
 
     if not name:
       setName("pyGradientScaleView")
+  
+  def construct(self, session_mdl):
+    self.m_session_mdl = session_mdl
+    self.m_avida = None
 
+
+
+
   def doubleToColor(self, x): return self.m_color_lookup and self.m_color_lookup(x) or QColor(Qt.black)
 
   def setRange(self, min, max):
@@ -92,7 +100,7 @@
     #text_height = self.fontMetrics().height()
     #label_width = self.fontMetrics().width("0.00000")
   
-    for i in range(self.s_stripes):
+    for i in xrange(self.s_stripes):
       x = float(i) / float(self.s_stripes);
       p.fillRect(
         (self.s_left_margin + x*plot_width),
@@ -125,6 +133,34 @@
       self.getLabelString(self.m_max_value)
     )
 
+# draw the number label for the midpoint
+    p.drawText(
+      #w - self.s_right_margin - label_width,
+#      w/2 - self.s_right_margin - self.s_label_text_width,
+      w/2 - self.s_label_text_width/2,
+      self.s_top_margin,
+      self.s_label_text_width,
+      self.s_text_height,
+      #label_width,
+      #text_height,
+      Qt.AlignBottom | Qt.AlignCenter,
+      self.getLabelString((self.m_max_value-self.m_min_value)/2.0)
+    )
+
+
+#  make a word label for the scale 
+    p.drawText(
+      w/2 - self.s_map_mode_name_label_width/2,
+      h - self.s_top_margin*4,            #the multiple is a hack
+      self.s_map_mode_name_label_width,
+      self.s_text_height,
+      #label_width,
+      #text_height,
+      Qt.AlignBottom | Qt.AlignCenter,
+      self.m_current_map_mode_name
+    )
+
+
       #self.s_spacing + 2 * self.fontMetrics().width("0.0e+02")
 
       #if i%self.s_step == 0:
@@ -200,6 +236,7 @@
     self.setMinimumHeight(h)
     self.setMaximumHeight(h)
 
+
   def getLabelString(self, x):
 
     # To show numbers < 10,000 without going to sci. notation had to
@@ -209,4 +246,5 @@
     if x >= 100:
       ix = int(x)
       x = float(ix)
-    return QString("%1").arg(x, 0, 'g', 5)
+    return QString("%1").arg(x, 0, 'g', 2)
+

Modified: branches/brysonda/source/python/AvidaGui2/pyHardwareCPUTrace.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyHardwareCPUTrace.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyHardwareCPUTrace.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -41,7 +41,7 @@
 
     self.m_last_copied_instruction = max(
       [hardware.GetMemory().GetFlagCopied(i) and i or self.m_last_copied_instruction \
-      for i in range(self.m_last_copied_instruction, hardware.GetMemory().GetSize())]
+      for i in xrange(self.m_last_copied_instruction, hardware.GetMemory().GetSize())]
     )
     self.m_last_copy_info.append(self.m_last_copied_instruction)
 
@@ -55,8 +55,15 @@
     self.m_ihead_moves_info.append(len(self.m_ihead_moves))
 
   def recordGenotypeSummary(self, analyze_genotype):
+    print "pyHardwareCPUTrace.recordGenotypeSummary() ..."
     self.m_is_viable = analyze_genotype.GetViable()
     self.m_gestation_time = analyze_genotype.GetGestTime()
     self.m_fitness = analyze_genotype.GetFitness()
     self.m_size = analyze_genotype.GetLength()
+    if not self.m_is_viable:
+      self.m_gestation_time = len(self.m_genome_info)
+    print "  self.m_is_viable", self.m_is_viable
+    print "  self.m_gestation_time", self.m_gestation_time
+    print "  self.m_fitness", self.m_fitness
+    print "  self.m_size", self.m_size
 

Modified: branches/brysonda/source/python/AvidaGui2/pyLiveControlsCtrl.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyLiveControlsCtrl.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyLiveControlsCtrl.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -60,3 +60,24 @@
   def clickedStartAvidaSlot(self):
     self.m_session_mdl.m_session_mdtr.emit(
       PYSIGNAL("fromLiveCtrlStartAvidaSig"), ())
+
+  def restart(self):
+    print "*** called pyLiveControlsCtrl.py:restart ***"
+    self.m_avida = None
+    self.disconnect(
+      self.m_session_mdl.m_session_mdtr, PYSIGNAL("setAvidaSig"),
+      self.setAvidaSlot)
+    self.disconnect(
+      self.m_session_mdl.m_session_mdtr, PYSIGNAL("doPauseAvidaSig"),
+      self.doPauseAvidaSlot)
+    self.disconnect(
+      self.m_session_mdl.m_session_mdtr, PYSIGNAL("doStartAvidaSig"),
+      self.doStartAvidaSlot)
+    self.disconnect(
+      self.m_play_button, SIGNAL("clicked()"),
+      self.clickedStartAvidaSlot)
+    self.disconnect(
+      self.m_pause_button, SIGNAL("clicked()"),
+      self.clickedPauseAvidaSlot)
+    self.m_session_mdl = None
+

Modified: branches/brysonda/source/python/AvidaGui2/pyMapProfile.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyMapProfile.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyMapProfile.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -155,7 +155,7 @@
       s = sigmoid(1 - x, 0.1, 30) * 255
       return QColor(h, s, v, QColor.Hsv)
 
-    self.m_color_cache = [sigmoidDoubleToColor(float(n)/(self.m_color_cache_size - 1)) for n in range(self.m_color_cache_size)]
+    self.m_color_cache = [sigmoidDoubleToColor(float(n)/(self.m_color_cache_size - 1)) for n in xrange(self.m_color_cache_size)]
     self.m_empty_color = QColor(Qt.black)
     self.m_off_scale_color = QColor(Qt.white)
     def sigmoidColorLookup(x):

Modified: branches/brysonda/source/python/AvidaGui2/pyOneAna_GraphCtrl.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyOneAna_GraphCtrl.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyOneAna_GraphCtrl.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -50,7 +50,8 @@
     self.m_petri_dish_dir_path = ' '
     self.m_petri_dish_dir_exists_flag = False
 
-    self.connect( self.m_session_mdl.m_session_mdtr, PYSIGNAL("freezerItemDoubleClickedOnInOneAnaSig"),
+    self.connect( self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("freezerItemDoubleClickedOnInOneAnaSig"),
       self.freezerItemDoubleClickedOn)  
 
 
@@ -113,7 +114,7 @@
     x_array = zeros(init_file.GetNumLines(), Float)
     y_array = zeros(init_file.GetNumLines(), Float)
 
-    for line_id in range(init_file.GetNumLines()):
+    for line_id in xrange(init_file.GetNumLines()):
       line = init_file.GetLine(line_id)
       x_array[line_id] = line.GetWord(colx - 1).AsDouble()
       y_array[line_id] = line.GetWord(coly - 1).AsDouble()

Modified: branches/brysonda/source/python/AvidaGui2/pyOneAna_PetriDishCtrl.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyOneAna_PetriDishCtrl.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyOneAna_PetriDishCtrl.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -12,9 +12,11 @@
 
   def construct(self, session_mdl):
     self.m_session_mdl = session_mdl     
-    self.connect( self.m_session_mdl.m_session_mdtr, PYSIGNAL("freezerItemDroppedInOneAnalyzeSig"),
+    self.connect( self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("freezerItemDroppedInOneAnalyzeSig"),
       self.freezerItemDropped)  
-    self.connect( self.m_session_mdl.m_session_mdtr, PYSIGNAL("freezerItemDoubleClickedOnInOneAnaSig"),
+    self.connect( self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("freezerItemDoubleClickedOnInOneAnaSig"),
       self.freezerItemDoubleClickedOn)  
 
 
@@ -26,6 +28,5 @@
       self.m_one_ana_pop_name.setText(os.path.splitext((os.path.split(str(freezer_item_name))[1]))[0])
 
   def freezerItemDoubleClickedOn(self, freezer_item_name):
-    print freezer_item_name
     self.m_one_ana_pop_name.setText(os.path.split(os.path.splitext(os.path.split(freezer_item_name)[0])[0])[1])
 

Modified: branches/brysonda/source/python/AvidaGui2/pyOneAnalyzeCtrl.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyOneAnalyzeCtrl.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyOneAnalyzeCtrl.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -15,10 +15,13 @@
     self.m_one_ana_graph_ctrl.construct(self.m_session_mdl)
     self.m_one_ana_petri_ctrl.construct(self.m_session_mdl) 
     self.connect( self, PYSIGNAL("freezerItemDroppedInOneAnalyzeSig"),
-      self.m_session_mdl.m_session_mdtr, PYSIGNAL("freezerItemDroppedInOneAnalyzeSig"))
+      self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("freezerItemDroppedInOneAnalyzeSig"))
     self.connect( self, PYSIGNAL("freezerItemDoubleClickedOnInOneAnaSig"),
-      self.m_session_mdl.m_session_mdtr, PYSIGNAL("freezerItemDoubleClickedOnInOneAnaSig"))
-    self.connect( self.m_session_mdl.m_session_mdtr, PYSIGNAL("freezerItemDoubleClicked"),
+      self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("freezerItemDoubleClickedOnInOneAnaSig"))
+    self.connect( self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("freezerItemDoubleClicked"),
       self.freezerItemDoubleClicked)
 
   def dropEvent( self, e ):
@@ -34,7 +37,8 @@
       print "that was not a valid path(3)"
     else:
       if self.isVisible():
-         self.emit(PYSIGNAL("freezerItemDoubleClickedOnInOneAnaSig"), (freezer_item_name,))
+        self.emit(PYSIGNAL("freezerItemDoubleClickedOnInOneAnaSig"), 
+          (freezer_item_name,))
       
 
 

Modified: branches/brysonda/source/python/AvidaGui2/pyOneOrg_ScopeCtrl.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyOneOrg_ScopeCtrl.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyOneOrg_ScopeCtrl.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -2,6 +2,7 @@
 
 from pyOneOrg_ScopeView import pyOneOrg_ScopeView
 import qt
+import os
 
 class pyOneOrg_ScopeCtrl(pyOneOrg_ScopeView):
 
@@ -13,19 +14,44 @@
     self.m_organism_scope_ctrl.construct(self.m_session_mdl)
     self.m_execution_step_slider.setMinValue(0)
     self.m_execution_step_slider.setMaxValue(0)
+    self.m_clock = qt.QTime()
+    self.m_timer = qt.QTimer()
+    self.m_next = qt.QTimer()
+    self.m_timer_interval = 250
+
     self.connect(
       self.m_execution_step_slider, qt.SIGNAL("valueChanged(int)"),
-      self.m_organism_scope_ctrl.showFrame)
+      self.sliderValueChangedSlot)
     self.connect(
+      self.m_execution_step_slider, qt.SIGNAL("sliderMoved(int)"),
+      self.sliderMovedSlot)
+
+    self.connect(
       self.m_organism_scope_ctrl, qt.PYSIGNAL("gestationTimeChangedSig"),
       self.gestationTimeChangedSlot)
     self.connect(
       self.m_organism_scope_ctrl, qt.PYSIGNAL("executionStepResetSig"),
       self.executionStepResetSlot)
 
+    self.connect(
+      self.m_analyze_controls_ctrl.m_rewind_btn, qt.SIGNAL("clicked()"),
+      self.rewindSlot)
+    self.connect(
+      self.m_analyze_controls_ctrl.m_cue_btn, qt.SIGNAL("clicked()"),
+      self.cueSlot)
+    self.connect(
+      self.m_analyze_controls_ctrl.m_play_btn, qt.SIGNAL("clicked()"),
+      self.playSlot)
+    self.connect(
+      self.m_analyze_controls_ctrl.m_pause_btn, qt.SIGNAL("clicked()"),
+      self.pauseSlot)
+
+    self.connect(self.m_timer, qt.SIGNAL("timeout()"), self.advanceSlot)
+
   def gestationTimeChangedSlot(self, gestation_time):
     print "pyOneOrg_ScopeCtrl.gestationTimeChangedSlot called, gestation_time ", gestation_time
     self.m_execution_step_slider.setMaxValue(gestation_time - 1)
+    self.rewindSlot()
 
   def executionStepResetSlot(self, execution_step):
     print "pyOneOrg_ScopeCtrl.executionStepResetSlot called, execution_step ", execution_step
@@ -33,3 +59,40 @@
     # This may be redundant (I'm not sure). @kgn
     self.m_execution_step_slider.emit(qt.SIGNAL("valueChanged(int)"),(execution_step,))
 
+  def sliderValueChangedSlot(self, frame_number):
+    print "pyOneOrg_ScopeCtrl.sliderValueChangedSlot(", frame_number, ")."
+    self.m_organism_scope_ctrl.showFrame(frame_number)
+
+  def sliderMovedSlot(self, frame_number):
+    print "pyOneOrg_ScopeCtrl.sliderMovedSlot()."
+    self.pauseSlot()
+
+  def rewindSlot(self):
+    print "pyOneOrg_ScopeCtrl.rewindSlot()."
+    self.m_execution_step_slider.setValue(0)
+    self.pauseSlot()
+
+  def cueSlot(self):
+    print "pyOneOrg_ScopeCtrl.cueSlot()."
+    self.m_execution_step_slider.setValue(self.m_execution_step_slider.maxValue())
+    self.pauseSlot()
+
+  def pauseSlot(self):
+    print "pyOneOrg_ScopeCtrl.pauseSlot()."
+    self.m_analyze_controls_ctrl.m_widget_stack.raiseWidget(self.m_analyze_controls_ctrl.m_play_page)
+    self.m_timer.stop()
+
+  def playSlot(self):
+    print "pyOneOrg_ScopeCtrl.playSlot()."
+    self.m_analyze_controls_ctrl.m_widget_stack.raiseWidget(self.m_analyze_controls_ctrl.m_pause_page)
+    self.m_timer.start(self.m_timer_interval, True)
+    self.m_clock.start()
+
+  def advanceSlot(self):
+    #print "pyOneOrg_ScopeCtrl.advanceSlot()."
+    slider_value = self.m_execution_step_slider.value()
+    if self.m_execution_step_slider.maxValue() <= slider_value:
+      self.pauseSlot()
+    else:
+      self.m_execution_step_slider.setValue(slider_value + 1)
+      self.m_timer.start(min(0, self.m_timer_interval - self.m_clock.restart(), True))

Modified: branches/brysonda/source/python/AvidaGui2/pyOneOrg_ScopeView.ui
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyOneOrg_ScopeView.ui	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyOneOrg_ScopeView.ui	2005-07-26 14:44:40 UTC (rev 263)
@@ -70,7 +70,7 @@
                 </spacer>
                 <widget class="pyAnalyzeControlsCtrl">
                     <property name="name">
-                        <cstring>pyAnalyzeControlsCtrl1</cstring>
+                        <cstring>m_analyze_controls_ctrl</cstring>
                     </property>
                     <property name="sizePolicy">
                         <sizepolicy>
@@ -123,6 +123,8 @@
         <property type="3">-1</property>
         <property type="1">pyAnalyzeControlsCtrl</property>
         <property type="3">-1</property>
+        <property type="1">pyAnalyzeControlsCtrl</property>
+        <property type="0">-1</property>
         <property type="pyAnalyzeControlsCtrl"></property>
         <property type="-1">1</property>
     </customwidget>

Modified: branches/brysonda/source/python/AvidaGui2/pyOnePop_GraphCtrl.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyOnePop_GraphCtrl.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyOnePop_GraphCtrl.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -153,3 +153,22 @@
         filter.setOptions(QwtPlotPrintFilter.PrintAll & ~QwtPlotPrintFilter.PrintCanvasBackground)
       self.m_graph_ctrl.printPlot(printer, filter)
 
+  def restart(self):
+    self.m_avida = None
+    self.m_combo_box.clear()
+    self.m_combo_box.setInsertionPolicy(QComboBox.AtBottom)
+    for entry in self.m_avida_stats_interface.m_entries:
+      self.m_combo_box.insertItem(entry[0])
+    self.connect(
+      self.m_combo_box, SIGNAL("activated(int)"), self.modeActivatedSlot)
+
+    self.m_x_array = zeros(2, Float)
+    self.m_y_array = zeros(2, Float)
+
+    self.m_graph_ctrl.setAxisTitle(QwtPlot.xBottom, "Time (updates)")
+    self.m_graph_ctrl.setAxisAutoScale(QwtPlot.xBottom)
+
+    # Start with second graph mode -- "Average Fitness".
+    self.m_combo_box.setCurrentItem(2)
+    self.modeActivatedSlot(self.m_combo_box.currentItem())
+

Modified: branches/brysonda/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -5,49 +5,71 @@
 from pyOnePop_PetriDishView import pyOnePop_PetriDishView
 import os
 from pyReadFreezer import pyReadFreezer
+from pyGradientScaleView import pyGradientScaleView
+from pyQuitDialogCtrl import pyQuitDialogCtrl
 
+
 class pyOnePop_PetriDishCtrl(pyOnePop_PetriDishView):
 
   def __init__(self,parent = None,name = None,fl = 0):
     pyOnePop_PetriDishView.__init__(self,parent,name,fl)
+    self.m_gradient_scale_view = pyGradientScaleView(self,"m_gradient_scale_ctrl")
 
   def construct(self, session_mdl):
     self.m_session_mdl = session_mdl
     self.m_avida = None
     self.dishDisabled = False
+
     self.m_petri_dish_ctrl.construct(self.m_session_mdl)
+
     self.m_gradient_scale_ctrl.construct(self.m_session_mdl)
+    self.m_gradient_scale_view.construct(self.m_session_mdl)
+
     self.m_live_controls_ctrl.construct(self.m_session_mdl)
     self.m_petri_configure_ctrl.construct(self.m_session_mdl)
-    self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("freezeDishPhaseISig"), self.m_petri_dish_ctrl.extractPopulationSlot)
-    self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("freezeDishPhaseISig"), self.freezeDishPhaseISlot)
-
-    self.connect(self.m_petri_configure_ctrl, PYSIGNAL("freezeDishPhaseISig"), self.m_petri_dish_ctrl.extractPopulationSlot)
-    self.connect(self.m_petri_dish_ctrl, PYSIGNAL("freezeDishPhaseIISig"), self.m_petri_configure_ctrl.FreezePetriSlot)
-    self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("setAvidaSig"), self.setAvidaSlot)
-    self.connect(self.m_petri_dish_toggle, SIGNAL("clicked()"), self.ToggleDishSlot)
-    self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("doDefrostDishSig"), self.shouldIDefrost)
-#    self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("doDefrostDishSig"), self.RenameDishSlot)
-#    self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("doDefrostDishSig"), self.MakeConfigVisiableSlot)
-    self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("doDisablePetriDishSig"), self.SetDishDisabledSlot)
-    self.connect(self.m_zoom_spinbox, SIGNAL("valueChanged(int)"), self.m_petri_dish_ctrl.zoomSlot)
-    self.connect(self.m_petri_dish_ctrl, PYSIGNAL("zoomSig"), self.m_zoom_spinbox.setValue)
-    self.connect(self.m_mode_combobox, SIGNAL("activated(int)"), self.modeActivatedSlot)
-    self.connect( self.m_session_mdl.m_session_mdtr, PYSIGNAL("petriDishDroppedInPopViewSig"),
-      self.petriDropped)  
-
+    self.connect(self.m_session_mdl.m_session_mdtr,
+      PYSIGNAL("freezeDishPhaseISig"),
+      self.m_petri_dish_ctrl.extractPopulationSlot)
+    self.connect(self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("freezeDishPhaseISig"), self.freezeDishPhaseISlot)
+    self.connect(self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("setAvidaSig"), self.setAvidaSlot)
+    self.connect(self.m_petri_dish_toggle, SIGNAL("clicked()"), 
+      self.ToggleDishSlot)
+    self.connect(self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("doDefrostDishSig"), self.DefrostSlot)
+#    self.connect(self.m_session_mdl.m_session_mdtr, 
+#       PYSIGNAL("doDefrostDishSig"), self.RenameDishSlot)
+#    self.connect(self.m_session_mdl.m_session_mdtr, 
+#       PYSIGNAL("doDefrostDishSig"), self.MakeConfigVisiableSlot)
+    self.connect(self.m_session_mdl.m_session_mdtr, 
+       PYSIGNAL("doDisablePetriDishSig"), self.SetDishDisabledSlot)
+    self.connect(self.m_session_mdl.m_session_mdtr, 
+       PYSIGNAL("doEnablePetriDishSig"), self.SetDishEnabledSlot)
+    self.connect(self.m_zoom_spinbox, SIGNAL("valueChanged(int)"), 
+       self.m_petri_dish_ctrl.zoomSlot)
+    self.connect(self.m_petri_dish_ctrl, PYSIGNAL("zoomSig"), 
+       self.m_zoom_spinbox.setValue)
+    self.connect(self.m_mode_combobox, SIGNAL("activated(int)"), 
+       self.modeActivatedSlot)
+    self.connect(self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("petriDishDroppedInPopViewSig"), self.petriDropped)  
+    self.connect(self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("finishedPetriDishSig"), self.finishedPetriDishSlot)  
     self.m_mode_combobox.clear()
     self.m_mode_combobox.setInsertionPolicy(QComboBox.AtBottom)
     self.m_map_profile = pyMapProfile(self.m_session_mdl)
     for i in range(self.m_map_profile.getSize()):
       self.m_mode_combobox.insertItem(self.m_map_profile.getModeName(i))
-
+ 
     # Start with second map mode -- "Fitness".
     self.m_mode_combobox.setCurrentItem(2)
     self.m_mode_index = self.m_mode_combobox.currentItem()
     self.modeActivatedSlot(self.m_mode_index)
-    #self.m_petri_dish_ctrl.emit(PYSIGNAL("zoomSig"), (self.m_petri_dish_ctrl.m_initial_target_zoom,))
+    # self.m_petri_dish_ctrl.emit(PYSIGNAL("zoomSig"), 
+    #   (self.m_petri_dish_ctrl.m_initial_target_zoom,))
 
+
   def setAvidaSlot(self, avida):
     print "pyOnePop_PetriDishCtrl.setAvidaSlot() ..."
     old_avida = self.m_avida
@@ -87,9 +109,12 @@
   def SetDishDisabledSlot(self):
     self.dishDisabled = True
 
+  def SetDishEnabledSlot(self):
+    self.dishDisabled = False
+
   def modeActivatedSlot(self, index):
     self.m_avida and self.m_avida.m_avida_threaded_driver.m_lock.acquire()
-
+    self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("mapModeChangedSig"), (self.m_map_profile.getModeName(index),))
     self.m_mode_index = index
     self.m_petri_dish_ctrl.setIndexer(self.m_map_profile.getIndexer(self.m_mode_index))
     self.m_petri_dish_ctrl.setColorLookupFunctor(self.m_map_profile.getColorLookup(self.m_mode_index))
@@ -123,9 +148,8 @@
     if update: self.m_update_label.setText(QString("%1").arg(update))
     
   def RenameDishSlot(self, dishName):
-    if self.dishDisabled:
-      return
-    self.PopulationTextLabel.setText(dishName)
+    if (not self.dishDisabled):
+      self.PopulationTextLabel.setText(dishName)
     
   # Dummy routine
     
@@ -144,8 +168,10 @@
         return
       elif freezer_item_name[-4:] == 'full':
         freezer_item_name_temp = os.path.join(str(freezer_item_name), 'petri_dish')
+        self.m_session_mdl.new_full_dish = True
       else:
         freezer_item_name_temp = str(freezer_item_name)
+        self.m_session_mdl.new_empty_dish = True
       thawed_item = pyReadFreezer(freezer_item_name_temp)
       self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("doDefrostDishSig"),  
         (os.path.splitext((os.path.split(str(freezer_item_name))[1]))[0], thawed_item,))
@@ -154,7 +180,88 @@
       current_page_int = self.m_petri_dish_widget_stack.id(current_page)
       self.MakeConfigVisiableSlot()
 
-  def shouldIDefrost(self, dishName):
+  def DefrostSlot(self, dish_name, petri_dict):
     if self.isVisible():
-      self.RenameDishSlot(dishName)
+
+      Restart_Only_Flag = False
+      # If the petri dish is already filled prompt the user if they want to 
+      # freeze the existing dish
+
+      if self.m_petri_configure_ctrl.DishDisabled:
+
+        self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("doPauseAvidaSig"), ())
+
+        # check to see if the user needs/wants to save (recycle the quit dialog
+        # widget) the dish
+
+        if (not self.m_session_mdl.saved_full_dish):
+          m_check_to_freeze = pyQuitDialogCtrl("Restart")
+          quit_return = m_check_to_freeze.showDialog()
+          if quit_return == m_check_to_freeze.QuitFlag:
+            Restart_Only_Flag = True
+            self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("doEnablePetriDishSig"), ())
+          elif quit_return == m_check_to_freeze.FreezeQuitFlag:
+            print "BDB: Freeze than Restart" 
+            self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("doEnablePetriDishSig"), ())
+            self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("freezeDishPhaseISig"), (True, False, ))
+  
+          # if the user clicked the cancel button
+  
+          else:
+            print "BDB: hit cancel button"
+            return
+
+      self.RenameDishSlot(dish_name)
       self.MakeConfigVisiableSlot()
+      self.finishedPetriDish = False
+      self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("FillDishSig"), 
+        (dish_name, petri_dict, ))
+ 
+      # Be sure that the petri dish is finished being filled before going on
+
+      while (not self.finishedPetriDish):
+        pass
+
+      if (Restart_Only_Flag):
+        print "BDB: sending reset signal from pyPetriConfigureCtrl:FillDishSlot"
+        self.m_session_mdl.m_session_mdtr.emit(
+          PYSIGNAL("restartPopulationSig"), (self.m_session_mdl, ))
+
+  def finishedPetriDishSlot(self):
+    self.finishedPetriDish = True
+
+  def restart(self, session_mdl):
+    print "pyOnePop_PetriDishCtrl.py:restart called"
+    self.dishDisabled = False
+
+    # self.m_petri_dish_ctrl.restart()
+    # self.m_gradient_scale_ctrl.destruct()
+    # self.m_live_controls_ctrl.restart()
+    # self.m_petri_configure_ctrl.destruct()
+    # self.disconnect(self.m_session_mdl.m_session_mdtr,
+    #   PYSIGNAL("freezeDishPhaseISig"),
+    #   self.m_petri_dish_ctrl.extractPopulationSlot)
+    # self.disconnect(self.m_session_mdl.m_session_mdtr, 
+    #   PYSIGNAL("freezeDishPhaseISig"), self.freezeDishPhaseISlot)
+    # self.disconnect(self.m_session_mdl.m_session_mdtr, 
+    #   PYSIGNAL("setAvidaSig"), self.setAvidaSlot)
+    # self.disconnect(self.m_petri_dish_toggle, SIGNAL("clicked()"), 
+    #   self.ToggleDishSlot)
+    # self.disconnect(self.m_session_mdl.m_session_mdtr, 
+    #   PYSIGNAL("doDefrostDishSig"), self.DefrostSlot)
+    # self.disconnect(self.m_session_mdl.m_session_mdtr, 
+    #    PYSIGNAL("doDisablePetriDishSig"), self.SetDishDisabledSlot)
+    # self.disconnect(self.m_zoom_spinbox, SIGNAL("valueChanged(int)"), 
+    #    self.m_petri_dish_ctrl.zoomSlot)
+    # self.disconnect(self.m_petri_dish_ctrl, PYSIGNAL("zoomSig"), 
+    #    self.m_zoom_spinbox.setValue)
+    # self.disconnect(self.m_mode_combobox, SIGNAL("activated(int)"), 
+    #    self.modeActivatedSlot)
+    # self.disconnect(self.m_session_mdl.m_session_mdtr, 
+    #   PYSIGNAL("petriDishDroppedInPopViewSig"), self.petriDropped)  
+    # self.m_mode_index = None
+    # self.m_session_mdl = None
+    # self.m_avida = None
+    self.m_update_label.setText("-")
+    # print "*** pyOnePop_PetriDishCtrl.py:restartPopulationSlot about to call se.f.construct ***"
+    # self.construct(session_mdl)

Modified: branches/brysonda/source/python/AvidaGui2/pyOnePop_StatsCtrl.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyOnePop_StatsCtrl.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyOnePop_StatsCtrl.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -11,7 +11,7 @@
 
   def __init__(self,parent = None,name = None,fl = 0):
     pyOnePop_StatsView.__init__(self,parent,name,fl)
-       
+
   def construct(self, session_mdl):
     self.m_session_mdl = session_mdl
     self.m_avida = None
@@ -22,9 +22,11 @@
     self.connect(
       self.m_session_mdl.m_session_mdtr, PYSIGNAL("orgClickedOnSig"),
       self.updateOrgReportSlot)
-    self.connect( self.m_session_mdl.m_session_mdtr, PYSIGNAL("petriDishDroppedInPopViewSig"),
+    self.connect( self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("petriDishDroppedInPopViewSig"),
       self.petriDropped)  
-    self.connect( self.m_session_mdl.m_session_mdtr, PYSIGNAL("freezerItemDoubleClickedOnInOnePopSig"),
+    self.connect( self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("freezerItemDoubleClickedOnInOnePopSig"),
       self.freezerItemDoubleClickedOn)  
     self.m_clicked_cell_number = -99
 
@@ -162,18 +164,16 @@
 
 
 
-  def updateOrgReportSlot(self, clicked_cell_item):
+  def updateOrgReportSlot(self, clicked_cell_item = None):
 
     self.m_clicked_cell_item = clicked_cell_item
     if clicked_cell_item:
       clicked_cell_num = clicked_cell_item.m_population_cell.GetID()
-#the_item.brush().color()
-#the_item.m_population_cell.GetID()
-    if clicked_cell_item:
       self.m_clicked_cell_number = clicked_cell_num
-#    if clicked_cell_num is None or not self.m_avida.m_population.GetCell(int(clicked_cell_num)).IsOccupied():
     if clicked_cell_item is None or not self.m_avida.m_population.GetCell(int(clicked_cell_num)).IsOccupied():
-      #PAINT the stats fields empty
+
+      # PAINT the stats fields empty
+
       self.m_org_name.setText('empty cell')
       self.m_org_fitness.setText('-')
       self.m_org_merit.setText('-')
@@ -202,6 +202,11 @@
     organism = clicked_cell.GetOrganism()
     phenotype = organism.GetPhenotype()
     genotype = organism.GetGenotype()
+ 
+    # tee up drag information
+#    dragHolder = self.itemDrag( file_name, self )
+#    dragHolder = self.itemDrag( str(genotype.GetName()), self )
+#    dragHolder.dragCopy()
 
     # print info about the org clicked on 
 
@@ -346,3 +351,23 @@
       self.loadStats(freezer_item_dir)
     else:
       return
+
+  def restart(self):
+    self.m_avida = None
+    self.m_clicked_cell_number = -99
+    self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("orgClickedOnSig"),())
+    self.m_avg_fitness.setText("-")
+    self.m_num_orgs.setText("-")
+    self.m_avg_gest.setText("-")
+    self.m_avg_merit.setText("-")
+    self.m_avg_age.setText("-")
+    self.m_avg_genome_length.setText("-")
+    self.m_num_not.setText("-")
+    self.m_num_nand.setText("-")
+    self.m_num_and.setText("-")
+    self.m_num_ornot.setText("-")
+    self.m_num_or.setText("-")
+    self.m_num_andnot.setText("-")
+    self.m_num_nor.setText("-")
+    self.m_num_xor.setText("-")
+    self.m_num_equals.setText("-")

Modified: branches/brysonda/source/python/AvidaGui2/pyOnePopulationCtrl.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyOnePopulationCtrl.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyOnePopulationCtrl.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -1,5 +1,6 @@
 # -*- coding: utf-8 -*-
 
+from pyAvida import pyAvida
 from qt import *
 from pyOnePopulationView import pyOnePopulationView
 import os.path
@@ -17,15 +18,20 @@
     self.m_one_pop_stats_ctrl.construct(self.m_session_mdl)
     self.m_one_pop_timeline_ctrl.hide()
     self.connect( self, PYSIGNAL("petriDishDroppedInPopViewSig"),
-      self.m_session_mdl.m_session_mdtr, PYSIGNAL("petriDishDroppedInPopViewSig"))   
+      self.m_session_mdl.m_session_mdtr,
+      PYSIGNAL("petriDishDroppedInPopViewSig"))   
     self.connect( self, PYSIGNAL("freezerItemDoubleClickedOnInOnePopSig"), 
-      self.m_session_mdl.m_session_mdtr, PYSIGNAL("freezerItemDoubleClickedOnInOnePopSig"))
-    self.connect( self.m_session_mdl.m_session_mdtr, PYSIGNAL("freezerItemDoubleClicked"),
-      self.freezerItemDoubleClicked)
+      self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("freezerItemDoubleClickedOnInOnePopSig"))
+    self.connect( self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("freezerItemDoubleClicked"), self.freezerItemDoubleClicked)
+    self.connect(self.m_session_mdl.m_session_mdtr,
+      PYSIGNAL("restartPopulationSig"), self.restartPopulationSlot)
 
+
   def dropEvent( self, e ):
     freezer_item_name = QString()
-    print "dropEvent"
+    print "dropEvent in one population"
     if ( QTextDrag.decode( e, freezer_item_name ) ) : #freezer_item_name is a string...the file name 
       if os.path.exists(str(freezer_item_name)) == False:
         print "that was not a valid path (1)" 
@@ -33,7 +39,16 @@
         self.emit(PYSIGNAL("petriDishDroppedInPopViewSig"), (e,))
 
   def freezerItemDoubleClicked(self, freezer_item_name):
-   if  self.isVisible():
-       self.emit(PYSIGNAL("freezerItemDoubleClickedOnInOnePopSig"), (freezer_item_name,))
+   if self.isVisible():
+     self.emit(PYSIGNAL("freezerItemDoubleClickedOnInOnePopSig"), 
+       (freezer_item_name,))
 
- 
\ No newline at end of file
+  def restartPopulationSlot(self, session_mdl):
+    self.m_one_pop_petri_dish_ctrl.restart(self.m_session_mdl)
+    self.m_one_pop_graph_ctrl.restart()
+    self.m_one_pop_stats_ctrl.restart()
+    # self.m_session_mdl.m_session_mdtr.emit(
+    #   PYSIGNAL("doInitializeAvidaPhaseISig"), (self.m_session_mdl.m_tempdir,))
+
+
+

Modified: branches/brysonda/source/python/AvidaGui2/pyOrganismScopeCtrl.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyOrganismScopeCtrl.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyOrganismScopeCtrl.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -20,8 +20,10 @@
     if not name: self.setName("pyOrganismScopeCtrl")
 
   def construct(self, session_mdl):
+    print "pyOrganismScopeCtrl.construct()."
     self.m_session_mdl = session_mdl
     self.m_avida = None
+    self.setAcceptDrops(1)
     self.connect(
       self.m_session_mdl.m_session_mdtr, PYSIGNAL("setAvidaSig"),
       self.setAvidaSlot)
@@ -29,6 +31,41 @@
       self.m_session_mdl.m_session_mdtr, PYSIGNAL("setDebugOrganismFileSig"),
       self.setDebugOrganismFileSlot)
 
+  def dragEnterEvent( self, e ):
+    e.acceptAction(True)
+    if e.isAccepted():
+      print "pyOrganismScopeCtrl.dragEnterEvent(e): isAccepted."
+    else:
+      print "pyOrganismScopeCtrl.dragEnterEvent(e): not isAccepted."
+
+    freezer_item_name = QString()
+    if ( QTextDrag.decode( e, freezer_item_name ) ) :
+      if os.path.exists( str(freezer_item_name)) == False:
+        print "pyOrganismScopeCtrl.dragEnterEvent(e): that was not a valid path."
+      else:
+        print "pyOrganismScopeCtrl.dragEnterEvent(e): that was a valid path."
+        print "pyOrganismScopeCtrl.dragEnterEvent(e): freezer_item_name", freezer_item_name
+        if str(freezer_item_name).endswith('.organism'):
+          print "pyOrganismScopeCtrl.dragEnterEvent(e): freezer_item_name ends with .organism."
+          e.accept()
+        else:
+          print "pyOrganismScopeCtrl.dragEnterEvent(e): freezer_item_name doesn't end with .organism."
+
+  def dropEvent( self, e ):
+    freezer_item_name = QString()
+    if ( QTextDrag.decode( e, freezer_item_name ) ) :
+      if os.path.exists( str(freezer_item_name)) == False:
+        print "pyOrganismScopeCtrl.dropEvent(e): that was not a valid path."
+      else:
+        print "pyOrganismScopeCtrl.dropEvent(e): that was a valid path."
+        if str(freezer_item_name).endswith('.organism'):
+          print "pyOrganismScopeCtrl.dropEvent(e): freezer_item_name ends with .organism."
+          e.accept()
+          self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("setDebugOrganismFileSig"), (freezer_item_name,))
+        else:
+          print "pyOrganismScopeCtrl.dropEvent(e): freezer_item_name doesn't end with .organism."
+
+
   def setAvidaSlot(self, avida):
     print "pyOrganismScopeCtrl.setAvidaSlot() ..."
     old_avida = self.m_avida
@@ -40,19 +77,29 @@
   def setDebugOrganismFileSlot(self, organism_filename):
     print "pyOrganismScopeCtrl.setDebugOrganismFileSlot"
     if self.m_avida:
+      self.reset()
+
       inst_set = self.m_avida.m_environment.GetInstSet()
-      genome = cGenome(cInstUtil.LoadGenome(cString(organism_filename.ascii()), inst_set) )
+      org_file = open(organism_filename.ascii())
+      org_string = org_file.readline()
+      org_string = org_string.rstrip()
+      org_string = org_string.lstrip()
+      org_file.close
+      genome = cGenome(cString(org_string))
       analyze_genotype = cAnalyzeGenotype(genome, inst_set)
       hardware_tracer = pyHardwareTracer()
       hardware_tracer.traceAnalyzeGenotype(analyze_genotype, self.m_avida.m_environment, should_use_resources = False)
 
       # Translate from string genome representation to actual command names.
       inst_names = {}
+      ops = {}
       inst_set = self.m_avida.m_environment.GetInstSet()
       instruction = cInstruction()
-      for id in range(inst_set.GetSize()):
+      for id in xrange(inst_set.GetSize()):
         instruction.SetOp(id)
         inst_names[instruction.GetSymbol()] = str(inst_set.GetName(instruction))
+        ops[instruction.GetSymbol()] = id
 
       self.setInstNames(inst_names)
+      self.setOps(ops)
       self.setFrames(hardware_tracer.m_hardware_trace)

Modified: branches/brysonda/source/python/AvidaGui2/pyOrganismScopeView.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyOrganismScopeView.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyOrganismScopeView.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -1,10 +1,38 @@
 # -*- coding: utf-8 -*-
 
 
-from qt import PYSIGNAL, QBrush, QColor, QFont, QFontMetrics, QPointArray, QPoint, QScrollView, Qt, QWMatrix
-from qtcanvas import QCanvas, QCanvasSpline, QCanvasText, QCanvasView
+from qt import PYSIGNAL, QBrush, QColor, QFont, QFontMetrics, QPen, QPointArray, QPoint, QScrollView, Qt, QWMatrix
+from qtcanvas import QCanvas, QCanvasEllipse, QCanvasLine, QCanvasSpline, QCanvasText, QCanvasView
 import math
 
+class pyHeadPath:
+  def __init__(self, canvas):
+    self.m_canvas = canvas
+    self.m_line1 = QCanvasLine(canvas)
+    self.m_line2 = QCanvasLine(canvas)
+  def setCanvas(self, canvas):
+    self.m_canvas = canvas
+    self.m_line1.setCanvas(canvas)
+    self.m_line2.setCanvas(canvas)
+  def setControlPoints(self, point_array, ignored_bool):
+    x0 = point_array.point(0)[0]
+    x1 = point_array.point(1)[0]
+    x2 = point_array.point(2)[0]
+    y0 = point_array.point(0)[1]
+    y1 = point_array.point(1)[1]
+    y2 = point_array.point(2)[1]
+    self.m_line1.setPoints(x0, y0, x1, y1)
+    self.m_line2.setPoints(x1, y1, x2, y2)
+  def setPen(self, pen):
+    self.m_line1.setPen(pen)
+    self.m_line2.setPen(pen)
+  def show(self):
+    self.m_line1.show()
+    self.m_line2.show()
+  def hide(self):
+    self.m_line1.hide()
+    self.m_line2.hide()
+
 class pyOrganismScopeView(QCanvasView):
   def __init__(self,parent = None,name = None,fl = 0):
     QCanvasView.__init__(self,parent,name,fl)
@@ -29,15 +57,31 @@
 
   def reset(self):
     if hasattr(self, "m_instruction_items") and self.m_instruction_items is not None:
-      for instruction_item in self.m_instruction_items:
-        instruction_item.setCanvas(None)
+      for item in self.m_instruction_items:
+        item.setCanvas(None)
+    if hasattr(self, "m_instruction_bg_items") and self.m_instruction_bg_items is not None:
+      for item in self.m_instruction_bg_items:
+        item.setCanvas(None)
+    if hasattr(self, "m_ihead_move_items") and self.m_ihead_move_items is not None:
+      for item in self.m_ihead_move_items:
+        item.setCanvas(None)
+    if hasattr(self, "m_ihead_item") and self.m_ihead_item is not None:
+      self.m_ihead_item.setCanvas(None)
+    if hasattr(self, "m_rhead_item") and self.m_rhead_item is not None:
+      self.m_rhead_item.setCanvas(None)
+    if hasattr(self, "m_whead_item") and self.m_whead_item is not None:
+      self.m_whead_item.setCanvas(None)
+    if hasattr(self, "m_fhead_item") and self.m_fhead_item is not None:
+      self.m_fhead_item.setCanvas(None)
+
     self.m_instruction_items = None
-    self.m_task_items = None
+    self.m_instruction_bg_items = None
+    self.m_ihead_move_items = None
     self.m_ihead_item = None
     self.m_rhead_item = None
     self.m_whead_item = None
     self.m_fhead_item = None
-    self.m_rhead_move_items = None
+    self.m_task_items = None
 
     self.m_task_names = None
     self.m_inst_names = None
@@ -52,30 +96,70 @@
     self.m_current_rhead = None
     self.m_current_whead = None
     self.m_current_fhead = None
-    self.m_current_rhead_move = None
+    self.m_current_ihead_move = None
 
     # Hmm; can't emit gestationTimeChangedSig(0) without causing absurd slider values. @kgn
     self.emit(PYSIGNAL("gestationTimeChangedSig"),(1,))
     self.emit(PYSIGNAL("executionStepResetSig"),(0,))
 
   def setTaskNames(self, task_names = None):
-    old_task_names = self.m_task_names
     self.m_task_names = task_names
 
   def setInstNames(self, inst_names = None):
-    old_inst_names = self.m_inst_names
     self.m_inst_names = inst_names
 
+  def setOps(self, ops = None):
+    self.m_ops_dict = ops
+
   def setFrames(self, frames = None):
     self.reset()
     self.m_frames = frames
     if self.m_frames is not None:
       if self.m_frames.m_genome_info is not None:
         self.m_max_genome_size = max([len(genome) for genome in self.m_frames.m_genome_info])
-        self.m_instruction_items = [QCanvasText(self.m_canvas) for i in range(self.m_max_genome_size)]
+        self.m_instruction_items = [QCanvasText(self.m_canvas) for i in xrange(self.m_max_genome_size)]
+        self.m_instruction_bg_items = [QCanvasEllipse(self.m_canvas) for i in xrange(self.m_max_genome_size)]
+        for item in self.m_instruction_items:
+          item.setTextFlags(Qt.AlignCenter)
+          item.setZ(1.)
+        for item in self.m_instruction_bg_items:
+          item.setZ(0.)
+      text_height = 2 * 3.14159 * self.m_max_circle_radius / self.m_max_genome_size
+      font = QFont(self.font())
+      point_size_float = self.m_font_oversize_factor * text_height * self.m_font_points_per_pixel
+      font.setPointSizeFloat(point_size_float)
+      if self.m_frames.m_ihead_info is not None:
+        self.m_ihead_item = QCanvasText(self.m_canvas)
+        self.m_ihead_item.setTextFlags(Qt.AlignCenter)
+        self.m_ihead_item.setZ(1.)
+        self.m_ihead_item.setFont(font)
+        self.m_ihead_item.setText('i')
+      if self.m_frames.m_rhead_info is not None:
+        self.m_rhead_item = QCanvasText(self.m_canvas)
+        self.m_rhead_item.setTextFlags(Qt.AlignCenter)
+        self.m_rhead_item.setZ(1.)
+        self.m_rhead_item.setFont(font)
+        self.m_rhead_item.setText('r')
+      if self.m_frames.m_whead_info is not None:
+        self.m_whead_item = QCanvasText(self.m_canvas)
+        self.m_whead_item.setTextFlags(Qt.AlignCenter)
+        self.m_whead_item.setZ(1.)
+        self.m_whead_item.setFont(font)
+        self.m_whead_item.setText('w')
+      if self.m_frames.m_fhead_info is not None:
+        self.m_fhead_item = QCanvasText(self.m_canvas)
+        self.m_fhead_item.setTextFlags(Qt.AlignCenter)
+        self.m_fhead_item.setZ(1.)
+        self.m_fhead_item.setFont(font)
+        self.m_fhead_item.setText('f')
       if self.m_frames.m_ihead_moves is not None:
-        self.m_rhead_move_items = [QCanvasSpline(self.m_canvas) for i in range(len(self.m_frames.m_ihead_moves))]
-      self.emit(PYSIGNAL("gestationTimeChangedSig"),(self.m_frames.m_gestation_time,))
+        #self.m_ihead_move_items = [QCanvasSpline(self.m_canvas) for i in xrange(len(self.m_frames.m_ihead_moves))]
+        self.m_ihead_move_items = [pyHeadPath(self.m_canvas) for i in xrange(len(self.m_frames.m_ihead_moves))]
+
+      if self.m_frames.m_is_viable:
+        self.emit(PYSIGNAL("gestationTimeChangedSig"),(self.m_frames.m_gestation_time,))
+      else:
+        self.emit(PYSIGNAL("gestationTimeChangedSig"),(len(self.m_frames.m_genome_info),))
       self.updateCircle()
       self.showFrame(0)
 
@@ -99,26 +183,35 @@
     if self.m_instruction_items is not None:
       text_height = 2 * 3.14159 * self.m_max_circle_radius / self.m_max_genome_size
       font = QFont(self.font())
-      font.setPointSizeFloat(self.m_font_oversize_factor * text_height * self.m_font_points_per_pixel)
-      for instruction_item in self.m_instruction_items:
-        instruction_item.setFont(font)
+      point_size_float = self.m_font_oversize_factor * text_height * self.m_font_points_per_pixel
+      font.setPointSizeFloat(point_size_float)
+      for item in self.m_instruction_items:
+        item.setFont(font)
+      for item in self.m_instruction_bg_items:
+        item.setSize(point_size_float, point_size_float)
       self.m_circles = []
+      self.m_head_circles = []
       self.m_circle_radii = []
-      for frame_no in range(self.m_frames.m_gestation_time):
+      for frame_no in xrange(self.m_frames.m_gestation_time):
         organism_current_size = max(self.m_frames.m_last_copy_info[frame_no] + 1, self.m_frames.m_size)
         circumference = text_height * organism_current_size
         radius = circumference / (2 * 3.14159)
         dt = 2 * 3.14159 / (organism_current_size + 1)
         angle_offset = 3.14159 / 2
         circle_pts = []
-        for i in range(organism_current_size):
+        head_circle_pts = []
+        for i in xrange(organism_current_size + 1):
           theta = i * dt + angle_offset
           c = math.cos(theta)
           s = -math.sin(theta)
           x = radius * c + self.m_circle_center_x
           y = radius * s + self.m_circle_center_y
+          h_x = (radius + 10) * c + self.m_circle_center_x
+          h_y = (radius + 10) * s + self.m_circle_center_y
           circle_pts.append((x,y))
+          head_circle_pts.append((h_x,h_y))
         self.m_circles.append(circle_pts)
+        self.m_head_circles.append(head_circle_pts)
         self.m_circle_radii.append(radius)
 
   def showFrame(self, frame_number = 0):
@@ -130,7 +223,7 @@
     old_rhead = self.m_current_rhead
     old_whead = self.m_current_whead
     old_fhead = self.m_current_fhead
-    old_rhead_move = self.m_current_rhead_move
+    old_ihead_move = self.m_current_ihead_move
 
     self.m_current_frame_number = 0
     self.m_current_radius = None
@@ -140,25 +233,38 @@
     self.m_current_rhead = None
     self.m_current_whead = None
     self.m_current_fhead = None
-    self.m_current_rhead_move = None
+    self.m_current_ihead_move = None
 
     circle_pts = None
 
+    if frame_number < 0:
+      print "pyOrganismScopeView.showFrame() : bad frame_number", frame_number, "reset to zero."
+      frame_number = 0
+
     if self.m_frames is not None and frame_number < self.m_frames.m_gestation_time:
       self.m_current_frame_number = frame_number
       self.m_current_radius = self.m_circle_radii[frame_number]
       circle_pts = self.m_circles[frame_number]
+      head_circle_pts = self.m_head_circles[frame_number]
       if self.m_frames.m_genome_info is not None:
         self.m_current_genome = self.m_frames.m_genome_info[frame_number]
         if old_genome is None:
           displayed_genome_size = max(self.m_frames.m_last_copy_info[self.m_current_frame_number], self.m_frames.m_size)
           # Update all instruction_items.
-          for i in range(displayed_genome_size):
-            instruction_item = self.m_instruction_items[i]
-            instruction_item.setX(circle_pts[i][0])
-            instruction_item.setY(circle_pts[i][1])
-            instruction_item.setText(self.m_current_genome[i])
-            instruction_item.show()
+          color = QColor()
+          for i in xrange(displayed_genome_size):
+            item = self.m_instruction_items[i]
+            item.setX(circle_pts[i][0])
+            item.setY(circle_pts[i][1])
+            item.setText(self.m_current_genome[i])
+            item.show()
+
+            bg_item = self.m_instruction_bg_items[i]
+            bg_item.setX(circle_pts[i][0])
+            bg_item.setY(circle_pts[i][1])
+            color.setHsv((self.m_ops_dict[self.m_current_genome[i]] * 360) / len(self.m_ops_dict), 85, 248)
+            bg_item.setBrush(QBrush(color))
+            bg_item.show()
         else:
           # Update changed instruction_items.
           old_length = max(self.m_frames.m_last_copy_info[old_frame_number] + 1, self.m_frames.m_size)
@@ -167,95 +273,128 @@
           range_end = max(old_length, new_length)
 
           if old_radius != self.m_current_radius:
-            for i in range(compare_max):
-              instruction_item = self.m_instruction_items[i]
-              instruction_item.setX(circle_pts[i][0])
-              instruction_item.setY(circle_pts[i][1])
+            for i in xrange(compare_max):
+              item = self.m_instruction_items[i]
+              item.setX(circle_pts[i][0])
+              item.setY(circle_pts[i][1])
+              bg_item = self.m_instruction_bg_items[i]
+              bg_item.setX(circle_pts[i][0])
+              bg_item.setY(circle_pts[i][1])
             if old_length < new_length:
-              for i in range(compare_max, range_end):
-                instruction_item = self.m_instruction_items[i]
-                instruction_item.setX(circle_pts[i][0])
-                instruction_item.setY(circle_pts[i][1])
+              for i in xrange(compare_max, range_end):
+                item = self.m_instruction_items[i]
+                item.setX(circle_pts[i][0])
+                item.setY(circle_pts[i][1])
+                bg_item = self.m_instruction_bg_items[i]
+                bg_item.setX(circle_pts[i][0])
+                bg_item.setY(circle_pts[i][1])
 
-          for i in range(compare_max):
+          for i in xrange(compare_max):
             instruction_item = self.m_instruction_items[i]
             if old_genome[i] == self.m_current_genome[i]:
               pass
             else:
               self.m_instruction_items[i].setText(self.m_current_genome[i])
+              color = QColor()
+              color.setHsv((self.m_ops_dict[self.m_current_genome[i]] * 360) / len(self.m_ops_dict), 85, 248)
+              self.m_instruction_bg_items[i].setBrush(QBrush(color))
 
           if old_length < new_length:
-            for i in range(compare_max, range_end):
-              instruction_item = self.m_instruction_items[i]
-              instruction_item.setText(self.m_current_genome[i])
-              instruction_item.show()
+            for i in xrange(compare_max, range_end):
+              item = self.m_instruction_items[i]
+              item.setText(self.m_current_genome[i])
+              item.show()
+              bg_item = self.m_instruction_bg_items[i]
+              color = QColor()
+              color.setHsv((self.m_ops_dict[self.m_current_genome[i]] * 360) / len(self.m_ops_dict), 85, 248)
+              bg_item.setBrush(QBrush(color))
+              bg_item.show()
           else:
-            for i in range(compare_max, range_end):
+            for i in xrange(compare_max, range_end):
               self.m_instruction_items[i].hide()
+              self.m_instruction_bg_items[i].hide()
 
       if self.m_frames.m_ihead_moves_info is not None:
-        self.m_current_rhead_move = self.m_frames.m_ihead_moves_info[frame_number]
-        if old_rhead_move is None:
-          # Update all rhead_move_items.
-          for i in range(self.m_current_rhead_move):
-            rhead_move_item = self.m_rhead_move_items[self.m_current_rhead_move]
+        self.m_current_ihead_move = self.m_frames.m_ihead_moves_info[frame_number]
+        if old_ihead_move is None:
+          # Update all ihead_move_items.
+          for i in xrange(self.m_current_ihead_move):
+            if len(self.m_ihead_move_items) < i:
+              print "pyOrganismScopeView.showFrame(): i", i, ", len(self.m_ihead_move_items)", len(self.m_ihead_move_items)
+            ihead_move_item = self.m_ihead_move_items[self.m_current_ihead_move]
             anchor_radius = float(m_current_radius - 10)
             anchor_radii_ratio = anchor_radius / self.m_current_radius
-            control_radii_ratio = (0.5 + 0.4/math.ldexp(1, self.m_frames.m_ihead_moves[rhead_move_item][2])) * anchor_radii_ratio
-            point_array = QPointArray(4)
-            from_circle_pt = circle_pts[self.m_frames.m_ihead_moves[rhead_move_item][0]]
-            to_circle_pt = circle_pts[self.m_frames.m_ihead_moves[rhead_move_item][1]]
+            control_radii_ratio = 0.4 + 0.5 * pow(2., -float(self.m_frames.m_ihead_moves[i][2])/25)
+            #control_radii_ratio = 0.4 + 0.5 * pow(2., -float((1 + self.m_frames.m_ihead_moves[i][2]))/8)
+            point_array = QPointArray(3)
+            #from_circle_pt = circle_pts[self.m_frames.m_ihead_moves[i][0]]
+            #to_circle_pt = circle_pts[self.m_frames.m_ihead_moves[i][1]]
+            if len(circle_pts) > self.m_frames.m_ihead_moves[i][0]:
+              from_circle_pt = circle_pts[self.m_frames.m_ihead_moves[i][0]]
+            else:
+              from_circle_pt = circle_pts[-1]
+            if len(circle_pts) > self.m_frames.m_ihead_moves[i][1]:
+              to_circle_pt = circle_pts[self.m_frames.m_ihead_moves[i][1]]
+            else:
+              to_circle_pt = circle_pts[-1]
             point_array[0] = QPoint(
               self.m_circle_center_x + anchor_radii_ratio * (from_circle_pt[0] - self.m_circle_center_x),
               self.m_circle_center_y + anchor_radii_ratio * (from_circle_pt[1] - self.m_circle_center_y)
             )
             point_array[1] = QPoint(
-              self.m_circle_center_x + control_radii_ratio * (from_circle_pt[0] - self.m_circle_center_x),
-              self.m_circle_center_y + control_radii_ratio * (from_circle_pt[1] - self.m_circle_center_y)
+              self.m_circle_center_x + control_radii_ratio * ((from_circle_pt[0] + to_circle_pt[0])/2 - self.m_circle_center_x),
+              self.m_circle_center_y + control_radii_ratio * ((from_circle_pt[1] + to_circle_pt[1])/2 - self.m_circle_center_y),
             )
             point_array[2] = QPoint(
-              self.m_circle_center_x + control_radii_ratio * (to_circle_pt[0] - self.m_circle_center_x),
-              self.m_circle_center_y + control_radii_ratio * (to_circle_pt[1] - self.m_circle_center_y)
-            )
-            point_array[3] = QPoint(
               self.m_circle_center_x + anchor_radii_ratio * (to_circle_pt[0] - self.m_circle_center_x),
               self.m_circle_center_y + anchor_radii_ratio * (to_circle_pt[1] - self.m_circle_center_y)
             )
-            rhead_move_item.setControlPoints(point_array, False)
-            rhead_move_item.setBrush(QBrush(Qt.blue))
-            rhead_move_item.show()
+            ihead_move_item.setControlPoints(point_array, False)
+            if self.m_frames.m_ihead_moves[i][0] < self.m_frames.m_ihead_moves[i][1]:
+              ihead_move_item.setPen(QPen(Qt.blue))
+            else:
+              ihead_move_item.setPen(QPen(Qt.red))
+            ihead_move_item.show()
         else:
-          # Update changed rhead_move_items.
-          for i in range(self.m_current_rhead_move):
-            rhead_move_item = self.m_rhead_move_items[i]
+          # Update changed ihead_move_items.
+          for i in xrange(self.m_current_ihead_move):
+            ihead_move_item = self.m_ihead_move_items[i]
             anchor_radius = float(self.m_current_radius - 10)
             anchor_radii_ratio = anchor_radius / self.m_current_radius
-            control_radii_ratio = (0.5 + 0.4/math.ldexp(1, self.m_frames.m_ihead_moves[i][2])) * anchor_radii_ratio
-            point_array = QPointArray(4)
-            from_circle_pt = circle_pts[self.m_frames.m_ihead_moves[i][0]]
-            to_circle_pt = circle_pts[self.m_frames.m_ihead_moves[i][1]]
+            control_radii_ratio = 0.4 + 0.5 * pow(2., -float(self.m_frames.m_ihead_moves[i][2])/25)
+            #control_radii_ratio = 0.4 + 0.5 * pow(2., -float((1 + self.m_frames.m_ihead_moves[i][2]))/8)
+            point_array = QPointArray(3)
+            #from_circle_pt = circle_pts[self.m_frames.m_ihead_moves[i][0]]
+            #to_circle_pt = circle_pts[self.m_frames.m_ihead_moves[i][1]]
+            if len(circle_pts) > self.m_frames.m_ihead_moves[i][0]:
+              from_circle_pt = circle_pts[self.m_frames.m_ihead_moves[i][0]]
+            else:
+              from_circle_pt = circle_pts[-1]
+            if len(circle_pts) > self.m_frames.m_ihead_moves[i][1]:
+              to_circle_pt = circle_pts[self.m_frames.m_ihead_moves[i][1]]
+            else:
+              to_circle_pt = circle_pts[-1]
             point_array.setPoint(0, QPoint(
               self.m_circle_center_x + anchor_radii_ratio * (from_circle_pt[0] - self.m_circle_center_x),
               self.m_circle_center_y + anchor_radii_ratio * (from_circle_pt[1] - self.m_circle_center_y)
             ) )
             point_array.setPoint(1, QPoint(
-              self.m_circle_center_x + control_radii_ratio * (from_circle_pt[0] - self.m_circle_center_x),
-              self.m_circle_center_y + control_radii_ratio * (from_circle_pt[1] - self.m_circle_center_y)
+              self.m_circle_center_x + control_radii_ratio * ((from_circle_pt[0] + to_circle_pt[0])/2 - self.m_circle_center_x),
+              self.m_circle_center_y + control_radii_ratio * ((from_circle_pt[1] + to_circle_pt[1])/2 - self.m_circle_center_y),
             ) )
             point_array.setPoint(2, QPoint(
-              self.m_circle_center_x + control_radii_ratio * (to_circle_pt[0] - self.m_circle_center_x),
-              self.m_circle_center_y + control_radii_ratio * (to_circle_pt[1] - self.m_circle_center_y)
-            ) )
-            point_array.setPoint(3, QPoint(
               self.m_circle_center_x + anchor_radii_ratio * (to_circle_pt[0] - self.m_circle_center_x),
               self.m_circle_center_y + anchor_radii_ratio * (to_circle_pt[1] - self.m_circle_center_y)
             ) )
-            rhead_move_item.setControlPoints(point_array, False)
-            rhead_move_item.setBrush(QBrush(Qt.blue))
-            rhead_move_item.show()
-          if self.m_current_rhead_move < old_rhead_move:
-            for i in range(self.m_current_rhead_move, old_rhead_move):
-              self.m_rhead_move_items[i].hide()
+            ihead_move_item.setControlPoints(point_array, False)
+            if self.m_frames.m_ihead_moves[i][0] < self.m_frames.m_ihead_moves[i][1]:
+              ihead_move_item.setPen(QPen(Qt.blue))
+            else:
+              ihead_move_item.setPen(QPen(Qt.red))
+            ihead_move_item.show()
+          if self.m_current_ihead_move < old_ihead_move:
+            for i in xrange(self.m_current_ihead_move, old_ihead_move):
+              self.m_ihead_move_items[i].hide()
           pass
 
       if self.m_frames.m_tasks_info is not None:
@@ -264,18 +403,37 @@
 
       if self.m_frames.m_ihead_info is not None:
         self.m_current_ihead = self.m_frames.m_ihead_info[frame_number]
-        # Update changed ihead_item.
+        if len(head_circle_pts) < self.m_current_ihead:
+          self.m_current_ihead = -1
+        self.m_ihead_item.setX(head_circle_pts[self.m_current_ihead][0])
+        self.m_ihead_item.setY(head_circle_pts[self.m_current_ihead][1])
+        self.m_ihead_item.show()
 
       if self.m_frames.m_rhead_info is not None:
         self.m_current_rhead = self.m_frames.m_rhead_info[frame_number]
+        if len(head_circle_pts) <= self.m_current_rhead:
+          self.m_current_rhead = -1
+        self.m_rhead_item.setX(head_circle_pts[self.m_current_rhead][0])
+        self.m_rhead_item.setY(head_circle_pts[self.m_current_rhead][1])
+        self.m_rhead_item.show()
         # Update changed rhead_item.
 
       if self.m_frames.m_whead_info is not None:
         self.m_current_whead = self.m_frames.m_whead_info[frame_number]
+        if len(head_circle_pts) <= self.m_current_whead:
+          self.m_current_whead = -1
+        self.m_whead_item.setX(head_circle_pts[self.m_current_whead][0])
+        self.m_whead_item.setY(head_circle_pts[self.m_current_whead][1])
+        self.m_whead_item.show()
         # Update changed whead_item.
 
       if self.m_frames.m_fhead_info is not None:
         self.m_current_fhead = self.m_frames.m_fhead_info[frame_number]
+        if len(head_circle_pts) <= self.m_current_fhead:
+          self.m_current_fhead = -1
+        self.m_fhead_item.setX(head_circle_pts[self.m_current_fhead][0])
+        self.m_fhead_item.setY(head_circle_pts[self.m_current_fhead][1])
+        self.m_fhead_item.show()
         # Update changed fhead_item.
 
     self.m_canvas.update()

Modified: branches/brysonda/source/python/AvidaGui2/pyPetriCanvasView.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyPetriCanvasView.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyPetriCanvasView.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -1,4 +1,4 @@
-
+from qt import QTextDrag
 from qt import Qt, PYSIGNAL
 from qtcanvas import QCanvasView
 
@@ -18,5 +18,5 @@
           org_clicked_on__color = item.brush().color()
           org_clicked_on_item = item
       self.emit(PYSIGNAL("orgClickedOnSig"), (org_clicked_on_item,))
-      if org_clicked_on_item:
-        self.emit(PYSIGNAL("orgClickedOnSig"), (org_clicked_on_item,))
+
+   

Modified: branches/brysonda/source/python/AvidaGui2/pyPetriConfigureCtrl.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyPetriConfigureCtrl.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyPetriConfigureCtrl.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -52,23 +52,73 @@
       self.ChangeStopSpinBoxSlot)
     self.connect(self.SavePetriPushButton, SIGNAL("clicked()"), 
       self.m_session_mdl.m_session_mdtr, PYSIGNAL("freezeDishPhaseISig"))
-    self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("freezeDishPhaseIISig"), 
-      self.FreezePetriSlot)
+    self.connect(self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("freezeDishPhaseIISig"), self.FreezePetriSlot)
     self.connect(self.m_session_mdl.m_session_mdtr,
-      PYSIGNAL("doDefrostDishSig"), self.FillDishSlot)
-    self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("doInitializeAvidaPhaseISig"),
-      self.DisablePetriConfigureSlot)
-    self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("doInitializeAvidaPhaseISig"),
-      self.CreateFilesFromPetriSlot)
-    self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("setAvidaSig"), self.setAvidaSlot)
-    self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("doInitializeAvidaPhaseIISig"),
+      PYSIGNAL("FillDishSig"), self.FillDishSlot)
+    self.connect(self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("doInitializeAvidaPhaseISig"), self.DisablePetriConfigureSlot)
+    self.connect(self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("doEnablePetriDishSig"), self.EnablePetriConfigureSlot)
+    self.connect(self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("doInitializeAvidaPhaseISig"), self.CreateFilesFromPetriSlot)
+    self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("setAvidaSig"), 
+      self.setAvidaSlot)
+    self.connect(self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("doInitializeAvidaPhaseIISig"),
       self.doLoadPetriDishConfigFileSlot)
-    self.connect( self, PYSIGNAL("petriDishDroppedInPopViewSig"), self.m_session_mdl.m_session_mdtr, PYSIGNAL("petriDishDroppedInPopViewSig"))
+    self.connect( self, PYSIGNAL("petriDishDroppedInPopViewSig"), 
+      self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("petriDishDroppedInPopViewSig"))
     self.ChangeMutationTextSlot()
     self.ChangeWorldSizeTextSlot()
     self.populated = False
-    self.run_started = False    
+    
+  def destruct(self):
+    self.m_session_petri_view = None
+    self.m_avida = None
+    self.full_petri_dict = {}
+    self.DishDisabled = False
+    self.disconnect(self.MutationSlider, SIGNAL("valueChanged(int)"), 
+      self.ChangeMutationTextSlot)
+    self.disconnect(self.WorldSizeSlider, SIGNAL("valueChanged(int)"), 
+      self.ChangeWorldSizeTextSlot)
+    self.disconnect(self.DieYesButton, SIGNAL("clicked()"), 
+      self.ChangeDeathTextSlot)
+    self.disconnect(self.DieNoButton, SIGNAL("clicked()"), 
+      self.ChangeDeathTextSlot)
+    self.disconnect(self.RadomGeneratedRadioButton, SIGNAL("clicked()"), 
+      self.ChangeRandomSpinBoxSlot)
+    self.disconnect(self.RandomFixedRadioButton, SIGNAL("clicked()"), 
+      self.ChangeRandomSpinBoxSlot)
+    self.disconnect(self.StopManuallyRadioButton, SIGNAL("clicked()"), 
+      self.ChangeStopSpinBoxSlot)
+    self.disconnect(self.StopAtRadioButton, SIGNAL("clicked()"), 
+      self.ChangeStopSpinBoxSlot)
+    self.disconnect(self.SavePetriPushButton, SIGNAL("clicked()"), 
+      self.m_session_mdl.m_session_mdtr, PYSIGNAL("freezeDishPhaseISig"))
+    self.disconnect(self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("freezeDishPhaseIISig"), self.FreezePetriSlot)
+    self.disconnect(self.m_session_mdl.m_session_mdtr,
+      PYSIGNAL("FillDishSig"), self.FillDishSlot)
+    self.disconnect(self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("doInitializeAvidaPhaseISig"), self.DisablePetriConfigureSlot)
+    self.disconnect(self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("doEnablePetriDishSig"), self.EnablePetriConfigureSlot)
+    self.disconnect(self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("doInitializeAvidaPhaseISig"), self.CreateFilesFromPetriSlot)
+    self.disconnect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("setAvidaSig"), 
+      self.setAvidaSlot)
+    self.disconnect(self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("doInitializeAvidaPhaseIISig"),
+      self.doLoadPetriDishConfigFileSlot)
+    self.disconnect( self, PYSIGNAL("petriDishDroppedInPopViewSig"), 
+      self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("petriDishDroppedInPopViewSig"))
+    self.populated = False
+    self.m_session_mdl = None
 
+  
   def ChangeMutationTextSlot(self):
     slide_value = float(self.MutationSlider.value())/100.0
     slide_value = pow(10,slide_value)
@@ -113,10 +163,6 @@
   
   def FillDishSlot(self, dish_name, petri_dict):
     
-    # Stop from filling the petri dish if the dish is disabled
-
-    if self.DishDisabled:
-      return
     self.full_petri_dict = petri_dict.dictionary
     settings_dict =  petri_dict.dictionary["SETTINGS"]
     self.AncestorComboBox.removeItem (0)
@@ -163,10 +209,15 @@
        self.DeathTextLabel2.setEnabled(True)
        self.DeathTextLabel3.setEnabled(True)
        self.LifeSpanSpinBox.setEnabled(True)
+    self.m_session_mdl.new_empty_dish = True
+    self.m_session_mdl.m_session_mdtr.emit(
+      PYSIGNAL("finishedPetriDishSig"), ())
+
        
+  def DisablePetriConfigureSlot(self):
 
-  def DisablePetriConfigureSlot(self):
-    self.run_started = False
+    # Turn off the controls 
+
     self.AncestorComboBox.setEnabled(False)
     self.StopAtSpinBox.setEnabled(False)
     self.StopManuallyRadioButton.setEnabled(False)
@@ -196,6 +247,38 @@
     self.m_session_mdl.m_session_mdtr.emit(
       PYSIGNAL("doDisablePetriDishSig"), ())
 
+  def EnablePetriConfigureSlot(self):
+
+    # Turn on the controls 
+    
+    self.AncestorComboBox.setEnabled(True)
+    self.StopAtSpinBox.setEnabled(True)
+    self.StopManuallyRadioButton.setEnabled(True)
+    self.StopAtRadioButton.setEnabled(True)
+    self.WorldSizeSlider.setEnabled(True)
+    self.RandomSpinBox.setEnabled(True)
+    self.RadomGeneratedRadioButton.setEnabled(True)
+    self.RandomFixedRadioButton.setEnabled(True)
+    self.MutationSlider.setEnabled(True)
+    self.LocalBirthRadioButton.setEnabled(True)
+    self.MassActionRadioButton.setEnabled(True)
+    self.LifeSpanSpinBox.setEnabled(True)
+    self.DieNoButton.setEnabled(True)
+    self.DieYesButton.setEnabled(True)
+    self.MutationPercentTextLabel.setEnabled(True)
+    self.WorldSizeTextLabel.setEnabled(True)
+    self.MutationRateHeadTextLabel.setEnabled(True)
+    self.WorldSizeHeadTextLable.setEnabled(True)
+    self.DeathLabel.setEnabled(True)
+    self.RandomHeadTextLabel.setEnabled(True)
+    self.AncestorHeadTextLabel.setEnabled(True)
+    self.BirthHeadTextLabel.setEnabled(True)
+    self.StopHeadTextLabel.setEnabled(True)
+    self.DeathTextLabel2.setEnabled(True)
+    self.DeathTextLabel3.setEnabled(True)
+    self.DishDisabled = False
+
+
   def CreateFilesFromPetriSlot(self, out_dir = None):
 
     # The input files will be placed in a python generated temporary directory
@@ -246,32 +329,48 @@
     tmp_dict["SETTINGS"] = self.Form2Dictionary()
     m_pop_up_freezer_file_name = pyFreezeDialogCtrl()
     file_name = m_pop_up_freezer_file_name.showDialog(self.m_session_mdl.m_current_freezer)
+    file_name_len = len(file_name.rstrip())
 
     # If the user is saving a full population expand the name and insert
     # the population dictionary into the temporary dictionary
 
-    if (m_pop_up_freezer_file_name.isEmpty() == False):
-      os.mkdir(file_name)
+    if (file_name_len > 0):
+      is_empty_dish = m_pop_up_freezer_file_name.isEmpty()
+      if (not is_empty_dish):
+        os.mkdir(file_name)
 
-      # Copy the average and count files from the teporary output directory
-      # to the Freezer directory
+        # Copy the average and count files from the teporary output directory
+        # to the Freezer directory
         
-      shutil.copyfile(os.path.join(self.m_session_mdl.m_tempdir_out, "average.dat"), os.path.join(file_name, "average.dat"))
-      shutil.copyfile(os.path.join(self.m_session_mdl.m_tempdir_out, "count.dat"), os.path.join(file_name, "count.dat"))
-      file_name = os.path.join(file_name, "petri_dish")
-      tmp_dict["POPULATION"] = population_dict
-    is_empty_dish = m_pop_up_freezer_file_name.EmptyRadioButton.isChecked()
-    freezer_file = pyWriteToFreezer(tmp_dict, is_empty_dish, file_name)
+        tmp_ave_file = os.path.join(self.m_session_mdl.m_tempdir_out, "average.dat")
+        if (os.path.exists(tmp_ave_file)):
+          shutil.copyfile(tmp_ave_file, os.path.join(file_name, "average.dat"))
+        tmp_count_file = os.path.join(self.m_session_mdl.m_tempdir_out, "count.dat")
+        if (os.path.exists(tmp_count_file)):
+          shutil.copyfile(tmp_count_file, os.path.join(file_name, "count.dat"))
+        file_name = os.path.join(file_name, "petri_dish")
+        tmp_dict["POPULATION"] = population_dict
+      freezer_file = pyWriteToFreezer(tmp_dict, file_name)
+      if (is_empty_dish):
+        self.m_session_mdl.saved_empty_dish = True
+      else:
+        self.m_session_mdl.saved_full_dish = True
     
     self.m_session_mdl.m_session_mdtr.emit(
       PYSIGNAL("doRefreshFreezerInventorySig"), ())
     if send_reset_signal:
       print "sending reset signal from pyPetriConfigureCtrl:FreezePetriSlot" 
-    if send_quit_signal:
-      print "sending quit signal from pyPetriConfigureCtrl:FreezePetriSlot"
       self.m_session_mdl.m_session_mdtr.emit(
-        PYSIGNAL("quitAvidaPhaseIISig"), ())
+        PYSIGNAL("restartPopulationSig"), (self.m_session_mdl, ))
 
+    # If the send_quit_signal flag was sent to this routine kill the application
+    # (Instead of killing the application directly a signal should be sent
+    # upto the workspace moderator)
+
+    if send_quit_signal:
+      qApp.quit()
+
+
   def doLoadPetriDishConfigFileSlot(self, genesisFileName = None):
     genesis = cGenesis()
     genesis.Open(cString(genesisFileName))

Modified: branches/brysonda/source/python/AvidaGui2/pyPetriDishCtrl.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyPetriDishCtrl.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyPetriDishCtrl.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -1,4 +1,5 @@
 
+
 print """
 XXX fixme: in pyPetriDishCtrl.py,
 pyPetriDishCtrl.setAvidaSlot(),
@@ -8,9 +9,11 @@
 """
 
 from AvidaCore import cConfig
+from AvidaCore import cInitFile, cString
 
+from qt import *
 from math import exp
-from qt import PYSIGNAL, QBrush, QColor, QLayout, QPen, QSize, Qt, QVBoxLayout, QWidget, QWMatrix
+from qt import PYSIGNAL, QBrush, QColor, QLayout, QPen, QSize, Qt, QVBoxLayout, QWidget, QWMatrix, QTextDrag, QStoredDrag, QScrollView, QScrollBar
 from qtcanvas import QCanvas, QCanvasRectangle
 from pyPetriCanvasView import pyPetriCanvasView
 from pyPopulationCellItem import pyPopulationCellItem
@@ -37,11 +40,31 @@
 
     self.m_canvas = None
     self.m_cell_info = None
-    #self.m_petri_dish_layout = QVBoxLayout(self,0,0,"m_petri_dish_layout")
+    self.m_zoom_factor = 11
+    self.m_target_dish_width = 350
+    self.m_target_dish_scaling = 5.
+    self.m_map_cell_width = 5
+    self.m_h_scrollbar_offset = 0
+    self.m_v_scrollbar_offset = 0
+    self.m_zoom_old_value = self.m_zoom_factor
+
     self.m_petri_dish_layout = pySquareVBoxLayout(self,0,0,"m_petri_dish_layout")
     print "pyPetriDishCtrl.construct() self.m_petri_dish_layout.heightForWidth(20) :", self.m_petri_dish_layout.heightForWidth(20)
-    #self.m_petri_dish_layout.setResizeMode(QLayout.Minimum)
     self.m_canvas_view = pyPetriCanvasView(None, self,"m_canvas_view")
+
+    #hiding the scroll bars, the pre-packaged ones were not working so we are adding them manually elsewhere
+    self.m_canvas_view.setVScrollBarMode(QScrollView.AlwaysOff)
+    self.m_canvas_view.setHScrollBarMode(QScrollView.AlwaysOff)
+
+    #adding manual ones
+    self.m_scroll_bar_width = 15
+    # the following settings get overridden once the scroll bars are necessary, so they are junk
+    self.m_petri_dish_ctrl_h_scrollBar = QScrollBar(0,371,0,20,185,Qt.Horizontal,self.m_canvas_view)
+    self.m_petri_dish_ctrl_v_scrollBar = QScrollBar(0,371,0,20,185,Qt.Vertical,self.m_canvas_view)
+    # end junk settings
+    self.m_petri_dish_ctrl_h_scrollBar.setGeometry(0,371, 371,self.m_scroll_bar_width)
+    self.m_petri_dish_ctrl_v_scrollBar.setGeometry(371,0,self.m_scroll_bar_width,371)
+
     self.m_petri_dish_layout.addWidget(self.m_canvas_view)
     self.m_changed_cell_items = []
     self.m_indexer = None
@@ -51,18 +74,31 @@
     self.m_org_clicked_on_item = None
     self.m_occupied_cells_ids = []
 
-#    self.m_target_dish_width = 270
-    self.m_target_dish_width = 350
-    self.m_target_dish_scaling = 5.
-    self.m_map_cell_width = 5
+    self.connect( self.m_session_mdl.m_session_mdtr, PYSIGNAL("setAvidaSig"), 
+      self.setAvidaSlot)
+    self.connect( self.m_canvas_view, PYSIGNAL("orgClickedOnSig"), 
+      self.m_session_mdl.m_session_mdtr, PYSIGNAL("orgClickedOnSig"))
+    self.connect( self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("orgClickedOnSig"), self.updateOrgClickedOutlineCellNumberSlot)
+    self.connect( self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("orgClickedOnSig"), self.setDragSlot)
+    self.connect(self.m_petri_dish_ctrl_h_scrollBar, SIGNAL("valueChanged(int)"), self.moveCanvasHorizontallySlot)    
+    self.connect(self.m_petri_dish_ctrl_h_scrollBar, SIGNAL("nextLine()"), self.hbarScrollNextLineSlot)    
+    self.connect(self.m_petri_dish_ctrl_h_scrollBar, SIGNAL("prevLine()"), self.hbarScrollPrevLineSlot)    
+    self.connect(self.m_petri_dish_ctrl_v_scrollBar, SIGNAL("valueChanged(int)"), self.moveCanvasVerticallySlot)    
+    self.connect(self.m_petri_dish_ctrl_v_scrollBar, SIGNAL("nextLine()"), self.vbarScrollNextLineSlot)    
+    self.connect(self.m_petri_dish_ctrl_v_scrollBar, SIGNAL("prevLine()"), self.vbarScrollPrevLineSlot)    
 
-    self.connect( self.m_session_mdl.m_session_mdtr, PYSIGNAL("setAvidaSig"), self.setAvidaSlot)
-    self.connect( self.m_canvas_view, PYSIGNAL("orgClickedOnSig"), self.m_session_mdl.m_session_mdtr, PYSIGNAL("orgClickedOnSig"))
-    self.connect( self.m_session_mdl.m_session_mdtr, PYSIGNAL("orgClickedOnSig"),
-      self.updateOrgClickedOutlineCellNumberSlot)
 
+  def restart(self):
+    self.m_cell_info = None
+    self.m_changed_cell_items = []
+    self.m_color_lookup_functor = None
+    self.m_background_rect = None
+    self.m_change_list = None
+    self.m_org_clicked_on_item = None
+    self.m_occupied_cells_ids = []
 
-
   def setColorLookupFunctor(self, color_lookup_functor):
     self.m_color_lookup_functor = color_lookup_functor
 
@@ -91,12 +127,12 @@
     self.m_world_w = cConfig.GetWorldX()
     self.m_world_h = cConfig.GetWorldY()
     self.m_initial_target_zoom = int(self.m_target_dish_width / self.m_world_w)
-    print "self.m_map_cell_width", self.m_map_cell_width
-    
+
     self.emit(PYSIGNAL("zoomSig"), (self.m_initial_target_zoom,))
 
     if self.m_canvas: del self.m_canvas
-    self.m_canvas = QCanvas(self.m_map_cell_width * self.m_world_w, self.m_map_cell_width * self.m_world_h)
+    self.m_canvas = QCanvas(self.m_map_cell_width * self.m_world_w, 
+      self.m_map_cell_width * self.m_world_h)
     self.m_canvas.setBackgroundColor(Qt.darkGray)
     self.m_canvas_view.setCanvas(self.m_canvas)
 
@@ -121,6 +157,16 @@
     self.m_changed_cell_items = self.m_cell_info[:]
     self.updateCellItems(True)
 
+  def setDragSlot(self, org_clicked_on_item = None):
+    if org_clicked_on_item:
+      clicked_cell_num = org_clicked_on_item.m_population_cell.GetID()
+      clicked_cell = self.m_avida.m_population.GetCell(int(clicked_cell_num))
+      organism = clicked_cell.GetOrganism()
+
+      # tee up drag information
+      dragHolder = self.itemDrag( ('organism.' + str(organism.GetGenome().AsString())), self )
+      dragHolder.dragCopy()
+
   def setRange(self, min, max):
     self.m_cs_min_value = min
     self.m_cs_value_range = max - min
@@ -128,14 +174,18 @@
   def setIndexer(self, indexer):
     self.m_indexer = indexer
 
-  def updateOrgClickedOutlineCellNumberSlot(self, org_clicked_on_item):
+  def updateOrgClickedOutlineCellNumberSlot(self, org_clicked_on_item = None):
     if self.m_org_clicked_on_item:
       self.m_org_clicked_on_item.setPen(QPen(Qt.NoPen))
     self.m_org_clicked_on_item = org_clicked_on_item
     if self.m_org_clicked_on_item:
       self.updateCellItems(self.m_org_clicked_on_item.m_population_cell.GetID())
+      self.m_last_m_org_clicked_on_item = self.m_org_clicked_on_item
+    else:
+        if hasattr(self,"m_last_cell_outlined"):
+          self.m_last_cell_outlined.setPen(QPen(Qt.NoPen))
+          self.updateCellItems(self.m_last_m_org_clicked_on_item.m_population_cell.GetID())
 
-
   def updateCellItem(self, cell_id):
     if self.m_cell_info[cell_id] is None:
       self.m_cell_info[cell_id] = self.createNewCellItem(cell_id)
@@ -143,18 +193,17 @@
     self.m_indexer(cell_info_item, self.m_cs_min_value, self.m_cs_value_range)
     cell_info_item.updateColorUsingFunctor(self.m_color_lookup_functor)
 
-#JMC
     if self.m_org_clicked_on_item:
       if cell_info_item.m_population_cell.GetID == self.m_org_clicked_on_item.m_population_cell.GetID:
-        cell_info_item.setPen(QPen(QColor(0,255,0)))      
-#JMC
+        cell_info_item.setPen(QPen(QColor(0,255,0)))
+        self.m_last_cell_outlined = cell_info_item      
 
   def updateCellItems(self, should_update_all = False):
     if self.m_cell_info:
 
       self.m_avida and self.m_avida.m_avida_threaded_driver.m_lock.acquire()
       if self.m_change_list:
-        for index in range(self.m_change_list.GetChangeCount()):
+        for index in xrange(self.m_change_list.GetChangeCount()):
           self.updateCellItem(self.m_change_list[index])
         self.m_change_list.Reset()
       self.m_avida and self.m_avida.m_avida_threaded_driver.m_lock.release()
@@ -164,30 +213,116 @@
           self.updateCellItem(cell_id)
 
       if self.m_canvas: self.m_canvas.update()
-#jmc this is where you put the AllCellsPaintedSignal      
 
   def extractPopulationSlot(self, send_reset_signal = False, send_quit_signal = False):
+
+    # If there is an active Avida object find all the cells that are occupied
+    # and place them in a dictionary.  Fire off the signal for the next freezer
+    # phase with that signal.
+
     population_dict = {}
-    for x in range(self.m_world_w):
-      for y in range(self.m_world_h):
-        if self.m_avida != None:
+    if self.m_avida != None:
+      for x in range(self.m_world_w):
+        for y in range(self.m_world_h):
           cell = self.m_avida.m_population.GetCell(x + self.m_world_w*y)
           if cell.IsOccupied() == True:
             organism = cell.GetOrganism()
             genome = organism.GetGenome()
             population_dict[cell.GetID()] = str(genome.AsString())
-    self.emit(PYSIGNAL("freezeDishPhaseIISig"), (population_dict, send_reset_signal, send_quit_signal, ))
+    self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("freezeDishPhaseIISig"), 
+      (population_dict, send_reset_signal, send_quit_signal, ))
 
   def zoomSlot(self, zoom_factor):
+    if hasattr(self,"m_world_h") == False:
+      return
+
+    self.m_zoom_factor = zoom_factor
+    self.m_world_matrix = QWMatrix()
     if self.m_canvas_view:
-      m = QWMatrix()
-      m.scale(zoom_factor/self.m_target_dish_scaling, zoom_factor/self.m_target_dish_scaling)
-      trans_h = (self.m_canvas_view.size().height() - (self.m_map_cell_width * self.m_world_h)*
-        (zoom_factor/self.m_target_dish_scaling))/2
+      self.m_world_matrix.scale(self.m_zoom_factor/self.m_target_dish_scaling, self.m_zoom_factor/self.m_target_dish_scaling)
+      trans_h_preadjust = ((self.m_canvas_view.size().height()) - (self.m_map_cell_width * self.m_world_h)*
+        (self.m_zoom_factor/self.m_target_dish_scaling))/2
+      trans_w_preadjust = ((self.m_canvas_view.size().width()) - (self.m_map_cell_width * self.m_world_w)*
+        (self.m_zoom_factor/self.m_target_dish_scaling))/2
 
-      if zoom_factor == 0:
-        m.translate(trans_h/(1/self.m_target_dish_scaling),trans_h/(1/self.m_target_dish_scaling))
+      trans_h = trans_h_preadjust + self.m_v_scrollbar_offset*(self.m_zoom_factor/self.m_target_dish_scaling)
+      trans_w = trans_w_preadjust + self.m_h_scrollbar_offset*(self.m_zoom_factor/self.m_target_dish_scaling)
+
+
+      if self.m_zoom_factor == 0:
+        self.m_world_matrix.translate(trans_w/(1/self.m_target_dish_scaling),trans_h/(1/self.m_target_dish_scaling))
       else:
-        m.translate(trans_h/(zoom_factor/self.m_target_dish_scaling),trans_h/(zoom_factor/self.m_target_dish_scaling))    
-      self.m_canvas_view.setWorldMatrix(m)
- 
\ No newline at end of file
+        self.m_world_matrix.translate(trans_w/(self.m_zoom_factor/self.m_target_dish_scaling),trans_h/(self.m_zoom_factor/self.m_target_dish_scaling))    
+      self.m_canvas_view.setWorldMatrix(self.m_world_matrix)
+
+      black_box = (self.m_map_cell_width * self.m_world_h)*(self.m_zoom_factor/self.m_target_dish_scaling)
+      outside = black_box - 371
+      if outside < 0: 
+        outside = 1
+
+      self.m_setting_scrollbar_values = 1
+
+      self.m_petri_dish_ctrl_h_scrollBar.setMaxValue( 30 + outside/(self.m_zoom_factor/self.m_target_dish_scaling) )
+      self.m_petri_dish_ctrl_v_scrollBar.setMaxValue( 30 + outside/(self.m_zoom_factor/self.m_target_dish_scaling) )
+
+      self.m_h_scrollbar_offset = self.m_h_scrollbar_offset*(float(self.m_zoom_factor)/self.m_zoom_old_value) 
+      self.m_v_scrollbar_offset = self.m_v_scrollbar_offset*(float(self.m_zoom_factor)/self.m_zoom_old_value) 
+
+      self.m_petri_dish_ctrl_h_scrollBar.setValue( (self.m_petri_dish_ctrl_h_scrollBar.maxValue()/2) - self.m_h_scrollbar_offset)
+      self.m_petri_dish_ctrl_v_scrollBar.setValue( (self.m_petri_dish_ctrl_v_scrollBar.maxValue()/2) - self.m_v_scrollbar_offset)
+
+      self.m_zoom_old_value = self.m_zoom_factor
+
+      self.m_setting_scrollbar_values = 0
+
+  def moveCanvasHorizontallySlot(self,horizontal_value):
+  
+    if horizontal_value < 0:
+      return
+  
+    if self.m_setting_scrollbar_values == 1:
+      return
+
+    h_scroll_adjustment_needed = (horizontal_value- (self.m_petri_dish_ctrl_h_scrollBar.maxValue()/2)+ self.m_h_scrollbar_offset)*-1
+    self.m_h_scrollbar_offset = h_scroll_adjustment_needed + self.m_h_scrollbar_offset
+	
+    if self.m_canvas_view:
+      self.m_world_matrix.translate(h_scroll_adjustment_needed,0)
+      self.m_canvas_view.setWorldMatrix(self.m_world_matrix)
+
+  def moveCanvasVerticallySlot(self,vertical_value):
+    if vertical_value < 0:
+      return
+  
+    if self.m_setting_scrollbar_values == 1:
+      return
+
+    v_scroll_adjustment_needed = (vertical_value- (self.m_petri_dish_ctrl_v_scrollBar.maxValue()/2)+ self.m_v_scrollbar_offset)*-1
+    self.m_v_scrollbar_offset = v_scroll_adjustment_needed + self.m_v_scrollbar_offset
+
+    if self.m_canvas_view:
+      self.m_world_matrix.translate(0,v_scroll_adjustment_needed)
+      self.m_canvas_view.setWorldMatrix(self.m_world_matrix)
+
+
+  def hbarScrollNextLineSlot(self):
+    if self.m_petri_dish_ctrl_h_scrollBar.value() < self.m_petri_dish_ctrl_h_scrollBar.maxValue():
+      self.m_petri_dish_ctrl_h_scrollBar.setValue(self.m_petri_dish_ctrl_h_scrollBar.value()+1)
+
+  def vbarScrollNextLineSlot(self):
+    if self.m_petri_dish_ctrl_v_scrollBar.value() < self.m_petri_dish_ctrl_v_scrollBar.maxValue():
+      self.m_petri_dish_ctrl_v_scrollBar.setValue(self.m_petri_dish_ctrl_v_scrollBar.value()+1)
+
+  def hbarScrollPrevLineSlot(self):
+    if self.m_petri_dish_ctrl_h_scrollBar.value() > self.m_petri_dish_ctrl_h_scrollBar.minValue():
+      self.m_petri_dish_ctrl_h_scrollBar.setValue(self.m_petri_dish_ctrl_h_scrollBar.value()-1)
+
+  def vbarScrollPrevLineSlot(self):
+    if self.m_petri_dish_ctrl_v_scrollBar.value() > self.m_petri_dish_ctrl_v_scrollBar.minValue():
+      self.m_petri_dish_ctrl_v_scrollBar.setValue(self.m_petri_dish_ctrl_v_scrollBar.value()-1)
+
+  class itemDrag(QTextDrag):
+    def __init__(self, item_name, parent=None, name=None):
+        QStoredDrag.__init__(self, 'item name (QString)', parent, name)
+        self.setText(item_name)
+

Modified: branches/brysonda/source/python/AvidaGui2/pyPopulationCellItem.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyPopulationCellItem.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyPopulationCellItem.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -11,8 +11,6 @@
     return 271828
 
   def __init__(self, population_cell, x, y, w, h, canvas):
- #   x = x + 5
- #   y = y + 5
     QCanvasRectangle.__init__(self, x, y, w, h, canvas)
     self.m_population_cell = population_cell
     self.m_index = 0

Modified: branches/brysonda/source/python/AvidaGui2/pyQuitDialogCtrl.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyQuitDialogCtrl.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyQuitDialogCtrl.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -9,18 +9,21 @@
 # return the name of a file to save information to be frozen
 
 class pyQuitDialogCtrl (pyQuitDialogView):
-  def __init__(self):
+  def __init__(self, textChange = None):
     pyQuitDialogView.__init__(self)
     self.connect(self.QuitPushButton, SIGNAL("clicked()"), self.DownQuitSlot)
     self.FreezeQuitFlag = 0
     self.QuitFlag = 1
     self.CancelFlag = 2
+    if (textChange):
+      self.setCaption(textChange)
+      self.SaveToFreezerPushButton.setText("Freeze and " + textChange)
+      self.QuitPushButton.setText(textChange)
     
   def DownQuitSlot(self):
     self.QuitPushButton.setDown(True)
     
   def showDialog(self):
-    self.SaveToFreezerPushButton.setHidden(True)
     dialog_result = 1
     while (dialog_result > 0):
       while (self.exec_loop() and self.result() == 0):

Modified: branches/brysonda/source/python/AvidaGui2/pyQuitDialogView.ui
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyQuitDialogView.ui	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyQuitDialogView.ui	2005-07-26 14:44:40 UTC (rev 263)
@@ -9,7 +9,7 @@
             <x>0</x>
             <y>0</y>
             <width>324</width>
-            <height>135</height>
+            <height>113</height>
         </rect>
     </property>
     <property name="caption">
@@ -19,6 +19,14 @@
         <property name="name">
             <cstring>unnamed</cstring>
         </property>
+        <widget class="QLabel">
+            <property name="name">
+                <cstring>WarningLabel</cstring>
+            </property>
+            <property name="text">
+                <string>The current petri dish has not been saved in the freezer.</string>
+            </property>
+        </widget>
         <widget class="QLayoutWidget">
             <property name="name">
                 <cstring>layout21</cstring>
@@ -53,16 +61,6 @@
                 </widget>
             </hbox>
         </widget>
-        <widget class="QLabel">
-            <property name="name">
-                <cstring>WarningLabel</cstring>
-            </property>
-            <property name="text">
-                <string>&lt;b&gt;WARNING!&lt;/b&gt; Quiting will not save current work&lt;br&gt;
-Select Cancel and click on "Freeze Petri Dish" &lt;br&gt;
-button to save current population and/or settings.</string>
-            </property>
-        </widget>
     </vbox>
 </widget>
 <connections>

Modified: branches/brysonda/source/python/AvidaGui2/pyReadFreezer.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyReadFreezer.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyReadFreezer.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -10,6 +10,11 @@
     freezefile = open(self.file_name)
     lines = freezefile.readlines()
     freezefile.close
+    
+    # treat organism file differently (just one bare line)
+
+    if (in_file_name.endswith(".organism")):
+      pass
     for line in lines:
       comment_start = line.find("#")
       if comment_start > -1:

Modified: branches/brysonda/source/python/AvidaGui2/pySessionCtrl.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pySessionCtrl.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pySessionCtrl.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -59,6 +59,10 @@
     # Create "model" for storing state data.
     class pyMdl: pass
     self.m_session_mdl = pyMdl()
+    self.m_session_mdl.saved_empty_dish = False
+    self.m_session_mdl.saved_full_dish = False
+    self.m_session_mdl.new_empty_dish = True
+    self.m_session_mdl.new_full_dish = True
     self.m_session_mdl.m_current_workspace = "default.workspace"
     self.m_session_mdl.m_current_freezer = os.path.join(self.m_session_mdl.m_current_workspace, "freezer")
 
@@ -120,10 +124,20 @@
       PYSIGNAL("fromLiveCtrlPauseAvidaSig"),
       self.doPause)
 
+    self.connect(
+      self.m_session_mdl.m_session_mdtr,
+      PYSIGNAL("restartPopulationSig"),
+      self.restartPopulationSlot)
+
     self.doPause()
 
     return self
 
+  def restartPopulationSlot(self): 
+    print "BDB restartPopulationSlot Called"
+    self.sessionInitialized = False
+    self.m_should_update = False
+
   def setAvidaSlot(self, avida):
     "print *** pySessionCtrl setAvidaSlot ***"
     if (avida == None):
@@ -152,10 +166,10 @@
       del old_avida
     if self.m_avida and hasattr(self.m_avida, "m_avida_thread_mdtr"):
       print "pySessionCtrl.setAvidaSlot(): connecting self.m_avida ..."
-#      self.connect(
-#        self.m_avida.m_avida_thread_mdtr, PYSIGNAL("AvidaUpdatedSig"),
-#        self.avidaUpdatedSlot)
       self.connect(
+        self.m_avida.m_avida_thread_mdtr, PYSIGNAL("AvidaUpdatedSig"),
+        self.avidaUpdatedSlot)
+      self.connect(
         self.m_session_mdl.m_session_mdtr, PYSIGNAL("doStartAvidaSig"),
         self.m_avida.m_avida_thread_mdtr, PYSIGNAL("doStartAvidaSig"))
       self.connect(
@@ -196,7 +210,14 @@
     self.m_should_update = False
     self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("doPauseAvidaSig"), ())
 
+  def avidaUpdatedSlot(self):
 
+    # When there is a new update assume that the session has an unsaved 
+    # state and the dish is no longer new
+
+    self.m_session_mdl.saved_full_dish = False
+    self.m_session_mdl.new_full_dish = False
+
   def unitTest(self, recurse = False):
     return pyUnitTestSuiteRecurser("pySessionCtrl", globals(), recurse).construct().runTest().lastResult()
 

Modified: branches/brysonda/source/python/AvidaGui2/pyTemporaryReloads.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyTemporaryReloads.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyTemporaryReloads.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -41,11 +41,15 @@
 ]
 
 nontest_module_names = [
+  "AvidaGui2.pyQuitDialogView",
+  "AvidaGui2.pyQuitDialogCtrl",
   "AvidaGui2.pyAnalyzeControlsView",
   "AvidaGui2.pyAnalyzeControlsCtrl",
   "AvidaGui2.pyAvidaStatsInterface",
   "AvidaGui2.pyFreezeDialogView",
   "AvidaGui2.pyFreezeDialogCtrl",
+  "AvidaGui2.pyFreezeOrganismView",
+  "AvidaGui2.pyFreezeOrganismCtrl",
   "AvidaGui2.pyFreezerView",
   "AvidaGui2.pyFreezerCtrl",
   "AvidaGui2.pyGradientScaleView",
@@ -68,8 +72,6 @@
   "AvidaGui2.pyPetriDishView",
   "AvidaGui2.pyPetriDishCtrl",
   "AvidaGui2.pyPopulationCellItem",
-  "AvidaGui2.pyQuitDialogView",
-  "AvidaGui2.pyQuitDialogCtrl",
   "AvidaGui2.pyReadFreezer",
   "AvidaGui2.pyTimelineView",
   "AvidaGui2.pyTimelineCtrl",

Modified: branches/brysonda/source/python/AvidaGui2/pyWriteGenesisEvent.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyWriteGenesisEvent.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyWriteGenesisEvent.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -28,12 +28,19 @@
       if settings_dict.has_key("START_CREATURE"):
         world_x = settings_dict["WORLD-X"]
         world_y = settings_dict["WORLD-Y"]
-        self.start_cell_location = int(((world_y/2) * world_x) +(world_x/2))
+        self.start_cell_location = int(((world_y/2) * world_x) + (world_x/2))
         cells_dict[str(self.start_cell_location)] = str(1)
-        tmp_inst_set = pyInstructionSet.pyInstructionSet(os.path.join(workspace_dir, "inst_set.default"))
-        org_string = tmp_inst_set.OrgFile2LetterString(os.path.join(freeze_dir, settings_dict["START_CREATURE"]))
+
+        # Read the genome from the organism file 
+
+        org_file = open(os.path.join(freeze_dir, settings_dict["START_CREATURE"]))
+        org_string = org_file.readline()
+        org_string = org_string.rstrip()
+        org_string = org_string.lstrip()
+        org_file.close
         organisms_dict[str(1)] = org_string
-    self.modifyEventFile(cells_dict, organisms_dict, os.path.join(tmp_in_dir, "events.cfg"), tmp_out_dir)
+    self.modifyEventFile(cells_dict, organisms_dict, 
+      os.path.join(tmp_in_dir, "events.cfg"), tmp_out_dir)
     
     shutil.copyfile(os.path.join(workspace_dir, "environment.default"), os.path.join(tmp_in_dir, "environment.cfg"))
     shutil.copyfile(os.path.join(workspace_dir, "inst_set.default"), os.path.join(tmp_in_dir, "inst_set.default"))

Modified: branches/brysonda/source/python/AvidaGui2/pyWriteToFreezer.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/pyWriteToFreezer.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/pyWriteToFreezer.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -1,25 +1,60 @@
 # -*- coding: utf-8 -*-
 
 import string
-import qt
+from qt import *
+import os
 
 class pyWriteToFreezer:
 
-  def __init__(self, in_dict = None, empty_dish = True, out_file_name = None):
+  def __init__(self, in_dict = None, out_file_name = None):
+
+    is_org = False
+    is_dish = False
+    is_empty_dish = False
+
+    if out_file_name.endswith("petri_dish"):
+      out_file_name = (os.path.split(out_file_name)[0])
+
+    if out_file_name.endswith(".organism"):
+      print "that was an org"
+      is_org = True
+
+    elif out_file_name.endswith(".full"):
+      print "that was a full dish man"
+      is_dish = True
+      self.simplifyPopulation(in_dict)
+      out_file_name = (out_file_name + '/petri_dish')
+
+    elif out_file_name.endswith(".empty"):
+      print "that was an empty dish man"
+      is_dish = True
+      is_empty_dish = True
+
+    else:
+      print "that was junk man"
+
+    out_freezer_file = open((out_file_name), "w")
+
   
-    if empty_dish == False:
-      self.simplifyPopulation(in_dict)
-    out_freezer_file = open(out_file_name, "w")
-    for section in in_dict.keys():
+    if is_org == True:
+      print "writing org"
+      genome = str(in_dict[1])
+      out_freezer_file.write(genome + "\n")
+    elif is_dish == True:
+
+      for section in in_dict.keys():
     
-      # Always print out the petri dishes settings and if it is a full dish
-      # print out the cell and organism information
+        # Always print out the petri dishes settings and if it is a full dish
+        # print out the cell and organism information
       
-      if ((section == "SETTINGS") or (empty_dish == False)):
-        out_freezer_file.write("*" + section + "\n")
-        info_dict = in_dict[section]
-        for info_key in info_dict.keys():
-          out_freezer_file.write(str(info_key) + " " + str(info_dict[info_key]) + "\n")
+        if ((section == "SETTINGS") or (is_empty_dish == False)):
+          out_freezer_file.write("*" + section + "\n")
+          info_dict = in_dict[section]
+          for info_key in info_dict.keys():
+            out_freezer_file.write(str(info_key) + " " + str(info_dict[info_key]) + "\n")
+    else: 
+      print "something is wrong, that was not an org or a dish"
+
     out_freezer_file.close()
     
   def simplifyPopulation(self, in_dict = None):

Modified: branches/brysonda/source/python/AvidaGui2/py_test_utils.py
===================================================================
--- branches/brysonda/source/python/AvidaGui2/py_test_utils.py	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/AvidaGui2/py_test_utils.py	2005-07-26 14:44:40 UTC (rev 263)
@@ -93,7 +93,7 @@
       # will have the index embedded in it. similarly, embedded keys for
       # undeleted objects in dictionaries.
       if type(o) == types.ListType:
-        for i in range(len(o)):
+        for i in xrange(len(o)):
           attr = o[i]
           if not id_dict.has_key(id(attr)):
             enqueueAndMark(attr, id_dict[id(o)] + '[%d]'%i + str(attr), id_dict, object_queue)

Modified: branches/brysonda/source/python/CMakeLists.txt
===================================================================
--- branches/brysonda/source/python/CMakeLists.txt	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/CMakeLists.txt	2005-07-26 14:44:40 UTC (rev 263)
@@ -57,4 +57,4 @@
   # @kgn
 ENDIF(AVD_GUI_PYQT)
 
-
+# vim: set ft=conf:

Copied: branches/brysonda/source/python/default.workspace (from rev 262, trunk/source/python/default.workspace)

Modified: branches/brysonda/source/python/setup_osx.py.in
===================================================================
--- branches/brysonda/source/python/setup_osx.py.in	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/python/setup_osx.py.in	2005-07-26 14:44:40 UTC (rev 263)
@@ -6,72 +6,43 @@
 """
 
 from distutils.core import setup
-from glob import glob
-import os
 import py2app
 import site
 
-#avida_ed_python_basedir = '../../source/bindings/Boost.Python'
+# Hack :
+#
+# py2app usually ignores cvs and svn metadata directories, but we want
+# to keep svn metadata (so that our programmers can hack on Avida-ED.app
+# python code without rebuilding from the source tree, but can still
+# commit their changes). The variable to change is py2app.util.SCMDIRS,
+# which usually reads ['CVS', '.svn'].
+# 
+py2app.util.SCMDIRS=['CVS']
+
+# Tell Python where to find Avida and Avida-ED python modules and packages.
 avida_ed_python_basedir = '${CMAKE_CURRENT_SOURCE_DIR}'
 site.addsitedir(avida_ed_python_basedir)
 site.addsitedir('${LIBRARY_OUTPUT_PATH}')
 
-# make a list of subversion metadata files in AvidaGui2/.svn
-svn_source_dir = avida_ed_python_basedir + '/AvidaGui2/.svn'
-svn_target_dir = '../Resources/Python/site-packages/AvidaGui2/.svn'
-svn_metadata_subdirs = [
-  'prop-base',
-  'props',
-  'text-base',
-  'wcprops',
-  'tmp/prop-base',
-  'tmp/props',
-  'tmp/text-base',
-  'tmp/wcprops',
-]
-
-for svn_subdir in svn_metadata_subdirs:
-  f = open(svn_source_dir + '/' + svn_subdir + '/empty-file', 'w')
-  f.close()
-
-svn_metadata_files = [
-  ( svn_target_dir + '/' + svn_subdir, glob(svn_source_dir + '/' + svn_subdir + '/*')) for svn_subdir in svn_metadata_subdirs
-] + [
-  (svn_target_dir, [ svn_source_dir + '/' + svn_file for svn_file in ['empty-file', 'entries', 'format', 'README.txt']]),
-]
-
 setup(  
+  # Python startup script
   app=['Avida-ED.py'],
+  # Options for distutils
   options = dict(
+    # Options for py2app
     py2app = dict(
+      # Python modules to copy :
       includes = ['iqt', 'qt', 'qwt', 'readline', 'unittest', 'IPython', 'AvidaGui2', 'AvidaCore'],
+      # Python packages to copy :
       packages = ['IPython', 'AvidaGui2'],
+      # Subdirectory in which Avi :da-ED.app should be assembled
       dist_dir = '${EXECUTABLE_OUTPUT_PATH}',
+      # Extra files and folders to  :copy into Resources subdirectory
+      resources = ['${CMAKE_CURRENT_SOURCE_DIR}/AvidaGui2/avidalogo.png', '${CMAKE_CURRENT_SOURCE_DIR}/default.workspace'],
+      # Strip symbols from libraries.
       strip = True,
+      # Generate a file named Avida-ED.dot containing dependency graphs.
+      graph = True,
     )
   ),
-  data_files=[
-    ('../Resources',
-      [ '${CMAKE_CURRENT_SOURCE_DIR}/AvidaGui2/avidalogo.png' ]
-      #+
-      ## Avida configuration files
-      ## FIXME # these only temporarily live in Resources, until we make
-      ## a file-open dialog.
-      ## @kgn
-      #[
-      #  '${PROJECT_SOURCE_DIR}/source/support/' + configuration_file
-      #  for configuration_file in ['genesis', 'environment.cfg',
-      #  'events.cfg', 'inst_set.default', 'organism.default']
-      #]
-    ),
-  ]
-  # subversion metadata files
-  + svn_metadata_files,
 )
-
-#print """
-#FIXME:
-#Remember to reenable symbol stripping by commenting-out the option "strip = False"
-#at line 51 of source/python/setup_osx.py.in.
-#@kgn
-#"""

Modified: branches/brysonda/source/tools/data_file_manager.hh
===================================================================
--- branches/brysonda/source/tools/data_file_manager.hh	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/tools/data_file_manager.hh	2005-07-26 14:44:40 UTC (rev 263)
@@ -38,6 +38,9 @@
 
   cDataFile * InternalFind(const cString & name);
 
+private:
+  // disabled copy constructor.
+  cDataFileManager(const cDataFileManager &);
 public:
   cDataFileManager() { ; }
   ~cDataFileManager();

Modified: branches/brysonda/source/tools/help_manager.hh
===================================================================
--- branches/brysonda/source/tools/help_manager.hh	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/tools/help_manager.hh	2005-07-26 14:44:40 UTC (rev 263)
@@ -32,6 +32,9 @@
 
   // Private methods...
   cHelpType * GetType(const cString type_name);
+private:
+  // disabled copy constructor.
+  cHelpManager(const cHelpManager &);
 public:
   cHelpManager() : last_entry(NULL), verbose (false) { ; }
   ~cHelpManager() { while (type_list.GetSize() > 0) delete type_list.Pop(); }

Modified: branches/brysonda/source/tools/help_type.hh
===================================================================
--- branches/brysonda/source/tools/help_type.hh	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/tools/help_type.hh	2005-07-26 14:44:40 UTC (rev 263)
@@ -28,6 +28,9 @@
   tList<cHelpEntry> entry_list;
   cHelpManager * manager;
   int num_entries;
+private:
+  // disabled copy constructor.
+  cHelpType(const cHelpType &);
 public:
   cHelpType(const cString & _name, cHelpManager * _manager)
     : name(_name), manager(_manager), num_entries(0) { ; }

Modified: branches/brysonda/source/tools/tDictionary.hh
===================================================================
--- branches/brysonda/source/tools/tDictionary.hh	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/tools/tDictionary.hh	2005-07-26 14:44:40 UTC (rev 263)
@@ -1,10 +1,47 @@
 //////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology             //
+// Copyright (C) 1993 - 2005 California Institute of Technology             //
 //                                                                          //
 // Read the COPYING and README files, or contact 'avida at alife.org',         //
 // before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
 //////////////////////////////////////////////////////////////////////////////
 
+/*
+ * This template is used to look up objects of the desired type by name.
+ * I is implemented through use of a linked list and a hash table.  The linked
+ * list contains all of the individual entries stored in the dictionary (in an
+ * arbitrary order).  The hash table points to the first entry in the list
+ * that fits in its cell.  If there are no entries that fit in the cell, the
+ * has table contains a NULL pointer at that location.
+ *
+ * INTERFACE:
+ *    tDictionary(int in_hash_size=DICTIONARY_HASH_DEFAULT)  // Constructor
+ *    ~tDictionary()                                // Destructor
+ *    int GetSize()                                 // Get dictionary size
+ *    void Add(const cString & name, T data)        // Add new entry
+ *    bool HasEntry(const cString & name)           // Test if key exists
+ *    bool Find(const cString & name, T & out_data) // Find entry for key
+ *    T Remove(const cString & name)                // Remove entry
+ *    cString NearMatch(const cString name)         // Find closest key
+ *    void SetHash(int _hash)                       // Change hash table size
+ *
+ *
+ * IMPLEMENTATION NOTES:
+ *
+ * On INSERT: If a cell already has at least one entry in it, the new entry
+ * gets inserted into the linked list before the existing entry.  If the cell
+ * is currently empty, the new entry gets placed at the end of the linked
+ * list.  In either case, the cell is updated to point at the new entry.
+ *
+ * On DELETE: Start looking at the position in the list where the cell is
+ * pointing and continue until the entry-to-be-deleted is found.  If the
+ * entry to be deleted is the one being pointed at, be sure to update the
+ * cell.
+ *
+ * On LOOKUP: If the cell has a NULL pointer, lookup fails.  Otherwise search
+ * through list until either correct entry is found (lookup succeeds) or else
+ * the lookup finds an entry not in the current cell (lookup fails).
+ */
+
 #ifndef TDICTIONARY_HH
 #define TDICTIONARY_HH
 
@@ -14,6 +51,9 @@
 #ifndef STRING_UTIL_HH
 #include "string_util.hh"
 #endif
+#ifndef TARRAY_HH
+#include "tArray.hh"
+#endif
 #ifndef TLIST_HH
 #include "tList.hh"
 #endif
@@ -29,49 +69,122 @@
 
 template <class T> class tDictionary {
 
+  // We create a structure with full information about each entry stored in
+  // this dictionary.
   template <class U> struct tDictEntry {
     cString name;
+    int id;
     U data;
   };
 
 private:
-  int size;
-  int hash_size;
-  tList< tDictEntry<T> > * hash_table;
+  int dict_size;  // How many entries are we storing?
+  int hash_size;  // What size hash table are we using?
+
+  tList< tDictEntry<T> > entry_list;      // A linked list of ALL entries
+  tArray< tListNode< tDictEntry<T> > * > cell_array;       // Pointers to the entry list.
+  tListIterator< tDictEntry<T> > list_it; // Iterator for entry_list
   
+  // Currently, we hash a string simply by adding up the individual character
+  // values in that string and modding by the hash size.  For most applications
+  // this will work fine (and it is fast!) but some patters will cause all
+  // strings to go into the same cell.  For example, "ABC"=="CBA"=="BBB".
   int HashString(const cString & key) const {
     unsigned int out_hash = 0;
     for (int i = 0; i < key.GetSize(); i++)
       out_hash += (unsigned int) key[i];
     return out_hash % hash_size;
   }
+
+  // Function to find the appropriate tDictEntry for a string that is passed
+  // in and return it.
   tDictEntry<T> * FindEntry(const cString & name) {
     const int bin = HashString(name);
-    tListIterator< tDictEntry<T> > list_it(hash_table[bin]);
-    while (list_it.Next() != NULL) {
+    if (cell_array[bin] == NULL) return NULL;
+
+    // Set the list iterator to the first entry of this bin.
+    list_it.Set(cell_array[bin]);
+
+    // Loop through all entries in this bin to see if any are a perfect match.
+    while (list_it.Get() != NULL && list_it.Get()->id == bin) {
       if (list_it.Get()->name == name) return list_it.Get();
+      list_it.Next();
     }
+
+    // No matches found.
     return NULL;
   }
 public:
-  tDictionary() : size(0), hash_size(DICTIONARY_HASH_DEFAULT) {
-    hash_table = new tList< tDictEntry<T> >[hash_size];
+  tDictionary(int in_hash_size=DICTIONARY_HASH_DEFAULT)
+    : dict_size(0)
+    , hash_size(in_hash_size)
+    , cell_array(in_hash_size)
+    , list_it(entry_list)
+  {
+    cell_array.SetAll(NULL);
   }
+
   ~tDictionary() {
-    for (int i = 0; i < hash_size; i++)
-      while (hash_table[i].GetSize()) delete hash_table[i].Pop();
-    delete [] hash_table;
+    while (entry_list.GetSize()) delete entry_list.Pop();
   }
 
-  int GetSize() { return size; }
+
+  bool OK() {
+    using namespace std;
+    cout << "DICT_SIZE = " << dict_size << endl;
+    cout << "HASH_SIZE = " << hash_size << endl;
+    int count = 0;
+    cout << "LIST ELEMENTS:" << endl;
+    list_it.Reset();
+    while (list_it.Next() != NULL) {
+      tDictEntry<T> * cur_entry = list_it.Get();
+      cout << "  " << count << " : "
+	   << cur_entry->id << " "
+	   << cur_entry->name << " "
+	   << cur_entry->data << " "
+	   << endl;
+    }
+    cout << endl;
+    cout << "ARRAY CELLS: "
+	 << cell_array.GetSize()
+	 << endl;
+    for (int i = 0; i < hash_size; i++) {
+      tListNode< tDictEntry<T> > * cur_list_node = cell_array[i];
+      if (cur_list_node == NULL) {
+	cout << "  NULL" << endl;
+      } else {
+	cout << "  " << cur_list_node->data->id
+	     << " " << cur_list_node->data->name
+	     << endl;
+      }
+    }
+
+    return true;
+  }
+
+  int GetSize() { return dict_size; }
   
   void Add(const cString & name, T data) {
+    // Build the new entry...
     tDictEntry<T> * new_entry = new tDictEntry<T>;
     new_entry->name = name;
     new_entry->data = data;
     const int bin = HashString(name);
-    hash_table[bin].Push(new_entry);
-    size++;
+    new_entry->id = bin;
+
+
+    // Determine where this new entry should go; either at the end of
+    // the list (if there are no others in the bin) or following another
+    // entry in the bin.
+    if (cell_array[bin] == NULL) { list_it.Reset(); } // Reset to list start
+    else { list_it.Set(cell_array[bin]); }            // Else find insert point
+
+    entry_list.Insert(list_it, new_entry); // Place new entry in the list
+    list_it.Prev();                        // Back up to new entry
+    cell_array[bin] = list_it.GetPos();    // Record position
+
+    // Update our entry count...
+    dict_size++;
   }
   
   bool HasEntry(const cString & name) {
@@ -88,56 +201,110 @@
   }
 
   T Remove(const cString & name) {
+    // Determine the bin that we are going to be using.
     const int bin = HashString(name);
+
     T out_data = NULL;
-    tListIterator< tDictEntry<T> > list_it(hash_table[bin]);
-    while (list_it.Next() != NULL) {
-      if (list_it.Get()->name == name) {
-	out_data = list_it.Get()->data;
-	list_it.Remove();
-	size--;
-	break;
+    assert(cell_array[bin] != NULL);
+    list_it.Set(cell_array[bin]);
+
+    // If we are deleting the first entry in this bin we must clean up...
+    if (list_it.Get()->name == name) {
+      out_data = list_it.Get()->data;
+      list_it.Remove();
+      list_it.Next();
+      dict_size--;
+      // See if the next entry is still part of this cell.
+      if (list_it.AtRoot() == false && list_it.Get()->id == bin) {
+	cell_array[bin] = list_it.GetPos();
+      } else {
+	cell_array[bin] = NULL;
       }
     }
+
+    // If it was not the first entry in this cell, keep looking!
+    else {
+      while (list_it.Next() != NULL && list_it.Get()->id == bin) {
+	if (list_it.Get()->name == name) {
+	  out_data = list_it.Get()->data;
+	  list_it.Remove();
+	  dict_size--;
+	  break;
+	}
+      }
+    }
+
     return out_data;
   }
 
   cString NearMatch(const cString name) {
     cString best_match("");
     int best_dist = name.GetSize();
-    for (int i = 0; i < hash_size; i++) {
-      tListIterator< tDictEntry<T> > list_it(hash_table[i]);
-      while (list_it.Next() != NULL) {
-	int dist = cStringUtil::EditDistance(name, list_it.Get()->name);
-	if (dist < best_dist) {
-	  best_dist = dist;
-	  best_match = list_it.Get()->name;
-	}
+    list_it.Reset();
+    while (list_it.Next() != NULL) {
+      int dist = cStringUtil::EditDistance(name, list_it.Get()->name);
+      if (dist < best_dist) {
+	best_dist = dist;
+	best_match = list_it.Get()->name;
       }
     }
     return best_match;
   }
 
   void SetHash(int _hash) {
-    const int old_hash_size = hash_size;
-
     // Create the new table...
     hash_size = _hash;
-    tList< tDictEntry<T> > * new_hash_table =
-      new tList< tDictEntry<T> >[hash_size];
+    cell_array.ResizeClear(hash_size);
+    cell_array.SetAll(NULL);
 
-    // Move everything over...
-    for (int i = 0; i < old_hash_size; i++) {
-      while (hash_table[i].GetSize() > 0) {
-	tDictEntry<T> * cur_entry = hash_table[i].Pop();
-	const int bin = HashString(cur_entry->name);
-	new_hash_table[bin].Push(cur_entry);
+    // Backup all of the entries in the list and re-insert them one-by-one.
+    tList< tDictEntry<T> > backup_list;
+    backup_list.Transfer(entry_list);
+
+    while (backup_list.GetSize() > 0) {
+      tDictEntry<T> * cur_entry = backup_list.Pop();
+
+      // determine the new bin for this entry.
+      int bin = HashString(cur_entry->name);
+      cur_entry->id = bin;
+
+      if (cell_array[bin] == NULL) { list_it.Reset(); } // Reset to list start
+      else { list_it.Set(cell_array[bin]); }            // Else find insert point
+      
+      entry_list.Insert(list_it, cur_entry); // Place new entry in the list
+      list_it.Prev();                        // Back up to new entry
+      cell_array[bin] = list_it.GetPos();    // Record position
+    }
+  }
+    
+  // The following method allows the user to convert the dictionary contents
+  // into lists.  Empty lists show be passed in as arguments and the method
+  // will fill in their contents.
+  void AsLists(tList<cString> & name_list, tList<T> & value_list) {
+    // Setup the lists to fill in.
+    assert(name_list.GetSize() == 0);
+    assert(value_list.GetSize() == 0);
+    tListIterator<cString> name_it(name_list);
+    tListIterator<T> value_it(value_list);
+
+    // Loop through the current entries and included them into the output
+    // list one at a time.
+    list_it.Reset();
+    while (list_it.Next() != NULL) {
+      // Grab the info about the current entry.
+      cString & cur_name = list_it.Get()->name;
+      T & cur_value = list_it.Get()->data;
+      
+      // Find the position to place this in the lists.
+      name_it.Reset();
+      value_it.Reset();
+      value_it.Next();
+      while (name_it.Next() != NULL && cur_name > *(name_it.Get())) {
+	value_it.Next();
       }
+      name_list.Insert(name_it, &cur_name);
+      value_list.Insert(value_it, &cur_value);
     }
-
-    // Cleanup...
-    delete [] hash_table;
-    hash_table = new_hash_table;
   }
 };
 

Modified: branches/brysonda/source/tools/tList.hh
===================================================================
--- branches/brysonda/source/tools/tList.hh	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/tools/tList.hh	2005-07-26 14:44:40 UTC (rev 263)
@@ -32,6 +32,9 @@
   tBaseIterator() { ; }
   virtual ~tBaseIterator() { ; }
 
+  virtual void Set(tListNode<T> * in_node) = 0;
+  virtual void Reset() = 0;
+
   virtual const T * GetConst() = 0;
   virtual const T * NextConst() = 0;
   virtual const T * PrevConst() = 0;
@@ -50,9 +53,12 @@
   const tListNode<T> * GetConstNode() { return node; }
 public:
   explicit tListIterator(tList<T> & _list);
+  explicit tListIterator(tList<T> & _list, tListNode<T> * start_node);
   ~tListIterator();
 
+  void Set(tListNode<T> * in_node) { node = in_node; }
   void Reset();
+  tListNode<T> * GetPos() { return node; }
 
   T * Get();
   T * Next();
@@ -80,8 +86,11 @@
   const tListNode<T> * GetConstNode() { return node; }
 public:
   explicit tConstListIterator(const tList<T> & _list);
+  explicit tConstListIterator(const tList<T> & _list,
+			      const tListNode<T> * start_node);
   ~tConstListIterator();
 
+  void Set(tListNode<T> * in_node) { node = in_node; }
   void Reset();
 
   const T * Get();
@@ -215,19 +224,24 @@
   void CircPrev() { if (size > 0) Push(PopRear()); }
 
   T * Remove(tListIterator<T> & other) {
-    if (&(other.list) != this) return NULL;
+    if (&(other.list) != this) return NULL; // @CAO make this an assert?
     return RemoveNode(other.node);
   }
 
   T * Insert(tListIterator<T> & list_it, T * in_data) {
+    tListNode<T> * cur_node = list_it.node;
+
+    // Build the new node for the list...
     tListNode<T> * new_node = new tListNode<T>;
     new_node->data = in_data;
-    new_node->next = list_it.node->next;
-    new_node->prev = list_it.node;
 
-    list_it.node->next->prev = new_node;
-    list_it.node->next = new_node;
+    // Insert the new node before the iterator...
+    new_node->next = cur_node;
+    new_node->prev = cur_node->prev;
+    cur_node->prev->next = new_node;
+    cur_node->prev = new_node;
     size++;
+
     return in_data;
   }
 
@@ -249,11 +263,39 @@
 
   int GetSize() const { return size; }
 
+  // Copy another list onto the end of this one.
   void Append(tList<T> & other_list) {
     tListIterator<T> other_it(other_list);
     while (other_it.Next() != NULL) PushRear(other_it.Get());
   }
 
+  // Empty out another list, transferring its contents to the end of this one.
+  void Transfer(tList<T> & other_list) {
+    // If the other list is empty, stop here.
+    if (other_list.GetSize() == 0) return;
+
+    // Hook this list into the other one.
+    other_list.root.next->prev = root.prev;
+    other_list.root.prev->next = &root;
+    root.prev->next = other_list.root.next;
+    root.prev       = other_list.root.prev;
+
+    // Clean up the other list so it has no entries.
+    other_list.root.next = &(other_list.root);
+    other_list.root.prev = &(other_list.root);
+
+    // Update the size
+    size += other_list.size;
+    other_list.size = 0;
+
+    // Update all iterators in the other list to point at the root.
+    tListNode< tBaseIterator<T> > * test_it = other_list.it_root.next;
+    while (test_it != &other_list.it_root) {
+      test_it->data->Reset();
+      test_it = test_it->next;
+    }
+  }
+
   // Find by value
   T * Find(T * _in) const {
     tListNode<T> * test = root.next;
@@ -384,6 +426,13 @@
   list.AddIterator(this);
 }
 
+template <class T> tListIterator<T>::tListIterator(tList<T> & _list,
+						   tListNode<T> * start_node)
+  : list(_list), node(start_node)
+{
+  list.AddIterator(this);
+}
+
 template <class T> tListIterator<T>::~tListIterator()
 {
   list.RemoveIterator(this);
@@ -445,6 +494,12 @@
   list.AddIterator(this);
 }
 
+template <class T> tConstListIterator<T>::tConstListIterator(const tList<T> & _list, const tListNode<T> * start_node)
+  : list(_list), node(start_node)
+{
+  list.AddIterator(this);
+}
+
 template <class T> tConstListIterator<T>::~tConstListIterator()
 {
   list.RemoveIterator(this);

Modified: branches/brysonda/source/tools/tVector.hh
===================================================================
--- branches/brysonda/source/tools/tVector.hh	2005-07-26 04:46:56 UTC (rev 262)
+++ branches/brysonda/source/tools/tVector.hh	2005-07-26 14:44:40 UTC (rev 263)
@@ -138,8 +138,8 @@
 
 public:
   T& operator[](int idx) {
-    assert_error( idx >= 0, "Lower Bounds Error" );
-    assert_error( idx < Size(), "Upper Bounds Error" );
+    assert( idx >= 0);
+    assert( idx < Size());
     if(idx >= 0 && idx < Size()) { // it is in range
       return _data[idx];
     }
@@ -150,8 +150,8 @@
   }
 
   T operator[](int idx) const {
-    assert_error( idx >= 0, "Lower Bounds Error" );
-    assert_error( idx < Size(), "Upper Bounds Error" );
+    assert( idx >= 0);
+    assert( idx < Size());
     if(idx >= 0 && idx < Size()) {
       return _data[idx];
     }




More information about the Avida-cvs mailing list