[Avida-SVN] r3198 - in development: Avida.xcodeproj source/analyze source/classification source/cpu source/drivers source/main

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Mon Mar 30 09:14:08 PDT 2009


Author: brysonda
Date: 2009-03-30 12:14:07 -0400 (Mon, 30 Mar 2009)
New Revision: 3198

Added:
   development/source/main/cMetaGenome.h
Modified:
   development/Avida.xcodeproj/project.pbxproj
   development/source/analyze/cAnalyze.cc
   development/source/classification/cGenotype.cc
   development/source/classification/cInjectGenotype.cc
   development/source/classification/cSpecies.cc
   development/source/cpu/cCPUMemory.cc
   development/source/cpu/cCPUMemory.h
   development/source/cpu/cHardwareBase.cc
   development/source/cpu/cHardwareBase.h
   development/source/cpu/cHardwareCPU.cc
   development/source/cpu/cHardwareCPU.h
   development/source/cpu/cHardwareExperimental.cc
   development/source/cpu/cHardwareExperimental.h
   development/source/cpu/cHardwareGX.cc
   development/source/cpu/cHardwareGX.h
   development/source/cpu/cHardwareManager.cc
   development/source/cpu/cHardwareManager.h
   development/source/cpu/cHardwareSMT.cc
   development/source/cpu/cHardwareSMT.h
   development/source/cpu/cHardwareTransSMT.cc
   development/source/cpu/cHardwareTransSMT.h
   development/source/cpu/cTestCPU.cc
   development/source/cpu/cTestCPU.h
   development/source/cpu/cTestCPUInterface.cc
   development/source/cpu/cTestCPUInterface.h
   development/source/drivers/cDefaultRunDriver.cc
   development/source/main/cBirthChamber.cc
   development/source/main/cBirthChamber.h
   development/source/main/cGenome.cc
   development/source/main/cGenome.h
   development/source/main/cOrgInterface.h
   development/source/main/cOrganism.cc
   development/source/main/cOrganism.h
   development/source/main/cPopulation.cc
   development/source/main/cPopulation.h
   development/source/main/cPopulationInterface.cc
   development/source/main/cPopulationInterface.h
Log:
Begin implementing support for multiple in-run co-existing hardware types and instruction sets.   This is far from complete.  The birth chamber passes the meta genome through, but does not pay attention to the information.  The hardware manager will only hand out the default instruction set currently and there is no way to load additional sets.  None of the classification tools are aware of any of this.   Yet, I have to start somewhere. :-)

Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/Avida.xcodeproj/project.pbxproj	2009-03-30 16:14:07 UTC (rev 3198)
@@ -465,6 +465,7 @@
 		70436B250C36C64000A05ABA /* platform.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = platform.h; sourceTree = "<group>"; };
 		70436B260C36C64000A05ABA /* PlatformExpert.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformExpert.cc; sourceTree = "<group>"; };
 		70436B270C36C64000A05ABA /* PlatformExpert.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PlatformExpert.h; sourceTree = "<group>"; };
+		70447AA20F8010F100E1BF72 /* cMetaGenome.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cMetaGenome.h; sourceTree = "<group>"; };
 		7048A95E0EA417CD0087B7BD /* cASNativeObjectMethod.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cASNativeObjectMethod.h; sourceTree = "<group>"; };
 		7048A9A40EA431140087B7BD /* cASCPPParameter_NativeObjectSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cASCPPParameter_NativeObjectSupport.h; sourceTree = "<group>"; };
 		7049F2D70A66859300640512 /* cHardwareTransSMT.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cHardwareTransSMT.cc; sourceTree = "<group>"; };
@@ -1559,6 +1560,7 @@
 				70166B8D0B519CFE009533A5 /* cTaskState.h */,
 				709A1E540EB69DA6006090AF /* cResourceHistory.h */,
 				70310E690EDD09260044971B /* cStateGrid.h */,
+				70447AA20F8010F100E1BF72 /* cMetaGenome.h */,
 			);
 			path = main;
 			sourceTree = "<group>";

Modified: development/source/analyze/cAnalyze.cc
===================================================================
--- development/source/analyze/cAnalyze.cc	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/analyze/cAnalyze.cc	2009-03-30 16:14:07 UTC (rev 3198)
@@ -1759,16 +1759,17 @@
     for (int i=0; i<number_to_sample; i++) {
       test_cpu->TestGenome(m_world->GetDefaultContext(), test_info, parent_genotype->GetGenome());
       cAnalyzeGenotype * offspring_genotype = NULL;
-      bool found = genome_hash.Find(test_info.GetTestOrganism(0)->ChildGenome().AsString(), offspring_genotype);
+      bool found = genome_hash.Find(test_info.GetTestOrganism(0)->OffspringGenome().GetGenome().AsString(), offspring_genotype);
       if (found) {
         offspring_genotype->SetNumCPUs(offspring_genotype->GetNumCPUs() + 1);
       }
       else {
-        cAnalyzeGenotype * offspring_genotype = new cAnalyzeGenotype(m_world, test_info.GetTestOrganism(0)->ChildGenome(), inst_set);
+        cAnalyzeGenotype* offspring_genotype =
+          new cAnalyzeGenotype(m_world, test_info.GetTestOrganism(0)->OffspringGenome().GetGenome(), inst_set);
         offspring_genotype->SetID(parent_genotype->GetID());
         offspring_genotype->SetNumCPUs(1);
         offspring_list.Push(offspring_genotype);
-        genome_hash.Add(test_info.GetTestOrganism(0)->ChildGenome().AsString(), offspring_genotype);
+        genome_hash.Add(test_info.GetTestOrganism(0)->OffspringGenome().GetGenome().AsString(), offspring_genotype);
       }
     }
     batch_it.Remove();
@@ -8663,7 +8664,7 @@
        parent, if the parent is viable, so that genome of first descendent may
        differ from that of parent.
        */
-      offspring_genome_array[array_pos] = test_info.GetTestOrganism(0)->ChildGenome();
+      offspring_genome_array[array_pos] = test_info.GetTestOrganism(0)->OffspringGenome().GetGenome();
     } else {
       fitness_array[array_pos] = 0.0;
     }

Modified: development/source/classification/cGenotype.cc
===================================================================
--- development/source/classification/cGenotype.cc	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/classification/cGenotype.cc	2009-03-30 16:14:07 UTC (rev 3198)
@@ -109,13 +109,7 @@
 
 bool cGenotype::OK()
 {
-  bool ret_value = true;
-
-  // Check the components...
-
-  if (!genome.OK()) ret_value = false;
-
-  // And the statistics
+  // Check statistics
   assert( id_num >= 0 && num_organisms >= 0 && total_organisms >= 0 );
   assert( birth_data.update_born >= -1 && birth_data.parent_distance >= -1 );
   assert( sum_copied_size.Sum() >= 0 && sum_exe_size.Sum() >= 0 );
@@ -125,7 +119,7 @@
   assert( tmp_sum_gestation_time.Sum() >= 0 && tmp_sum_repro_rate.Sum() >= 0 );
   assert( tmp_sum_merit.Sum() >= 0 && tmp_sum_fitness.Sum() >= 0 );
 
-  return ret_value;
+  return true;
 }
 
 void cGenotype::AddMerit(const cMerit & in)

Modified: development/source/classification/cInjectGenotype.cc
===================================================================
--- development/source/classification/cInjectGenotype.cc	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/classification/cInjectGenotype.cc	2009-03-30 16:14:07 UTC (rev 3198)
@@ -98,11 +98,7 @@
 {
   bool ret_value = true;
 
-  // Check the components...
-
-  if (!genome.OK()) ret_value = false;
-
-  // And the statistics
+  // Check statistics
   assert( id_num >= 0 && num_injected >= 0 && total_injected >= 0 );
   assert( birth_data.update_born >= -1);
 

Modified: development/source/classification/cSpecies.cc
===================================================================
--- development/source/classification/cSpecies.cc	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/classification/cSpecies.cc	2009-03-30 16:14:07 UTC (rev 3198)
@@ -155,7 +155,6 @@
 bool cSpecies::OK()
 {
   assert(id_num >= 0);  // Species has negative ID value!
-  assert(genome.OK());  // Species genome not registering as OK!
 
   // Assert valid statistics in species.
   assert(total_organisms >= 0 && total_genotypes >= 0 &&

Modified: development/source/cpu/cCPUMemory.cc
===================================================================
--- development/source/cpu/cCPUMemory.cc	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/cpu/cCPUMemory.cc	2009-03-30 16:14:07 UTC (rev 3198)
@@ -27,102 +27,41 @@
 
 using namespace std;
 
-const int MEMORY_INCREASE_MINIMUM = 10;
-const double MEMORY_INCREASE_FACTOR = 1.5;
-const double MEMORY_SHRINK_TEST_FACTOR = 4.0;
 
-cCPUMemory::cCPUMemory(const cCPUMemory& in_memory)
-  : cGenome(in_memory), flag_array(in_memory.GetSize())
+cCPUMemory::cCPUMemory(const cCPUMemory& in_memory) : cGenome(in_memory), m_flag_array(in_memory.GetSize())
 {
-  for (int i = 0; i < flag_array.GetSize(); i++) {
-    flag_array[i] = in_memory.flag_array[i];
-  }
+  for (int i = 0; i < m_flag_array.GetSize(); i++) m_flag_array[i] = in_memory.m_flag_array[i];
 }
 
 
-void cCPUMemory::SloppyResize(int new_size)
+void cCPUMemory::adjustCapacity(int new_size)
 {
-  assert(new_size > 0);
-
-  // Make sure we're really changing the size...
-  if (new_size == active_size) return;
-
-  const int array_size = genome.GetSize();
-
-  // Determine if we need to adjust the allocated array sizes...
-  if (new_size > array_size || new_size * MEMORY_SHRINK_TEST_FACTOR < array_size) {
-    int new_array_size = (int) (new_size * MEMORY_INCREASE_FACTOR);
-    const int new_array_min = new_size + MEMORY_INCREASE_MINIMUM;
-		if (new_array_min > new_array_size) new_array_size = new_array_min;
-    genome.Resize(new_array_size);
-    flag_array.Resize(new_array_size);
-  }
-  
-  // And just change the active_size once we're sure it will be in range.
-  active_size = new_size;
+  cGenome::adjustCapacity(new_size);
+  if (m_genome.GetSize() != m_flag_array.GetSize()) m_flag_array.Resize(m_genome.GetSize()); 
 }
 
 
-void cCPUMemory::SloppyInsert(int pos, int num_lines)
+void cCPUMemory::prepareInsert(int pos, int num_sites)
 {
-  assert(pos >= 0 && pos <= active_size); // Must insert at a legal position!
-  assert(num_lines > 0);  // Must insert positive number of lines!
-
+  assert(pos >= 0 && pos <= m_active_size); // Must insert at a legal position!
+  assert(num_sites > 0); // Must insert positive number of lines!
+  
   // Re-adjust the size...
-  const int old_size = active_size;
-  const int new_size = active_size + num_lines;
-  SloppyResize(new_size);
-
-  // Shift any lines needed...
-  for (int i = old_size - 1; i >= pos; i--) {
-    genome[i+num_lines] = genome[i];
-    flag_array[i+num_lines] = flag_array[i];
-  }
+  const int old_size = m_active_size;
+  const int new_size = m_active_size + num_sites;
+  adjustCapacity(new_size);
+  
+  // Shift any sites needed...
+  for (int i = old_size - 1; i >= pos; i--) m_genome[i + num_sites] = m_genome[i];
+  for (int i = old_size - 1; i >= pos; i--) m_flag_array[i + num_sites] = m_flag_array[i];
 }
 
 
-// ---  Public Methods ---
-
-
-void cCPUMemory::operator=(const cCPUMemory & other_memory)
-{
-  SloppyResize(other_memory.active_size);
-
-  // Fill in the new information...
-  for (int i = 0; i < active_size; i++) {
-    genome[i] = other_memory.genome[i];
-    flag_array[i] = other_memory.flag_array[i];
-  }
-}
-
-
-void cCPUMemory::operator=(const cGenome & other_genome)
-{
-  SloppyResize(other_genome.GetSize());
-
-  // Fill in the new information...
-  for (int i = 0; i < active_size; i++) {
-    genome[i] = other_genome[i];
-    flag_array[i] = 0;
-  }
-}
-
-void cCPUMemory::Copy(int to, int from)
-{
-  assert(to >= 0);
-  assert(to < genome.GetSize());
-  assert(from >= 0);
-  assert(from < genome.GetSize());
-
-  genome[to] = genome[from];
-  flag_array[to] = flag_array[from];
-}
-
 void cCPUMemory::Reset(int new_size)
 {
   assert(new_size >= 0);
 
-  SloppyResize(new_size);
+  adjustCapacity(new_size);
   Clear();
 }
 
@@ -131,14 +70,12 @@
 {
   assert(new_size >= 0);
 
-  // Do a sloppy resize first, saving old values...
-  const int old_size = active_size;
-  SloppyResize(new_size);
+  const int old_size = m_active_size;
+  adjustCapacity(new_size);
   
-  // Clean up all of the old memory that might need it...
   for (int i = old_size; i < new_size; i++) {
-    genome[i].SetOp(0);
-    flag_array[i] = 0;
+    m_genome[i].SetOp(0);
+    m_flag_array[i] = 0;
   }
 }
 
@@ -147,68 +84,101 @@
 {
   assert(new_size >= 0);
 
-  const int old_size = active_size;
+  const int old_size = m_active_size;
+  adjustCapacity(new_size);
 
-  // Do a sloppy resize, which will still have old values.
-  SloppyResize(new_size);
+  for (int i = old_size; i < new_size; i++) m_flag_array[i] = 0;
+}
 
-  for (int i = old_size; i < new_size; i++) {
-    flag_array[i] = 0;
-  }
+
+void cCPUMemory::Copy(int to, int from)
+{
+  assert(to >= 0);
+  assert(to < m_genome.GetSize());
+  assert(from >= 0);
+  assert(from < m_genome.GetSize());
+  
+  m_genome[to] = m_genome[from];
+  m_flag_array[to] = m_flag_array[from];
 }
 
 
-void cCPUMemory::Insert(int pos, const cInstruction & in_inst)
+void cCPUMemory::Insert(int pos, const cInstruction& inst)
 {
   assert(pos >= 0);
-  assert(pos <= genome.GetSize());
+  assert(pos <= m_genome.GetSize());
 
-  SloppyInsert(pos, 1);
-  genome[pos] = in_inst;
-  flag_array[pos] = 0;
+  prepareInsert(pos, 1);
+  m_genome[pos] = inst;
+  m_flag_array[pos] = 0;
 }
 
-void cCPUMemory::Insert(int pos, const cGenome & in_genome)
+void cCPUMemory::Insert(int pos, const cGenome& genome)
 {
   assert(pos >= 0);
-  assert(pos <= genome.GetSize());
+  assert(pos <= m_genome.GetSize());
 
-  SloppyInsert(pos, in_genome.GetSize());
-  for (int i = 0; i < in_genome.GetSize(); i++) {
-    genome[i+pos] = in_genome[i];
-    flag_array[i+pos] = 0;
+  prepareInsert(pos, genome.GetSize());
+  for (int i = 0; i < genome.GetSize(); i++) {
+    m_genome[i + pos] = genome[i];
+    m_flag_array[i + pos] = 0;
   }
 }
 
-void cCPUMemory::Remove(int pos, int num_insts)
+void cCPUMemory::Remove(int pos, int num_sites)
 {
-  assert(num_insts > 0);                  // Must remove something...
-  assert(pos >= 0);                       // Removal must be in genome.
-  assert(pos + num_insts <= active_size); // Cannot extend past end of genome.
+  assert(num_sites > 0);                    // Must remove something...
+  assert(pos >= 0);                         // Removal must be in genome.
+  assert(pos + num_sites <= m_active_size); // Cannot extend past end of genome.
 
-  const int new_size = active_size - num_insts;
+  const int new_size = m_active_size - num_sites;
   for (int i = pos; i < new_size; i++) {
-    genome[i] = genome[i + num_insts];
-    flag_array[i] = flag_array[i + num_insts];
+    m_genome[i] = m_genome[i + num_sites];
+    m_flag_array[i] = m_flag_array[i + num_sites];
   }
-  SloppyResize(new_size);
+  adjustCapacity(new_size);
 }
 
-void cCPUMemory::Replace(int pos, int num_insts, const cGenome & in_genome)
+void cCPUMemory::Replace(int pos, int num_sites, const cGenome& genome)
 {
-  assert(pos >= 0);                       // Replace must be in genome.
-  assert(num_insts >= 0);                 // Cannot replace negative.
-  assert(pos + num_insts <= active_size); // Cannot extend past end!
+  assert(pos >= 0);                         // Replace must be in genome
+  assert(num_sites >= 0);                   // Cannot replace negative
+  assert(pos + num_sites <= m_active_size); // Cannot extend past end!
+  
+  const int size_change = genome.GetSize() - num_sites;
+  
+  // First, get the size right
+  if (size_change > 0) prepareInsert(pos, size_change);
+  else if (size_change < 0) Remove(pos, -size_change);
+  
+  // Now just copy everything over!
+  for (int i = 0; i < genome.GetSize(); i++) {
+    m_genome[i + pos] = genome[i];
+    m_flag_array[i + pos] = 0;
+  }
+}
 
-  const int size_change = in_genome.GetSize() - num_insts;
 
-  // First, get the size right.
-  if (size_change > 0) SloppyInsert(pos, size_change);
-  else if (size_change < 0) Remove(pos, -size_change);
+void cCPUMemory::operator=(const cCPUMemory& other_memory)
+{
+  adjustCapacity(other_memory.m_active_size);
+  
+  // Fill in the new information...
+  for (int i = 0; i < m_active_size; i++) {
+    m_genome[i] = other_memory.m_genome[i];
+    m_flag_array[i] = other_memory.m_flag_array[i];
+  }
+}
 
-  // Now just copy everything over!
-  for (int i = 0; i < in_genome.GetSize(); i++) {
-    genome[i + pos] = in_genome[i];
-    flag_array[i + pos] = 0;
+
+void cCPUMemory::operator=(const cGenome& other_genome)
+{
+  adjustCapacity(other_genome.GetSize());
+  
+  // Fill in the new information...
+  for (int i = 0; i < m_active_size; i++) {
+    m_genome[i] = other_genome[i];
+    m_flag_array[i] = 0;
   }
 }
+

Modified: development/source/cpu/cCPUMemory.h
===================================================================
--- development/source/cpu/cCPUMemory.h	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/cpu/cCPUMemory.h	2009-03-30 16:14:07 UTC (rev 3198)
@@ -46,81 +46,66 @@
 	static const unsigned char MASK_INJECTED = 0x40;
 	static const unsigned char MASK_UNUSED   = 0x80; // unused bit
   
-  tArray<unsigned char> flag_array;
+  tArray<unsigned char> m_flag_array;
 
-  // A collection of sloppy instructions to perform oft-used functions that
-  // will need to be cleaned up after this is run.
-  void SloppyResize(int new_size);           // Set size, ignore new contents.
-  void SloppyInsert(int pos, int num_lines); // Add lines, ignore new contents.
+  void adjustCapacity(int new_size);
+  void prepareInsert(int pos, int num_sites);
 
 public:
-  explicit cCPUMemory(int _size=1)  : cGenome(_size), flag_array(_size) { ClearFlags(); }
+  explicit cCPUMemory(int size = 1)  : cGenome(size), m_flag_array(size) { ClearFlags(); }
   cCPUMemory(const cCPUMemory& in_memory);
-  cCPUMemory(const cGenome& in_genome) : cGenome(in_genome), flag_array(in_genome.GetSize()) { ; }
-  cCPUMemory(const cString& in_string) : cGenome(in_string), flag_array(in_string.GetSize()) { ; }
-  //! Construct a cCPUMemory object from a cInstruction range.
-  cCPUMemory(cInstruction* begin, cInstruction* end) : cGenome(begin, end), flag_array(GetSize()) { ClearFlags(); }
+  cCPUMemory(const cGenome& in_genome) : cGenome(in_genome), m_flag_array(in_genome.GetSize()) { ; }
+  cCPUMemory(const cString& in_string) : cGenome(in_string), m_flag_array(in_string.GetSize()) { ; }
+  cCPUMemory(cInstruction* begin, cInstruction* end) : cGenome(begin, end), m_flag_array(GetSize()) { ClearFlags(); }
   ~cCPUMemory() { ; }
 
-  void operator=(const cCPUMemory& other_memory);
-  void operator=(const cGenome& other_genome);
-  void Copy(int to, int from);
-
+  inline bool FlagCopied(int pos) const     { return MASK_COPIED   & m_flag_array[pos]; }
+  inline bool FlagMutated(int pos) const    { return MASK_MUTATED  & m_flag_array[pos]; }
+  inline bool FlagExecuted(int pos) const   { return MASK_EXECUTED & m_flag_array[pos]; }
+  inline bool FlagBreakpoint(int pos) const { return MASK_BREAK    & m_flag_array[pos]; }
+  inline bool FlagPointMut(int pos) const   { return MASK_POINTMUT & m_flag_array[pos]; }
+  inline bool FlagCopyMut(int pos) const    { return MASK_COPYMUT  & m_flag_array[pos]; }
+  inline bool FlagInjected(int pos) const   { return MASK_INJECTED & m_flag_array[pos]; }
+  
+  inline void SetFlagCopied(int pos)     { m_flag_array[pos] |= MASK_COPIED;   }
+  inline void SetFlagMutated(int pos)    { m_flag_array[pos] |= MASK_MUTATED;  }
+  inline void SetFlagExecuted(int pos)   { m_flag_array[pos] |= MASK_EXECUTED; }
+  inline void SetFlagBreakpoint(int pos) { m_flag_array[pos] |= MASK_BREAK;    }
+  inline void SetFlagPointMut(int pos)   { m_flag_array[pos] |= MASK_POINTMUT; }
+  inline void SetFlagCopyMut(int pos)    { m_flag_array[pos] |= MASK_COPYMUT;  }
+  inline void SetFlagInjected(int pos)   { m_flag_array[pos] |= MASK_INJECTED; }
+	
+	inline void ClearFlagCopied(int pos)     { m_flag_array[pos] &= ~MASK_COPIED;   }
+	inline void ClearFlagMutated(int pos)    { m_flag_array[pos] &= ~MASK_MUTATED;  }
+	inline void ClearFlagExecuted(int pos)   { m_flag_array[pos] &= ~MASK_EXECUTED; }
+	inline void ClearFlagBreakpoint(int pos) { m_flag_array[pos] &= ~MASK_BREAK;    }
+	inline void ClearFlagPointMut(int pos)   { m_flag_array[pos] &= ~MASK_POINTMUT; }
+	inline void ClearFlagCopyMut(int pos)    { m_flag_array[pos] &= ~MASK_COPYMUT;  }
+  inline void ClearFlagInjected(int pos)   { m_flag_array[pos] &= ~MASK_INJECTED; }
+  
+  
   void Clear()
 	{
-		for (int i = 0; i < active_size; i++) {
-			genome[i].SetOp(0);
-			flag_array[i] = 0;
+		for (int i = 0; i < m_active_size; i++) {
+			m_genome[i].SetOp(0);
+			m_flag_array[i] = 0;
 		}
     m_mutation_steps.Clear();
 	}
-  void ClearFlags() { flag_array.SetAll(0); }
+  inline void ClearFlags() { m_flag_array.SetAll(0); }
   void Reset(int new_size);     // Reset size, clearing contents...
-  void Resize(int new_size);    // Reset size, save contents, init to default
   void ResizeOld(int new_size); // Reset size, save contents, init to previous
-
-  bool FlagCopied(int pos) const     { return MASK_COPIED   & flag_array[pos]; }
-  bool FlagMutated(int pos) const    { return MASK_MUTATED  & flag_array[pos]; }
-  bool FlagExecuted(int pos) const   { return MASK_EXECUTED & flag_array[pos]; }
-  bool FlagBreakpoint(int pos) const { return MASK_BREAK    & flag_array[pos]; }
-  bool FlagPointMut(int pos) const   { return MASK_POINTMUT & flag_array[pos]; }
-  bool FlagCopyMut(int pos) const    { return MASK_COPYMUT  & flag_array[pos]; }
-  bool FlagInjected(int pos) const   { return MASK_INJECTED & flag_array[pos]; }
-  
-  void SetFlagCopied(int pos)     { flag_array[pos] |= MASK_COPIED;   }
-  void SetFlagMutated(int pos)    { flag_array[pos] |= MASK_MUTATED;  }
-  void SetFlagExecuted(int pos)   { flag_array[pos] |= MASK_EXECUTED; }
-  void SetFlagBreakpoint(int pos) { flag_array[pos] |= MASK_BREAK;    }
-  void SetFlagPointMut(int pos)   { flag_array[pos] |= MASK_POINTMUT; }
-  void SetFlagCopyMut(int pos)    { flag_array[pos] |= MASK_COPYMUT;  }
-  void SetFlagInjected(int pos)   { flag_array[pos] |= MASK_INJECTED; }
-	
-	void ClearFlagCopied(int pos)     { flag_array[pos] &= ~MASK_COPIED;   }
-	void ClearFlagMutated(int pos)    { flag_array[pos] &= ~MASK_MUTATED;  }
-	void ClearFlagExecuted(int pos)   { flag_array[pos] &= ~MASK_EXECUTED; }
-	void ClearFlagBreakpoint(int pos) { flag_array[pos] &= ~MASK_BREAK;    }
-	void ClearFlagPointMut(int pos)   { flag_array[pos] &= ~MASK_POINTMUT; }
-	void ClearFlagCopyMut(int pos)    { flag_array[pos] &= ~MASK_COPYMUT;  }
-  void ClearFlagInjected(int pos)   { flag_array[pos] &= ~MASK_INJECTED; }
     
-  void Append(const cInstruction& in_inst) { Insert(GetSize(), in_inst); }
-  void Append(const cGenome& in_genome) { Insert(GetSize(), in_genome); }
-  void Insert(int pos, const cInstruction& in_inst);
-  void Insert(int pos, const cGenome& in_genome);
-  void Remove(int pos, int num_insts=1);
-  void Replace(int pos, int num_insts, const cGenome& in_genome);
+  
+  void Resize(int new_size);
+  void Copy(int to, int from);
+  void Insert(int pos, const cInstruction& inst);
+  void Insert(int pos, const cGenome& genome);
+  void Remove(int pos, int num_sites = 1);
+  void Replace(int pos, int num_sites, const cGenome& genome);
+
+  void operator=(const cCPUMemory& other_memory);
+  void operator=(const cGenome& other_genome);
 };
 
-
-#ifdef ENABLE_UNIT_TESTS
-namespace nCPUMemory {
-  /**
-   * 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/cpu/cHardwareBase.cc
===================================================================
--- development/source/cpu/cHardwareBase.cc	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/cpu/cHardwareBase.cc	2009-03-30 16:14:07 UTC (rev 3198)
@@ -181,7 +181,7 @@
 int cHardwareBase::Divide_DoMutations(cAvidaContext& ctx, double mut_multiplier, const int maxmut)
 {
   int totalMutations = 0;
-  cCPUMemory& offspring_genome = m_organism->ChildGenome();
+  cGenome& offspring_genome = m_organism->OffspringGenome().GetGenome();
   
   m_organism->GetPhenotype().SetDivType(mut_multiplier);
   
@@ -327,7 +327,7 @@
 }
 
 
-bool cHardwareBase::doUniformMutation(cAvidaContext& ctx, cCPUMemory& genome)
+bool cHardwareBase::doUniformMutation(cAvidaContext& ctx, cGenome& genome)
 {
   int mut = ctx.GetRandom().GetUInt((m_inst_set->GetSize() * 2) + 1);
   
@@ -363,7 +363,7 @@
 // to another random position and continued reading to the end.
 // This can cause large deletions or tandem duplications.
 // Unlucky organisms might exceed the allowed length (randomly) if these mutations occur.
-void cHardwareBase::doSlipMutation(cAvidaContext& ctx, cCPUMemory& genome, int from)
+void cHardwareBase::doSlipMutation(cAvidaContext& ctx, cGenome& genome, int from)
 {
   cGenome genome_copy = cGenome(genome);
   
@@ -448,7 +448,7 @@
 {
   int maxmut = pointmut;
   int totalMutations = 0;
-  cCPUMemory& child_genome = m_organism->ChildGenome();
+  cGenome& child_genome = m_organism->OffspringGenome().GetGenome();
   
   m_organism->GetPhenotype().SetDivType(mut_multiplier);
   
@@ -485,7 +485,7 @@
 bool cHardwareBase::Divide_TestFitnessMeasures(cAvidaContext& ctx)
 {
   cPhenotype & phenotype = m_organism->GetPhenotype();
-  phenotype.CopyTrue() = ( m_organism->ChildGenome() == m_organism->GetGenome() );
+  phenotype.CopyTrue() = ( m_organism->OffspringGenome() == m_organism->GetMetaGenome() );
   phenotype.ChildFertile() = true;
 	
   // Only continue if we're supposed to do a fitness test on divide...
@@ -504,7 +504,7 @@
       cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
       cCPUTestInfo test_info;
       test_info.UseRandomInputs();
-      testcpu->TestGenome(ctx, test_info, m_organism->ChildGenome());
+      testcpu->TestGenome(ctx, test_info, m_organism->OffspringGenome().GetGenome());
       const double child_fitness = test_info.GetGenotypeFitness();
       delete testcpu;
       
@@ -534,7 +534,7 @@
       // Ideally, we won't have reversions and sterilizations turned on at the
       // same time, but if we do, give revert the priority.
       if (revert == true) {
-        m_organism->ChildGenome() = m_organism->GetGenome();
+        m_organism->OffspringGenome() = m_organism->GetMetaGenome();
       }
       
       if (sterilize == true) {
@@ -552,7 +552,7 @@
 bool cHardwareBase::Divide_TestFitnessMeasures1(cAvidaContext& ctx)
 {
   cPhenotype & phenotype = m_organism->GetPhenotype();
-  phenotype.CopyTrue() = (m_organism->ChildGenome() == m_organism->GetGenome());
+  phenotype.CopyTrue() = (m_organism->OffspringGenome() == m_organism->GetMetaGenome());
   phenotype.ChildFertile() = true;
 	
   // Only continue if we're supposed to do a fitness test on divide...
@@ -571,7 +571,7 @@
   cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
   cCPUTestInfo test_info;
   test_info.UseRandomInputs();
-  testcpu->TestGenome(ctx, test_info, m_organism->ChildGenome());
+  testcpu->TestGenome(ctx, test_info, m_organism->OffspringGenome().GetGenome());
   const double child_fitness = test_info.GetGenotypeFitness();
   delete testcpu;
   
@@ -605,7 +605,7 @@
   // Ideally, we won't have reversions and sterilizations turned on at the
   // same time, but if we do, give revert the priority.
   if (revert == true) {
-    m_organism->ChildGenome() = m_organism->GetGenome();
+    m_organism->OffspringGenome() = m_organism->GetMetaGenome();
   }
   
   if (sterilize == true) {
@@ -630,14 +630,13 @@
   return num_muts;
 }
 
-void cHardwareBase::TriggerMutations_Body(cAvidaContext& ctx, int type, cCPUMemory & target_memory, cHeadCPU& cur_head)
+void cHardwareBase::TriggerMutations_Body(cAvidaContext& ctx, int type, cGenome& target_memory, cHeadCPU& cur_head)
 {
   const int pos = cur_head.GetPosition();
 	
   switch (type) {
 		case nMutation::TYPE_POINT:
 			target_memory[pos] = m_inst_set->GetRandomInst(ctx);
-			target_memory.SetFlagMutated(pos);
 			break;
 		case nMutation::TYPE_INSERT:
 		case nMutation::TYPE_DELETE:
@@ -653,7 +652,7 @@
 
 
 bool cHardwareBase::TriggerMutations_ScopeGenome(cAvidaContext& ctx, const cMutation* cur_mut,
-                                                 cCPUMemory& target_memory, cHeadCPU& cur_head, const double rate)
+                                                 cGenome& target_memory, cHeadCPU& cur_head, const double rate)
 {
   // The rate we have stored indicates the probability that a single
   // mutation will occur anywhere in the genome.
@@ -670,7 +669,7 @@
 }
 
 bool cHardwareBase::TriggerMutations_ScopeLocal(cAvidaContext& ctx, const cMutation* cur_mut,
-                                                cCPUMemory& target_memory, cHeadCPU& cur_head, const double rate)
+                                                cGenome& target_memory, cHeadCPU& cur_head, const double rate)
 {
   // The rate we have stored is the probability for a mutation at this single
   // position in the genome.
@@ -682,8 +681,8 @@
   return false;
 }
 
-int cHardwareBase::TriggerMutations_ScopeGlobal(cAvidaContext& ctx, const cMutation * cur_mut,
-                                                cCPUMemory & target_memory, cHeadCPU& cur_head, const double rate)
+int cHardwareBase::TriggerMutations_ScopeGlobal(cAvidaContext& ctx, const cMutation* cur_mut,
+                                                cGenome& target_memory, cHeadCPU& cur_head, const double rate)
 {
   // The probability we have stored is per-site, so we can pull a random
   // number from a binomial distribution to determine the number of mutations
@@ -727,7 +726,7 @@
   bool has_mutation = false;
 	
   // Determine what memory this mutation will be affecting.
-  cCPUMemory& target_mem = (trigger == nMutation::TRIGGER_DIVIDE) ? m_organism->ChildGenome() : GetMemory();
+  cGenome& target_mem = (trigger == nMutation::TRIGGER_DIVIDE) ? m_organism->OffspringGenome().GetGenome() : GetMemory();
 	
   // Loop through all mutations associated with this trigger and test them.
   tConstListIterator<cMutation> mut_it(mut_list);

Modified: development/source/cpu/cHardwareBase.h
===================================================================
--- development/source/cpu/cHardwareBase.h	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/cpu/cHardwareBase.h	2009-03-30 16:14:07 UTC (rev 3198)
@@ -60,6 +60,7 @@
 protected:
   cWorld* m_world;
   cOrganism* m_organism;     // Organism using this hardware.
+  int m_inst_set_id;
   cInstSet* m_inst_set;      // Instruction set being used.
   cHardwareTracer* m_tracer; // Set this if you want execution traced.
 
@@ -81,8 +82,8 @@
   cHardwareBase& operator=(const cHardwareBase&); // @not_implemented
 
 public:
-  cHardwareBase(cWorld* world, cOrganism* in_organism, cInstSet* inst_set)
-    : m_world(world), m_organism(in_organism), m_inst_set(inst_set), m_tracer(NULL)
+  cHardwareBase(cWorld* world, cOrganism* in_organism, cInstSet* inst_set, int inst_set_id)
+    : m_world(world), m_organism(in_organism), m_inst_set_id(inst_set_id), m_inst_set(inst_set), m_tracer(NULL)
     , m_has_costs(inst_set->HasCosts()), m_has_ft_costs(inst_set->HasFTCosts())
     , m_has_energy_costs(m_inst_set->HasEnergyCosts())
   {
@@ -90,6 +91,8 @@
     assert(m_organism != NULL);
   }
   virtual ~cHardwareBase() { ; }
+  
+  int GetInstSetID() const { return m_inst_set_id; }
 
   
   // --------  Organism  ---------
@@ -107,6 +110,7 @@
   
   // --------  Helper methods  --------
   virtual int GetType() const = 0;
+  virtual bool SupportsSpeculative() const = 0;
   virtual bool OK() = 0;
   virtual void PrintStatus(std::ostream& fp) = 0;
   void SetTrace(cHardwareTracer* tracer) { m_tracer = tracer; }
@@ -214,9 +218,9 @@
 
   
   // --------  Mutation Helper Methods  --------
-  bool doUniformMutation(cAvidaContext& ctx, cCPUMemory& genome);
+  bool doUniformMutation(cAvidaContext& ctx, cGenome& genome);
   void doUniformCopyMutation(cAvidaContext& ctx, cHeadCPU& head);
-  void doSlipMutation(cAvidaContext& ctx, cCPUMemory& genome, int from = -1);
+  void doSlipMutation(cAvidaContext& ctx, cGenome& genome, int from = -1);
   
 
   // --------  Organism Execution Property Calculation  --------
@@ -231,13 +235,13 @@
   
 
   // --------  Mutation Triggers  --------
-  void TriggerMutations_Body(cAvidaContext& ctx, int type, cCPUMemory& target_memory, cHeadCPU& cur_head);
+  void TriggerMutations_Body(cAvidaContext& ctx, int type, cGenome& target_memory, cHeadCPU& cur_head);
   bool TriggerMutations_ScopeGenome(cAvidaContext& ctx, const cMutation* cur_mut,
-																		cCPUMemory& target_memory, cHeadCPU& cur_head, const double rate);
+																		cGenome& target_memory, cHeadCPU& cur_head, const double rate);
   bool TriggerMutations_ScopeLocal(cAvidaContext& ctx, const cMutation* cur_mut,
-																	 cCPUMemory& target_memory, cHeadCPU& cur_head, const double rate);
+																	 cGenome& target_memory, cHeadCPU& cur_head, const double rate);
   int TriggerMutations_ScopeGlobal(cAvidaContext& ctx, const cMutation* cur_mut,
-																	 cCPUMemory& target_memory, cHeadCPU& cur_head, const double rate);  
+																	 cGenome& target_memory, cHeadCPU& cur_head, const double rate);  
 };
 
 

Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/cpu/cHardwareCPU.cc	2009-03-30 16:14:07 UTC (rev 3198)
@@ -565,8 +565,8 @@
   return new tInstLib<tMethod>(f_size, s_f_array, n_names, nop_mods, functions, def, null_inst);
 }
 
-cHardwareCPU::cHardwareCPU(cAvidaContext& ctx, cWorld* world, cOrganism* in_organism, cInstSet* in_m_inst_set)
-: cHardwareBase(world, in_organism, in_m_inst_set)
+cHardwareCPU::cHardwareCPU(cAvidaContext& ctx, cWorld* world, cOrganism* in_organism, cInstSet* in_inst_set, int inst_set_id)
+: cHardwareBase(world, in_organism, in_inst_set, inst_set_id)
 , m_last_cell_data(false, 0)
 {
   m_functions = s_inst_slib->GetFunctions();
@@ -841,9 +841,7 @@
 bool cHardwareCPU::OK()
 {
   bool result = true;
-  
-  if (!m_memory.OK()) result = false;
-  
+    
   for (int i = 0; i < m_threads.GetSize(); i++) {
     if (m_threads[i].stack.OK() == false) result = false;
     if (m_threads[i].next_label.OK() == false) result = false;
@@ -1461,8 +1459,10 @@
   
   // Since the divide will now succeed, set up the information to be sent
   // to the new organism
-  cGenome & child_genome = m_organism->ChildGenome();
+  cGenome& child_genome = m_organism->OffspringGenome().GetGenome();
   child_genome = cGenomeUtil::Crop(m_memory, div_point, div_point+child_size);
+  m_organism->OffspringGenome().SetHardwareType(GetType());
+  m_organism->OffspringGenome().SetInstSetID(GetInstSetID());
   
   // Make sure it is an exact copy at this point (before divide mutations) if required
   if (m_world->GetConfig().REQUIRE_EXACT_COPY.Get() && (m_organism->GetGenome() != child_genome) ) {
@@ -1529,8 +1529,10 @@
   
   // Since the divide will now succeed, set up the information to be sent
   // to the new organism
-  cGenome & child_genome = m_organism->ChildGenome();
+  cGenome& child_genome = m_organism->OffspringGenome().GetGenome();
   child_genome = cGenomeUtil::Crop(m_memory, div_point, div_point+child_size);
+  m_organism->OffspringGenome().SetHardwareType(GetType());
+  m_organism->OffspringGenome().SetInstSetID(GetInstSetID());
   
   // Cut off everything in this memory past the divide point.
   m_memory.Resize(div_point);
@@ -1620,8 +1622,10 @@
   
   // Since the divide will now succeed, set up the information to be sent
   // to the new organism
-  cGenome & child_genome = m_organism->ChildGenome();
+  cGenome& child_genome = m_organism->OffspringGenome().GetGenome();
   child_genome = cGenomeUtil::Crop(m_memory, div_point, div_point+child_size);
+  m_organism->OffspringGenome().SetHardwareType(GetType());
+  m_organism->OffspringGenome().SetInstSetID(GetInstSetID());
   
   // Cut off everything in this memory past the divide point.
   m_memory.Resize(div_point);
@@ -1711,8 +1715,10 @@
   
   // Since the divide will now succeed, set up the information to be sent
   // to the new organism
-  cGenome & child_genome = m_organism->ChildGenome();
+  cGenome& child_genome = m_organism->OffspringGenome().GetGenome();
   child_genome = cGenomeUtil::Crop(m_memory, div_point, div_point+child_size);
+  m_organism->OffspringGenome().SetHardwareType(GetType());
+  m_organism->OffspringGenome().SetInstSetID(GetInstSetID());
   
   // Cut off everything in this memory past the divide point.
   m_memory.Resize(div_point);
@@ -2789,19 +2795,16 @@
   if (!transposon_in_use) return;
   
   static cInstruction transposon_inst = GetInstSet().GetInst(cStringUtil::Stringf("transposon"));
-  cCPUMemory& child_genome = m_organism->ChildGenome();
+  cGenome& child_genome = m_organism->OffspringGenome().GetGenome();
 
   // Count the number of transposons that are marked as executed
   int tr_count = 0;
-  for (int i=0; i < child_genome.GetSize(); i++) 
-  {
-    if (child_genome.FlagExecuted(i) && (child_genome[i] == transposon_inst)) tr_count++;
+  for (int i = 0; i < m_memory.GetSize(); i++) {
+    if (m_memory.FlagExecuted(i) && (m_memory[i] == transposon_inst)) tr_count++;
   }
   
-  for (int i=0; i < tr_count; i++) 
-  {
-    if (ctx.GetRandom().P(0.01))
-    {
+  for (int i = 0; i < tr_count; i++) {
+    if (ctx.GetRandom().P(0.01)) {
       const unsigned int mut_line = ctx.GetRandom().GetUInt(child_genome.GetSize() + 1);
       child_genome.Insert(mut_line, transposon_inst);
     }
@@ -2831,8 +2834,10 @@
   if (m_organism->GetPhenotype().GetCurBonus() < m_world->GetConfig().REQUIRED_BONUS.Get()) return false;
   
   // Setup child
-  cCPUMemory& child_genome = m_organism->ChildGenome();
+  cGenome& child_genome = m_organism->OffspringGenome().GetGenome();
   child_genome = m_organism->GetGenome();
+  m_organism->OffspringGenome().SetHardwareType(GetType());
+  m_organism->OffspringGenome().SetInstSetID(GetInstSetID());
 
   // Do transposon movement and copying before other mutations
   Divide_DoTransposons(ctx);
@@ -2849,7 +2854,7 @@
   Divide_DoMutations(ctx);
   
   // Check viability
-  bool viable = Divide_CheckViable(ctx, m_organism->GetGenome().GetSize(), m_organism->ChildGenome().GetSize(), 1);
+  bool viable = Divide_CheckViable(ctx, m_organism->GetGenome().GetSize(), m_organism->OffspringGenome().GetSize(), 1);
   if (!viable) { return false; }
   
   // Many tests will require us to run the offspring through a test CPU;

Modified: development/source/cpu/cHardwareCPU.h
===================================================================
--- development/source/cpu/cHardwareCPU.h	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/cpu/cHardwareCPU.h	2009-03-30 16:14:07 UTC (rev 3198)
@@ -245,8 +245,9 @@
   cHardwareCPU& operator=(const cHardwareCPU&); // @not_implemented
 
 public:
-  cHardwareCPU(cAvidaContext& ctx, cWorld* world, cOrganism* in_organism, cInstSet* in_inst_set);
+  cHardwareCPU(cAvidaContext& ctx, cWorld* world, cOrganism* in_organism, cInstSet* in_inst_set, int inst_set_id);
   ~cHardwareCPU() { ; }
+  
   static tInstLib<tMethod>* GetInstLib() { return s_inst_slib; }
   static cString GetDefaultInstFilename() { return "instset-classic.cfg"; }
 
@@ -256,6 +257,7 @@
   
   // --------  Helper methods  --------
   int GetType() const { return HARDWARE_TYPE_CPU_ORIGINAL; }  
+  bool SupportsSpeculative() const { return true; }
   bool OK();
   void PrintStatus(std::ostream& fp);
 

Modified: development/source/cpu/cHardwareExperimental.cc
===================================================================
--- development/source/cpu/cHardwareExperimental.cc	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/cpu/cHardwareExperimental.cc	2009-03-30 16:14:07 UTC (rev 3198)
@@ -210,8 +210,9 @@
   return new tInstLib<tMethod>(f_size, s_f_array, n_names, nop_mods, functions, def, null_inst);
 }
 
-cHardwareExperimental::cHardwareExperimental(cAvidaContext& ctx, cWorld* world, cOrganism* in_organism, cInstSet* in_m_inst_set)
-: cHardwareBase(world, in_organism, in_m_inst_set)
+cHardwareExperimental::cHardwareExperimental(cAvidaContext& ctx, cWorld* world, cOrganism* in_organism,
+                                             cInstSet* in_inst_set, int inst_set_id)
+: cHardwareBase(world, in_organism, in_inst_set, inst_set_id)
 {
   m_functions = s_inst_slib->GetFunctions();
   
@@ -476,8 +477,6 @@
 {
   bool result = true;
   
-  if (!m_memory.OK()) result = false;
-  
   for (int i = 0; i < m_threads.GetSize(); i++) {
     if (m_threads[i].next_label.OK() == false) result = false;
   }
@@ -950,8 +949,9 @@
   
   // Since the divide will now succeed, set up the information to be sent
   // to the new organism
-  cGenome & child_genome = m_organism->ChildGenome();
-  child_genome = cGenomeUtil::Crop(m_memory, div_point, div_point+child_size);
+  m_organism->OffspringGenome().SetGenome(cGenomeUtil::Crop(m_memory, div_point, div_point+child_size));
+  m_organism->OffspringGenome().SetHardwareType(GetType());
+  m_organism->OffspringGenome().SetInstSetID(GetInstSetID());
   
   // Cut off everything in this memory past the divide point.
   m_memory.Resize(div_point);
@@ -1869,9 +1869,10 @@
   
   // Since the divide will now succeed, set up the information to be sent
   // to the new organism
-  cGenome & child_genome = m_organism->ChildGenome();
-  child_genome = m_memory;
-  m_organism->GetPhenotype().SetLinesCopied(child_genome.GetSize());
+  m_organism->OffspringGenome().SetGenome(m_memory);
+  m_organism->OffspringGenome().SetHardwareType(GetType());
+  m_organism->OffspringGenome().SetInstSetID(GetInstSetID());
+  m_organism->GetPhenotype().SetLinesCopied(m_memory.GetSize());
 
   int lines_executed = 0;
   for (int i = 0; i < m_memory.GetSize(); i++) if (m_memory.FlagExecuted(i)) lines_executed++;
@@ -1881,7 +1882,7 @@
   // Perform Copy Mutations...
   if (m_organism->GetCopyMutProb() > 0) { // Skip this if no mutations....
     for (int i = 0; i < m_memory.GetSize(); i++) {
-      if (m_organism->TestCopyMut(ctx)) child_genome[i] = m_inst_set->GetRandomInst(ctx);
+      if (m_organism->TestCopyMut(ctx)) m_organism->OffspringGenome().GetGenome()[i] = m_inst_set->GetRandomInst(ctx);
     }
   }
   

Modified: development/source/cpu/cHardwareExperimental.h
===================================================================
--- development/source/cpu/cHardwareExperimental.h	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/cpu/cHardwareExperimental.h	2009-03-30 16:14:07 UTC (rev 3198)
@@ -231,7 +231,7 @@
 
   
 public:
-  cHardwareExperimental(cAvidaContext& ctx, cWorld* world, cOrganism* in_organism, cInstSet* in_inst_set);
+  cHardwareExperimental(cAvidaContext& ctx, cWorld* world, cOrganism* in_organism, cInstSet* in_inst_set, int inst_set_id);
   ~cHardwareExperimental() { ; }
   
   static tInstLib<cHardwareExperimental::tMethod>* GetInstLib() { return s_inst_slib; }
@@ -244,7 +244,8 @@
 
   
   // --------  Helper Methods  --------
-  int GetType() const { return HARDWARE_TYPE_CPU_ORIGINAL; }  
+  int GetType() const { return HARDWARE_TYPE_CPU_EXPERIMENTAL; }  
+  bool SupportsSpeculative() const { return true; }
   bool OK();
   void PrintStatus(std::ostream& fp);
 
@@ -355,7 +356,6 @@
   
   // --------  Division Support  -------
   bool Divide_Main(cAvidaContext& ctx, const int divide_point, const int extra_lines=0, double mut_multiplier=1);
-  void Divide_DoTransposons(cAvidaContext& ctx);
   
 
   // --------  Parasite Stuff  --------

Modified: development/source/cpu/cHardwareGX.cc
===================================================================
--- development/source/cpu/cHardwareGX.cc	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/cpu/cHardwareGX.cc	2009-03-30 16:14:07 UTC (rev 3198)
@@ -311,8 +311,9 @@
 /*! Construct a cHardwareGX instance from the passed-in cOrganism.  This amounts to
 creating an initial cProgramid from in_organism's genome.
 */
-cHardwareGX::cHardwareGX(cAvidaContext& ctx, cWorld* world, cOrganism* in_organism, cInstSet* in_m_inst_set)
-: cHardwareBase(world, in_organism, in_m_inst_set)
+cHardwareGX::cHardwareGX(cAvidaContext& ctx, cWorld* world, cOrganism* in_organism,
+                         cInstSet* in_inst_set, int inst_set_id)
+: cHardwareBase(world, in_organism, in_inst_set, inst_set_id)
 {
   m_last_unique_id_assigned = 0;
   m_functions = s_inst_slib->GetFunctions();
@@ -413,6 +414,8 @@
   */
 bool cHardwareGX::SingleProcess(cAvidaContext& ctx, bool speculative)
 {
+  if (speculative) return false;
+
   cPhenotype& phenotype = m_organism->GetPhenotype();
 
   // Turn over programids if using the implicit model
@@ -630,7 +633,7 @@
 {
   bool result = true;
   for(programid_list::iterator i=m_programids.begin(); i!=m_programids.end() && result; ++i) {
-    result = result && (*i)->m_memory.OK() && (*i)->m_stack.OK() && (*i)->m_next_label.OK();
+    result = result && (*i)->m_stack.OK() && (*i)->m_next_label.OK();
   }
   return result;
 }
@@ -1245,7 +1248,7 @@
 //  
 //  // Since the divide will now succeed, set up the information to be sent
 //  // to the new organism
-//  cGenome & child_genome = m_organism->ChildGenome();
+//  cGenome & child_genome = m_organism->OffspringGenome();
 //  child_genome = cGenomeUtil::Crop(m_memory, div_point, div_point+child_size);
 //  
 //  // Cut off everything in this memory past the divide point.
@@ -2076,8 +2079,10 @@
 bool cHardwareGX::Inst_Repro(cAvidaContext& ctx)
 {
   // Setup child
-  cCPUMemory& child_genome = m_organism->ChildGenome();
+  cGenome& child_genome = m_organism->OffspringGenome().GetGenome();
   child_genome = m_organism->GetGenome();
+  m_organism->OffspringGenome().SetHardwareType(GetType());
+  m_organism->OffspringGenome().SetInstSetID(GetInstSetID());
   m_organism->GetPhenotype().SetLinesCopied(m_organism->GetGenome().GetSize());
   
   Divide_DoMutations(ctx);
@@ -3766,8 +3771,10 @@
   
   // Ok, we're good to go.  We have to create the offspring's genome and delete the
   // offspring's programids from m_programids.
-  cCPUMemory& child_genome = m_organism->ChildGenome();
+  cGenome& child_genome = m_organism->OffspringGenome().GetGenome();
   child_genome.Resize(1);
+  m_organism->OffspringGenome().SetHardwareType(GetType());
+  m_organism->OffspringGenome().SetInstSetID(GetInstSetID());
   if (m_world->GetVerbosity() >= VERBOSE_DETAILS) std::cout << "-=OFFSPRING=-" << endl;
   for(programid_list::iterator i=offspring.begin(); i!=offspring.end(); ++i) {
     (*i)->AppendLinearGenome(child_genome);
@@ -3881,9 +3888,11 @@
 
   // Since the divide will now succeed, set up the information to be sent
   // to the new organism
-  cGenome & child_genome = m_organism->ChildGenome();
+  cGenome& child_genome = m_organism->OffspringGenome().GetGenome();
   child_genome = m_programids[write_head.GetMemSpace()]->GetMemory();
   child_genome = cGenomeUtil::Crop(child_genome, 0, child_end);
+  m_organism->OffspringGenome().SetHardwareType(GetType());
+  m_organism->OffspringGenome().SetInstSetID(GetInstSetID());
 
 
   // Handle Divide Mutations...
@@ -4333,7 +4342,7 @@
 /*! Append this programid's genome to the passed in genome.  Include the tags
 that specify what this programid is capable of.
 */
-void cHardwareGX::cProgramid::AppendLinearGenome(cCPUMemory& genome) {
+void cHardwareGX::cProgramid::AppendLinearGenome(cGenome& genome) {
   genome.Append(GetInst("PROGRAMID"));
   if(GetExecutable()) { genome.Append(GetInst("EXECUTABLE")); }
   if(GetBindable()) { genome.Append(GetInst("BINDABLE")); }

Modified: development/source/cpu/cHardwareGX.h
===================================================================
--- development/source/cpu/cHardwareGX.h	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/cpu/cHardwareGX.h	2009-03-30 16:14:07 UTC (rev 3198)
@@ -187,7 +187,7 @@
     const cCPUMemory& GetMemory() const { return m_memory; }
     
     //! Append this programid's genome to the passed-in genome in linear format (includes tags).
-    void AppendLinearGenome(cCPUMemory& genome);
+    void AppendLinearGenome(cGenome& genome);
 
     //! Print this programid's genome, in linear format.
     void PrintGenome(std::ostream& out);
@@ -307,7 +307,7 @@
 
 public:
   //! Main constructor for cHardwareGX; called from cHardwareManager for every organism.
-  cHardwareGX(cAvidaContext& ctx, cWorld* world, cOrganism* in_organism, cInstSet* in_inst_set);
+  cHardwareGX(cAvidaContext& ctx, cWorld* world, cOrganism* in_organism, cInstSet* in_inst_set, int inst_set_id);
   virtual ~cHardwareGX(); //!< Destructor; removes all cProgramids.
     
   static tInstLib<tMethod>* GetInstLib() { return s_inst_slib; }
@@ -319,6 +319,7 @@
   
   // --------  Helper methods  --------
   int GetType() const { return HARDWARE_TYPE_CPU_GX; }  
+  bool SupportsSpeculative() const { return false; }
   bool OK();
   void PrintStatus(std::ostream& fp);
 

Modified: development/source/cpu/cHardwareManager.cc
===================================================================
--- development/source/cpu/cHardwareManager.cc	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/cpu/cHardwareManager.cc	2009-03-30 16:14:07 UTC (rev 3198)
@@ -34,18 +34,20 @@
 #include "cHardwareStatusPrinter.h"
 #include "cInitFile.h"
 #include "cInstSet.h"
+#include "cMetaGenome.h"
 #include "cStringUtil.h"
 #include "cWorld.h"
 #include "tDictionary.h"
 
+
 cHardwareManager::cHardwareManager(cWorld* world)
-: m_world(world), m_type(world->GetConfig().HARDWARE_TYPE.Get()), m_cpu_count(0)
+: m_world(world), m_cpu_count(0)
 {
   cString filename = world->GetConfig().INST_SET.Get();
 
   // Setup the instruction library and collect the default filename
   cString default_filename;
-	switch (m_type)
+	switch (world->GetConfig().HARDWARE_TYPE.Get())
 	{
 		case HARDWARE_TYPE_CPU_ORIGINAL:
       m_inst_set = new cInstSet(world, cHardwareCPU::GetInstLib());
@@ -83,27 +85,30 @@
   }
 }
 
-cHardwareBase* cHardwareManager::Create(cAvidaContext& ctx, cOrganism* in_org, cInstSet* inst_set)
+cHardwareBase* cHardwareManager::Create(cAvidaContext& ctx, cOrganism* org, const cMetaGenome& mg, cInstSet* is)
 {
-  assert(in_org != NULL);
+  assert(org != NULL);
 	
+  int inst_set_id = (is == NULL) ? 1 : -1;
+  cInstSet* inst_set = (is == NULL) ? m_inst_set : is;
+  
   cHardwareBase* hw = 0;
 	
-  switch (m_type) {
+  switch (mg.GetHardwareType()) {
     case HARDWARE_TYPE_CPU_ORIGINAL:
-      hw = new cHardwareCPU(ctx, m_world, in_org, inst_set);
+      hw = new cHardwareCPU(ctx, m_world, org, inst_set, inst_set_id);
       break;
     case HARDWARE_TYPE_CPU_SMT:
-      hw = new cHardwareSMT(ctx, m_world, in_org, inst_set);
+      hw = new cHardwareSMT(ctx, m_world, org, inst_set, inst_set_id);
       break;
     case HARDWARE_TYPE_CPU_TRANSSMT:
-      hw = new cHardwareTransSMT(ctx, m_world, in_org, inst_set);
+      hw = new cHardwareTransSMT(ctx, m_world, org, inst_set, inst_set_id);
       break;
     case HARDWARE_TYPE_CPU_EXPERIMENTAL:
-      hw = new cHardwareExperimental(ctx, m_world, in_org, inst_set);
+      hw = new cHardwareExperimental(ctx, m_world, org, inst_set, inst_set_id);
       break;
     case HARDWARE_TYPE_CPU_GX:
-      hw = new cHardwareGX(ctx, m_world, in_org, inst_set);
+      hw = new cHardwareGX(ctx, m_world, org, inst_set, inst_set_id);
       break;
     default:
       cDriverManager::Status().SignalError("Unknown/Unsupported HARDWARE_TYPE specified", -1);
@@ -119,16 +124,3 @@
   assert(hw != 0);
   return hw;
 }
-
-bool cHardwareManager::SupportsSpeculative()
-{
-  switch (m_type)
-  {
-    case HARDWARE_TYPE_CPU_ORIGINAL:      return true;
-    case HARDWARE_TYPE_CPU_SMT:           return false;
-    case HARDWARE_TYPE_CPU_TRANSSMT:      return false;
-    case HARDWARE_TYPE_CPU_EXPERIMENTAL:  return true;
-    case HARDWARE_TYPE_CPU_GX:            return false;
-    default:                              return false;
-  }
-}

Modified: development/source/cpu/cHardwareManager.h
===================================================================
--- development/source/cpu/cHardwareManager.h	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/cpu/cHardwareManager.h	2009-03-30 16:14:07 UTC (rev 3198)
@@ -38,6 +38,7 @@
 class cAvidaContext;
 class cHardwareBase;
 class cInstSet;
+class cMetaGenome;
 class cOrganism;
 class cWorld;
 
@@ -50,7 +51,6 @@
 private:
   cWorld* m_world;
   cInstSet* m_inst_set;
-  int m_type;
   int m_cpu_count;
   
   
@@ -63,14 +63,11 @@
   cHardwareManager(cWorld* world);
   ~cHardwareManager() { ; }
   
-  cHardwareBase* Create(cAvidaContext& ctx, cOrganism* in_org, cInstSet* inst_set);
-  inline cHardwareBase* Create(cAvidaContext& ctx, cOrganism* in_org) { return Create(ctx, in_org, m_inst_set); }
-  cTestCPU* CreateTestCPU() { return new cTestCPU(m_world); }
+  cHardwareBase* Create(cAvidaContext& ctx, cOrganism* org, const cMetaGenome& mg, cInstSet* is = NULL);
+  inline cTestCPU* CreateTestCPU() { return new cTestCPU(m_world); }
 
   const cInstSet& GetInstSet() const { return *m_inst_set; }
   cInstSet& GetInstSet() { return *m_inst_set; }
-  
-  bool SupportsSpeculative();
 };
 
 

Modified: development/source/cpu/cHardwareSMT.cc
===================================================================
--- development/source/cpu/cHardwareSMT.cc	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/cpu/cHardwareSMT.cc	2009-03-30 16:14:07 UTC (rev 3198)
@@ -133,8 +133,8 @@
   return new tInstLib<tMethod>(f_size, s_f_array, n_names, nop_mods, functions, def, null_inst);
 }
 
-cHardwareSMT::cHardwareSMT(cAvidaContext& ctx, cWorld* world, cOrganism* in_organism, cInstSet* in_m_inst_set)
-: cHardwareBase(world, in_organism, in_m_inst_set), m_mem_array(1), m_mem_marks(1)
+cHardwareSMT::cHardwareSMT(cAvidaContext& ctx, cWorld* world, cOrganism* in_organism, cInstSet* in_inst_set, int inst_set_id)
+: cHardwareBase(world, in_organism, in_inst_set, inst_set_id), m_mem_array(1), m_mem_marks(1)
 , m_mem_lbls(Pow(NUM_NOPS, MAX_MEMSPACE_LABEL) / MEM_LBLS_HASH_FACTOR)
 , m_thread_lbls(Pow(NUM_NOPS, MAX_THREAD_LABEL) / THREAD_LBLS_HASH_FACTOR)
 {
@@ -186,6 +186,8 @@
 // to be as optimized as possible.  This is the heart of avida.
 bool cHardwareSMT::SingleProcess(cAvidaContext& ctx, bool speculative)
 {
+  if (speculative) return false;
+
   // Mark this organism as running...
   m_organism->SetRunning(true);
 	
@@ -299,11 +301,7 @@
 }
 
 bool cHardwareSMT::OK()
-{
-  for(int i = 0 ; i < m_mem_array.GetSize(); i++) {
-    if (!m_mem_array[i].OK()) return false;
-  }
-	
+{	
   for (int i = 0; i < m_threads.GetSize(); i++) {
     for(int j=0; j < NUM_LOCAL_STACKS; j++)
 			if (m_threads[i].local_stacks[j].OK() == false) return false;
@@ -917,7 +915,9 @@
   
   // Since the divide will now succeed, set up the information to be sent to the new organism
   m_mem_array[mem_space_used].Resize(write_head_pos);
-  m_organism->ChildGenome() = m_mem_array[mem_space_used];
+  m_organism->OffspringGenome().SetGenome(m_mem_array[mem_space_used]);
+  m_organism->OffspringGenome().SetHardwareType(GetType());
+  m_organism->OffspringGenome().SetInstSetID(GetInstSetID());
 	
   // Handle Divide Mutations...
   Divide_DoMutations(ctx, mut_multiplier);

Modified: development/source/cpu/cHardwareSMT.h
===================================================================
--- development/source/cpu/cHardwareSMT.h	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/cpu/cHardwareSMT.h	2009-03-30 16:14:07 UTC (rev 3198)
@@ -200,8 +200,9 @@
   cHardwareSMT& operator=(const cHardwareSMT&); // @not_implemented
   
 public:
-  cHardwareSMT(cAvidaContext& ctx, cWorld* world, cOrganism* in_organism, cInstSet* in_inst_set);
+  cHardwareSMT(cAvidaContext& ctx, cWorld* world, cOrganism* in_organism, cInstSet* in_inst_set, int inst_set_id);
   ~cHardwareSMT() { ; }
+
   static cInstLib* GetInstLib() { return s_inst_slib; }
   static cString GetDefaultInstFilename() { return "instset-smt.cfg"; }
 	
@@ -210,6 +211,7 @@
 	
   // --------  Helper methods  --------
   int GetType() const { return HARDWARE_TYPE_CPU_SMT; }
+  bool SupportsSpeculative() const { return false; }
   bool OK();
   void PrintStatus(std::ostream& fp);
 	

Modified: development/source/cpu/cHardwareTransSMT.cc
===================================================================
--- development/source/cpu/cHardwareTransSMT.cc	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/cpu/cHardwareTransSMT.cc	2009-03-30 16:14:07 UTC (rev 3198)
@@ -131,9 +131,10 @@
 	
   return new tInstLib<tMethod>(f_size, s_f_array, n_names, nop_mods, functions, def, null_inst);
 }
-
-cHardwareTransSMT::cHardwareTransSMT(cAvidaContext& ctx, cWorld* world, cOrganism* in_organism, cInstSet* in_m_inst_set)
-: cHardwareBase(world, in_organism, in_m_inst_set), m_mem_array(1)
+ 
+cHardwareTransSMT::cHardwareTransSMT(cAvidaContext& ctx, cWorld* world, cOrganism* in_organism,
+                                     cInstSet* in_inst_set, int inst_set_id)
+: cHardwareBase(world, in_organism, in_inst_set, inst_set_id), m_mem_array(1)
 , m_mem_lbls(Pow(NUM_NOPS, MAX_MEMSPACE_LABEL) / MEM_LBLS_HASH_FACTOR)
 , m_thread_lbls(Pow(NUM_NOPS, MAX_THREAD_LABEL) / THREAD_LBLS_HASH_FACTOR)
 {
@@ -185,6 +186,8 @@
 // to be as optimized as possible.  This is the heart of avida.
 bool cHardwareTransSMT::SingleProcess(cAvidaContext& ctx, bool speculative)
 {
+  if (speculative) return false;
+  
   // Mark this organism as running...
   m_organism->SetRunning(true);
 	
@@ -297,11 +300,7 @@
 }
 
 bool cHardwareTransSMT::OK()
-{
-  for(int i = 0 ; i < m_mem_array.GetSize(); i++) {
-    if (!m_mem_array[i].OK()) return false;
-  }
-	
+{	
   for (int i = 0; i < m_threads.GetSize(); i++) {
     for(int j=0; j < NUM_LOCAL_STACKS; j++)
 			if (m_threads[i].local_stacks[j].OK() == false) return false;
@@ -921,7 +920,9 @@
   
   // Since the divide will now succeed, set up the information to be sent to the new organism
   m_mem_array[mem_space_used].Resize(write_head_pos);
-  m_organism->ChildGenome() = m_mem_array[mem_space_used];
+  m_organism->OffspringGenome().SetGenome(m_mem_array[mem_space_used]);
+  m_organism->OffspringGenome().SetHardwareType(GetType());
+  m_organism->OffspringGenome().SetInstSetID(GetInstSetID());
 	
   // Handle Divide Mutations...
   Divide_DoMutations(ctx, mut_multiplier);

Modified: development/source/cpu/cHardwareTransSMT.h
===================================================================
--- development/source/cpu/cHardwareTransSMT.h	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/cpu/cHardwareTransSMT.h	2009-03-30 16:14:07 UTC (rev 3198)
@@ -198,8 +198,9 @@
   cHardwareTransSMT& operator=(const cHardwareTransSMT&); // @not_implemented
   
 public:
-  cHardwareTransSMT(cAvidaContext& ctx, cWorld* world, cOrganism* in_organism, cInstSet* in_inst_set);
+  cHardwareTransSMT(cAvidaContext& ctx, cWorld* world, cOrganism* in_organism, cInstSet* in_inst_set, int inst_set_id);
   ~cHardwareTransSMT() { ; }
+
   static cInstLib* GetInstLib() { return s_inst_slib; }
   static cString GetDefaultInstFilename() { return "instset-transsmt.cfg"; }
 	
@@ -207,7 +208,8 @@
   void ProcessBonusInst(cAvidaContext& ctx, const cInstruction& inst);
 	
   // --------  Helper methods  --------
-  int GetType() const { return HARDWARE_TYPE_CPU_SMT; }
+  int GetType() const { return HARDWARE_TYPE_CPU_TRANSSMT; }
+  bool SupportsSpeculative() const { return false; }
   bool OK();
   void PrintStatus(std::ostream& fp);
 	

Modified: development/source/cpu/cTestCPU.cc
===================================================================
--- development/source/cpu/cTestCPU.cc	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/cpu/cTestCPU.cc	2009-03-30 16:14:07 UTC (rev 3198)
@@ -213,7 +213,8 @@
 bool cTestCPU::TestGenome(cAvidaContext& ctx, cCPUTestInfo& test_info, const cGenome& genome)
 {
   test_info.Clear();
-  TestGenome_Body(ctx, test_info, genome, 0);
+  cMetaGenome mg(m_world->GetConfig().HARDWARE_TYPE.Get(), 1, genome); // @TODO - fix test cpu metagenome handling
+  TestGenome_Body(ctx, test_info, mg, 0);
 
   return test_info.is_viable;
 }
@@ -222,7 +223,8 @@
                           ofstream& out_fp)
 {
   test_info.Clear();
-  TestGenome_Body(ctx, test_info, genome, 0);
+  cMetaGenome mg(m_world->GetConfig().HARDWARE_TYPE.Get(), 1, genome); // @TODO - fix test cpu metagenome handling
+  TestGenome_Body(ctx, test_info, mg, 0);
 
   ////////////////////////////////////////////////////////////////
   // IsViable() == false
@@ -250,8 +252,7 @@
   return test_info.is_viable;
 }
 
-bool cTestCPU::TestGenome_Body(cAvidaContext& ctx, cCPUTestInfo& test_info,
-                               const cGenome& genome, int cur_depth)
+bool cTestCPU::TestGenome_Body(cAvidaContext& ctx, cCPUTestInfo& test_info, const cMetaGenome& genome, int cur_depth)
 {
   assert(cur_depth < test_info.generation_tests);
 
@@ -273,8 +274,7 @@
     receive_array[2] = 0x5562eb41;  // 01010101 01100010 11101011 01000001
   }
   
-	if (cur_depth == 0)
-		test_info.used_inputs = input_array;
+	if (cur_depth == 0) test_info.used_inputs = input_array;
 	
   if (cur_depth > test_info.max_depth) test_info.max_depth = cur_depth;
 
@@ -292,7 +292,7 @@
   
   test_info.org_array[cur_depth] = organism;
   organism->SetOrgInterface(ctx, new cTestCPUInterface(this, test_info));
-  organism->GetPhenotype().SetupInject(genome);
+  organism->GetPhenotype().SetupInject(genome.GetGenome());
 
   // Run the current organism.
   ProcessGestation(ctx, test_info, cur_depth);
@@ -319,7 +319,7 @@
   // Case 3:  ////////////////////////////////////
   bool is_ancestor = false;
   for (int anc_depth = 0; anc_depth < cur_depth; anc_depth++) {
-    if (organism->ChildGenome() == test_info.org_array[anc_depth]->GetGenome()){
+    if (organism->OffspringGenome().GetGenome() == test_info.org_array[anc_depth]->GetGenome()){
       is_ancestor = true;
       const int cur_cycle = cur_depth - anc_depth;
       if (test_info.max_cycle < cur_cycle) test_info.max_cycle = cur_cycle;
@@ -334,9 +334,9 @@
 
   // Case 4:  ////////////////////////////////////
   // If we haven't reached maximum depth yet, check out the child.
-  if (cur_depth+1 < test_info.generation_tests) {
-    // Run the child's genome.
-    return TestGenome_Body(ctx, test_info, organism->ChildGenome(), cur_depth+1);
+  if (cur_depth + 1 < test_info.generation_tests) {
+    // Run the offspring's genome.
+    return TestGenome_Body(ctx, test_info, organism->OffspringGenome(), cur_depth + 1);
   }
 
   // All options have failed; just return false.

Modified: development/source/cpu/cTestCPU.h
===================================================================
--- development/source/cpu/cTestCPU.h	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/cpu/cTestCPU.h	2009-03-30 16:14:07 UTC (rev 3198)
@@ -46,6 +46,7 @@
 class cGenotype;
 class cInjectGenotype;
 class cInstSet;
+class cMetaGenome;
 class cResourceCount;
 class cResourceHistory;
 class cWorld;
@@ -77,7 +78,7 @@
   
 
   bool ProcessGestation(cAvidaContext& ctx, cCPUTestInfo& test_info, int cur_depth);
-  bool TestGenome_Body(cAvidaContext& ctx, cCPUTestInfo& test_info, const cGenome& genome, int cur_depth);
+  bool TestGenome_Body(cAvidaContext& ctx, cCPUTestInfo& test_info, const cMetaGenome& genome, int cur_depth);
 
   
   cTestCPU(); // @not_implemented
@@ -89,6 +90,7 @@
   void UpdateResources(int cpu_cycles_used);
   inline void SetResourceUpdate(int update, bool exact = true);
   inline void SetResource(int id, double new_level);
+  
 public:
   cTestCPU(cWorld* world);
   ~cTestCPU() { }

Modified: development/source/cpu/cTestCPUInterface.cc
===================================================================
--- development/source/cpu/cTestCPUInterface.cc	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/cpu/cTestCPUInterface.cc	2009-03-30 16:14:07 UTC (rev 3198)
@@ -29,10 +29,10 @@
 #include "cTestCPU.h"
 
 
-bool cTestCPUInterface::Divide(cAvidaContext& ctx, cOrganism* parent, cGenome& child_genome)
+bool cTestCPUInterface::Divide(cAvidaContext& ctx, cOrganism* parent, const cMetaGenome& offspring_genome)
 {
   parent->GetPhenotype().TestDivideReset(parent->GetGenome());
-  // @CAO in the future, we probably want to pass this child the test_cpu!
+  // @CAO in the future, we probably want to pass this offspring the test_cpu!
   return true;
 }
 

Modified: development/source/cpu/cTestCPUInterface.h
===================================================================
--- development/source/cpu/cTestCPUInterface.h	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/cpu/cTestCPUInterface.h	2009-03-30 16:14:07 UTC (rev 3198)
@@ -62,7 +62,7 @@
   void SetPrevSeenCellID(int in_id) { ; }
   void SetPrevTaskCellID(int in_id) { ; }
 
-  bool Divide(cAvidaContext& ctx, cOrganism* parent, cGenome& child_genome);
+  bool Divide(cAvidaContext& ctx, cOrganism* parent, const cMetaGenome& offspring_genome);
   cOrganism* GetNeighbor();
   bool IsNeighborCellOccupied();
   int GetNumNeighbors();

Modified: development/source/drivers/cDefaultRunDriver.cc
===================================================================
--- development/source/drivers/cDefaultRunDriver.cc	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/drivers/cDefaultRunDriver.cc	2009-03-30 16:14:07 UTC (rev 3198)
@@ -73,7 +73,7 @@
   const double point_mut_prob = m_world->GetConfig().POINT_MUT_PROB.Get();
   
   void (cPopulation::*ActiveProcessStep)(cAvidaContext& ctx, double step_size, int cell_id) = &cPopulation::ProcessStep;
-  if (m_world->GetHardwareManager().SupportsSpeculative() && m_world->GetConfig().SPECULATIVE.Get() &&
+  if (m_world->GetConfig().SPECULATIVE.Get() &&
       m_world->GetConfig().THREAD_SLICING_METHOD.Get() != 1 && !m_world->GetConfig().IMPLICIT_REPRO_END.Get()) {
     ActiveProcessStep = &cPopulation::ProcessStepSpeculative;
   }

Modified: development/source/main/cBirthChamber.cc
===================================================================
--- development/source/main/cBirthChamber.cc	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/main/cBirthChamber.cc	2009-03-30 16:14:07 UTC (rev 3198)
@@ -29,7 +29,7 @@
 #include "tArray.h"
 #include "functions.h"
 #include "cClassificationManager.h"
-#include "cGenome.h"
+#include "cCPUMemory.h"
 #include "cGenomeUtil.h"
 #include "cGenotype.h"
 #include "cOrganism.h"
@@ -148,13 +148,13 @@
 }
 
 
-bool cBirthChamber::DoAsexBirth(cAvidaContext& ctx, const cGenome& child_genome, cOrganism& parent,
+bool cBirthChamber::DoAsexBirth(cAvidaContext& ctx, const cMetaGenome& offspring_genome, cOrganism& parent,
                                 tArray<cOrganism*>& child_array, tArray<cMerit>& merit_array)
 {
   // This is asexual who doesn't need to wait in the birth chamber
   // just build the child and return.
   child_array.Resize(1);
-  child_array[0] = new cOrganism(m_world, ctx, child_genome);
+  child_array[0] = new cOrganism(m_world, ctx, offspring_genome);
   merit_array.Resize(1);
   
   if(m_world->GetConfig().ENERGY_ENABLED.Get() == 1) {
@@ -173,7 +173,7 @@
   
   if (parent.GetPhenotype().CopyTrue() == false) {
     // Add this genotype with only one parent since its asexual.
-    child_genotype = m_world->GetClassificationManager().GetGenotype(child_genome, parent.GetGenotype(), NULL);
+    child_genotype = m_world->GetClassificationManager().GetGenotype(offspring_genome.GetGenome(), parent.GetGenotype(), NULL);
   }
 
   child_array[0]->SetGenotype(child_genotype);
@@ -184,12 +184,8 @@
   return true;
 }
 
-bool cBirthChamber::DoPairAsexBirth(cAvidaContext& ctx,
-				    const cBirthEntry& old_entry,
-				    const cGenome& new_genome,
-                                    cOrganism& parent,
-				    tArray<cOrganism*>& child_array,
-				    tArray<cMerit>& merit_array)
+bool cBirthChamber::DoPairAsexBirth(cAvidaContext& ctx, const cBirthEntry& old_entry, const cMetaGenome& new_genome,
+                                    cOrganism& parent, tArray<cOrganism*>& child_array, tArray<cMerit>& merit_array)
 {
   // Build both child organisms...
   child_array.Resize(2);
@@ -214,9 +210,9 @@
   return true;
 }
 
-cBirthChamber::cBirthEntry* cBirthChamber::FindSexSizeWaiting(const cGenome& child_genome, cOrganism& parent)
+cBirthChamber::cBirthEntry* cBirthChamber::FindSexSizeWaiting(const cMetaGenome& offspring_genome, cOrganism& parent)
 {
-  const int child_length = child_genome.GetSize();
+  const int child_length = offspring_genome.GetSize();
 
   // If this is a new largest genome, increase the array size.
   if (size_wait_entry.GetSize() <= child_length) {
@@ -227,7 +223,7 @@
   if ( EvaluateEntry(size_wait_entry[child_length]) == false ) {
     cGenotype * parent_genotype = parent.GetGenotype();
     parent_genotype->IncDeferAdjust();
-    size_wait_entry[child_length].genome = child_genome;
+    size_wait_entry[child_length].genome = offspring_genome;
     if(m_world->GetConfig().ENERGY_ENABLED.Get() == 1) {
       size_wait_entry[child_length].energy4Offspring = parent.GetPhenotype().ExtractParentEnergy();
       size_wait_entry[child_length].merit.EnergyToMerit(size_wait_entry[child_length].energy4Offspring, m_world);
@@ -243,7 +239,7 @@
   return &( size_wait_entry[child_length] ); 
 }
 
-cBirthChamber::cBirthEntry* cBirthChamber::FindSexMateSelectWaiting(const cGenome& child_genome, cOrganism& parent)
+cBirthChamber::cBirthEntry* cBirthChamber::FindSexMateSelectWaiting(const cMetaGenome& offspring_genome, cOrganism& parent)
 {
   const int mate_id = parent.GetPhenotype().MateSelectID();
 
@@ -256,7 +252,7 @@
   if ( EvaluateEntry(mate_select_wait_entry[mate_id]) == false ) {
     cGenotype * parent_genotype = parent.GetGenotype();
     parent_genotype->IncDeferAdjust();
-    mate_select_wait_entry[mate_id].genome = child_genome;
+    mate_select_wait_entry[mate_id].genome = offspring_genome;
     if(m_world->GetConfig().ENERGY_ENABLED.Get() == 1) {
       mate_select_wait_entry[mate_id].energy4Offspring = parent.GetPhenotype().ExtractParentEnergy();
       mate_select_wait_entry[mate_id].merit.EnergyToMerit(mate_select_wait_entry[mate_id].energy4Offspring, m_world);
@@ -272,7 +268,7 @@
   return &( mate_select_wait_entry[mate_id] ); 
 }
 
-cBirthChamber::cBirthEntry* cBirthChamber::FindSexLocalWaiting(cAvidaContext& ctx, const cGenome& child_genome,
+cBirthChamber::cBirthEntry* cBirthChamber::FindSexLocalWaiting(cAvidaContext& ctx, const cMetaGenome& offspring_genome,
                                                                cOrganism& parent)
 {
   // Collect some info for building the child.
@@ -284,7 +280,7 @@
   if (GetNeighborWaiting(parent_id, world_x, world_y) == false) { 
     cGenotype * parent_genotype = parent.GetGenotype();
     parent_genotype->IncDeferAdjust();
-    local_wait_entry[parent_id].genome = child_genome;
+    local_wait_entry[parent_id].genome = offspring_genome;
     if(m_world->GetConfig().ENERGY_ENABLED.Get() == 1) {
       local_wait_entry[parent_id].energy4Offspring = parent.GetPhenotype().ExtractParentEnergy();
       local_wait_entry[parent_id].merit.EnergyToMerit(local_wait_entry[parent_id].energy4Offspring, m_world);
@@ -301,7 +297,7 @@
   return &( local_wait_entry[found_location] ); 
 }
 
-cBirthChamber::cBirthEntry* cBirthChamber::FindSexDemeWaiting(const cGenome& child_genome, cOrganism& parent)
+cBirthChamber::cBirthEntry* cBirthChamber::FindSexDemeWaiting(const cMetaGenome& offspring_genome, cOrganism& parent)
 {
   // Collect some info for building the child.
   const int world_x = m_world->GetConfig().WORLD_X.Get();
@@ -315,7 +311,7 @@
   if ( EvaluateEntry(deme_wait_entry[parent_deme]) == false ) { 
     cGenotype * parent_genotype = parent.GetGenotype();
     parent_genotype->IncDeferAdjust();
-    deme_wait_entry[parent_deme].genome = child_genome;
+    deme_wait_entry[parent_deme].genome = offspring_genome;
     if(m_world->GetConfig().ENERGY_ENABLED.Get() == 1) {
       deme_wait_entry[parent_deme].energy4Offspring = parent.GetPhenotype().ExtractParentEnergy();
       deme_wait_entry[parent_deme].merit.EnergyToMerit(deme_wait_entry[parent_deme].energy4Offspring, m_world);
@@ -332,13 +328,13 @@
 
 }
 
-cBirthChamber::cBirthEntry* cBirthChamber::FindSexGlobalWaiting(const cGenome& child_genome, cOrganism& parent)
+cBirthChamber::cBirthEntry* cBirthChamber::FindSexGlobalWaiting(const cMetaGenome& offspring_genome, cOrganism& parent)
 {
   // If no other child is waiting, store this one.
   if ( EvaluateEntry(global_wait_entry) == false ) {
     cGenotype * parent_genotype = parent.GetGenotype();
     parent_genotype->IncDeferAdjust();
-    global_wait_entry.genome = child_genome;
+    global_wait_entry.genome = offspring_genome;
     if(m_world->GetConfig().ENERGY_ENABLED.Get() == 1) {
       global_wait_entry.energy4Offspring = parent.GetPhenotype().ExtractParentEnergy();
       global_wait_entry.merit.EnergyToMerit(global_wait_entry.energy4Offspring, m_world);
@@ -518,16 +514,13 @@
   child_genotype->IncDeferAdjust();
 }
 
-bool cBirthChamber::SubmitOffspring(cAvidaContext& ctx,
-				    const cGenome& child_genome,
-				    cOrganism& parent,
-                                    tArray<cOrganism*>& child_array,
-				    tArray<cMerit>& merit_array)
+bool cBirthChamber::SubmitOffspring(cAvidaContext& ctx, const cMetaGenome& offspring_genome, cOrganism& parent,
+                                    tArray<cOrganism*>& child_array, tArray<cMerit>& merit_array)
 {
   cPhenotype& parent_phenotype = parent.GetPhenotype();
 
   if (parent_phenotype.DivideSex() == false) {
-    return DoAsexBirth(ctx, child_genome, parent, child_array, merit_array);
+    return DoAsexBirth(ctx, offspring_genome, parent, child_array, merit_array);
   }
 
   // If we make it this far, this must be a sexual or a "waiting" asexual
@@ -540,27 +533,27 @@
   // First check if the birth method is one of the local ones... 
   if (birth_method < NUM_LOCAL_POSITION_CHILD ||
       birth_method == POSITION_CHILD_PARENT_FACING) { 
-    old_entry = FindSexLocalWaiting(ctx, child_genome, parent);
+    old_entry = FindSexLocalWaiting(ctx, offspring_genome, parent);
   }
   // ... then check if population is split into demes
   else if (birth_method == POSITION_CHILD_DEME_RANDOM) {
-    old_entry = FindSexDemeWaiting(child_genome, parent);
+    old_entry = FindSexDemeWaiting(offspring_genome, parent);
   }
 
   // If none of the previous conditions were met, it must be global.
   // ...check if recombination must be with organisms of the same length
   else if (m_world->GetConfig().SAME_LENGTH_SEX.Get() != 0) {
-    old_entry = FindSexSizeWaiting(child_genome, parent);
+    old_entry = FindSexSizeWaiting(offspring_genome, parent);
   }
 
   // ...check if we have mate selection
   else if (parent_phenotype.MateSelectID() >= 0) {
-    old_entry = FindSexMateSelectWaiting(child_genome, parent);
+    old_entry = FindSexMateSelectWaiting(offspring_genome, parent);
   }
 
   // If everything failed until this point, use default global.
   else {
-    old_entry = FindSexGlobalWaiting(child_genome, parent);
+    old_entry = FindSexGlobalWaiting(offspring_genome, parent);
   }
 
   // If we couldn't find a waiting entry, this one was saved -- stop here!
@@ -574,11 +567,11 @@
   // If we are NOT recombining, handle that here.
   if (parent_phenotype.CrossNum() == 0 || 
       ctx.GetRandom().GetDouble() > m_world->GetConfig().RECOMBINATION_PROB.Get()) {
-    return DoPairAsexBirth(ctx, *old_entry, child_genome, parent, child_array, merit_array);
+    return DoPairAsexBirth(ctx, *old_entry, offspring_genome, parent, child_array, merit_array);
   }
   // If we made it this far, RECOMBINATION will happen!
-  cCPUMemory genome0 = old_entry->genome;
-  cCPUMemory genome1 = child_genome;
+  cCPUMemory genome0 = old_entry->genome.GetGenome();
+  cCPUMemory genome1 = offspring_genome.GetGenome();
   double meritOrEnergy0;
   double meritOrEnergy1;
 
@@ -623,13 +616,16 @@
 
   const int two_fold_cost = m_world->GetConfig().TWO_FOLD_COST_SEX.Get();
 
-  cGenotype * parent0_genotype = old_entry->parent_genotype;
-  cGenotype * parent1_genotype = parent.GetGenotype();
+  cGenotype* parent0_genotype = old_entry->parent_genotype;
+  cGenotype* parent1_genotype = parent.GetGenotype();
+  
+  const int hw_type = offspring_genome.GetHardwareType();
+  const int inst_set_id = offspring_genome.GetInstSetID();
 
   if (two_fold_cost == 0) {	// Build the two organisms.
     child_array.Resize(2);
-    child_array[0] = new cOrganism(m_world, ctx, genome0);
-    child_array[1] = new cOrganism(m_world, ctx, genome1);
+    child_array[0] = new cOrganism(m_world, ctx, hw_type, inst_set_id, genome0);
+    child_array[1] = new cOrganism(m_world, ctx, hw_type, inst_set_id, genome1);
     
     if(m_world->GetConfig().ENERGY_ENABLED.Get() == 1) {
       child_array[0]->GetPhenotype().SetEnergy(meritOrEnergy0);
@@ -652,7 +648,7 @@
     merit_array.Resize(1);
 
     if (ctx.GetRandom().GetDouble() < 0.5) {
-      child_array[0] = new cOrganism(m_world, ctx, genome0);
+      child_array[0] = new cOrganism(m_world, ctx, hw_type, inst_set_id, genome0);
       if(m_world->GetConfig().ENERGY_ENABLED.Get() == 1) {
         child_array[0]->GetPhenotype().SetEnergy(meritOrEnergy0);
         meritOrEnergy0 = cMerit::EnergyToMerit(child_array[0]->GetPhenotype().GetStoredEnergy(), m_world);
@@ -663,7 +659,7 @@
       SetupGenotypeInfo(child_array[0], parent0_genotype, parent1_genotype);
     } 
     else {
-      child_array[0] = new cOrganism(m_world, ctx, genome1);
+      child_array[0] = new cOrganism(m_world, ctx, hw_type, inst_set_id, genome1);
       if(m_world->GetConfig().ENERGY_ENABLED.Get() == 1) {
         child_array[0]->GetPhenotype().SetEnergy(meritOrEnergy1);
         meritOrEnergy1 = cMerit::EnergyToMerit(child_array[1]->GetPhenotype().GetStoredEnergy(), m_world);

Modified: development/source/main/cBirthChamber.h
===================================================================
--- development/source/main/cBirthChamber.h	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/main/cBirthChamber.h	2009-03-30 16:14:07 UTC (rev 3198)
@@ -26,13 +26,14 @@
 #ifndef cBirthChamber_h
 #define cBirthChamber_h
 
-#ifndef cCPUMemory_h
-#include "cCPUMemory.h"
-#endif
 #ifndef cMerit_h
 #include "cMerit.h"
 #endif
+#ifndef cMetaGenome_h
+#include "cMetaGenome.h"
+#endif
 
+
 /**
  * All genome-based organisms must go through the birth chamber, which will
  * handle any special modifications during the birth process, such as divide
@@ -42,6 +43,7 @@
  **/
 
 class cAvidaContext;
+class cCPUMemory;
 class cGenome;
 class cGenotype;
 class cOrganism;
@@ -53,7 +55,7 @@
 
   class cBirthEntry {
   public:
-    cCPUMemory genome;
+    cMetaGenome genome;
     double energy4Offspring;
     cMerit merit;
     cGenotype * parent_genotype;
@@ -82,18 +84,18 @@
   bool RegionSwap(cCPUMemory& genome0, cCPUMemory& genome1, int start0, int end0, int start1, int end1);
   void GenomeSwap(cCPUMemory& genome0, cCPUMemory& genome1, double& merit0, double& merit1);
 
-  bool DoAsexBirth(cAvidaContext& ctx, const cGenome& child_genome, cOrganism& parent,
+  bool DoAsexBirth(cAvidaContext& ctx, const cMetaGenome& offspring_genome, cOrganism& parent,
                    tArray<cOrganism*>& child_array, tArray<cMerit>& merit_array);
-  bool DoPairAsexBirth(cAvidaContext& ctx, const cBirthEntry& old_entry, const cGenome& new_genome, cOrganism& parent,
+  bool DoPairAsexBirth(cAvidaContext& ctx, const cBirthEntry& old_entry, const cMetaGenome& new_genome, cOrganism& parent,
                        tArray<cOrganism*>& child_array, tArray<cMerit>& merit_array);
-  cBirthEntry* FindSexLocalWaiting(cAvidaContext& ctx, const cGenome& child_genome, cOrganism& parent);
-  cBirthEntry* FindSexDemeWaiting(const cGenome& child_genome, cOrganism& parent);
-  cBirthEntry* FindSexSizeWaiting(const cGenome & child_genome, cOrganism& parent);
-  cBirthEntry* FindSexMateSelectWaiting(const cGenome & child_genome, cOrganism& parent);
-  cBirthEntry* FindSexGlobalWaiting(const cGenome & child_genome, cOrganism& parent);
+  
+  cBirthEntry* FindSexLocalWaiting(cAvidaContext& ctx, const cMetaGenome& offspring_genome, cOrganism& parent);
+  cBirthEntry* FindSexDemeWaiting(const cMetaGenome& offspring_genome, cOrganism& parent);
+  cBirthEntry* FindSexSizeWaiting(const cMetaGenome& offspring_genome, cOrganism& parent);
+  cBirthEntry* FindSexMateSelectWaiting(const cMetaGenome& offspring_genome, cOrganism& parent);
+  cBirthEntry* FindSexGlobalWaiting(const cMetaGenome& offspring_genome, cOrganism& parent);
 
-  void DoBasicRecombination(cAvidaContext& ctx, cCPUMemory& genome0, cCPUMemory& genome1,
-                            double& merit0, double& merit1);
+  void DoBasicRecombination(cAvidaContext& ctx, cCPUMemory& genome0, cCPUMemory& genome1, double& merit0, double& merit1);
   void DoModularContRecombination(cAvidaContext& ctx, cCPUMemory& genome0, cCPUMemory& genome1,
                                   double& merit0, double& merit1);
   void DoModularNonContRecombination(cAvidaContext& ctx, cCPUMemory& genome0, cCPUMemory& genome1,
@@ -104,7 +106,7 @@
   void SetupGenotypeInfo(cOrganism* organism, cGenotype* parent0_genotype, cGenotype* parent1_genotype);
 
   // Pick a random waiting genome from the nehighborhood for recombination
-  int PickRandRecGenome(cAvidaContext& ctx, const int & parent_id, int world_x, int world_y);
+  int PickRandRecGenome(cAvidaContext& ctx, const int& parent_id, int world_x, int world_y);
   
 
   cBirthChamber(); // @not_implemented
@@ -117,7 +119,7 @@
 
   // Handle manipulations & tests of genome.  Return false if divide process
   // should halt.  Place offspring in child_array.
-  bool SubmitOffspring(cAvidaContext& ctx, const cGenome& child_genome, cOrganism& parent,
+  bool SubmitOffspring(cAvidaContext& ctx, const cMetaGenome& offspring_genome, cOrganism& parent,
                        tArray<cOrganism*>& child_array, tArray<cMerit>& merit_array);
 
   // Check the neighborhood for waiting genomes

Modified: development/source/main/cGenome.cc
===================================================================
--- development/source/main/cGenome.cc	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/main/cGenome.cc	2009-03-30 16:14:07 UTC (rev 3198)
@@ -29,15 +29,20 @@
 using namespace std;
 
 
+const int MEMORY_INCREASE_MINIMUM = 5;
+const double MEMORY_INCREASE_FACTOR = 1.5;
+const double MEMORY_SHRINK_TEST_FACTOR = 4.0;
+
+
 cGenome::cGenome(int _size)
-  : genome(_size), active_size(_size)
+  : m_genome(_size), m_active_size(_size)
 {
 }
 
 cGenome::cGenome(const cGenome & in_genome)
-  : genome(in_genome.GetSize()), active_size(in_genome.GetSize()), m_mutation_steps(in_genome.GetMutationSteps())
+  : m_genome(in_genome.GetSize()), m_active_size(in_genome.GetSize()), m_mutation_steps(in_genome.GetMutationSteps())
 {
-  for (int i = 0; i < active_size; i++)  genome[i] = in_genome[i];
+  for (int i = 0; i < m_active_size; i++)  m_genome[i] = in_genome[i];
 }
 
 cGenome::cGenome(const cString & in_string)
@@ -45,10 +50,10 @@
   cString tmp_string(in_string);
   tmp_string.RemoveChar('_');  // Remove all blanks from alignments...
 
-  active_size = tmp_string.GetSize();
-  genome.ResizeClear(active_size);
-  for (int i = 0; i < active_size; i++) {
-    genome[i].SetSymbol(tmp_string[i]);
+  m_active_size = tmp_string.GetSize();
+  m_genome.ResizeClear(m_active_size);
+  for (int i = 0; i < m_active_size; i++) {
+    m_genome[i].SetSymbol(tmp_string[i]);
   }
 }
 
@@ -56,15 +61,12 @@
 /*! This constructor is used to build a new cGenome from a range of instructions.
 It expects STL semantics for an iterator range.  We're avoiding templating this
 (for now).  Refactor if a new range type is needed.
-
-\todo Just as an aside, it looks like Push continually reallocs memory in tArray.
 */
-cGenome::cGenome(cInstruction* begin, cInstruction* end)
-: active_size(0)
+cGenome::cGenome(cInstruction* begin, cInstruction* end) : m_active_size(0)
 {
-  for(cInstruction* i=begin; i!=end; ++i,++active_size) {
-    genome.Push(*i);
-  }
+  m_genome.Resize((end - begin) / sizeof(cInstruction));
+  
+  for (cInstruction* i = begin; i != end; i++, m_active_size++) m_genome[m_active_size] = *i;
 }
 
 
@@ -73,58 +75,141 @@
 }
 
 
-void cGenome::operator=(const cGenome & other_genome)
+void cGenome::adjustCapacity(int new_size)
 {
-  // If we need to resize, do so...
-  active_size = other_genome.GetSize();
-  genome.ResizeClear(active_size);
-
-  // Now that both code arrays are the same size, copy the other one over.
-
-  for (int i = 0; i < active_size; i++) {
-    genome[i] = other_genome[i];
+  assert(new_size > 0);
+  
+  // Make sure we're really changing the size...
+  if (new_size == m_active_size) return;
+  
+  const int array_size = m_genome.GetSize();
+  
+  // Determine if we need to adjust the allocated array sizes...
+  if (new_size > array_size || new_size * MEMORY_SHRINK_TEST_FACTOR < array_size) {
+    int new_array_size = (int) (new_size * MEMORY_INCREASE_FACTOR);
+    const int new_array_min = new_size + MEMORY_INCREASE_MINIMUM;
+		if (new_array_min > new_array_size) new_array_size = new_array_min;
+    m_genome.Resize(new_array_size);
   }
   
-  m_mutation_steps = other_genome.m_mutation_steps;
+  // And just change the m_active_size once we're sure it will be in range.
+  m_active_size = new_size;
 }
 
+void cGenome::prepareInsert(int pos, int num_sites)
+{
+  assert(pos >= 0 && pos <= m_active_size); // Must insert at a legal position!
+  assert(num_sites > 0); // Must insert positive number of lines!
+  
+  // Re-adjust the size...
+  const int old_size = m_active_size;
+  const int new_size = m_active_size + num_sites;
+  adjustCapacity(new_size);
+  
+  // Shift any sites needed...
+  for (int i = old_size - 1; i >= pos; i--) m_genome[i + num_sites] = m_genome[i];
+}
 
-bool cGenome::operator==(const cGenome & other_genome) const
+
+void cGenome::Copy(int to, int from)
 {
-  // Make sure the sizes are the same.
-  if (active_size != other_genome.active_size) return false;
+  assert(to   >= 0   && to   < m_active_size);
+  assert(from >= 0   && from < m_active_size);
+  m_genome[to] = m_genome[from];
+}
+ 
 
-  // Then go through line by line.
-  for (int i = 0; i < active_size; i++)
-    if (genome[i] != other_genome[i]) return false;
+// Return the genome as an alphabetic string
 
-  return true;
+cString cGenome::AsString() const
+{
+  cString out_string(m_active_size);
+  for (int i = 0; i < m_active_size; i++) {
+    out_string[i] = m_genome[i].GetSymbol();
+  }
+
+  return out_string;
 }
 
 
-void cGenome::Copy(int to, int from)
+void cGenome::Resize(int new_size)
 {
-  assert(to   >= 0   && to   < active_size);
-  assert(from >= 0   && from < active_size);
-  genome[to] = genome[from];
+  assert(new_size >= 0);
+  
+  const int old_size = m_active_size;
+  adjustCapacity(new_size);
+  
+  for (int i = old_size; i < new_size; i++) m_genome[i].SetOp(0);
 }
 
-bool cGenome::OK() const
+void cGenome::Insert(int pos, const cInstruction& inst)
 {
-  assert (active_size <= genome.GetSize()); // active_size too large!
+  assert(pos >= 0);
+  assert(pos <= m_genome.GetSize());
+  
+  prepareInsert(pos, 1);
+  m_genome[pos] = inst;
+}
 
-  return true;
+void cGenome::Insert(int pos, const cGenome& genome)
+{
+  assert(pos >= 0);
+  assert(pos <= m_genome.GetSize());
+  
+  prepareInsert(pos, genome.GetSize());
+  for (int i = 0; i < genome.GetSize(); i++) m_genome[i + pos] = genome[i];
 }
- 
 
-// Return the genome as an alphabetic string
+void cGenome::Remove(int pos, int num_sites)
+{
+  assert(num_sites > 0);                    // Must remove something...
+  assert(pos >= 0);                         // Removal must be in genome
+  assert(pos + num_sites <= m_active_size); // Cannot extend past end of genome
+  
+  const int new_size = m_active_size - num_sites;
+  for (int i = pos; i < new_size; i++) m_genome[i] = m_genome[i + num_sites];
+  adjustCapacity(new_size);
+}
 
-cString cGenome::AsString() const
+void cGenome::Replace(int pos, int num_sites, const cGenome& genome)
 {
-  cString out_string(active_size);
-  for (int i = 0; i < active_size; i++) {
-    out_string[i] = genome[i].GetSymbol();
-  }
+  assert(pos >= 0);                         // Replace must be in genome
+  assert(num_sites >= 0);                   // Cannot replace negative
+  assert(pos + num_sites <= m_active_size); // Cannot extend past end!
+  
+  const int size_change = genome.GetSize() - num_sites;
+  
+  // First, get the size right
+  if (size_change > 0) prepareInsert(pos, size_change);
+  else if (size_change < 0) Remove(pos, -size_change);
+  
+  // Now just copy everything over!
+  for (int i = 0; i < genome.GetSize(); i++) m_genome[i + pos] = genome[i];
+}
 
-  return out_string;
+
+void cGenome::operator=(const cGenome& other_genome)
+{
+  m_active_size = other_genome.m_active_size;
+  m_genome.ResizeClear(m_active_size);
+  
+  // Now that both code arrays are the same size, copy the other one over
+  for (int i = 0; i < m_active_size; i++) m_genome[i] = other_genome[i];
+  
+  m_mutation_steps = other_genome.m_mutation_steps;
 }
+
+
+bool cGenome::operator==(const cGenome& other_genome) const
+{
+  // Make sure the sizes are the same.
+  if (m_active_size != other_genome.m_active_size) return false;
+  
+  // Then go through line by line.
+  for (int i = 0; i < m_active_size; i++)
+    if (m_genome[i] != other_genome[i]) return false;
+  
+  return true;
+}
+
+

Modified: development/source/main/cGenome.h
===================================================================
--- development/source/main/cGenome.h	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/main/cGenome.h	2009-03-30 16:14:07 UTC (rev 3198)
@@ -49,51 +49,47 @@
 class cGenome
 {
 protected:
-  tArray<cInstruction> genome;
-  int active_size;
+  tArray<cInstruction> m_genome;
+  int m_active_size;
   cMutationSteps m_mutation_steps;
+  
+  
+  virtual void adjustCapacity(int new_size);
+  virtual void prepareInsert(int pos, int num_sites);
+  
 
 public:
-  //! Default constructor.
-  cGenome() { ; }
-  explicit cGenome(int _size); //! Constructor that builds a 'blank' cGenome of the specified size.
-  cGenome(const cGenome& in_genome); //! Copy constructor.
-  cGenome(const cString& in_string); //! Constructor that builds a cGenome from a string.  
-  //! Constructor that takes a range of instructions from which to build a new cGenome.
-  cGenome(cInstruction* begin, cInstruction* end);
+  cGenome() { ; }                                   //! Default constructor
+  explicit cGenome(int _size);                      //! Constructor that builds a 'blank' cGenome of the specified size
+  cGenome(const cGenome& in_genome);                //! Copy constructor
+  cGenome(const cString& in_string);                //! Constructor that builds genome from a string
+  cGenome(cInstruction* begin, cInstruction* end);  //! Constructor that builds genome from a range of instructions  
+  virtual ~cGenome();                               //! Virtual destructor; there are subclasses.
+
+  inline int GetSize() const { return m_active_size; }
+  cString AsString() const;
   
-  virtual ~cGenome(); //! Virtual destructor; there are subclasses.
+  inline cMutationSteps& GetMutationSteps() { return m_mutation_steps; }
+  inline const cMutationSteps& GetMutationSteps() const { return m_mutation_steps; }
+  
+  inline cInstruction& operator[](int idx) { assert(idx >= 0 && idx < m_active_size);  return m_genome[idx]; }
+  inline const cInstruction& operator[](int idx) const { assert(idx >= 0 && idx < m_active_size);  return m_genome[idx]; }
 
+  virtual void Resize(int new_size);
+  virtual void Copy(int to, int from);
+  virtual void Insert(int pos, const cInstruction& inst);
+  virtual void Insert(int pos, const cGenome& genome);
+  virtual void Remove(int pos, int num_sites = 1);
+  virtual void Replace(int pos, int num_sites, const cGenome& genome);
+
+  inline void Append(const cInstruction& in_inst) { Insert(GetSize(), in_inst); }
+  inline void Append(const cGenome& in_genome) { Insert(GetSize(), in_genome); }
+
   virtual void operator=(const cGenome& other_genome);
   virtual bool operator==(const cGenome& other_genome) const;
   virtual bool operator!=(const cGenome& other_genome) const { return !(this->operator==(other_genome)); }
   virtual bool operator<(const cGenome& other_genome) const { return AsString() < other_genome.AsString(); }
-
-  cInstruction& operator[](int index) { assert(index >= 0 && index < active_size);  return genome[index]; }
-  const cInstruction& operator[](int index) const { assert(index >= 0 && index < active_size);  return genome[index]; }
-
-  virtual void Copy(int to, int from);
-
-  bool OK() const;
-   
-  int GetSize() const { return active_size; }
-  cString AsString() const;
   
-  cMutationSteps& GetMutationSteps() { return m_mutation_steps; }
-  const cMutationSteps& GetMutationSteps() const { return m_mutation_steps; }
-
 };
 
-
-#ifdef ENABLE_UNIT_TESTS
-namespace nGenome {
-  /**
-   * Run unit tests
-   *
-   * @param full Run full test suite; if false, just the fast tests.
-   **/
-  void UnitTests(bool full = false);
-}
-#endif  
-
 #endif

Added: development/source/main/cMetaGenome.h
===================================================================
--- development/source/main/cMetaGenome.h	                        (rev 0)
+++ development/source/main/cMetaGenome.h	2009-03-30 16:14:07 UTC (rev 3198)
@@ -0,0 +1,62 @@
+/*
+ *  cMetaGenome.h
+ *  Avida
+ *
+ *  Created by David Bryson on 3/29/09.
+ *  Copyright 2009 Michigan State University. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; version 2
+ *  of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ */
+
+#ifndef cMetaGenome_h
+#define cMetaGenome_h
+
+#include "cGenome.h"
+
+
+class cMetaGenome
+{
+private:
+  int m_hw_type;
+  int m_inst_set_id;
+  cGenome m_genome;
+ 
+  
+public:
+  cMetaGenome() : m_hw_type(-1), m_inst_set_id(-1) { ; }
+  cMetaGenome(int hw, int is, const cGenome& gen) : m_hw_type(hw), m_inst_set_id(is), m_genome(gen) { ; }
+  cMetaGenome(const cMetaGenome& mg) : m_hw_type(mg.m_hw_type), m_inst_set_id(mg.m_inst_set_id), m_genome(mg.m_genome) { ; }
+  
+  inline int GetHardwareType() const { return m_hw_type; }
+  inline int GetInstSetID() const { return m_inst_set_id; }
+  inline const cGenome& GetGenome() const { return m_genome; }
+  inline cGenome& GetGenome() { return m_genome; }
+  
+  inline int GetSize() const { return m_genome.GetSize(); }
+  
+  inline void SetHardwareType(int type) { m_hw_type = type; }
+  inline void SetInstSetID(int is) { m_inst_set_id = is; }
+  inline void SetGenome(const cGenome& gen) { m_genome = gen; }
+  
+  bool operator==(const cMetaGenome& mg) const
+    { return (m_hw_type == mg.m_hw_type && m_inst_set_id == mg.m_inst_set_id && m_genome == mg.m_genome); }
+  cMetaGenome& operator=(const cMetaGenome& mg)
+    { m_hw_type = mg.m_hw_type; m_inst_set_id = mg.m_inst_set_id; m_genome = mg.m_genome; return *this; }
+};
+
+
+#endif

Modified: development/source/main/cOrgInterface.h
===================================================================
--- development/source/main/cOrgInterface.h	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/main/cOrgInterface.h	2009-03-30 16:14:07 UTC (rev 3198)
@@ -38,6 +38,7 @@
 class cCodeLabel;
 class cDeme;
 class cGenome;
+class cMetaGenome;
 class cOrganism;
 class cOrgMessage;
 class cOrgSinkMessage;
@@ -70,7 +71,7 @@
   virtual void SetPrevSeenCellID(int in_id) = 0;
   virtual void SetPrevTaskCellID(int in_id) = 0;
 
-  virtual bool Divide(cAvidaContext& ctx, cOrganism* parent, cGenome& child_genome) = 0;
+  virtual bool Divide(cAvidaContext& ctx, cOrganism* parent, const cMetaGenome& offspring_genome) = 0;
   
   virtual cOrganism* GetNeighbor() = 0;
   virtual bool IsNeighborCellOccupied() = 0;

Modified: development/source/main/cOrganism.cc
===================================================================
--- development/source/main/cOrganism.cc	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/main/cOrganism.cc	2009-03-30 16:14:07 UTC (rev 3198)
@@ -53,12 +53,12 @@
 using namespace std;
 
 
-cOrganism::cOrganism(cWorld* world, cAvidaContext& ctx, const cGenome& in_genome)
+cOrganism::cOrganism(cWorld* world, cAvidaContext& ctx, const cMetaGenome& genome)
   : m_world(world)
   , m_genotype(NULL)
   , m_phenotype(world)
-  , m_initial_genome(in_genome)
-  , m_mut_info(world->GetEnvironment().GetMutationLib(), in_genome.GetSize())
+  , m_initial_genome(genome)
+  , m_mut_info(world->GetEnvironment().GetMutationLib(), genome.GetSize())
   , m_interface(NULL)
   , m_lineage_label(-1)
   , m_lineage(NULL)
@@ -82,17 +82,50 @@
   , m_msg(0)
   , m_opinion(0)
 {
-  m_hardware = m_world->GetHardwareManager().Create(ctx, this);
+  m_hardware = m_world->GetHardwareManager().Create(ctx, this, m_initial_genome);
+  
+  initialize(ctx);
+}
+cOrganism::cOrganism(cWorld* world, cAvidaContext& ctx, int hw_type, int inst_set_id, const cGenome& genome)
+  : m_world(world)
+  , m_genotype(NULL)
+  , m_phenotype(world)
+  , m_initial_genome(hw_type, inst_set_id, genome)
+  , m_mut_info(world->GetEnvironment().GetMutationLib(), genome.GetSize())
+  , m_interface(NULL)
+  , m_lineage_label(-1)
+  , m_lineage(NULL)
+  , m_rbins(0)
+  , m_input_pointer(0)
+  , m_input_buf(world->GetEnvironment().GetInputSize())
+  , m_output_buf(world->GetEnvironment().GetOutputSize())
+  , m_received_messages(RECEIVED_MESSAGES_SIZE)
+  , m_cur_sg(0)
+  , m_sent_value(0)
+  , m_sent_active(false)
+  , m_test_receive_pos(0)
+  , m_pher_drop(false)
+  , frac_energy_donating(m_world->GetConfig().ENERGY_SHARING_PCT.Get())
+  , m_max_executed(-1)
+  , m_is_running(false)
+  , m_is_sleeping(false)
+  , m_is_dead(false)
+  , killed_event(false)
+  , m_net(NULL)
+  , m_msg(0)
+  , m_opinion(0)
+{
+  m_hardware = m_world->GetHardwareManager().Create(ctx, this, m_initial_genome);
 
   initialize(ctx);
 }
 
-cOrganism::cOrganism(cWorld* world, cAvidaContext& ctx, const cGenome& in_genome, cInstSet* inst_set)
+cOrganism::cOrganism(cWorld* world, cAvidaContext& ctx, const cMetaGenome& genome, cInstSet* inst_set)
   : m_world(world)
   , m_genotype(NULL)
   , m_phenotype(world)
-  , m_initial_genome(in_genome)
-  , m_mut_info(world->GetEnvironment().GetMutationLib(), in_genome.GetSize())
+  , m_initial_genome(genome)
+  , m_mut_info(world->GetEnvironment().GetMutationLib(), genome.GetSize())
   , m_interface(NULL)
   , m_lineage_label(-1)
   , m_lineage(NULL)
@@ -116,7 +149,7 @@
   , m_msg(0)
   , m_opinion(0)
 {
-  m_hardware = m_world->GetHardwareManager().Create(ctx, this, inst_set);
+  m_hardware = m_world->GetHardwareManager().Create(ctx, this, m_initial_genome, inst_set);
   
   initialize(ctx);
 }
@@ -666,7 +699,7 @@
   } else {
     fp << endl;
     fp << "# Final Memory: " << m_hardware->GetMemory().AsString() << endl;
-    fp << "# Child Memory: " << m_child_genome.AsString() << endl;
+    fp << "# Child Memory: " << m_offspring_genome.GetGenome().AsString() << endl;
   }
 }
 
@@ -715,7 +748,7 @@
   DoOutput(ctx, true);
 
   // Activate the child!  (Keep Last: may kill this organism!)
-  return m_interface->Divide(ctx, this, m_child_genome);
+  return m_interface->Divide(ctx, this, m_offspring_genome);
 }
 
 

Modified: development/source/main/cOrganism.h
===================================================================
--- development/source/main/cOrganism.h	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/main/cOrganism.h	2009-03-30 16:14:07 UTC (rev 3198)
@@ -35,12 +35,12 @@
 #ifndef cCPUMemory_h
 #include "cCPUMemory.h"
 #endif
-#ifndef cGenome_h
-#include "cGenome.h"
-#endif
 #ifndef cLocalMutations_h
 #include "cLocalMutations.h"
 #endif
+#ifndef cMetaGenome_h
+#include "cMetaGenome.h"
+#endif
 #ifndef cMutationRates_h
 #include "cMutationRates.h"
 #endif
@@ -94,7 +94,7 @@
   cHardwareBase* m_hardware;              // The actual machinery running this organism.
   cGenotype* m_genotype;                  // Information about organisms with this genome.
   cPhenotype m_phenotype;                 // Descriptive attributes of organism.
-  const cGenome m_initial_genome;         // Initial genome; can never be changed!
+  const cMetaGenome m_initial_genome;         // Initial genome; can never be changed!
   tArray<cInjectGenotype*> m_parasites;   // List of all parasites associated with this organism.
   cMutationRates m_mut_rates;             // Rate of all possible mutations.
   cLocalMutations m_mut_info;             // Info about possible mutations;
@@ -107,7 +107,7 @@
   																				// Note: m_rbins gets its proper size in SetOrgInterface()
   
 	// Other stats
-  cCPUMemory m_child_genome;              // Child genome, while under construction.
+  cMetaGenome m_offspring_genome;              // Child genome, while under construction.
 
   // Input and Output with the environment
   int m_input_pointer;
@@ -156,8 +156,9 @@
   cOrganism& operator=(const cOrganism&); // @not_implemented
   
 public:
-  cOrganism(cWorld* world, cAvidaContext& ctx, const cGenome& in_genome);
-  cOrganism(cWorld* world, cAvidaContext& ctx, const cGenome& in_genome, cInstSet* inst_set);
+  cOrganism(cWorld* world, cAvidaContext& ctx, const cMetaGenome& genome);
+  cOrganism(cWorld* world, cAvidaContext& ctx, int hw_type, int inst_set_id, const cGenome& genome);
+  cOrganism(cWorld* world, cAvidaContext& ctx, const cMetaGenome& genome, cInstSet* inst_set);
   ~cOrganism();
 
   // --------  Support Methods  --------
@@ -180,7 +181,8 @@
   cPhenotype& GetPhenotype() { return m_phenotype; }
   void SetPhenotype(cPhenotype& _in_phenotype) { m_phenotype = _in_phenotype; }
 
-  const cGenome& GetGenome() const { return m_initial_genome; }
+  const cGenome& GetGenome() const { return m_initial_genome.GetGenome(); }
+  const cMetaGenome& GetMetaGenome() const { return m_initial_genome; }
   
   const cMutationRates& MutationRates() const { return m_mut_rates; }
   cMutationRates& MutationRates() { return m_mut_rates; }
@@ -209,7 +211,7 @@
 
   int GetMaxExecuted() const { return m_max_executed; }
   
-  cCPUMemory& ChildGenome() { return m_child_genome; }
+  cMetaGenome& OffspringGenome() { return m_offspring_genome; }
 
   void SetRunning(bool in_running) { m_is_running = in_running; }
   bool IsRunning() { return m_is_running; }

Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/main/cPopulation.cc	2009-03-30 16:14:07 UTC (rev 3198)
@@ -310,7 +310,7 @@
 // Activate the child, given information from the parent.
 // Return true if parent lives through this process.
 
-bool cPopulation::ActivateOffspring(cAvidaContext& ctx, cGenome& child_genome, cOrganism& parent_organism)
+bool cPopulation::ActivateOffspring(cAvidaContext& ctx, const cMetaGenome& offspring_genome, cOrganism& parent_organism)
 {
   if (m_world->GetConfig().FASTFORWARD_NUM_ORGS.Get() > 0 && GetNumOrganisms() >= m_world->GetConfig().FASTFORWARD_NUM_ORGS.Get())
   {
@@ -327,7 +327,7 @@
   cPhenotype& parent_phenotype = parent_organism.GetPhenotype();
   parent_phenotype.DivideReset(parent_organism.GetGenome());
   
-  birth_chamber.SubmitOffspring(ctx, child_genome, parent_organism, child_array, merit_array);
+  birth_chamber.SubmitOffspring(ctx, offspring_genome, parent_organism, child_array, merit_array);
   
   // First, setup the genotype of all of the offspring.
   cGenotype* parent_genotype = parent_organism.GetGenotype();
@@ -359,8 +359,8 @@
     }
     
     // Update the phenotypes of each child....
-    const cGenome & child_genome = child_array[i]->GetGenome();
-    child_array[i]->GetPhenotype().SetupOffspring(parent_phenotype,child_genome);
+    const cGenome& genome = child_array[i]->GetGenome();
+    child_array[i]->GetPhenotype().SetupOffspring(parent_phenotype, genome);
     child_array[i]->GetPhenotype().SetMerit(merit_array[i]);
     
     // Do lineage tracking for the new organisms.
@@ -405,7 +405,7 @@
     }
     
     // Purge the mutations since last division
-    parent_organism.ChildGenome().GetMutationSteps().Clear();
+    parent_organism.OffspringGenome().GetGenome().GetMutationSteps().Clear();
   }
   
   // Do any statistics on the parent that just gave birth...
@@ -3715,7 +3715,6 @@
 {
   assert(step_size > 0.0);
   assert(cell_id < cell_array.GetSize());
-  assert(m_world->GetHardwareManager().SupportsSpeculative());
   
   // If cell_id is negative, no cell could be found -- stop here.
   if (cell_id < 0) return;
@@ -4622,7 +4621,7 @@
 
 // This function injects a new organism into the population at cell_id based
 // on the genotype passed in.
-void cPopulation::InjectGenotype(int cell_id, cGenotype *new_genotype)
+void cPopulation::InjectGenotype(int cell_id, cGenotype* new_genotype)
 {
   assert(cell_id >= 0 && cell_id < cell_array.GetSize());
   if (cell_id < 0 || cell_id >= cell_array.GetSize()) {
@@ -4631,7 +4630,8 @@
   
   cAvidaContext& ctx = m_world->GetDefaultContext();
   
-  cOrganism* new_organism = new cOrganism(m_world, ctx, new_genotype->GetGenome());
+  cMetaGenome tmp_genome(m_world->GetConfig().HARDWARE_TYPE.Get(), 1, new_genotype->GetGenome()); // @TODO - genotypes need metagenomes
+  cOrganism* new_organism = new cOrganism(m_world, ctx, tmp_genome);
   
   //Coalescense Clade Setup
   new_organism->SetCCladeLabel(-1);  
@@ -4699,7 +4699,7 @@
   
   cAvidaContext& ctx = m_world->GetDefaultContext();
   
-  cOrganism* new_organism = new cOrganism(m_world, ctx, orig_org.GetGenome());
+  cOrganism* new_organism = new cOrganism(m_world, ctx, orig_org.GetMetaGenome());
   
   // Set the genotype...
   new_organism->SetGenotype(orig_org.GetGenotype());
@@ -4737,20 +4737,20 @@
   cAvidaContext& ctx = m_world->GetDefaultContext();
   
   // Do mutations on the child genome, but restore it to its current state afterward.
-  cGenome save_child = parent.ChildGenome();
+  cMetaGenome save_child = parent.OffspringGenome();
   parent.GetHardware().Divide_DoMutations(ctx);
-  cGenome child_genome = parent.ChildGenome();
+  cMetaGenome child_genome = parent.OffspringGenome();
   parent.GetHardware().Divide_TestFitnessMeasures(ctx);
-  parent.ChildGenome() = save_child;
+  parent.OffspringGenome() = save_child;
   cOrganism* new_organism = new cOrganism(m_world, ctx, child_genome);
   
   // Set the genotype...
   assert(parent.GetGenotype());  
-  cGenotype* new_genotype = m_world->GetClassificationManager().GetGenotype(child_genome, parent.GetGenotype(), NULL);
+  cGenotype* new_genotype = m_world->GetClassificationManager().GetGenotype(child_genome.GetGenome(), parent.GetGenotype(), NULL);
   new_organism->SetGenotype(new_genotype);
   
   // Setup the phenotype...
-  new_organism->GetPhenotype().SetupOffspring(parent.GetPhenotype(),child_genome);
+  new_organism->GetPhenotype().SetupOffspring(parent.GetPhenotype(),child_genome.GetGenome());
   
   // Prep the cell..
   if (m_world->GetConfig().BIRTH_METHOD.Get() == POSITION_CHILD_FULL_SOUP_ELDEST &&
@@ -5302,8 +5302,8 @@
     org_count[from_cell_id]--;
     org_count[to_cell_id]++;
     
-    cOrganism * organism = GetCell(from_cell_id).GetOrganism();
-    organism->ChildGenome() = organism->GetGenome();
+    cOrganism* organism = GetCell(from_cell_id).GetOrganism();
+    organism->OffspringGenome() = organism->GetMetaGenome();
     if (m_world->GetVerbosity() >= VERBOSE_DETAILS) cout << "Injecting Child " << from_cell_id << " to " << to_cell_id << endl;  
     InjectChild( to_cell_id, *organism );  
     
@@ -5316,8 +5316,8 @@
     for (int cell_id = 0; cell_id < num_cells; cell_id++) {
       if (!is_init[cell_id])
       {
-        cOrganism * organism = GetCell(cell_id).GetOrganism();
-        organism->ChildGenome() = organism->GetGenome();
+        cOrganism* organism = GetCell(cell_id).GetOrganism();
+        organism->OffspringGenome() = organism->GetMetaGenome();
         if (m_world->GetVerbosity() >= VERBOSE_DETAILS) cout << "Re-injecting Self " << cell_id << " to " << cell_id << endl;  
         InjectChild( cell_id, *organism ); 
       }

Modified: development/source/main/cPopulation.h
===================================================================
--- development/source/main/cPopulation.h	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/main/cPopulation.h	2009-03-30 16:14:07 UTC (rev 3198)
@@ -163,7 +163,7 @@
   void InitiatePop();
 
   // Activate the offspring of an organism in the population
-  bool ActivateOffspring(cAvidaContext& ctx, cGenome& child_genome, cOrganism& parent_organism);
+  bool ActivateOffspring(cAvidaContext& ctx, const cMetaGenome& offspring_genome, cOrganism& parent_organism);
   bool ActivateParasite(cOrganism& parent, const cCodeLabel& label, const cGenome& injected_code);
   
   // Inject an organism from the outside world.

Modified: development/source/main/cPopulationInterface.cc
===================================================================
--- development/source/main/cPopulationInterface.cc	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/main/cPopulationInterface.cc	2009-03-30 16:14:07 UTC (rev 3198)
@@ -55,16 +55,16 @@
   m_world->GetPopulation().GetCell(m_cell_id).SetCellData(newData);
 }
 
-bool cPopulationInterface::Divide(cAvidaContext& ctx, cOrganism* parent, cGenome& child_genome)
+bool cPopulationInterface::Divide(cAvidaContext& ctx, cOrganism* parent, const cMetaGenome& offspring_genome)
 {
   assert(parent != NULL);
   assert(m_world->GetPopulation().GetCell(m_cell_id).GetOrganism() == parent);
-  return m_world->GetPopulation().ActivateOffspring(ctx, child_genome, *parent);
+  return m_world->GetPopulation().ActivateOffspring(ctx, offspring_genome, *parent);
 }
 
-cOrganism * cPopulationInterface::GetNeighbor()
+cOrganism* cPopulationInterface::GetNeighbor()
 {
-  cPopulationCell & cell = m_world->GetPopulation().GetCell(m_cell_id);
+  cPopulationCell& cell = m_world->GetPopulation().GetCell(m_cell_id);
   assert(cell.IsOccupied());
   
   return cell.ConnectionList().GetFirst()->GetOrganism();

Modified: development/source/main/cPopulationInterface.h
===================================================================
--- development/source/main/cPopulationInterface.h	2009-03-27 21:32:17 UTC (rev 3197)
+++ development/source/main/cPopulationInterface.h	2009-03-30 16:14:07 UTC (rev 3198)
@@ -76,7 +76,7 @@
   void SetPrevSeenCellID(int in_id) { m_prevseen_cell_id = in_id; }
   void SetPrevTaskCellID(int in_id) { m_prev_task_cell = in_id; }
 
-  bool Divide(cAvidaContext& ctx, cOrganism* parent, cGenome& child_genome);
+  bool Divide(cAvidaContext& ctx, cOrganism* parent, const cMetaGenome& offspring_genome);
   cOrganism* GetNeighbor();
   bool IsNeighborCellOccupied();
   int GetNumNeighbors();




More information about the Avida-cvs mailing list