[Avida-cvs] [avida-svn] r836 - in development: Avida.xcodeproj source/cpu source/targets/avida-viewer

brysonda@myxo.css.msu.edu brysonda at myxo.css.msu.edu
Fri Jul 14 11:42:37 PDT 2006


Author: brysonda
Date: 2006-07-14 14:42:37 -0400 (Fri, 14 Jul 2006)
New Revision: 836

Removed:
   development/source/cpu/cHeadMultiMem.cc
   development/source/cpu/cHeadMultiMem.h
Modified:
   development/Avida.xcodeproj/project.pbxproj
   development/source/cpu/CMakeLists.txt
   development/source/cpu/SConscript
   development/source/cpu/cHardwareBase.h
   development/source/cpu/cHardwareCPU.cc
   development/source/cpu/cHardwareCPU.h
   development/source/cpu/cHardwareSMT.cc
   development/source/cpu/cHardwareSMT.h
   development/source/cpu/cHardwareTransSMT.cc
   development/source/cpu/cHardwareTransSMT.h
   development/source/cpu/cHeadCPU.cc
   development/source/cpu/cHeadCPU.h
   development/source/targets/avida-viewer/cZoomScreen.cc
Log:
Simplify CPU heads into a single class (at the moment).  This has the advantage of unifying the design of heads shared between cpu models making the strange casting within cZoomScreen unnecessary.  Also, the potentially hazardous use of (at the moment) untracked foreign hardware objects has been removed.   This can be re-implemented in a safer manner in the future (if necessary). Finally, the simplified class allows for more function inlining yielding about a 1.5% performance improvement (under TransSMT).

Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj	2006-07-14 18:31:02 UTC (rev 835)
+++ development/Avida.xcodeproj/project.pbxproj	2006-07-14 18:42:37 UTC (rev 836)
@@ -214,13 +214,11 @@
 		70C1F02B08C3C71300F50912 /* cHardwareSMT.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02308C3C71300F50912 /* cHardwareSMT.cc */; };
 		70C1F02C08C3C71300F50912 /* cHardwareStatusPrinter.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02408C3C71300F50912 /* cHardwareStatusPrinter.cc */; };
 		70C1F02E08C3C71300F50912 /* cHeadCPU.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02608C3C71300F50912 /* cHeadCPU.cc */; };
-		70C1F02F08C3C71300F50912 /* cHeadMultiMem.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02708C3C71300F50912 /* cHeadMultiMem.cc */; };
 		70C1F03008C3C71300F50912 /* cTestCPU.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02808C3C71300F50912 /* cTestCPU.cc */; };
 		70C1F03108C3C71300F50912 /* cTestUtil.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02908C3C71300F50912 /* cTestUtil.cc */; };
 		70C1F03308C3C71300F50912 /* cHardwareSMT.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02308C3C71300F50912 /* cHardwareSMT.cc */; };
 		70C1F03408C3C71300F50912 /* cHardwareStatusPrinter.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02408C3C71300F50912 /* cHardwareStatusPrinter.cc */; };
 		70C1F03608C3C71300F50912 /* cHeadCPU.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02608C3C71300F50912 /* cHeadCPU.cc */; };
-		70C1F03708C3C71300F50912 /* cHeadMultiMem.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02708C3C71300F50912 /* cHeadMultiMem.cc */; };
 		70C1F03808C3C71300F50912 /* cTestCPU.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02808C3C71300F50912 /* cTestCPU.cc */; };
 		70C1F03908C3C71300F50912 /* cTestUtil.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02908C3C71300F50912 /* cTestUtil.cc */; };
 		70C1F19408C6A11100F50912 /* cEventList.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F18F08C6A11100F50912 /* cEventList.cc */; };
@@ -272,7 +270,6 @@
 		70DCACAE097AF7CC002F8733 /* cHardwareSMT.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02308C3C71300F50912 /* cHardwareSMT.cc */; };
 		70DCACAF097AF7CC002F8733 /* cHardwareStatusPrinter.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02408C3C71300F50912 /* cHardwareStatusPrinter.cc */; };
 		70DCACB0097AF7CC002F8733 /* cHeadCPU.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02608C3C71300F50912 /* cHeadCPU.cc */; };
-		70DCACB1097AF7CC002F8733 /* cHeadMultiMem.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02708C3C71300F50912 /* cHeadMultiMem.cc */; };
 		70DCACB2097AF7CC002F8733 /* cTestCPU.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02808C3C71300F50912 /* cTestCPU.cc */; };
 		70DCACB3097AF7CC002F8733 /* cTestUtil.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02908C3C71300F50912 /* cTestUtil.cc */; };
 		70DCACB4097AF7CC002F8733 /* cEventList.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F18F08C6A11100F50912 /* cEventList.cc */; };
@@ -765,14 +762,12 @@
 		70C1F01508C3C6FC00F50912 /* cHardwareStatusPrinter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cHardwareStatusPrinter.h; sourceTree = "<group>"; };
 		70C1F01908C3C6FC00F50912 /* cHardwareTracer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cHardwareTracer.h; sourceTree = "<group>"; };
 		70C1F01B08C3C6FC00F50912 /* cHeadCPU.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cHeadCPU.h; sourceTree = "<group>"; };
-		70C1F01C08C3C6FC00F50912 /* cHeadMultiMem.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cHeadMultiMem.h; sourceTree = "<group>"; };
 		70C1F01D08C3C6FC00F50912 /* cInstLibCPU.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cInstLibCPU.h; sourceTree = "<group>"; };
 		70C1F01F08C3C6FC00F50912 /* cTestCPU.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cTestCPU.h; sourceTree = "<group>"; };
 		70C1F02008C3C6FC00F50912 /* cTestUtil.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cTestUtil.h; sourceTree = "<group>"; };
 		70C1F02308C3C71300F50912 /* cHardwareSMT.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cHardwareSMT.cc; sourceTree = "<group>"; };
 		70C1F02408C3C71300F50912 /* cHardwareStatusPrinter.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cHardwareStatusPrinter.cc; sourceTree = "<group>"; };
 		70C1F02608C3C71300F50912 /* cHeadCPU.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cHeadCPU.cc; sourceTree = "<group>"; };
-		70C1F02708C3C71300F50912 /* cHeadMultiMem.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cHeadMultiMem.cc; sourceTree = "<group>"; };
 		70C1F02808C3C71300F50912 /* cTestCPU.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cTestCPU.cc; sourceTree = "<group>"; };
 		70C1F02908C3C71300F50912 /* cTestUtil.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cTestUtil.cc; sourceTree = "<group>"; };
 		70C1F0A808C3FF1800F50912 /* nHardware.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nHardware.h; sourceTree = "<group>"; };
@@ -1308,8 +1303,6 @@
 				70C1F01908C3C6FC00F50912 /* cHardwareTracer.h */,
 				70C1F02608C3C71300F50912 /* cHeadCPU.cc */,
 				70C1F01B08C3C6FC00F50912 /* cHeadCPU.h */,
-				70C1F02708C3C71300F50912 /* cHeadMultiMem.cc */,
-				70C1F01C08C3C6FC00F50912 /* cHeadMultiMem.h */,
 				70C1F01D08C3C6FC00F50912 /* cInstLibCPU.h */,
 				70C1EF6108C3954700F50912 /* cCPUStack.cc */,
 				70C1EF6008C3953A00F50912 /* cCPUStack.h */,
@@ -1839,7 +1832,6 @@
 				70C1F03308C3C71300F50912 /* cHardwareSMT.cc in Sources */,
 				70C1F03408C3C71300F50912 /* cHardwareStatusPrinter.cc in Sources */,
 				70C1F03608C3C71300F50912 /* cHeadCPU.cc in Sources */,
-				70C1F03708C3C71300F50912 /* cHeadMultiMem.cc in Sources */,
 				70C1F03808C3C71300F50912 /* cTestCPU.cc in Sources */,
 				70C1F03908C3C71300F50912 /* cTestUtil.cc in Sources */,
 				70C1F19908C6A11100F50912 /* cEventList.cc in Sources */,
@@ -1979,7 +1971,6 @@
 				70DCACAE097AF7CC002F8733 /* cHardwareSMT.cc in Sources */,
 				70DCACAF097AF7CC002F8733 /* cHardwareStatusPrinter.cc in Sources */,
 				70DCACB0097AF7CC002F8733 /* cHeadCPU.cc in Sources */,
-				70DCACB1097AF7CC002F8733 /* cHeadMultiMem.cc in Sources */,
 				70DCACB2097AF7CC002F8733 /* cTestCPU.cc in Sources */,
 				70DCACB3097AF7CC002F8733 /* cTestUtil.cc in Sources */,
 				70DCACB4097AF7CC002F8733 /* cEventList.cc in Sources */,
@@ -2098,7 +2089,6 @@
 				70C1F02B08C3C71300F50912 /* cHardwareSMT.cc in Sources */,
 				70C1F02C08C3C71300F50912 /* cHardwareStatusPrinter.cc in Sources */,
 				70C1F02E08C3C71300F50912 /* cHeadCPU.cc in Sources */,
-				70C1F02F08C3C71300F50912 /* cHeadMultiMem.cc in Sources */,
 				70C1F03008C3C71300F50912 /* cTestCPU.cc in Sources */,
 				70C1F03108C3C71300F50912 /* cTestUtil.cc in Sources */,
 				70C1F19408C6A11100F50912 /* cEventList.cc in Sources */,

Modified: development/source/cpu/CMakeLists.txt
===================================================================
--- development/source/cpu/CMakeLists.txt	2006-07-14 18:31:02 UTC (rev 835)
+++ development/source/cpu/CMakeLists.txt	2006-07-14 18:42:37 UTC (rev 836)
@@ -11,7 +11,6 @@
   cHardwareStatusPrinter.cc
   cHardwareTransSMT.cc
   cHeadCPU.cc
-  cHeadMultiMem.cc
   cTestCPU.cc
   cTestCPUInterface.cc
   cTestUtil.cc

Modified: development/source/cpu/SConscript
===================================================================
--- development/source/cpu/SConscript	2006-07-14 18:31:02 UTC (rev 835)
+++ development/source/cpu/SConscript	2006-07-14 18:42:37 UTC (rev 836)
@@ -17,7 +17,6 @@
   'cHardwareTracer.h',
   'cHardwareTrans.h',
   'cHeadCPU.h',
-  'cHeadMultiMem.h',
   'cInstLibCPU.h',
   'cTestCPU.h',
   'cTestCPUInterface.h',
@@ -41,7 +40,6 @@
   'cHardwareStatusPrinter.cc',
   'cHardwareTransSMT.cc',
   'cHeadCPU.cc',
-  'cHeadMultiMem.cc',
   'cTestCPU.cc',
   'cTestCPUInterface.cc',
   'cTestUtil.cc',

Modified: development/source/cpu/cHardwareBase.h
===================================================================
--- development/source/cpu/cHardwareBase.h	2006-07-14 18:31:02 UTC (rev 835)
+++ development/source/cpu/cHardwareBase.h	2006-07-14 18:42:37 UTC (rev 836)
@@ -94,6 +94,7 @@
   virtual cHeadCPU& GetHead(int head_id) = 0;
   virtual const cHeadCPU& GetHead(int head_id, int thread) const = 0;
   virtual cHeadCPU& GetHead(int head_id, int thread) = 0;
+  virtual int GetNumHeads() const = 0;
   
   virtual const cHeadCPU& IP() const = 0;
   virtual cHeadCPU& IP() = 0;
@@ -133,7 +134,6 @@
   
   
   // --------  Parasite Stuff  --------
-  virtual int TestParasite() const = 0;
   virtual bool InjectHost(const cCodeLabel& in_label, const cGenome& injection) = 0;
   
     

Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc	2006-07-14 18:31:02 UTC (rev 835)
+++ development/source/cpu/cHardwareCPU.cc	2006-07-14 18:42:37 UTC (rev 836)
@@ -969,11 +969,9 @@
   }
   organism->GetPhenotype().IsModified() = true;
   
-  // Adjust all of the heads to take into account the new mem size.
-  
+  // Adjust all of the heads to take into account the new mem size.  
   for (int i = 0; i < nHardware::NUM_HEADS; i++) {    
-    if (!GetHead(i).TestParasite() && GetHead(i).GetPosition() > line_num)
-      GetHead(i).Jump(inject_size);
+    if (GetHead(i).GetPosition() > line_num) GetHead(i).Jump(inject_size);
   }
 }
 
@@ -1046,12 +1044,6 @@
 }
 
 
-int cHardwareCPU::TestParasite() const
-{
-  return IP().TestParasite();
-}
-
-
 bool cHardwareCPU::KillThread()
 {
   // Make sure that there is always at least one thread...
@@ -1535,7 +1527,7 @@
   // If there is no label, jump to line BX in creature.
   if (GetLabel().GetSize() == 0) {
     const int new_pos = GetRegister(nHardwareCPU::REG_BX);
-    IP().Set(new_pos, &other_hardware);
+    IP().Set(new_pos);
     organism->GetPhenotype().IsParasite() = true;
     return true;
   }
@@ -1563,7 +1555,7 @@
   
   // If there is no label, jump to line BX in creature.
   if (GetLabel().GetSize() == 0) {
-    IP().Set(GetRegister(nHardwareCPU::REG_BX), this);
+    IP().Set(GetRegister(nHardwareCPU::REG_BX));
     return true;
   }
   
@@ -1630,7 +1622,7 @@
 bool cHardwareCPU::Inst_HeadPop(cAvidaContext& ctx)
 {
   const int head_used = FindModifiedHead(nHardware::HEAD_IP);
-  GetHead(head_used).Set(StackPop(), this);
+  GetHead(head_used).Set(StackPop());
   return true;
 }
 
@@ -2980,7 +2972,7 @@
 bool cHardwareCPU::Inst_SetFlow(cAvidaContext& ctx)
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_CX);
-  GetHead(nHardware::HEAD_FLOW).Set(GetRegister(reg_used), this);
+  GetHead(nHardware::HEAD_FLOW).Set(GetRegister(reg_used));
 return true; 
 }
 

Modified: development/source/cpu/cHardwareCPU.h
===================================================================
--- development/source/cpu/cHardwareCPU.h	2006-07-14 18:31:02 UTC (rev 835)
+++ development/source/cpu/cHardwareCPU.h	2006-07-14 18:42:37 UTC (rev 836)
@@ -182,6 +182,7 @@
   cHeadCPU& GetHead(int head_id) { return threads[cur_thread].heads[head_id];}
   const cHeadCPU& GetHead(int head_id, int thread) const { return threads[thread].heads[head_id]; }
   cHeadCPU& GetHead(int head_id, int thread) { return threads[thread].heads[head_id];}
+  int GetNumHeads() const { return nHardware::NUM_HEADS; }
   
   const cHeadCPU& IP() const { return threads[cur_thread].heads[nHardware::HEAD_IP]; }
   cHeadCPU& IP() { return threads[cur_thread].heads[nHardware::HEAD_IP]; }
@@ -197,7 +198,7 @@
   // --------  Memory Manipulation  --------
   const cCPUMemory& GetMemory() const { return memory; }
   cCPUMemory& GetMemory() { return memory; }
-  const cCPUMemory& GetMemory(int value) const { return memory;}
+  const cCPUMemory& GetMemory(int value) const { return memory; }
   cCPUMemory& GetMemory(int value) { return memory; }
   
   
@@ -221,7 +222,6 @@
   
   
   // --------  Parasite Stuff  --------
-  int TestParasite() const;
   bool InjectHost(const cCodeLabel& in_label, const cGenome& injection);
 
   

Modified: development/source/cpu/cHardwareSMT.cc
===================================================================
--- development/source/cpu/cHardwareSMT.cc	2006-07-14 18:31:02 UTC (rev 835)
+++ development/source/cpu/cHardwareSMT.cc	2006-07-14 18:42:37 UTC (rev 836)
@@ -178,7 +178,7 @@
 void cHardwareSMT::cLocalThread::Reset(cHardwareBase* in_hardware, int mem_space)
 {
   for (int i = 0; i < NUM_LOCAL_STACKS; i++) local_stacks[i].Clear();
-  for (int i = 0; i < nHardware::NUM_HEADS; i++) heads[i].Reset(mem_space, in_hardware);
+  for (int i = 0; i < NUM_EXTENDED_HEADS; i++) heads[i].Reset(in_hardware, mem_space);
 	
   cur_head = nHardware::HEAD_IP;
   read_label.Clear();
@@ -403,12 +403,12 @@
 // results.  If direction is 0, search from the beginning of the genome.
 //
 /////////////////////////////////////////////////////////////////////////
-cHeadMultiMem cHardwareSMT::FindLabel(int direction)
+cHeadCPU cHardwareSMT::FindLabel(int direction)
 {
-  cHeadMultiMem& inst_ptr = IP();
+  cHeadCPU& inst_ptr = IP();
 	
   // Start up a search head at the position of the instruction pointer.
-  cHeadMultiMem search_head(inst_ptr);
+  cHeadCPU search_head(inst_ptr);
   cCodeLabel& search_label = GetLabel();
 	
   // Make sure the label is of size  > 0.
@@ -602,7 +602,7 @@
 }
 
 // Search for 'in_label' anywhere in the hardware.
-cHeadMultiMem cHardwareSMT::FindLabel(const cCodeLabel& in_label, int direction)
+cHeadCPU cHardwareSMT::FindLabel(const cCodeLabel& in_label, int direction)
 {
   assert (in_label.GetSize() > 0);
 	
@@ -613,7 +613,7 @@
   // FOR NOW:
   // Get something which works, no matter how inefficient!!!
 	
-  cHeadMultiMem temp_head(this);
+  cHeadCPU temp_head(this);
 	
   while (temp_head.InMemory()) {
     // IDEALY: Analyze the label we are in; see if the one we are looking
@@ -640,11 +640,11 @@
 
 // @CAO: direction is not currently used; should be used to indicate the
 // direction which the heads[nHardware::HEAD_IP] should progress through a creature.
-cHeadMultiMem cHardwareSMT::FindFullLabel(const cCodeLabel & in_label)
+cHeadCPU cHardwareSMT::FindFullLabel(const cCodeLabel & in_label)
 {
   assert(in_label.GetSize() > 0); // Trying to find label of 0 size!
 	
-  cHeadMultiMem temp_head(this);
+  cHeadCPU temp_head(this);
 	
   while (temp_head.InMemory()) {
     // If we are not in a label, jump to the next checkpoint...
@@ -725,7 +725,7 @@
   // reset the memory space that was injected
   m_mem_array[mem_space_used] = cGenome("a"); 
 	
-  for (int x = 0; x < nHardware::NUM_HEADS; x++) GetHead(x).Reset(IP().GetMemSpace(), this);
+  for (int x = 0; x < nHardware::NUM_HEADS; x++) GetHead(x).Reset(this, IP().GetMemSpace());
   for (int x = 0; x < NUM_LOCAL_STACKS; x++) Stack(x).Clear();
   
   AdvanceIP() = false;
@@ -767,7 +767,7 @@
 void cHardwareSMT::ReadLabel(int max_size)
 {
   int count = 0;
-  cHeadMultiMem& inst_ptr = IP();
+  cHeadCPU& inst_ptr = IP();
 	
   GetLabel().Clear();
 	
@@ -826,13 +826,7 @@
 }
 
 
-int cHardwareSMT::TestParasite() const
-{
-  return IP().TestParasite();
-}
 
-
-
 ////////////////////////////
 //  Instruction Helpers...
 ////////////////////////////
@@ -1059,7 +1053,7 @@
         //this will reset the current thread's heads and stacks.  It will 
         //not touch any other threads or memory spaces (ie: parasites)
 	      for(int x = 0; x < nHardware::NUM_HEADS; x++) {
-					GetHead(x).Reset(0, this);
+					GetHead(x).Reset(this, 0);
 				}
 	      for(int x = 0; x < NUM_LOCAL_STACKS; x++) {
 					Stack(x).Clear();
@@ -1301,7 +1295,7 @@
   const int src = STACK_AX;
 #endif
 
-  cHeadMultiMem & active_head = GetHead(head_id);
+  cHeadCPU & active_head = GetHead(head_id);
   int mem_space_used = active_head.GetMemSpace();
   
   if(active_head.GetPosition() >= m_mem_array[mem_space_used].GetSize() - 1)
@@ -1313,7 +1307,7 @@
   active_head.Adjust();
 	
   int value = Stack(src).Pop();
-  if (value < 0 || value >= m_inst_set->GetSize()) value = NOPX;
+  if (value < 0 || value >= m_inst_set->GetSize()) value = 0;
 	
   active_head.SetInst(cInstruction(value));
   active_head.SetFlagCopied();
@@ -1397,7 +1391,7 @@
 #else
   const int src = STACK_BX;
 #endif
-  GetHead(head_used).Set(Stack(src).Pop(), GetHead(head_used).GetMemSpace(), this);
+  GetHead(head_used).Set(Stack(src).Pop(), GetHead(head_used).GetMemSpace());
   return true;
 }
 
@@ -1422,10 +1416,10 @@
 {
   ReadLabel();
   GetLabel().Rotate(2, NUM_NOPS);
-  cHeadMultiMem found_pos = FindLabel(0);
+  cHeadCPU found_pos = FindLabel(0);
   if(found_pos.GetPosition() - IP().GetPosition() == 0)
 	{
-		GetHead(nHardware::HEAD_FLOW).Set(IP().GetPosition() + 1, IP().GetMemSpace(), this);
+		GetHead(nHardware::HEAD_FLOW).Set(IP().GetPosition() + 1, IP().GetMemSpace());
 		// pushing zero into STACK_AX on a missed search makes it difficult to create
 		// a self-replicating organism.  @law
 		Stack(STACK_BX).Push(0);
@@ -1664,7 +1658,7 @@
   
   Stack(dst).Push(ra);
   
-  cHeadMultiMem& flow = GetHead(nHardware::HEAD_FLOW);
+  cHeadCPU& flow = GetHead(nHardware::HEAD_FLOW);
   IP().Set(flow.GetPosition(), flow.GetMemSpace());
   
   return true;
@@ -1683,6 +1677,7 @@
   
   ReadLabel(MAX_MEMSPACE_LABEL);
   
+  // If a label was specified, call target label
   if (GetLabel().GetSize() != 0) {
     int mem_space_used = FindMemorySpaceLabel(GetLabel(), -1);
     if (mem_space_used > -1) {
@@ -1690,9 +1685,14 @@
       IP().Set(0, mem_space_used);
       return true;
     }
+    return false;
   }
-  
-  return false;
+
+  // Default to calling the flow head
+  cHeadCPU& flow = GetHead(nHardware::HEAD_FLOW);
+  IP().Set(flow.GetPosition(), flow.GetMemSpace());
+
+  return true;
 }
 
 //47

Modified: development/source/cpu/cHardwareSMT.h
===================================================================
--- development/source/cpu/cHardwareSMT.h	2006-07-14 18:31:02 UTC (rev 835)
+++ development/source/cpu/cHardwareSMT.h	2006-07-14 18:42:37 UTC (rev 836)
@@ -23,8 +23,8 @@
 #ifndef cCPUStack_h
 #include "cCPUStack.h"
 #endif
-#ifndef cHeadMultiMem_h
-#include "cHeadMultiMem.h"
+#ifndef cHeadCPU_h
+#include "cHeadCPU.h"
 #endif
 #ifndef cHardwareBase_h
 #include "cHardwareBase.h"
@@ -54,9 +54,9 @@
   static const int NUM_GLOBAL_STACKS = 1;
   static const int NUM_STACKS = NUM_LOCAL_STACKS + NUM_GLOBAL_STACKS;
   static const int NUM_NOPS = 4;
-  static const int NOPX = 4;
   static const int MAX_MEMSPACE_LABEL = 3;
   static const int MAX_THREAD_LABEL = 3;
+  static const int NUM_EXTENDED_HEADS = nHardware::NUM_HEADS + NUM_NOPS;
 
   enum tStacks { STACK_AX = 0, STACK_BX, STACK_CX, STACK_DX };
   
@@ -68,7 +68,7 @@
   class cLocalThread
   {
   public:
-    cHeadMultiMem heads[nHardware::NUM_HEADS];
+    cHeadCPU heads[NUM_EXTENDED_HEADS];
     unsigned char cur_head;
     cCPUStack local_stacks[NUM_LOCAL_STACKS];
     
@@ -143,11 +143,11 @@
   
   // --------  Label Manipulation  -------
   void ReadLabel(int max_size=nHardware::MAX_LABEL_SIZE);
-  cHeadMultiMem FindLabel(int direction);
+  cHeadCPU FindLabel(int direction);
   int FindLabel_Forward(const cCodeLabel& search_label, const cGenome& search_genome, int pos);
   int FindLabel_Backward(const cCodeLabel& search_label, const cGenome& search_genome, int pos);
-  cHeadMultiMem FindLabel(const cCodeLabel& in_label, int direction);
-  cHeadMultiMem FindFullLabel(const cCodeLabel& in_label);
+  cHeadCPU FindLabel(const cCodeLabel& in_label, int direction);
+  cHeadCPU FindFullLabel(const cCodeLabel& in_label);
   const cCodeLabel& GetReadLabel() const { return m_threads[m_cur_thread].read_label; }
   cCodeLabel& GetReadLabel() { return m_threads[m_cur_thread].read_label; }
 
@@ -209,15 +209,16 @@
 	
 
   // --------  Head Manipulation (including IP)  --------
-  const cHeadMultiMem& GetHead(int head_id) const { return m_threads[m_cur_thread].heads[head_id]; }
-  cHeadMultiMem& GetHead(int head_id) { return m_threads[m_cur_thread].heads[head_id];}
-  const cHeadMultiMem& GetHead(int head_id, int thread) const { return m_threads[thread].heads[head_id]; }
-  cHeadMultiMem& GetHead(int head_id, int thread) { return m_threads[thread].heads[head_id];}
+  const cHeadCPU& GetHead(int head_id) const { return m_threads[m_cur_thread].heads[head_id]; }
+  cHeadCPU& GetHead(int head_id) { return m_threads[m_cur_thread].heads[head_id];}
+  const cHeadCPU& GetHead(int head_id, int thread) const { return m_threads[thread].heads[head_id]; }
+  cHeadCPU& GetHead(int head_id, int thread) { return m_threads[thread].heads[head_id];}
+  int GetNumHeads() const { return NUM_EXTENDED_HEADS; }
 	
-  const cHeadMultiMem& IP() const { return m_threads[m_cur_thread].heads[nHardware::HEAD_IP]; }
-  cHeadMultiMem& IP() { return m_threads[m_cur_thread].heads[nHardware::HEAD_IP]; }
-  const cHeadMultiMem& IP(int thread) const { return m_threads[thread].heads[nHardware::HEAD_IP]; }
-  cHeadMultiMem& IP(int thread) { return m_threads[thread].heads[nHardware::HEAD_IP]; }
+  const cHeadCPU& IP() const { return m_threads[m_cur_thread].heads[nHardware::HEAD_IP]; }
+  cHeadCPU& IP() { return m_threads[m_cur_thread].heads[nHardware::HEAD_IP]; }
+  const cHeadCPU& IP(int thread) const { return m_threads[thread].heads[nHardware::HEAD_IP]; }
+  cHeadCPU& IP(int thread) { return m_threads[thread].heads[nHardware::HEAD_IP]; }
 	  
   
   // --------  Label Manipulation  -------
@@ -252,7 +253,6 @@
   
   
   // --------  Parasite Stuff  --------
-  int TestParasite() const;
   bool InjectHost(const cCodeLabel& in_label, const cGenome& inject_code);
 	
   

Modified: development/source/cpu/cHardwareTransSMT.cc
===================================================================
--- development/source/cpu/cHardwareTransSMT.cc	2006-07-14 18:31:02 UTC (rev 835)
+++ development/source/cpu/cHardwareTransSMT.cc	2006-07-14 18:42:37 UTC (rev 836)
@@ -178,7 +178,7 @@
 void cHardwareTransSMT::cLocalThread::Reset(cHardwareBase* in_hardware, int mem_space)
 {
   for (int i = 0; i < NUM_LOCAL_STACKS; i++) local_stacks[i].Clear();
-  for (int i = 0; i < nHardware::NUM_HEADS; i++) heads[i].Reset(mem_space, in_hardware);
+  for (int i = 0; i < nHardware::NUM_HEADS; i++) heads[i].Reset(in_hardware, mem_space);
 	
   cur_head = nHardware::HEAD_IP;
   read_label.Clear();
@@ -403,12 +403,12 @@
 // results.  If direction is 0, search from the beginning of the genome.
 //
 /////////////////////////////////////////////////////////////////////////
-cHeadMultiMem cHardwareTransSMT::FindLabel(int direction)
+cHeadCPU cHardwareTransSMT::FindLabel(int direction)
 {
-  cHeadMultiMem& inst_ptr = IP();
+  cHeadCPU& inst_ptr = IP();
 	
   // Start up a search head at the position of the instruction pointer.
-  cHeadMultiMem search_head(inst_ptr);
+  cHeadCPU search_head(inst_ptr);
   cCodeLabel& search_label = GetLabel();
 	
   // Make sure the label is of size  > 0.
@@ -602,7 +602,7 @@
 }
 
 // Search for 'in_label' anywhere in the hardware.
-cHeadMultiMem cHardwareTransSMT::FindLabel(const cCodeLabel& in_label, int direction)
+cHeadCPU cHardwareTransSMT::FindLabel(const cCodeLabel& in_label, int direction)
 {
   assert (in_label.GetSize() > 0);
 	
@@ -613,7 +613,7 @@
   // FOR NOW:
   // Get something which works, no matter how inefficient!!!
 	
-  cHeadMultiMem temp_head(this);
+  cHeadCPU temp_head(this);
 	
   while (temp_head.InMemory()) {
     // IDEALY: Analyze the label we are in; see if the one we are looking
@@ -640,11 +640,11 @@
 
 // @CAO: direction is not currently used; should be used to indicate the
 // direction which the heads[nHardware::HEAD_IP] should progress through a creature.
-cHeadMultiMem cHardwareTransSMT::FindFullLabel(const cCodeLabel & in_label)
+cHeadCPU cHardwareTransSMT::FindFullLabel(const cCodeLabel & in_label)
 {
   assert(in_label.GetSize() > 0); // Trying to find label of 0 size!
 	
-  cHeadMultiMem temp_head(this);
+  cHeadCPU temp_head(this);
 	
   while (temp_head.InMemory()) {
     // If we are not in a label, jump to the next checkpoint...
@@ -725,7 +725,7 @@
   // reset the memory space that was injected
   m_mem_array[mem_space_used] = cGenome("a"); 
 	
-  for (int x = 0; x < nHardware::NUM_HEADS; x++) GetHead(x).Reset(IP().GetMemSpace(), this);
+  for (int x = 0; x < nHardware::NUM_HEADS; x++) GetHead(x).Reset(this, IP().GetMemSpace());
   for (int x = 0; x < NUM_LOCAL_STACKS; x++) Stack(x).Clear();
   
   AdvanceIP() = false;
@@ -767,7 +767,7 @@
 void cHardwareTransSMT::ReadLabel(int max_size)
 {
   int count = 0;
-  cHeadMultiMem& inst_ptr = IP();
+  cHeadCPU& inst_ptr = IP();
 	
   GetLabel().Clear();
 	
@@ -826,13 +826,7 @@
 }
 
 
-int cHardwareTransSMT::TestParasite() const
-{
-  return IP().TestParasite();
-}
 
-
-
 ////////////////////////////
 //  Instruction Helpers...
 ////////////////////////////
@@ -1059,7 +1053,7 @@
         //this will reset the current thread's heads and stacks.  It will 
         //not touch any other threads or memory spaces (ie: parasites)
 	      for(int x = 0; x < nHardware::NUM_HEADS; x++) {
-					GetHead(x).Reset(0, this);
+					GetHead(x).Reset(this, 0);
 				}
 	      for(int x = 0; x < NUM_LOCAL_STACKS; x++) {
 					Stack(x).Clear();
@@ -1301,7 +1295,7 @@
   const int src = STACK_AX;
 #endif
 
-  cHeadMultiMem & active_head = GetHead(head_id);
+  cHeadCPU & active_head = GetHead(head_id);
   int mem_space_used = active_head.GetMemSpace();
   
   if(active_head.GetPosition() >= m_mem_array[mem_space_used].GetSize() - 1)
@@ -1397,7 +1391,7 @@
 #else
   const int src = STACK_BX;
 #endif
-  GetHead(head_used).Set(Stack(src).Pop(), GetHead(head_used).GetMemSpace(), this);
+  GetHead(head_used).Set(Stack(src).Pop(), GetHead(head_used).GetMemSpace());
   return true;
 }
 
@@ -1422,10 +1416,10 @@
 {
   ReadLabel();
   GetLabel().Rotate(2, NUM_NOPS);
-  cHeadMultiMem found_pos = FindLabel(0);
+  cHeadCPU found_pos = FindLabel(0);
   if(found_pos.GetPosition() - IP().GetPosition() == 0)
 	{
-		GetHead(nHardware::HEAD_FLOW).Set(IP().GetPosition() + 1, IP().GetMemSpace(), this);
+		GetHead(nHardware::HEAD_FLOW).Set(IP().GetPosition() + 1, IP().GetMemSpace());
 		// pushing zero into STACK_AX on a missed search makes it difficult to create
 		// a self-replicating organism.  @law
 		Stack(STACK_BX).Push(0);
@@ -1664,7 +1658,7 @@
   
   Stack(dst).Push(ra);
   
-  cHeadMultiMem& flow = GetHead(nHardware::HEAD_FLOW);
+  cHeadCPU& flow = GetHead(nHardware::HEAD_FLOW);
   IP().Set(flow.GetPosition(), flow.GetMemSpace());
   
   return true;

Modified: development/source/cpu/cHardwareTransSMT.h
===================================================================
--- development/source/cpu/cHardwareTransSMT.h	2006-07-14 18:31:02 UTC (rev 835)
+++ development/source/cpu/cHardwareTransSMT.h	2006-07-14 18:42:37 UTC (rev 836)
@@ -23,8 +23,8 @@
 #ifndef cCPUStack_h
 #include "cCPUStack.h"
 #endif
-#ifndef cHeadMultiMem_h
-#include "cHeadMultiMem.h"
+#ifndef cHeadCPU_h
+#include "cHeadCPU.h"
 #endif
 #ifndef cHardwareBase_h
 #include "cHardwareBase.h"
@@ -68,7 +68,7 @@
   class cLocalThread
   {
   public:
-    cHeadMultiMem heads[nHardware::NUM_HEADS];
+    cHeadCPU heads[nHardware::NUM_HEADS];
     unsigned char cur_head;
     cCPUStack local_stacks[NUM_LOCAL_STACKS];
     
@@ -143,11 +143,11 @@
   
   // --------  Label Manipulation  -------
   void ReadLabel(int max_size=nHardware::MAX_LABEL_SIZE);
-  cHeadMultiMem FindLabel(int direction);
+  cHeadCPU FindLabel(int direction);
   int FindLabel_Forward(const cCodeLabel& search_label, const cGenome& search_genome, int pos);
   int FindLabel_Backward(const cCodeLabel& search_label, const cGenome& search_genome, int pos);
-  cHeadMultiMem FindLabel(const cCodeLabel& in_label, int direction);
-  cHeadMultiMem FindFullLabel(const cCodeLabel& in_label);
+  cHeadCPU FindLabel(const cCodeLabel& in_label, int direction);
+  cHeadCPU FindFullLabel(const cCodeLabel& in_label);
   const cCodeLabel& GetReadLabel() const { return m_threads[m_cur_thread].read_label; }
   cCodeLabel& GetReadLabel() { return m_threads[m_cur_thread].read_label; }
 
@@ -209,15 +209,16 @@
 	
 
   // --------  Head Manipulation (including IP)  --------
-  const cHeadMultiMem& GetHead(int head_id) const { return m_threads[m_cur_thread].heads[head_id]; }
-  cHeadMultiMem& GetHead(int head_id) { return m_threads[m_cur_thread].heads[head_id];}
-  const cHeadMultiMem& GetHead(int head_id, int thread) const { return m_threads[thread].heads[head_id]; }
-  cHeadMultiMem& GetHead(int head_id, int thread) { return m_threads[thread].heads[head_id];}
+  const cHeadCPU& GetHead(int head_id) const { return m_threads[m_cur_thread].heads[head_id]; }
+  cHeadCPU& GetHead(int head_id) { return m_threads[m_cur_thread].heads[head_id];}
+  const cHeadCPU& GetHead(int head_id, int thread) const { return m_threads[thread].heads[head_id]; }
+  cHeadCPU& GetHead(int head_id, int thread) { return m_threads[thread].heads[head_id];}
+  int GetNumHeads() const { return nHardware::NUM_HEADS; }
 	
-  const cHeadMultiMem& IP() const { return m_threads[m_cur_thread].heads[nHardware::HEAD_IP]; }
-  cHeadMultiMem& IP() { return m_threads[m_cur_thread].heads[nHardware::HEAD_IP]; }
-  const cHeadMultiMem& IP(int thread) const { return m_threads[thread].heads[nHardware::HEAD_IP]; }
-  cHeadMultiMem& IP(int thread) { return m_threads[thread].heads[nHardware::HEAD_IP]; }
+  const cHeadCPU& IP() const { return m_threads[m_cur_thread].heads[nHardware::HEAD_IP]; }
+  cHeadCPU& IP() { return m_threads[m_cur_thread].heads[nHardware::HEAD_IP]; }
+  const cHeadCPU& IP(int thread) const { return m_threads[thread].heads[nHardware::HEAD_IP]; }
+  cHeadCPU& IP(int thread) { return m_threads[thread].heads[nHardware::HEAD_IP]; }
 	  
   
   // --------  Label Manipulation  -------
@@ -252,7 +253,6 @@
   
   
   // --------  Parasite Stuff  --------
-  int TestParasite() const;
   bool InjectHost(const cCodeLabel& in_label, const cGenome& inject_code);
 	
   

Modified: development/source/cpu/cHeadCPU.cc
===================================================================
--- development/source/cpu/cHeadCPU.cc	2006-07-14 18:31:02 UTC (rev 835)
+++ development/source/cpu/cHeadCPU.cc	2006-07-14 18:42:37 UTC (rev 836)
@@ -10,96 +10,49 @@
 
 #include "cHeadCPU.h"
 
-#include "cCPUMemory.h"
 #include "cCodeLabel.h"
 #include "cGenome.h"
-#include "cHardwareBase.h"
-#include "cInstSet.h"
 #include "cInstruction.h"
 #include "cStringUtil.h"
 
 #include <assert.h>
 
-cHeadCPU::cHeadCPU() {
-  main_hardware = NULL;
-  cur_hardware = NULL;
-  position = 0;
-}
 
-cHeadCPU::cHeadCPU(cHardwareBase * in_hardware, int in_pos) {
-  main_hardware = in_hardware;
-  cur_hardware  = in_hardware;
-  
-  position = in_pos;
-  if (in_pos) Adjust();
-}
-
-cHeadCPU::cHeadCPU(const cHeadCPU & in_cpu_head) {
-  main_hardware = in_cpu_head.main_hardware;
-  cur_hardware  = in_cpu_head.cur_hardware;
-  position = in_cpu_head.position;
-}
-
-
-
 void cHeadCPU::Adjust()
 {
-  assert(cur_hardware != NULL);
-  assert(main_hardware != NULL);
+  const int mem_size = GetMemory().GetSize();
   
-  const int mem_size = cur_hardware->GetMemory().GetSize();
-  
   // If we are still in range, stop here!
-  if (position >= 0 && position < mem_size) return;
+  if (m_position >= 0 && m_position < mem_size) return;
   
   // If the memory is gone, just stick it at the begining of its parent.
-  if (mem_size == 0) {
-    cur_hardware = main_hardware;
-    position = 0;
-  }
-  else if (position <= 0) { position = 0; }
-  else if (position >= mem_size) {
-    // Always loop into the begining of the owner hardware.
-    cur_hardware = main_hardware;
-    position -= mem_size;
-    while (position >= GetMemory().GetSize()) {
-      // position back at the begining of the creature.
-      position %= GetMemory().GetSize();
-    }
-  }
+  if (mem_size == 0 || m_position < 0) m_position = 0;
   
+  // position back at the begining of the creature as necessary.
+  m_position %= GetMemory().GetSize();
 }
 
 
+/*
+ FindLabel(direction)
 
-/////////////////////////////////////////////////////////////////////////
-// Method: cHeadCPU::FindLabel(direction)
-//
-// Search in 'direction' (+ or - 1) from this head for the compliment of
-//  the label in 'next_label' and return a head to the resulting pos.
-//
-/////////////////////////////////////////////////////////////////////////
-
-cHeadCPU cHeadCPU::FindLabel(const cCodeLabel & label, int direction)
+ Search in 'direction' (+ or - 1) from this head for the compliment of
+ the label in 'next_label' and return a head to the resulting pos.
+*/
+cHeadCPU cHeadCPU::FindLabel(const cCodeLabel& label, int direction)
 {
   // Make sure the label is of size > 0.
-  if (label.GetSize() == 0) {
-    return *this;
-  }
+  if (label.GetSize() == 0) return *this;
   
   int found_pos = -1;
   
   // Call special functions depending on if jump is forwards or backwards.
-  if( direction < 0 ) {
-    found_pos =
-    FindLabel_Backward(label, GetMemory(), GetPosition() - label.GetSize());
+  if (direction < 0) {
+    found_pos = FindLabel_Backward(label, GetMemory(), m_position - label.GetSize());
+  } else {
+    found_pos = FindLabel_Forward(label, GetMemory(), m_position);
   }
   
-  // Jump forwards.
-  else {
-    found_pos = FindLabel_Forward(label, GetMemory(), GetPosition());
-  }
-  
   if (found_pos >= 0) {
     // Return the last line of the found label, or the starting point.
     cHeadCPU search_head(*this);
@@ -111,236 +64,21 @@
   return *this;
 }
 
-void cHeadCPU::Reset(cHardwareBase * new_hardware) {
-  if (new_hardware) main_hardware = new_hardware;
-  cur_hardware  = new_hardware;
-  position = 0;
-}
+/*
+ FindLabel_Forward
 
-void cHeadCPU::Set(int new_pos, cHardwareBase * in_hardware)
-{
-  position = new_pos;
-  if (in_hardware) cur_hardware = in_hardware;
-  Adjust();
-}
-
-
-void cHeadCPU::Jump(int jump)
-{
-  position += jump;
-  Adjust();
-}
-
-void cHeadCPU::LoopJump(int jump)
-{
-  position += jump;
-  
-  // If we are out of range, bring back in.
-  if (position < 0 || position >= GetMemory().GetSize()) {
-    position %= GetMemory().GetSize();
-    if (position <= 0) position += GetMemory().GetSize();
-  }
-}
-
-void cHeadCPU::AbsJump(int jump)
-{
-  position += jump;
-}
-
-void cHeadCPU::Advance()
-{
-  position++;
-  Adjust();
-}
-
-void cHeadCPU::Retreat()
-{
-  position--;
-  Adjust();
-}
-
-
-const cCPUMemory & cHeadCPU::GetMemory() const
-{
-  assert(cur_hardware != NULL);
-  return cur_hardware->GetMemory();
-}
-
-
-const cInstruction & cHeadCPU::GetInst() const
-{
-  assert(position >= 0);
-  assert(position < GetMemory().GetSize());
-  return GetMemory()[position];
-}
-
-const cInstruction & cHeadCPU::GetInst(int offset) const {
-  int new_pos = position + offset;
-  
-  return GetMemory()[new_pos];
-}
-
-
-void cHeadCPU::SetInst(const cInstruction & value)
-{
-  assert(cur_hardware != NULL);
-#if WRITE_PROTECTION
-  if (main_hardware == cur_hardware) cur_hardware->GetMemory()[position] = value;
-#else
-  cur_hardware->GetMemory()[position] = value;
-  if (main_hardware != cur_hardware) cur_hardware->SetModified();
-#endif
-}
-
-
-void cHeadCPU::InsertInst(const cInstruction & value)
-{
-  assert(cur_hardware != NULL);
-#if WRITE_PROTECTION
-  if (main_hardware == cur_hardware) cur_hardware->GetMemory().Insert(position, value);
-#else
-  cur_hardware->GetMemory().Insert(position, value);
-  if (main_hardware != cur_hardware) cur_hardware->SetModified();
-#endif
-}
-
-void cHeadCPU::RemoveInst()
-{
-  assert(cur_hardware != NULL);
-#if WRITE_PROTECTION
-  if (main_hardware == cur_hardware) cur_hardware->GetMemory().Remove(position);
-#else
-  cur_hardware->GetMemory().Remove(position);
-  if (main_hardware != cur_hardware) cur_hardware->SetModified();
-#endif
-}
-
-const cInstruction & cHeadCPU::GetNextInst()
-{
-  return (AtEnd()) ? cInstSet::GetInstError() : GetMemory()[position+1];
-}
-
-
-
-void cHeadCPU::SetFlagCopied()
-{
-  assert(cur_hardware != NULL);
-  return cur_hardware->GetMemory().SetFlagCopied(position);     
-}
-
-void cHeadCPU::SetFlagMutated()
-{
-  assert(cur_hardware != NULL);
-  return cur_hardware->GetMemory().SetFlagMutated(position);    
-}
-
-void cHeadCPU::SetFlagExecuted()
-{
-  assert(cur_hardware != NULL);
-  return cur_hardware->GetMemory().SetFlagExecuted(position);   
-}
-
-void cHeadCPU::SetFlagBreakpoint()
-{
-  assert(cur_hardware != NULL);
-  return cur_hardware->GetMemory().SetFlagBreakpoint(position); 
-}
-
-void cHeadCPU::SetFlagPointMut()
-{
-  assert(cur_hardware != NULL);
-  return cur_hardware->GetMemory().SetFlagPointMut(position);   
-}
-
-void cHeadCPU::SetFlagCopyMut()
-{
-  assert(cur_hardware != NULL);
-  return cur_hardware->GetMemory().SetFlagCopyMut(position);    
-}
-
-void cHeadCPU::ClearFlagCopied()
-{
-  assert(cur_hardware != NULL);
-  return cur_hardware->GetMemory().ClearFlagCopied(position);    
-}
-
-void cHeadCPU::ClearFlagMutated()
-{
-  assert(cur_hardware != NULL);
-  return cur_hardware->GetMemory().ClearFlagMutated(position);    
-}
-
-void cHeadCPU::ClearFlagExecuted()
-{
-  assert(cur_hardware != NULL);
-  return cur_hardware->GetMemory().ClearFlagExecuted(position);    
-}
-
-void cHeadCPU::ClearFlagBreakpoint()
-{
-  assert(cur_hardware != NULL);
-  return cur_hardware->GetMemory().ClearFlagBreakpoint(position);    
-}
-
-void cHeadCPU::ClearFlagPointMut()
-{
-  assert(cur_hardware != NULL);
-  return cur_hardware->GetMemory().ClearFlagPointMut(position);    
-}
-
-void cHeadCPU::ClearFlagCopyMut()
-{
-  assert(cur_hardware != NULL);
-  return cur_hardware->GetMemory().ClearFlagCopyMut(position);    
-}
-
-cHeadCPU & cHeadCPU::operator=(const cHeadCPU & in_cpu_head)
-{
-  main_hardware = in_cpu_head.main_hardware;
-  cur_hardware  = in_cpu_head.cur_hardware;
-  position = in_cpu_head.position;
-  return *this;
-}
-
-
-cHeadCPU & cHeadCPU::operator++()
-{
-  position++;
-  Adjust();
-  return *this;
-}
-
-cHeadCPU & cHeadCPU::operator--()
-{
-  position--;
-  Adjust();
-  return *this;
-}
-
-cHeadCPU & cHeadCPU::operator++(int)
-{
-  return operator++();
-}
-
-cHeadCPU & cHeadCPU::operator--(int)
-{
-  return operator--();
-}
-
-
-// Search forwards for search_label from _after_ position pos in the
-// memory.  Return the first line _after_ the the found label.  It is okay
-// to find search label's match inside another label.
-
-int cHeadCPU::FindLabel_Forward(const cCodeLabel & search_label,
-                                const cGenome & search_mem, int pos)
+ Search forwards for search_label from _after_ position pos in the
+ memory.  Return the first line _after_ the the found label.  It is okay
+ to find search label's match inside another label.
+*/
+int cHeadCPU::FindLabel_Forward(const cCodeLabel& search_label, const cGenome& search_mem, int pos)
 { 
-  assert (pos < search_mem.GetSize() && pos >= 0);
+  assert(pos < search_mem.GetSize() && pos >= 0);
   
   int search_start = pos;
   int label_size = search_label.GetSize();
   bool found_label = false;
-  const cInstSet & inst_set = main_hardware->GetInstSet();
+  const cInstSet& inst_set = m_hardware->GetInstSet();
   
   // Move off the template we are on.
   pos += label_size;
@@ -409,19 +147,22 @@
   return pos;
 }
 
-// Search backwards for search_label from _before_ position pos in the
-// memory.  Return the first line _after_ the the found label.  It is okay
-// to find search label's match inside another label.
 
-int cHeadCPU::FindLabel_Backward(const cCodeLabel & search_label,
-                                 const cGenome & search_mem, int pos)
+/*
+ FindLabel_Backward
+ 
+ Search backwards for search_label from _before_ position pos in the
+ memory.  Return the first line _after_ the the found label.  It is okay
+ to find search label's match inside another label.
+*/
+int cHeadCPU::FindLabel_Backward(const cCodeLabel& search_label, const cGenome& search_mem, int pos)
 { 
-  assert (pos < search_mem.GetSize());
+  assert(pos < search_mem.GetSize());
   
   int search_start = pos;
   int label_size = search_label.GetSize();
   bool found_label = false;
-  const cInstSet & inst_set = main_hardware->GetInstSet();
+  const cInstSet& inst_set = m_hardware->GetInstSet();
   
   // Move off the template we are on.
   pos -= label_size;
@@ -487,29 +228,3 @@
   
   return pos;
 }
-
-bool cHeadCPU::operator==(const cHeadCPU & in_cpu_head) const {
-  return (cur_hardware == in_cpu_head.cur_hardware) &&
-  (position == in_cpu_head.position);
-}
-
-bool cHeadCPU::AtEnd() const
-{
-  return (position + 1 == GetMemory().GetSize());
-}
-
-bool cHeadCPU::InMemory() const
-{
-  return (position >= 0 && position < GetMemory().GetSize());
-}
-
-int cHeadCPU::TestParasite() const
-{
-  // If CPU has a head in another creature, mark it as a parasite.
-  return (cur_hardware != main_hardware);
-}
-
-cString cHeadCPU::GetPositionString() const
-{
-  return cStringUtil::Stringf("%2d", position);
-}

Modified: development/source/cpu/cHeadCPU.h
===================================================================
--- development/source/cpu/cHeadCPU.h	2006-07-14 18:31:02 UTC (rev 835)
+++ development/source/cpu/cHeadCPU.h	2006-07-14 18:42:37 UTC (rev 836)
@@ -11,6 +11,15 @@
 #ifndef cHeadCPU_h
 #define cHeadCPU_h
 
+#ifndef cCPUMemory_h
+#include "cCPUMemory.h"
+#endif
+#ifndef cHardwareBase_h
+#include "cHardwareBase.h"
+#endif
+#ifndef cInstSet_h
+#include "cInstSet.h"
+#endif
 #ifndef defs_h
 #include "defs.h"
 #endif
@@ -19,9 +28,7 @@
  * The cHeadCPU class contains a pointer to locations in memory for a CPU.
  **/
 
-class cHardwareBase;
 class cCodeLabel;
-class cCPUMemory;
 class cGenome;
 class cInstruction;
 class cString;
@@ -29,105 +36,120 @@
 class cHeadCPU
 {
 protected:
-  cHardwareBase* main_hardware;
-  cHardwareBase* cur_hardware;
-  int position;
+  cHardwareBase* m_hardware;
+  int m_position;
+  int m_mem_space;
 
   int FindLabel_Forward(const cCodeLabel& search_label, const cGenome& search_mem, int pos);
   int FindLabel_Backward(const cCodeLabel& search_label, const cGenome& search_mem, int pos);
+  
 
 public:
-  cHeadCPU();
-  cHeadCPU(cHardwareBase* in_hardware, int in_pos = 0);
-  cHeadCPU(const cHeadCPU& in_cpu_head);
-  virtual ~cHeadCPU() { ; }
+  inline cHeadCPU(cHardwareBase* hw = NULL, int pos = 0, int ms = 0);
+  inline cHeadCPU(const cHeadCPU& in_cpu_head);
+  ~cHeadCPU() { ; }
   
-  /**
-   * This function keeps the position within the range of the current memory.
-   **/
-  virtual void Adjust();
-
-  virtual void Reset(cHardwareBase * new_hardware = NULL);
+  inline const cCPUMemory& GetMemory() const { return m_hardware->GetMemory(m_mem_space); }
+  inline cCPUMemory& GetMemory() { return m_hardware->GetMemory(m_mem_space); }
   
-  /**
-   * Set the new position of the head (and adjust it into range in Set()).
-   **/
+  inline int GetMemSpace() const { return m_mem_space; }
 
-  virtual void Set(int new_pos, cHardwareBase * in_hardware = NULL);
+  void Adjust();
+  inline void Reset(cHardwareBase* hw, int ms = 0) { m_hardware = hw; m_position = 0; m_mem_space = ms; }
   
-  void AbsSet(int new_pos) { position = new_pos; }
-  
-  virtual void Set(const cHeadCPU & in_head) {
-    position = in_head.position;
-    cur_hardware  = in_head.cur_hardware;
-  }
+  inline void Set(int pos, int ms = 0) { m_position = pos; m_mem_space = ms; Adjust(); }
+  inline void Set(const cHeadCPU& in_head) { m_position = in_head.m_position; m_mem_space = in_head.m_mem_space; }
+  inline void AbsSet(int new_pos) { m_position = new_pos; }
 
-  /**
-   * Increment the new position of the head by 'jump'.
-   **/
-
-  void Jump(int jump);
-  virtual void LoopJump(int jump);
-  void AbsJump(int jump);
+  inline void Jump(int jump) { m_position += jump; Adjust(); }
+  inline void AbsJump(int jump) { m_position += jump; }
+  inline void LoopJump(int jump);
   
-  // Other manipulation functions.
-  void Advance();
-  void Retreat();
-  cHeadCPU FindLabel(const cCodeLabel & label, int direction=1);
+  inline void Advance() { m_position++; Adjust(); }
+  inline void Retreat() { m_position--; Adjust(); }
+  cHeadCPU FindLabel(const cCodeLabel& label, int direction = 1);
 
-  // Accessors.
-  int GetPosition() const { return position; }
-  virtual const cCPUMemory & GetMemory() const;
-  cHardwareBase * GetCurHardware() const { return cur_hardware; }
-  cHardwareBase * GetMainHardware() const { return main_hardware; }
-  virtual const cInstruction & GetInst() const;
-  virtual const cInstruction & GetInst(int offset) const;
-  // int GetFlag(int id) const;
+  inline int GetPosition() const { return m_position; }
+  inline const cInstruction& GetInst() const { return GetMemory()[m_position]; }
+  inline const cInstruction& GetInst(int offset) const { return GetMemory()[m_position + offset]; }
+  inline const cInstruction& GetNextInst() const;
 
-  virtual void SetInst(const cInstruction & value);
-  virtual void InsertInst(const cInstruction & in_char);
-  virtual void RemoveInst();
-  virtual const cInstruction & GetNextInst();
+  inline void SetInst(const cInstruction& value) { GetMemory()[m_position] = value; }
+  inline void InsertInst(const cInstruction& inst) { GetMemory().Insert(m_position, inst); }
+  inline void RemoveInst() { GetMemory().Remove(m_position); }
 
-  virtual void SetFlagCopied();
-  virtual void SetFlagMutated();
-  virtual void SetFlagExecuted();
-  virtual void SetFlagBreakpoint();
-  virtual void SetFlagPointMut();
-  virtual void SetFlagCopyMut();
+  inline void SetFlagCopied() { return GetMemory().SetFlagCopied(m_position); }
+  inline void SetFlagMutated() { return GetMemory().SetFlagMutated(m_position); }
+  inline void SetFlagExecuted() { return GetMemory().SetFlagExecuted(m_position); }
+  inline void SetFlagBreakpoint() { return GetMemory().SetFlagBreakpoint(m_position); }
+  inline void SetFlagPointMut() { return GetMemory().SetFlagPointMut(m_position); }
+  inline void SetFlagCopyMut() { return GetMemory().SetFlagCopyMut(m_position); }
   
-  virtual void ClearFlagCopied();
-  virtual void ClearFlagMutated();
-  virtual void ClearFlagExecuted();
-  virtual void ClearFlagBreakpoint();
-  virtual void ClearFlagPointMut();
-  virtual void ClearFlagCopyMut();
-    
+  inline void ClearFlagCopied() { return GetMemory().ClearFlagCopied(m_position); }
+  inline void ClearFlagMutated() { return GetMemory().ClearFlagMutated(m_position); }
+  inline void ClearFlagExecuted() { return GetMemory().ClearFlagExecuted(m_position); }
+  inline void ClearFlagBreakpoint() { return GetMemory().ClearFlagBreakpoint(m_position); }
+  inline void ClearFlagPointMut() { return GetMemory().ClearFlagPointMut(m_position); }
+  inline void ClearFlagCopyMut() { return GetMemory().ClearFlagCopyMut(m_position); }
+  
   // Operator Overloading...
-  virtual cHeadCPU& operator=(const cHeadCPU& in_cpu_head);
-  cHeadCPU & operator++();
-  cHeadCPU & operator--();
-  cHeadCPU & operator++(int);
-  cHeadCPU & operator--(int);
+  inline cHeadCPU& operator=(const cHeadCPU& in_cpu_head);
+  inline cHeadCPU& operator++() { m_position++; Adjust(); return *this; }
+  inline cHeadCPU& operator--() { m_position--; Adjust(); return *this; }
+  inline cHeadCPU& operator++(int) { return operator++(); }
+  inline cHeadCPU& operator--(int) { return operator--(); }
+  inline int operator-(const cHeadCPU& in_cpu_head) { return m_position - in_cpu_head.m_position; }
+  inline bool operator==(const cHeadCPU& in_cpu_head) const;
 
-  inline int operator-(const cHeadCPU & in_cpu_head) {
-    if (cur_hardware != in_cpu_head.cur_hardware) return 0;
-    else return position - in_cpu_head.position;
-  }
-  virtual bool operator==(const cHeadCPU & in_cpu_head) const;
-
   // Bool Tests...
-  inline bool AtFront() const { return (position == 0); }
-  virtual bool AtEnd() const;
-  virtual bool InMemory() const;
+  inline bool AtFront() const { return (m_position == 0); }
+  inline bool AtEnd() const { return (m_position + 1 == GetMemory().GetSize()); }
+  inline bool InMemory() const { return (m_position >= 0 && m_position < GetMemory().GetSize()); }
+};
 
-  // Test functions...
-  int TestParasite() const;
+
+inline cHeadCPU::cHeadCPU(cHardwareBase* hw, int pos, int ms) : m_hardware(hw), m_position(pos), m_mem_space(ms)
+{
+  if (pos) Adjust();
+}
+
+inline cHeadCPU::cHeadCPU(const cHeadCPU& in_cpu_head)
+{
+  m_hardware = in_cpu_head.m_hardware;
+  m_position = in_cpu_head.m_position;
+  m_mem_space = in_cpu_head.m_mem_space;
+}
+
+inline void cHeadCPU::LoopJump(int jump)
+{
+  m_position += jump;
   
-  virtual cString GetPositionString() const;
-};
+  // keep in range
+  m_position %= GetMemory().GetSize();
+  if (m_position <= 0) m_position += GetMemory().GetSize();
+}
 
+inline cHeadCPU& cHeadCPU::operator=(const cHeadCPU& in_cpu_head)
+{
+  m_hardware = in_cpu_head.m_hardware;
+  m_position = in_cpu_head.m_position;
+  m_mem_space = in_cpu_head.m_mem_space;
+  return *this;
+}
 
+inline bool cHeadCPU::operator==(const cHeadCPU& in_cpu_head) const
+{
+  return (m_hardware == in_cpu_head.m_hardware) && (m_position == in_cpu_head.m_position) &&
+  (m_mem_space == in_cpu_head.m_mem_space);
+}
+
+inline const cInstruction& cHeadCPU::GetNextInst() const
+{
+  return (AtEnd()) ? cInstSet::GetInstError() : GetMemory()[m_position + 1];
+}
+
+
+
 #ifdef ENABLE_UNIT_TESTS
 namespace nHeadCPU {
   /**

Deleted: development/source/cpu/cHeadMultiMem.cc
===================================================================
--- development/source/cpu/cHeadMultiMem.cc	2006-07-14 18:31:02 UTC (rev 835)
+++ development/source/cpu/cHeadMultiMem.cc	2006-07-14 18:42:37 UTC (rev 836)
@@ -1,248 +0,0 @@
-/*
- *  cHeadMultiMem.cc
- *  Avida
- *
- *  Created by David on 11/30/05.
- *  Copyright 2005-2006 Michigan State University. All rights reserved.
- *  Copyright 1999-2003 California Institute of Technology.
- *
- */
-
-#include "cHeadMultiMem.h"
-
-#include "cCPUMemory.h"
-#include "cHardwareBase.h"
-#include "cInstSet.h"
-#include "cInstruction.h"
-#include "cStringUtil.h"
-
-#include <assert.h>
-
-void cHeadMultiMem::Adjust()
-{
-  assert(cur_hardware != NULL);
-  assert(main_hardware != NULL);
-
-  const int mem_size = GetMemory().GetSize();
-
-  // If we are still in range, stop here!
-  if (position >= 0 && position < mem_size) return;
-
-  // If the memory is gone, just stick it at the begining of its parent.
-  if (mem_size == 0) {
-    cur_hardware = main_hardware;
-    position = 0;
-  }
-  else if (position <= 0) { position = 0; }
-  else if (position >= mem_size) {
-    // Always loop into the begining of the owner hardware.
-    cur_hardware = main_hardware;
-    position -= mem_size;
-    while (position >= GetMemory().GetSize()) {
-      // position back at the begining of the creature.
-      position %= GetMemory().GetSize();
-    }
-  }
-}
-
-void cHeadMultiMem::Reset(int in_mem_space, cHardwareBase * new_hardware)
-{
-  if (new_hardware) main_hardware = new_hardware;
-  cur_hardware  = new_hardware;
-  position = 0;
-  mem_space = in_mem_space;
-}
-
-void cHeadMultiMem::Set(int new_pos, int in_mem_space, cHardwareBase * in_hardware)
-{
-  position = new_pos;
-  if (in_hardware) cur_hardware = in_hardware;
-  mem_space = in_mem_space;
-  Adjust();
-}
-
-void cHeadMultiMem::Set(const cHeadMultiMem & in_head)
-{
-  position = in_head.position;
-  cur_hardware = in_head.cur_hardware;
-  mem_space = in_head.mem_space;
-  Adjust();
-}
-
-void cHeadMultiMem::LoopJump(int jump)
-{
-  position += jump;
-
-  // If we are out of range, bring back in.
-  if (position < 0 || position >= GetMemory().GetSize()) {
-    position %= GetMemory().GetSize();
-    if (position <= 0) position += GetMemory().GetSize();
-  }
-}
-
-const cCPUMemory & cHeadMultiMem::GetMemory() const
-{
-  assert(cur_hardware != NULL);
-  return cur_hardware->GetMemory(mem_space);
-}
-
-cCPUMemory & cHeadMultiMem::GetMemory()
-{
-  assert(cur_hardware != NULL);
-  return cur_hardware->GetMemory(mem_space);
-}
-
-const cInstruction & cHeadMultiMem::GetInst() const
-{
-  assert(position >= 0);
-  assert(position < GetMemory().GetSize());
-  return GetMemory()[position];
-}
-
-const cInstruction & cHeadMultiMem::GetInst(int offset) const 
-{
-  int new_pos = position + offset;
-  return GetMemory()[new_pos];
-}
-
-
-void cHeadMultiMem::SetInst(const cInstruction & value)
-{
-  assert(cur_hardware != NULL);
-#if WRITE_PROTECTION
-  if (main_hardware == cur_hardware) GetMemory()[position] = value;
-#else
-  GetMemory()[position] = value;
-  if (main_hardware != cur_hardware) cur_hardware->SetModified();
-#endif
-}
-
-void cHeadMultiMem::InsertInst(const cInstruction & value)
-{
-  assert(cur_hardware != NULL);
-#if WRITE_PROTECTION
-  if (main_hardware == cur_hardware) GetMemory().Insert(position, value);
-#else
-  GetMemory().Insert(position, value);
-  if (main_hardware != cur_hardware) cur_hardware->SetModified();
-#endif
-}
-
-void cHeadMultiMem::RemoveInst()
-{
-  assert(cur_hardware != NULL);
-#if WRITE_PROTECTION
-  if (main_hardware == cur_hardware) GetMemory().Remove(position);
-#else
-  GetMemory().Remove(position);
-  if (main_hardware != cur_hardware) cur_hardware->SetModified();
-#endif
-}
-
-const cInstruction & cHeadMultiMem::GetNextInst()
-{
-  return (AtEnd()) ? cInstSet::GetInstError() : GetMemory()[position+1];
-}
-
-void cHeadMultiMem::SetFlagCopied()
-{
-  assert(cur_hardware != NULL);
-  GetMemory().SetFlagCopied(position);     
-}
-
-void cHeadMultiMem::SetFlagMutated()
-{
-  assert(cur_hardware != NULL);
-  GetMemory().SetFlagMutated(position);    
-}
-
-void cHeadMultiMem::SetFlagExecuted()
-{
-  assert(cur_hardware != NULL);
-  GetMemory().SetFlagExecuted(position);   
-}
-
-void cHeadMultiMem::SetFlagBreakpoint()
-{
-  assert(cur_hardware != NULL);
-  GetMemory().SetFlagBreakpoint(position); 
-}
-
-void cHeadMultiMem::SetFlagPointMut()
-{
-  assert(cur_hardware != NULL);
-  GetMemory().SetFlagPointMut(position);   
-}
-
-void cHeadMultiMem::SetFlagCopyMut()
-{
-  assert(cur_hardware != NULL);
-  GetMemory().SetFlagCopyMut(position);    
-}
-
-void cHeadMultiMem::ClearFlagCopied()
-{
-  assert(cur_hardware != NULL);
-  GetMemory().ClearFlagCopied(position);     
-}
-
-void cHeadMultiMem::ClearFlagMutated()
-{
-  assert(cur_hardware != NULL);
-  GetMemory().ClearFlagMutated(position);    
-}
-
-void cHeadMultiMem::ClearFlagExecuted()
-{
-  assert(cur_hardware != NULL);
-  GetMemory().ClearFlagExecuted(position);   
-}
-
-void cHeadMultiMem::ClearFlagBreakpoint()
-{
-  assert(cur_hardware != NULL);
-  GetMemory().ClearFlagBreakpoint(position); 
-}
-
-void cHeadMultiMem::ClearFlagPointMut()
-{
-  assert(cur_hardware != NULL);
-  GetMemory().ClearFlagPointMut(position);   
-}
-
-void cHeadMultiMem::ClearFlagCopyMut()
-{
-  assert(cur_hardware != NULL);
-  GetMemory().ClearFlagCopyMut(position);    
-}
-
-cHeadMultiMem & cHeadMultiMem::operator=(const cHeadMultiMem & in_cpu_head)
-{
-  main_hardware = in_cpu_head.main_hardware;
-  cur_hardware  = in_cpu_head.cur_hardware;
-  position = in_cpu_head.position;
-  mem_space = in_cpu_head.mem_space;
-  return *this;
-}
-
-bool cHeadMultiMem::operator==(const cHeadMultiMem & in_cpu_head) const 
-{
-  return (cur_hardware == in_cpu_head.cur_hardware) && 
-    (position == in_cpu_head.position) &&
-    (mem_space == in_cpu_head.mem_space);
-}
-  
-bool cHeadMultiMem::AtEnd() const
-{
-  return (position + 1 == GetMemory().GetSize());
-}
-
-bool cHeadMultiMem::InMemory() const
-{
-  return (position >= 0 && position < GetMemory().GetSize());
-}
-
-cString cHeadMultiMem::GetPositionString() const
-{
-  return cStringUtil::Stringf("(%2d, %2d)", mem_space, position);
-}

Deleted: development/source/cpu/cHeadMultiMem.h
===================================================================
--- development/source/cpu/cHeadMultiMem.h	2006-07-14 18:31:02 UTC (rev 835)
+++ development/source/cpu/cHeadMultiMem.h	2006-07-14 18:42:37 UTC (rev 836)
@@ -1,80 +0,0 @@
-/*
- *  cHeadMultiMem.h
- *  Avida
- *
- *  Created by David on 11/30/05.
- *  Copyright 2005-2006 Michigan State University. All rights reserved.
- *  Copyright 1999-2003 California Institute of Technology.
- *
- */
-
-#ifndef cHeadMultiMem_h
-#define cHeadMultiMem_h
-
-#ifndef cHeadCPU_h
-#include "cHeadCPU.h"
-#endif
-
-class cHeadMultiMem : public cHeadCPU
-{
-private:
-  int mem_space;
-
-public:
-  cHeadMultiMem() : cHeadCPU() { mem_space = 0; }
-  cHeadMultiMem(cHardwareBase* hw, int pos = 0, int ms = 0) : cHeadCPU(hw, pos) { mem_space = ms; }
-  cHeadMultiMem(const cHeadMultiMem& in_head) : cHeadCPU(in_head) { mem_space = in_head.mem_space; }
-
-  void Adjust();
-  void Reset(int in_mem_space = 0, cHardwareBase* new_hardware = NULL);
-  void Set(int new_pos, int in_mem_space = 0, cHardwareBase* in_hardware = NULL);
-  void Set(const cHeadMultiMem& in_head);
-  void LoopJump(int jump);
-  const cCPUMemory& GetMemory() const;
-  cCPUMemory& GetMemory();
-  const cInstruction& GetInst() const;
-  const cInstruction& GetInst(int offset) const;
-
-  int GetMemSpace() const { return mem_space; }
-
-  void SetInst(const cInstruction & value);
-  void InsertInst(const cInstruction & in_char);
-  void RemoveInst();
-  const cInstruction& GetNextInst();
-
-  void SetFlagCopied();
-  void SetFlagMutated();
-  void SetFlagExecuted();
-  void SetFlagBreakpoint();
-  void SetFlagPointMut();
-  void SetFlagCopyMut();
-  
-  void ClearFlagCopied();
-  void ClearFlagMutated();
-  void ClearFlagExecuted();
-  void ClearFlagBreakpoint();
-  void ClearFlagPointMut();
-  void ClearFlagCopyMut();
-  
-  // Operator Overloading...
-  cHeadMultiMem& operator=(const cHeadMultiMem& in_cpu_head);
-  bool operator==(const cHeadMultiMem& in_cpu_head) const; 
-  bool AtEnd() const;
-  bool InMemory() const;
-  
-  cString GetPositionString() const;
-};
-
-
-#ifdef ENABLE_UNIT_TESTS
-namespace nHeadMultiMem {
-  /**
-   * Run unit tests
-   *
-   * @param full Run full test suite; if false, just the fast tests.
-   **/
-  void UnitTests(bool full = false);
-}
-#endif  
-
-#endif

Modified: development/source/targets/avida-viewer/cZoomScreen.cc
===================================================================
--- development/source/targets/avida-viewer/cZoomScreen.cc	2006-07-14 18:31:02 UTC (rev 835)
+++ development/source/targets/avida-viewer/cZoomScreen.cc	2006-07-14 18:42:37 UTC (rev 836)
@@ -21,7 +21,6 @@
 #include "cHardwareBase.h"
 #include "cHardwareCPU.h"
 #include "nHardware.h"
-#include "cHeadMultiMem.h"
 
 #include "cView.h"
 #include "cMenuWindow.h"
@@ -34,8 +33,7 @@
 //  The Zoom Screen
 /////////////////////
 
-cZoomScreen::cZoomScreen(int y_size, int x_size, int y_start, int x_start,
-                         cViewInfo & in_info, cPopulation & in_pop)
+cZoomScreen::cZoomScreen(int y_size, int x_size, int y_start, int x_start, cViewInfo& in_info, cPopulation& in_pop)
 : cScreen(y_size, x_size, y_start, x_start, in_info), population(in_pop)
 {
   memory_offset = 0;
@@ -158,7 +156,7 @@
   
   int task_num = task_offset;
   int col_num = 0;
-  const cTaskLib & task_lib = population.GetEnvironment().GetTaskLib();
+  const cTaskLib& task_lib = population.GetEnvironment().GetTaskLib();
   for (int cur_col = TASK_X + 2;
        task_num < info.GetWorld().GetNumTasks();
        cur_col += 14) {
@@ -429,7 +427,7 @@
   if (info.GetActiveCell() == NULL ||
       info.GetActiveCell()->IsOccupied() == false) return;
   
-  cHardwareBase & hardware = info.GetActiveCell()->GetOrganism()->GetHardware();
+  cHardwareBase& hardware = info.GetActiveCell()->GetOrganism()->GetHardware();
   if(mode == ZOOM_MODE_CPU) UpdateCPU(hardware);
   else if (mode == ZOOM_MODE_STATS) UpdateStats(hardware);
   else if (mode == ZOOM_MODE_GENOTYPE) UpdateGenotype();
@@ -437,17 +435,14 @@
   Refresh();
 }
 
-void cZoomScreen::UpdateStats(cHardwareBase & hardware)
+void cZoomScreen::UpdateStats(cHardwareBase& hardware)
 {
   if (info.GetActiveCell() == NULL ||
       info.GetActiveCell()->IsOccupied() == false) return;
   
-  cGenotype * genotype = info.GetActiveGenotype();
-  cPhenotype & phenotype = info.GetActiveCell()->GetOrganism()->GetPhenotype();
+  cGenotype* genotype = info.GetActiveGenotype();
+  cPhenotype& phenotype = info.GetActiveCell()->GetOrganism()->GetPhenotype();
   
-  //cHardwareBase & hardware =
-  //  info.GetActiveCell()->GetOrganism()->GetHardware();
-  
   SetBoldColor(COLOR_CYAN);
   
   // if there is an Active Genotype name AND it is not empty, show it
@@ -533,7 +528,7 @@
   
   
   if (info.GetActiveCell() == NULL) {
-    info.SetActiveCell( &(population.GetCell(0)) );
+    info.SetActiveCell(&(population.GetCell(0)) );
   }
   SetBoldColor(COLOR_WHITE);
   
@@ -566,7 +561,7 @@
   Print(15, 34, "%14d", hardware.GetStack(0));
   
   cHeadCPU inst_ptr(hardware.IP());
-  const cInstSet & inst_set = hardware.GetInstSet();
+  const cInstSet& inst_set = hardware.GetInstSet();
   
   for (int pos = 0; pos < 3; pos++) {
     // Clear the line
@@ -586,7 +581,7 @@
   Print(CPU_FLAGS_Y + 1, CPU_FLAGS_X + 1, "Mem Allocated");
   
   // And print the IP.
-  const cHeadCPU & active_inst_ptr = hardware.IP();
+  const cHeadCPU& active_inst_ptr = hardware.IP();
   // @CAO assume no parasites for now.
   int cur_id = info.GetActiveCell()->GetID();
   //active_inst_ptr.GetCurHardware()->GetOrganism()->GetEnvironment()->GetID();
@@ -620,14 +615,12 @@
   }
   
   // And print the IP.
-  const cHeadCPU& active_inst_ptr = hardware.IP();
+  const cHeadCPU& ip = hardware.IP();
   // @CAO assume no parasites for now.
-  //int cur_id = info.GetActiveCell()->GetID();
-  //active_inst_ptr.GetCurHardware()->GetOrganism()->GetEnvironment()->GetID();
-  Print(11, 36, "%12s", static_cast<const char*>(active_inst_ptr.GetPositionString()));
+  Print(11, 36, "%12s", static_cast<const char*>(cStringUtil::Stringf("(%2d, %2d)", ip.GetMemSpace(), ip.GetPosition())));
 }
 
-void cZoomScreen::UpdateCPU(cHardwareBase & hardware)
+void cZoomScreen::UpdateCPU(cHardwareBase& hardware)
 {
   // Place the visible section of the current memory onto the screen.
   
@@ -643,7 +636,7 @@
   Print(14, 69, "%10d", info.GetActiveGenotypeID());
   Print(15, 69, "%10s", static_cast<const char*>(info.GetActiveName()));
   
-  cPhenotype & phenotype = info.GetActiveCell()->GetOrganism()->GetPhenotype();
+  cPhenotype& phenotype = info.GetActiveCell()->GetOrganism()->GetPhenotype();
   Print(17, 69, "%10d", phenotype.GetCurNumErrors());
   Print(18, 69, "%10d", phenotype.GetNumDivides());
   if (info.GetThreadLock() != -1) Print(19, 67, "LOCKED");
@@ -664,7 +657,7 @@
     Print(INPUT_Y+3+i, INPUT_X+2, "%12d", info.GetActiveCell()->GetInput(i));
   }
   
-  const cString & cur_fault = phenotype.GetFault();
+  const cString& cur_fault = phenotype.GetFault();
   if (cur_fault.GetSize() > 0) {
     SetBoldColor(COLOR_RED);
     Print(FAULT_Y, FAULT_X, "Fault:");
@@ -733,8 +726,7 @@
   // creature we are viewing, but can also be a different one (if this is a
   // parasite).
   
-  const cCPUMemory & memory = (parasite_zoom) ?
-    hardware.GetMemory() : hardware.IP().GetMemory();
+  const cCPUMemory& memory = parasite_zoom ? hardware.GetMemory() : hardware.IP().GetMemory();
   SetColor(COLOR_WHITE);
   Print(MEMORY_Y + 1, MEMORY_X + 9, "%4d", memory.GetSize());
   
@@ -752,7 +744,7 @@
   int base_inst_ptr = hardware.IP().GetPosition();
   if (base_inst_ptr < 0 || parasite_zoom == true) base_inst_ptr = 0;
   
-  const cInstSet & inst_set = hardware.GetInstSet();
+  const cInstSet& inst_set = hardware.GetInstSet();
   
   // Determine the center (must be between 0 and size - 1)
   int center_pos = (base_inst_ptr + memory_offset) % memory.GetSize();
@@ -833,22 +825,10 @@
   if (cur_view_thread >= hardware.GetNumThreads())
   {
     cur_view_thread = 0;
-#ifdef DEBUG
-    cHeadMultiMem* p_cur_ip = dynamic_cast<cHeadMultiMem*>(&hardware.IP(cur_view_thread));
-    assert(p_cur_ip);
-    cur_mem_space = p_cur_ip->GetMemSpace();
-#else
-    cur_mem_space = static_cast<cHeadMultiMem&>(hardware.IP(cur_view_thread)).GetMemSpace();
-#endif
+    cur_mem_space = hardware.IP(cur_view_thread).GetMemSpace();
   }
 
-#ifdef DEBUG
-  cHeadMultiMem* p_cur_ip = dynamic_cast<cHeadMultiMem*>(&hardware.IP(cur_view_thread));
-  assert(p_cur_ip);
-  cHeadMultiMem& cur_ip = *p_cur_ip;
-#else
-  cHeadMultiMem& cur_ip = static_cast<cHeadMultiMem&>(hardware.IP(cur_view_thread));
-#endif
+  cHeadCPU& cur_ip = hardware.IP(cur_view_thread);
   
   // Place the stacks onto the screen.
   SetBoldColor(COLOR_CYAN);
@@ -879,7 +859,7 @@
   // creature we are viewing, but can also be a different one (if this is a
   // parasite).
   
-  const cCPUMemory & memory = hardware.GetMemory(cur_mem_space);
+  const cCPUMemory& memory = hardware.GetMemory(cur_mem_space);
   SetBoldColor(COLOR_BLUE);
   Print(MEMORY_Y + 1, MEMORY_X + 8, " Space ");	
   SetColor(COLOR_WHITE);
@@ -902,7 +882,7 @@
   int base_inst_ptr = cur_ip.GetPosition();
   if (base_inst_ptr < 0 || parasite_zoom == true) base_inst_ptr = 0;
   
-  const cInstSet & inst_set = hardware.GetInstSet();
+  const cInstSet& inst_set = hardware.GetInstSet();
   
   // Determine the center (must be between 0 and size - 1)
   int center_pos = (base_inst_ptr + memory_offset) % memory.GetSize();
@@ -962,15 +942,15 @@
       }
       
       if (adj_inst_ptr == hardware.GetHead(nHardware::HEAD_READ, cur_view_thread).GetPosition() &&
-          cur_mem_space == static_cast<cHeadMultiMem&>(hardware.GetHead(nHardware::HEAD_READ, cur_view_thread)).GetMemSpace()) {
+          cur_mem_space == hardware.GetHead(nHardware::HEAD_READ, cur_view_thread).GetMemSpace()) {
         Print(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X + 31, "R");
       }
       if (adj_inst_ptr == hardware.GetHead(nHardware::HEAD_WRITE, cur_view_thread).GetPosition() &&
-          cur_mem_space == static_cast<cHeadMultiMem&>(hardware.GetHead(nHardware::HEAD_WRITE, cur_view_thread)).GetMemSpace()) {
+          cur_mem_space == hardware.GetHead(nHardware::HEAD_WRITE, cur_view_thread).GetMemSpace()) {
         Print(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X + 32, "W");
       }
       if (adj_inst_ptr == hardware.GetHead(nHardware::HEAD_FLOW, cur_view_thread).GetPosition() &&
-          cur_mem_space == static_cast<cHeadMultiMem&>(hardware.GetHead(nHardware::HEAD_FLOW, cur_view_thread)).GetMemSpace()) {
+          cur_mem_space == hardware.GetHead(nHardware::HEAD_FLOW, cur_view_thread).GetMemSpace()) {
         Print(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X + 33, "F");
       }
     }
@@ -989,7 +969,7 @@
   Print(3, 12, "%9d", info.GetActiveSpeciesID());
   
   if (info.GetActiveGenotype() != NULL) {
-    cGenotype & genotype = *(info.GetActiveGenotype());
+    cGenotype& genotype = *(info.GetActiveGenotype());
     Print(5, 12, "%9d", genotype.GetNumOrganisms());
     Print(6, 12, "%9d", genotype.GetLength());
     Print(7, 12, "%9d", genotype.GetCopiedSize());
@@ -1053,11 +1033,9 @@
 {
   // Collect all of the needed variables.
   cHardwareBase& hardware = info.GetActiveCell()->GetOrganism()->GetHardware();
-  const cInstSet & inst_set = hardware.GetInstSet();
-  cHeadCPU edit_head( hardware.IP() );
-  if (parasite_zoom == true) {
-    edit_head.Set(0, &(info.GetActiveCell()->GetOrganism()->GetHardware()) );
-  }
+  const cInstSet& inst_set = hardware.GetInstSet();
+  cHeadCPU edit_head(hardware.IP());
+  if (parasite_zoom == true) edit_head.Set(0);
   edit_head.LoopJump(memory_offset);
   
   // Assemble first choice window.
@@ -1124,10 +1102,8 @@
 {
   // Collect all of the needed variables.
   cHardwareBase& hardware = info.GetActiveCell()->GetOrganism()->GetHardware();
-  cHeadCPU view_head( hardware.IP() );
-  if (parasite_zoom == true) {
-    view_head.Set(0, &(info.GetActiveCell()->GetOrganism()->GetHardware()) );
-  }
+  cHeadCPU view_head(hardware.IP());
+  if (parasite_zoom == true) view_head.Set(0);
   view_head.LoopJump(memory_offset);
   
   // Act on the view method!
@@ -1179,13 +1155,11 @@
   // Place the data.
   
   cHardwareBase& hardware = info.GetActiveCell()->GetOrganism()->GetHardware();
-  cHeadCPU inst_ptr( hardware.IP() );
-  if (parasite_zoom == true) {
-    inst_ptr.Set(0, &(info.GetActiveCell()->GetOrganism()->GetHardware()) );
-  }
+  cHeadCPU inst_ptr(hardware.IP());
+  if (parasite_zoom == true) inst_ptr.Set(0);
   inst_ptr.LoopJump(memory_offset);
   
-  const cInstSet & inst_set = hardware.GetInstSet();
+  const cInstSet& inst_set = hardware.GetInstSet();
   
   window->SetBoldColor(COLOR_YELLOW);
   window->Print(2, 16, "%s", static_cast<const char*>(inst_set.GetName(inst_ptr.GetInst())));
@@ -1363,7 +1337,7 @@
 
 void cZoomScreen::ViewInputs()
 {
-  cTextWindow * window = new cTextWindow(9, 54, 4, 13);
+  cTextWindow* window = new cTextWindow(9, 54, 4, 13);
   
   window->SetBoldColor(COLOR_WHITE);
   window->Box();
@@ -1521,13 +1495,7 @@
         ++cur_view_thread%=num_threads;
         if(info.GetConfig().HARDWARE_TYPE.Get() != HARDWARE_TYPE_CPU_ORIGINAL)
         {
-#ifdef DEBUG
-          cHeadMultiMem* p_cur_ip = dynamic_cast<cHeadMultiMem*>(&hardware.IP(cur_view_thread));
-          assert(p_cur_ip);
-          cur_mem_space = p_cur_ip->GetMemSpace();
-#else
-          cur_mem_space = static_cast<cHeadMultiMem&>(hardware.IP(cur_view_thread)).GetMemSpace();
-#endif
+          cur_mem_space = hardware.IP(cur_view_thread).GetMemSpace();
         }
         Update();
       }
@@ -1573,7 +1541,7 @@
         cur_view_thread=0;
         if (population.GetCell(mini_center_id).IsOccupied()) {
           memory_offset = 0;
-          info.SetActiveCell( &(population.GetCell(mini_center_id)));
+          info.SetActiveCell(&(population.GetCell(mini_center_id)));
         }
         Update();
       } else if (active_section == ZOOM_SECTION_MEMORY) {
@@ -1589,7 +1557,7 @@
         if (mini_center_id < 0) mini_center_id += population.GetSize();
         if (population.GetCell(mini_center_id).IsOccupied()) {
           memory_offset = 0;
-          info.SetActiveCell( &(population.GetCell(mini_center_id)));
+          info.SetActiveCell(&(population.GetCell(mini_center_id)));
         }
         Update();
       } else if (active_section == ZOOM_SECTION_MEMORY) {
@@ -1604,7 +1572,7 @@
         if (mini_center_id == population.GetSize()) mini_center_id = 0;
         if (population.GetCell(mini_center_id).IsOccupied()) {
           memory_offset = 0;
-          info.SetActiveCell( &(population.GetCell(mini_center_id)));
+          info.SetActiveCell(&(population.GetCell(mini_center_id)));
         }
       }
       else if (active_section == ZOOM_SECTION_MEMORY) {
@@ -1624,7 +1592,7 @@
         if (mini_center_id < 0) mini_center_id += population.GetSize();
         if (population.GetCell(mini_center_id).IsOccupied()) {
           memory_offset = 0;
-          info.SetActiveCell( &(population.GetCell(mini_center_id)));
+          info.SetActiveCell(&(population.GetCell(mini_center_id)));
         }
       }
       else if (active_section == ZOOM_SECTION_MEMORY) {
@@ -1657,7 +1625,7 @@
     case '\r':
       if (active_section == ZOOM_SECTION_MAP) {
         memory_offset = 0;
-        info.SetActiveCell( &(population.GetCell(mini_center_id)));
+        info.SetActiveCell(&(population.GetCell(mini_center_id)));
       }
       Update();
       break;




More information about the Avida-cvs mailing list