[Avida-SVN] r2737 - in branches/interrupt: Avida.xcodeproj source/actions source/analyze source/classification source/cpu source/main

beckma24 at myxo.css.msu.edu beckma24 at myxo.css.msu.edu
Thu Jul 31 10:03:15 PDT 2008


Author: beckma24
Date: 2008-07-31 13:03:14 -0400 (Thu, 31 Jul 2008)
New Revision: 2737

Modified:
   branches/interrupt/Avida.xcodeproj/project.pbxproj
   branches/interrupt/source/actions/PrintActions.cc
   branches/interrupt/source/analyze/cAnalyze.cc
   branches/interrupt/source/analyze/cAnalyzeGenotype.cc
   branches/interrupt/source/analyze/cMutationalNeighborhood.cc
   branches/interrupt/source/classification/cClassificationManager.cc
   branches/interrupt/source/classification/cGenotype.cc
   branches/interrupt/source/classification/cInjectGenotype.cc
   branches/interrupt/source/classification/cSpecies.cc
   branches/interrupt/source/cpu/cCPUMemory.cc
   branches/interrupt/source/cpu/cCPUMemory.h
   branches/interrupt/source/cpu/cHardwareBase.cc
   branches/interrupt/source/cpu/cHardwareCPU.cc
   branches/interrupt/source/cpu/cHardwareExperimental.cc
   branches/interrupt/source/cpu/cHardwareGX.cc
   branches/interrupt/source/cpu/cHardwareSMT.cc
   branches/interrupt/source/cpu/cHardwareTransSMT.cc
   branches/interrupt/source/cpu/cHeadCPU.h
   branches/interrupt/source/main/cBirthChamber.cc
   branches/interrupt/source/main/cGenome.cc
   branches/interrupt/source/main/cGenome.h
   branches/interrupt/source/main/cGenomeUtil.cc
   branches/interrupt/source/main/cLandscape.cc
   branches/interrupt/source/main/cMxCodeArray.cc
   branches/interrupt/source/main/cOrganism.h
   branches/interrupt/source/main/cPopulation.cc
Log:
First portion for code to enable instruction-level protection within a cCPUMemory.

Modified: branches/interrupt/Avida.xcodeproj/project.pbxproj
===================================================================
--- branches/interrupt/Avida.xcodeproj/project.pbxproj	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/Avida.xcodeproj/project.pbxproj	2008-07-31 17:03:14 UTC (rev 2737)
@@ -205,6 +205,7 @@
 		B4FA258A0C5EB65E0086D4B5 /* cPlasticPhenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = B4FA25810C5EB6510086D4B5 /* cPlasticPhenotype.cc */; };
 		B4FA25A90C5EB7880086D4B5 /* cPhenPlastGenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = B4FA259E0C5EB7600086D4B5 /* cPhenPlastGenotype.cc */; };
 		B516AF840C91E2D400023D53 /* cDemeCellEvent.cc in Sources */ = {isa = PBXBuildFile; fileRef = B516AF790C91E24600023D53 /* cDemeCellEvent.cc */; };
+		BB4461700E40D371009C33A7 /* cHardwareInterrupt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BB44616F0E40D371009C33A7 /* cHardwareInterrupt.cpp */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXBuildRule section */
@@ -220,23 +221,6 @@
 		};
 /* End PBXBuildRule section */
 
-/* Begin PBXBuildStyle section */
-		B54852BC0DF98D8E00AD254E /* Development */ = {
-			isa = PBXBuildStyle;
-			buildSettings = {
-				COPY_PHASE_STRIP = NO;
-			};
-			name = Development;
-		};
-		B54852BD0DF98D8E00AD254E /* Deployment */ = {
-			isa = PBXBuildStyle;
-			buildSettings = {
-				COPY_PHASE_STRIP = YES;
-			};
-			name = Deployment;
-		};
-/* End PBXBuildStyle section */
-
 /* Begin PBXContainerItemProxy section */
 		56F555DA0C3B36FC00E2E929 /* PBXContainerItemProxy */ = {
 			isa = PBXContainerItemProxy;
@@ -862,6 +846,8 @@
 		B4FA259E0C5EB7600086D4B5 /* cPhenPlastGenotype.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cPhenPlastGenotype.cc; sourceTree = "<group>"; };
 		B516AF790C91E24600023D53 /* cDemeCellEvent.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = cDemeCellEvent.cc; path = source/main/cDemeCellEvent.cc; sourceTree = SOURCE_ROOT; };
 		B516AF7A0C91E24600023D53 /* cDemeCellEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = cDemeCellEvent.h; path = source/main/cDemeCellEvent.h; sourceTree = SOURCE_ROOT; };
+		BB44616E0E40D371009C33A7 /* cHardwareInterrupt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cHardwareInterrupt.h; sourceTree = "<group>"; };
+		BB44616F0E40D371009C33A7 /* cHardwareInterrupt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cHardwareInterrupt.cpp; sourceTree = "<group>"; };
 		DCC30FCF0762539D008F7A48 /* Doxyfile */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = Doxyfile; sourceTree = "<group>"; };
 		DCC3109C0762539E008F7A48 /* avida.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = avida.cc; sourceTree = "<group>"; };
 		DCC31547076253A4008F7A48 /* cCycleCheck.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cCycleCheck.cc; sourceTree = "<group>"; };
@@ -1410,6 +1396,8 @@
 				7005A70109BA0FA90007E16E /* cTestCPUInterface.h */,
 				7005A70209BA0FA90007E16E /* cTestCPUInterface.cc */,
 				705260BB0B87A7DB0007426F /* cInstLibEntry.h */,
+				BB44616E0E40D371009C33A7 /* cHardwareInterrupt.h */,
+				BB44616F0E40D371009C33A7 /* cHardwareInterrupt.cpp */,
 			);
 			path = cpu;
 			sourceTree = "<group>";
@@ -1834,16 +1822,12 @@
 		DCC30C4D0762532C008F7A48 /* Project object */ = {
 			isa = PBXProject;
 			buildConfigurationList = 702442D70859E0B00059BD9B /* Build configuration list for PBXProject "Avida" */;
-			buildSettings = {
-			};
-			buildStyles = (
-				B54852BC0DF98D8E00AD254E /* Development */,
-				B54852BD0DF98D8E00AD254E /* Deployment */,
-			);
+			compatibilityVersion = "Xcode 2.4";
 			hasScannedForEncodings = 0;
 			mainGroup = DCC30C490762532C008F7A48;
 			productRefGroup = DCC3164E07626CF3008F7A48 /* Products */;
 			projectDirPath = "";
+			projectRoot = "";
 			targets = (
 				7023ED520C0A590200362B9C /* full-suite */,
 				DCC3164C07626CF3008F7A48 /* avida */,
@@ -2086,6 +2070,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				70DCAC9C097AF7C0002F8733 /* primitive.cc in Sources */,
+				BB4461700E40D371009C33A7 /* cHardwareInterrupt.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: branches/interrupt/source/actions/PrintActions.cc
===================================================================
--- branches/interrupt/source/actions/PrintActions.cc	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/actions/PrintActions.cc	2008-07-31 17:03:14 UTC (rev 2737)
@@ -185,7 +185,7 @@
         // access this CPU's code block
         cCPUMemory& cpu_mem = cell.GetOrganism()->GetHardware().GetMemory();
         const int mem_size = cpu_mem.GetSize();
-        for (int y = 0; y < mem_size; y++) inst_counts[cpu_mem[y].GetOp()]++;     
+        for (int y = 0; y < mem_size; y++) inst_counts[cpu_mem.GetOp(y)]++;     
       }
     }
     
@@ -2005,8 +2005,8 @@
       
       // Place this genotype into the histograms.
       for (int j = 0; j < length; j++) {
-        assert(genome[j].GetOp() < num_inst);
-        inst_hist[j].Insert(genome[j].GetOp(), num_organisms);
+        assert(genome.GetOp(j) < num_inst);
+        inst_hist[j].Insert(genome.GetOp(j), num_organisms);
       }
       
       // Mark all instructions beyond the length as -1 in histogram...
@@ -2045,7 +2045,7 @@
       if (mode == -1 && count == total) break;
       
       if ( i < con_length )
-        con_genome[i].SetOp(mode);
+        con_genome.SetOp(i, mode);
       
       // Print all needed files.
       if (i < m_lines_saved) {

Modified: branches/interrupt/source/analyze/cAnalyze.cc
===================================================================
--- branches/interrupt/source/analyze/cAnalyze.cc	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/analyze/cAnalyze.cc	2008-07-31 17:03:14 UTC (rev 2737)
@@ -508,11 +508,11 @@
   tArray<double> test_fitness(num_insts);
   tArray<double> prob(num_insts);
   for (int line_no = 0; line_no < num_lines; line_no ++) {
-    int cur_inst = base_genome[line_no].GetOp();
+    int cur_inst = base_genome.GetOp(line_no);
     
     // Test fitness of each mutant.
     for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) {
-      mod_genome[line_no].SetOp(mod_inst);
+      mod_genome.SetOp(line_no, mod_inst);
       cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
       test_genotype.Recalculate(m_ctx);
       // Ajust fitness ...
@@ -561,7 +561,7 @@
     entropy += this_entropy;
     
     // Reset the mod_genome back to the original sequence.
-    mod_genome[line_no].SetOp(cur_inst);
+    mod_genome.SetOp(line_no, cur_inst);
   }
   return entropy;
 }
@@ -606,14 +606,14 @@
       
       cerr << "[ " << line_1 << ", " << line_2 << " ]" << endl;
       
-      int cur_inst_1 = base_genome[line_1].GetOp(); 
-      int cur_inst_2 = base_genome[line_2].GetOp();
+      int cur_inst_1 = base_genome.GetOp(line_1); 
+      int cur_inst_2 = base_genome.GetOp(line_2);
       
       // Test fitness of each mutant.
       for (int mod_inst_1 = 0; mod_inst_1 < num_insts; mod_inst_1++){
         for (int mod_inst_2 = 0; mod_inst_2 < num_insts; mod_inst_2++) {
-          mod_genome[line_1].SetOp(mod_inst_1);
-          mod_genome[line_2].SetOp(mod_inst_2);
+          mod_genome.SetOp(line_1, mod_inst_1);
+          mod_genome.SetOp(line_2, mod_inst_2);
           cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
           test_genotype.Recalculate(m_ctx);
           // Adjust fitness ...
@@ -677,8 +677,8 @@
       pairwiseEntropy[line_1][line_2] = this_entropy;
       
       // Reset the mod_genome back to the original sequence.
-      mod_genome[line_1].SetOp(cur_inst_1);
-      mod_genome[line_2].SetOp(cur_inst_2);
+      mod_genome.SetOp(line_1, cur_inst_1);
+      mod_genome.SetOp(line_2, cur_inst_2);
       
     }  
   }  //End Loops
@@ -705,12 +705,12 @@
   tArray<double> test_fitness(num_insts);
   tArray<double> prob(num_insts);
   for (int line_no = 0; line_no < num_lines; line_no ++) {
-    int cur_inst = base_genome[line_no].GetOp();
-    int parent_inst = parent_genome[line_no].GetOp();
+    int cur_inst = base_genome.GetOp(line_no);
+    int parent_inst = parent_genome.GetOp(line_no);
     
     // Test fitness of each mutant.
     for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) {
-      mod_genome[line_no].SetOp(mod_inst);
+      mod_genome.SetOp(line_no, mod_inst);
       cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
       test_genotype.Recalculate(m_ctx);
       test_fitness[mod_inst] = test_genotype.GetFitness();
@@ -770,7 +770,7 @@
     entropy += this_entropy;
     
     // Reset the mod_genome back to the base_genome.
-    mod_genome[line_no].SetOp(cur_inst);
+    mod_genome.SetOp(line_no, cur_inst);
   }
   return entropy;
 }
@@ -803,11 +803,11 @@
   tArray<double> test_fitness(num_insts);
   tArray<double> prob(num_insts);
   for (int line_no = 0; line_no < num_lines; line_no ++) {
-    int cur_inst = genotype1_base_genome[line_no].GetOp();
+    int cur_inst = genotype1_base_genome.GetOp(line_no);
     
     // Test fitness of each mutant.
     for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) {
-      genotype1_mod_genome[line_no].SetOp(mod_inst);
+      genotype1_mod_genome.SetOp(line_no, mod_inst);
       cAnalyzeGenotype test_genotype(m_world, genotype1_mod_genome, inst_set);
       test_genotype.Recalculate(m_ctx);
       // Ajust fitness ...
@@ -855,7 +855,7 @@
     genotype1_info[line_no] = 1 - this_entropy;
     
     // Reset the mod_genome back to the original sequence.
-    genotype1_mod_genome[line_no].SetOp(cur_inst);
+    genotype1_mod_genome.SetOp(line_no, cur_inst);
   }
   
   genotype2->Recalculate(m_ctx);
@@ -872,11 +872,11 @@
   
   // Loop through all the lines of code, calculate increased information
   for (int line_no = 0; line_no < num_lines; line_no ++) {
-    int cur_inst = genotype2_base_genome[line_no].GetOp();
+    int cur_inst = genotype2_base_genome.GetOp(line_no);
     
     // Test fitness of each mutant.
     for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) {
-      genotype2_mod_genome[line_no].SetOp(mod_inst);
+      genotype2_mod_genome.SetOp(line_no, mod_inst);
       cAnalyzeGenotype test_genotype(m_world, genotype2_mod_genome, inst_set);
       test_genotype.Recalculate(m_ctx);
       // Ajust fitness ...
@@ -928,7 +928,7 @@
     } // else increasing is 0, do nothing
     
     // Reset the mod_genome back to the original sequence.
-    genotype2_mod_genome[line_no].SetOp(cur_inst);
+    genotype2_mod_genome.SetOp(line_no, cur_inst);
   }
   
   
@@ -2699,7 +2699,7 @@
       task_count[task_id] += num_cpus;
       task_gen_count[task_id]++;
       for (int i = 0; i < genotype->GetLength(); i++) {
-        inst_freq( i, genome[i].GetOp() ) += num_cpus;
+        inst_freq( i, genome.GetOp(i) ) += num_cpus;
       }
       for (int i = genotype->GetLength(); i < max_length; i++) {
         inst_freq(i, num_insts) += num_cpus; // Entry for "past genome end"
@@ -3037,9 +3037,9 @@
       const cGenome & base_genome = genotype->GetGenome();
       cGenome mod_genome(base_genome);
       for (int line = 0; line < length_genome; ++ line) {
-        int given_inst = given_genome[line].GetOp();
+        int given_inst = given_genome.GetOp(line);
         mod_genome = base_genome;
-        mod_genome[line].SetOp(given_inst);
+        mod_genome.SetOp(line, given_inst);
         cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
         test_genotype.Recalculate(m_ctx, &test_info);
         
@@ -3071,10 +3071,10 @@
     cGenome mod_genome(base_genome);
     
     for (int line = 0; line < length_genome; ++ line) {
-      int cur_inst = base_genome[line].GetOp();
+      int cur_inst = base_genome.GetOp(line);
       
       for (int mod_inst = 0; mod_inst < num_insts; ++ mod_inst) {
-        mod_genome[line].SetOp(mod_inst);
+        mod_genome.SetOp(line, mod_inst);
         cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
         test_genotype.Recalculate(m_ctx, &test_info);
         if (test_genotype.GetFitness() >= base_fitness) {
@@ -3085,7 +3085,7 @@
         }
       }
       
-      mod_genome[line].SetOp(cur_inst);
+      mod_genome.SetOp(line, cur_inst);
     }
     
     /////////////////////////////////////////
@@ -3481,11 +3481,11 @@
     cGenome mod_genome(base_genome);
     
     for (int line = 0; line < length_genome; ++ line) {
-      int cur_inst = base_genome[line].GetOp();
+      int cur_inst = base_genome.GetOp(line);
       int num_neutral = 0;
       
       for (int mod_inst = 0; mod_inst < num_insts; ++ mod_inst) {
-        mod_genome[line].SetOp(mod_inst);
+        mod_genome.SetOp(line, mod_inst);
         cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
         test_genotype.Recalculate(m_ctx, &test_info);
         if (test_genotype.GetFitness() >= base_fitness) {
@@ -3501,7 +3501,7 @@
       }
       
       
-      mod_genome[line].SetOp(cur_inst);
+      mod_genome.SetOp(line, cur_inst);
     }
     
     point_mut.insert(make_pair(genotype->GetID(), prob));
@@ -4215,7 +4215,7 @@
       if (copy_mut_prob > 0.0) {
         for (int i = 0; i < mod_genome.GetSize(); i++) {
           if (m_world->GetRandom().P(copy_mut_prob)) {
-            mod_genome[i] = inst_set.GetRandomInst(m_ctx);
+            mod_genome.SetInstruction(i, inst_set.GetRandomInst(m_ctx));
             num_mutations++;
           }
         }
@@ -4445,8 +4445,8 @@
     tArray<int> ko_effect(max_line);
     for (int line_num = 0; line_num < max_line; line_num++) {
       // Save a copy of the current instruction and replace it with "NULL"
-      int cur_inst = base_genome[line_num].GetOp();
-      mod_genome[line_num] = null_inst;
+      int cur_inst = base_genome.GetOp(line_num);
+      mod_genome.SetInstruction(line_num, null_inst);
       cAnalyzeGenotype ko_genotype(m_world, mod_genome, ko_inst_set);
       ko_genotype.Recalculate(m_ctx);
       
@@ -4468,17 +4468,17 @@
       }
       
       // Reset the mod_genome back to the original sequence.
-      mod_genome[line_num].SetOp(cur_inst);
+      mod_genome.SetOp(line_num, cur_inst);
     }
     
     tArray<int> ko_pair_effect(ko_effect);
     if (max_knockouts > 1) {
       for (int line1 = 0; line1 < max_line; line1++) {
       	for (int line2 = line1+1; line2 < max_line; line2++) {
-          int cur_inst1 = base_genome[line1].GetOp();
-          int cur_inst2 = base_genome[line2].GetOp();
-          mod_genome[line1] = null_inst;
-          mod_genome[line2] = null_inst;
+          int cur_inst1 = base_genome.GetOp(line1);
+          int cur_inst2 = base_genome.GetOp(line2);
+          mod_genome.SetInstruction(line1, null_inst);
+          mod_genome.SetInstruction(line2, null_inst);
           cAnalyzeGenotype ko_genotype(m_world, mod_genome, ko_inst_set);
           ko_genotype.Recalculate(m_ctx);
           
@@ -4503,8 +4503,8 @@
           }	
           
           // Reset the mod_genome back to the original sequence.
-          mod_genome[line1].SetOp(cur_inst1);
-          mod_genome[line2].SetOp(cur_inst2);
+          mod_genome.SetOp(line1, cur_inst1);
+          mod_genome.SetOp(line2, cur_inst2);
         }
       }
     }    
@@ -4813,10 +4813,10 @@
     
     // Loop through all the lines of code, testing the removal of each.
     for (int line_num = 0; line_num < max_line; line_num++) {
-      int cur_inst = base_genome[line_num].GetOp();
-      char cur_symbol = base_genome[line_num].GetSymbol();
+      int cur_inst = base_genome.GetOp(line_num);
+      char cur_symbol = base_genome.GetSymbol(line_num);
       
-      mod_genome[line_num] = null_inst;
+      mod_genome.SetInstruction(line_num, null_inst);
       cAnalyzeGenotype test_genotype(m_world, mod_genome, map_inst_set);
       test_genotype.Recalculate(m_ctx, &test_info);
       
@@ -4861,7 +4861,7 @@
       fp << endl;
       
       // Reset the mod_genome back to the original sequence.
-      mod_genome[line_num].SetOp(cur_inst);
+      mod_genome.SetOp(line_num, cur_inst);
     }
     
     
@@ -5060,9 +5060,9 @@
         
         // Loop through all the lines of code, testing the removal of each.
         for (int line_num = 0; line_num < max_line; line_num++) {
-          int cur_inst = base_genome[line_num].GetOp();
+          int cur_inst = base_genome.GetOp(line_num);
           
-          mod_genome[line_num] = null_inst;
+          mod_genome.SetInstruction(line_num, null_inst);
           cAnalyzeGenotype test_genotype(m_world, mod_genome, map_inst_set);
           cAnalyzeGenotype old_genotype(m_world, base_genome, map_inst_set);
           test_genotype.Recalculate(m_ctx);
@@ -5099,7 +5099,7 @@
           }
           
           // Reset the mod_genome back to the original sequence.
-          mod_genome[line_num].SetOp(cur_inst);
+          mod_genome.SetOp(line_num, cur_inst);
         } // end of genotype-phenotype mapping for a single organism
         
         for (int i = 0; i < num_cols; i++) {if (num_inst[i] != 0) total_task++;}
@@ -5285,10 +5285,10 @@
     
     // Loop through all lines in this genome
     for (int line_num = 0; line_num < base_length; line_num++) {
-      int cur_inst = base_genome[line_num].GetOp();
+      int cur_inst = base_genome.GetOp(line_num);
       
       // Determine what happens to this genotype when this line is knocked out
-      mod_genome[line_num] = null_inst;
+      mod_genome.SetInstruction(line_num, null_inst);
       cAnalyzeGenotype test_genotype(m_world, mod_genome, map_inst_set);
       test_genotype.Recalculate(m_ctx);
       
@@ -5319,7 +5319,7 @@
       }
       
       // Reset the mod_genome back to the original sequence.
-      mod_genome[line_num].SetOp(cur_inst);
+      mod_genome.SetOp(line_num, cur_inst);
     } // end of genotype-phenotype mapping for a single organism
     
     
@@ -5513,8 +5513,8 @@
     
     // Loop through all the lines of code, testing all mutations...
     for (int line_num = 0; line_num < max_line; line_num++) {
-      int cur_inst = base_genome[line_num].GetOp();
-      char cur_symbol = base_genome[line_num].GetSymbol();
+      int cur_inst = base_genome.GetOp(line_num);
+      char cur_symbol = base_genome.GetSymbol(line_num);
       int row_dead = 0, row_neg = 0, row_neut = 0, row_pos = 0;
       double row_fitness = 0.0;
       
@@ -5536,7 +5536,7 @@
           }
         }
         else {
-          mod_genome[line_num].SetOp(mod_inst);
+          mod_genome.SetOp(line_num, mod_inst);
           cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
           test_genotype.Recalculate(m_ctx);
           const double test_fitness = test_genotype.GetFitness() / base_fitness;
@@ -5572,7 +5572,7 @@
       }
       
       // Column: Knockout
-      mod_genome[line_num] = null_inst;
+      mod_genome.SetInstruction(line_num, null_inst);
       cAnalyzeGenotype test_genotype(m_world, mod_genome, map_inst_set);
       test_genotype.Recalculate(m_ctx);
       const double test_fitness = test_genotype.GetFitness() / base_fitness;
@@ -5617,7 +5617,7 @@
       fp << endl;
       
       // Reset the mod_genome back to the original sequence.
-      mod_genome[line_num].SetOp(cur_inst);
+      mod_genome.SetOp(line_num, cur_inst);
     }
     
     
@@ -6252,7 +6252,7 @@
       << length << " ";
     
     for (int i = 0; i < length; i++) {
-      fp << genome[i].GetOp() << " ";
+      fp << genome.GetOp(i) << " ";
     }
   }
   
@@ -6704,7 +6704,7 @@
     // Count it up!
     const int genome_size = genotype->GetLength();
     for (int i = 0; i < genome_size; i++) {
-      const int inst_id = genotype->GetGenome()[i].GetOp();
+      const int inst_id = genotype->GetGenome().GetOp(i);
       inst_bin[inst_id]++;
     }
     
@@ -6785,7 +6785,7 @@
     // Count it up!
     const int genome_size = genotype->GetLength();
     for (int i = 0; i < genome_size; i++) {
-      const int inst_id = genotype->GetGenome()[i].GetOp();
+      const int inst_id = genotype->GetGenome().GetOp(i);
       inst_bin[inst_id]++;
     }
     total_length += genome_size;
@@ -6872,8 +6872,8 @@
     continue;
     // Check to see if any sites have changed...
     for (int i = 0; i < size; i++) {
-      if (genotype->GetGenome()[i] != prev_genotype->GetGenome()[i]) {
-        prev_inst[i] = prev_genotype->GetGenome()[i].GetOp();
+      if (genotype->GetGenome().GetInstruction(i) != prev_genotype->GetGenome().GetInstruction(i)) {
+        prev_inst[i] = prev_genotype->GetGenome().GetOp(i);
       }
     }
     
@@ -6891,13 +6891,13 @@
     for (int i = 0; i < size; i++) {
       if (prev_inst[i] == -1) num_static++;
       else {
-        test_genome[i].SetOp(prev_inst[i]);
+        test_genome.SetOp(i, prev_inst[i]);
         testcpu->TestGenome(m_ctx, test_info, test_genome);
         const double cur_fitness = test_info.GetGenotypeFitness();
         if (cur_fitness > base_fitness) num_detrimental++;
         else if (cur_fitness < base_fitness) num_beneficial++;
         else num_neutral++;
-        test_genome[i] = genotype->GetGenome()[i];
+        test_genome.SetInstruction(i, genotype->GetGenome().GetInstruction(i));
       }      
     }
     
@@ -6998,7 +6998,7 @@
     tArray<double> test_fitness(num_insts);
     tArray<double> prob(num_insts);
     for (int line_num = 0; line_num < max_line; line_num++) {
-      int cur_inst = base_genome[line_num].GetOp();
+      int cur_inst = base_genome.GetOp(line_num);
       //char cur_symbol = base_genome[line_num].GetSymbol();
       
       // Column 1 ... the original instruction in the genome.
@@ -7006,7 +7006,7 @@
       
       // Test fitness of each mutant.
       for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) {
-        mod_genome[line_num].SetOp(mod_inst);
+        mod_genome.SetOp(line_num, mod_inst);
         cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
         test_genotype.Recalculate(m_ctx);
         test_fitness[mod_inst] = test_genotype.GetFitness();
@@ -7068,7 +7068,7 @@
       lineage_fp << complexity << " ";
       
       // Reset the mod_genome back to the original sequence.
-      mod_genome[line_num].SetOp(cur_inst);
+      mod_genome.SetOp(line_num, cur_inst);
     }
     
     m_world->GetDataFileManager().Remove(filename);
@@ -7188,8 +7188,8 @@
         fit_land_fp.WriteTimeStamp();
 
         // get current instructions at site 1 and site 2
-        int curr_inst1 = base_genome[site1].GetOp();
-        int curr_inst2 = base_genome[site2].GetOp();
+        int curr_inst1 = base_genome.GetOp(site1);
+        int curr_inst2 = base_genome.GetOp(site2);
       
         // get current fitness
         //double curr_fitness = genotype->GetFitness();
@@ -7199,8 +7199,8 @@
         for (int mod_inst1 = 0; mod_inst1 < num_insts; mod_inst1++) {
           for (int mod_inst2 = 0; mod_inst2 < num_insts; mod_inst2++) {
             // modify mod_genome at two sites
-            mod_genome[site1].SetOp(mod_inst1);
-            mod_genome[site2].SetOp(mod_inst2);
+            mod_genome.SetOp(site1, mod_inst1);
+            mod_genome.SetOp(site2, mod_inst2);
             // analyze mod_genome
             cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
             test_genotype.Recalculate(m_ctx);
@@ -7212,8 +7212,8 @@
           fit_land_fp.Endl();
         }   
         // Reset the mod_genome back to the original sequence.
-        mod_genome[site1].SetOp(curr_inst1);
-        mod_genome[site2].SetOp(curr_inst2);
+        mod_genome.SetOp(site1, curr_inst1);
+        mod_genome.SetOp(site2, curr_inst2);
         
         // close file
         m_world->GetDataFileManager().Remove(fl_filename);
@@ -7384,11 +7384,11 @@
     // run through lines in genome
     for (int line_num = 0; line_num < max_line; line_num++) {
       // get the current instruction at this line/site
-      int cur_inst = base_genome[line_num].GetOp();
+      int cur_inst = base_genome.GetOp(line_num);
       
       // recalculate fitness of each mutant.
       for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) {
-        mod_genome[line_num].SetOp(mod_inst);
+        mod_genome.SetOp(line_num, mod_inst);
         cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
         test_genotype.Recalculate(m_ctx);
         test_fitness[mod_inst] = test_genotype.GetFitness();
@@ -7484,7 +7484,7 @@
       entropy_ss_bits[line_num] = entropy_bits;
       
       // Reset the mod_genome back to the original sequence.
-      mod_genome[line_num].SetOp(cur_inst);
+      mod_genome.SetOp(line_num, cur_inst);
     }
     
     /*
@@ -7510,8 +7510,8 @@
         //cout << "line #1, #2: " << line_num1 << ", " << line_num2 << endl; 
         
         // get current instructions at site 1 and site 2
-        int cur_inst1 = base_genome[line_num1].GetOp();
-        int cur_inst2 = base_genome[line_num2].GetOp();
+        int cur_inst1 = base_genome.GetOp(line_num1);
+        int cur_inst2 = base_genome.GetOp(line_num2);
       
         // get current fitness
         double cur_inst_fitness_2s = genotype->GetFitness();
@@ -7526,8 +7526,8 @@
           for (int mod_inst1 = 0; mod_inst1 < num_insts; mod_inst1++) {
             for (int mod_inst2 = 0; mod_inst2 < num_insts; mod_inst2++) {
               // modify mod_genome at two sites
-              mod_genome[line_num1].SetOp(mod_inst1);
-              mod_genome[line_num2].SetOp(mod_inst2);
+              mod_genome.SetOp(line_num1, mod_inst1);
+              mod_genome.SetOp(line_num2, mod_inst2);
               // analyze mod_genome
               cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
               test_genotype.Recalculate(m_ctx);
@@ -7710,8 +7710,8 @@
         fp_2s.Endl();
                     
         // Reset the mod_genome back to the original sequence.
-        mod_genome[line_num1].SetOp(cur_inst1);
-        mod_genome[line_num2].SetOp(cur_inst2);
+        mod_genome.SetOp(line_num1, cur_inst1);
+        mod_genome.SetOp(line_num2, cur_inst2);
         
       }// end line 2
     }// end line 1
@@ -7797,7 +7797,7 @@
                                        //continue;
                                        //}
       for (int line_num = 0; line_num < seq_length; line_num ++) {
-        int cur_inst = base_genome[line_num].GetOp();
+        int cur_inst = base_genome.GetOp(line_num);
         inst_stat(line_num, cur_inst) ++;
       }
       //organism_index++;
@@ -8520,7 +8520,7 @@
     if (copy_mut_prob > 0.0) {
       for (int n = 0; n < child_genome.GetSize(); n++) {
         if (m_world->GetRandom().P(copy_mut_prob)) {
-          child_genome[n] = inst_set.GetRandomInst(m_ctx);
+          child_genome.SetInstruction(n, inst_set.GetRandomInst(m_ctx));
         }
       }
     }

Modified: branches/interrupt/source/analyze/cAnalyzeGenotype.cc
===================================================================
--- branches/interrupt/source/analyze/cAnalyzeGenotype.cc	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/analyze/cAnalyzeGenotype.cc	2008-07-31 17:03:14 UTC (rev 2737)
@@ -81,9 +81,9 @@
     
   // Make sure that the sequences jive with the inst_set
   for (int i = 0; i < genome.GetSize(); i++) {
-    if (genome[i].GetOp() >= inst_set.GetSize()) {
+    if (genome.GetOp(i) >= inst_set.GetSize()) {
       cString msg("Trying to load instruction ");
-      msg += genome[i].GetOp();
+      msg += genome.GetOp(i);
       msg += ".  Max in set is";
       msg += (inst_set.GetSize() - 1);
       m_world->GetDriver().RaiseException(msg);
@@ -242,8 +242,8 @@
   tArray<int> ko_effect(length);
   for (int line_num = 0; line_num < length; line_num++) {
     // Save a copy of the current instruction and replace it with "NULL"
-    int cur_inst = mod_genome[line_num].GetOp();
-    mod_genome[line_num] = null_inst;
+    int cur_inst = mod_genome.GetOp(line_num);
+    mod_genome.SetInstruction(line_num, null_inst);
     cAnalyzeGenotype ko_genotype(m_world, mod_genome, ko_inst_set);
     ko_genotype.Recalculate(ctx);
     if (check_chart == true) {
@@ -269,7 +269,7 @@
     }
     
     // Reset the mod_genome back to the original sequence.
-    mod_genome[line_num].SetOp(cur_inst);
+    mod_genome.SetOp(line_num, cur_inst);
   }
   
   // Only continue from here if we are looking at all pairs of knockouts
@@ -300,10 +300,10 @@
       // Calculate the fitness for this pair of knockouts to determine if its
       // something other than what we expected.
       
-      int cur_inst1 = mod_genome[line1].GetOp();
-      int cur_inst2 = mod_genome[line2].GetOp();
-      mod_genome[line1] = null_inst;
-      mod_genome[line2] = null_inst;
+      int cur_inst1 = mod_genome.GetOp(line1);
+      int cur_inst2 = mod_genome.GetOp(line2);
+      mod_genome.SetInstruction(line1, null_inst);
+      mod_genome.SetInstruction(line2, null_inst);
       cAnalyzeGenotype ko_genotype(m_world, mod_genome, ko_inst_set);
       ko_genotype.Recalculate(ctx);
       
@@ -328,8 +328,8 @@
       }	
       
       // Reset the mod_genome back to the original sequence.
-      mod_genome[line1].SetOp(cur_inst1);
-      mod_genome[line2].SetOp(cur_inst2);
+      mod_genome.SetOp(line1, cur_inst1);
+      mod_genome.SetOp(line2, cur_inst2);
     }
   }
   

Modified: branches/interrupt/source/analyze/cMutationalNeighborhood.cc
===================================================================
--- branches/interrupt/source/analyze/cMutationalNeighborhood.cc	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/analyze/cMutationalNeighborhood.cc	2008-07-31 17:03:14 UTC (rev 2737)
@@ -213,7 +213,7 @@
   cGenome mod_genome(m_base_genome);
   
   // Loop through all the lines of genome, testing trying all combinations.
-  int cur_inst = mod_genome[cur_site].GetOp();
+  int cur_inst = mod_genome.GetOp(cur_site);
   
   // Fill in unmutated entry in fitness table with base fitness
   m_fitness_point[cur_site][cur_inst] = m_base_fitness;
@@ -222,7 +222,7 @@
   for (int inst_num = 0; inst_num < inst_size; inst_num++) {
     if (cur_inst == inst_num) continue;
     
-    mod_genome[cur_site].SetOp(inst_num);
+    mod_genome.SetOp(cur_site, inst_num);
     m_fitness_point[cur_site][inst_num] = ProcessOneStepGenome(ctx, testcpu, test_info, mod_genome, odata, cur_site);
 
     ProcessTwoStepPoint(ctx, testcpu, test_info, cur_site, mod_genome);
@@ -239,7 +239,7 @@
   
   // Loop through all instructions...
   for (int inst_num = 0; inst_num < inst_size; inst_num++) {
-    mod_genome[cur_site].SetOp(inst_num);
+    mod_genome.SetOp(cur_site, inst_num);
     m_fitness_insert[cur_site][inst_num] = ProcessOneStepGenome(ctx, testcpu, test_info, mod_genome, odata, cur_site);
     
     ProcessTwoStepInsert(ctx, testcpu, test_info, cur_site, mod_genome);
@@ -324,21 +324,21 @@
 {
   const int inst_size = m_inst_set.GetSize();
   sTwoStep& tdata = m_twostep_point[cur_site];
-  sPendFit cur(m_fitness_point, cur_site, mod_genome[cur_site].GetOp());
+  sPendFit cur(m_fitness_point, cur_site, mod_genome.GetOp(cur_site));
 
   // Loop through remaining lines of genome, testing trying all combinations.
   for (int line_num = cur_site + 1; line_num < m_base_genome.GetSize(); line_num++) {
-    int cur_inst = mod_genome[line_num].GetOp();
+    int cur_inst = mod_genome.GetOp(line_num);
     
     // Loop through all instructions...
     for (int inst_num = 0; inst_num < inst_size; inst_num++) {
       if (cur_inst == inst_num) continue;
       
-      mod_genome[line_num].SetOp(inst_num);
+      mod_genome.SetOp(line_num, inst_num);
       ProcessTwoStepGenome(ctx, testcpu, test_info, mod_genome, tdata, sPendFit(m_fitness_point, line_num, inst_num), cur);
     }
     
-    mod_genome[line_num].SetOp(cur_inst);
+    mod_genome.SetOp(line_num, cur_inst);
   }
 }
 
@@ -349,14 +349,14 @@
   const int inst_size = m_inst_set.GetSize();
   const int mod_size = mod_genome.GetSize();
   sTwoStep& tdata = m_twostep_insert[cur_site];
-  sPendFit cur(m_fitness_insert, cur_site, mod_genome[cur_site].GetOp());
+  sPendFit cur(m_fitness_insert, cur_site, mod_genome.GetOp(cur_site));
   
   // Loop through all instructions...
   for (int line_num = cur_site + 1; line_num <= mod_size; line_num++) {
     mod_genome.Insert(line_num, cInstruction(0));
     
     for (int inst_num = 0; inst_num < inst_size; inst_num++) {
-      mod_genome[cur_site].SetOp(inst_num);
+      mod_genome.SetOp(cur_site, inst_num);
       ProcessTwoStepGenome(ctx, testcpu, test_info, mod_genome, tdata, sPendFit(m_fitness_insert, line_num - 1, inst_num), cur);
     }
     mod_genome.Remove(line_num);
@@ -373,7 +373,7 @@
   
   // Loop through all instructions...
   for (int line_num = cur_site; line_num < mod_size; line_num++) {
-    int cur_inst = mod_genome[line_num].GetOp();
+    int cur_inst = mod_genome.GetOp(line_num);
     mod_genome.Remove(line_num);
     ProcessTwoStepGenome(ctx, testcpu, test_info, mod_genome, tdata, sPendFit(m_fitness_delete, line_num + 1, 0), cur);
     mod_genome.Insert(line_num, cInstruction(cur_inst));
@@ -386,24 +386,24 @@
 {
   const int inst_size = m_inst_set.GetSize();
   sTwoStep& tdata = m_insert_point[cur_site];
-  sPendFit cur(m_fitness_insert, cur_site, mod_genome[cur_site].GetOp());
+  sPendFit cur(m_fitness_insert, cur_site, mod_genome.GetOp(cur_site));
   
   // Loop through all lines of genome, testing trying all combinations.
   for (int line_num = 0; line_num < mod_genome.GetSize(); line_num++) {
     if (line_num == cur_site) continue; // Skip the site of the insertion
     int actual = (line_num < cur_site) ? line_num : (line_num - 1); // if at or past insertion site, adjust pending target site
     
-    int cur_inst = mod_genome[line_num].GetOp();
+    int cur_inst = mod_genome.GetOp(line_num);
     
     // Loop through all instructions...
     for (int inst_num = 0; inst_num < inst_size; inst_num++) {
       if (cur_inst == inst_num) continue;
       
-      mod_genome[line_num].SetOp(inst_num);
+      mod_genome.SetOp(line_num, inst_num);
       ProcessTwoStepGenome(ctx, testcpu, test_info, mod_genome, tdata, sPendFit(m_fitness_point, actual, inst_num), cur);
     }
     
-    mod_genome[line_num].SetOp(cur_inst);
+    mod_genome.SetOp(line_num, cur_inst);
   }
 }
 
@@ -412,14 +412,14 @@
                                                        int cur_site, cCPUMemory& mod_genome)
 {
   sTwoStep& tdata = m_insert_delete[cur_site];
-  sPendFit cur(m_fitness_insert, cur_site, mod_genome[cur_site].GetOp());
+  sPendFit cur(m_fitness_insert, cur_site, mod_genome.GetOp(cur_site));
 
   // Loop through all lines of genome, testing trying all combinations.
   for (int line_num = 0; line_num < mod_genome.GetSize(); line_num++) {
     if (line_num == cur_site) continue; // Skip the site of the insertion
     int actual = (line_num < cur_site) ? line_num : (line_num - 1); // if at or past insertion site, adjust pending target site
     
-    int cur_inst = mod_genome[line_num].GetOp();
+    int cur_inst = mod_genome.GetOp(line_num);
     mod_genome.Remove(line_num);
     ProcessTwoStepGenome(ctx, testcpu, test_info, mod_genome, tdata, sPendFit(m_fitness_delete, actual, 0), cur);
     mod_genome.Insert(line_num, cInstruction(cur_inst));
@@ -436,18 +436,18 @@
   
   // Loop through all lines of genome, testing trying all combinations.
   for (int line_num = 0; line_num < mod_genome.GetSize(); line_num++) {
-    int cur_inst = mod_genome[line_num].GetOp();
+    int cur_inst = mod_genome.GetOp(line_num);
     int actual = (line_num < cur_site) ? line_num : (line_num + 1); // if at or past deletion site, adjust pending target site
     
     // Loop through all instructions...
     for (int inst_num = 0; inst_num < inst_size; inst_num++) {
       if (cur_inst == inst_num) continue;
       
-      mod_genome[line_num].SetOp(inst_num);
+      mod_genome.SetOp(line_num, inst_num);
       ProcessTwoStepGenome(ctx, testcpu, test_info, mod_genome, tdata, sPendFit(m_fitness_point, actual, inst_num), cur);
     }
     
-    mod_genome[line_num].SetOp(cur_inst);
+    mod_genome.SetOp(line_num, cur_inst);
   }
 }
 

Modified: branches/interrupt/source/classification/cClassificationManager.cc
===================================================================
--- branches/interrupt/source/classification/cClassificationManager.cc	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/classification/cClassificationManager.cc	2008-07-31 17:03:14 UTC (rev 2737)
@@ -1288,7 +1288,7 @@
   unsigned int total = 0;
   
   for (int i = 0; i < in_genome.GetSize(); i++) {
-    total += (in_genome[i].GetOp() + 3) * i;
+    total += (in_genome.GetOp(i) + 3) * i;
   }
   
   return total % nGenotype::HASH_SIZE;
@@ -1301,7 +1301,7 @@
   int i;
   
   for (i = 0; i < in_genome.GetSize(); i++) {
-    total *= in_genome[i].GetOp() + 10 + i << 6;
+    total *= in_genome.GetOp(i) + 10 + i << 6;
     total += 3;
   }
   

Modified: branches/interrupt/source/classification/cGenotype.cc
===================================================================
--- branches/interrupt/source/classification/cGenotype.cc	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/classification/cGenotype.cc	2008-07-31 17:03:14 UTC (rev 2737)
@@ -78,7 +78,7 @@
   fp << genome.GetSize() << " ";
 
   for (int i = 0; i < genome.GetSize(); i++) {
-    fp << ((int) genome[i].GetOp()) << " ";
+    fp << ((int) genome.GetOp(i)) << " ";
   }
 
   return true;
@@ -99,7 +99,7 @@
     int inst_op;
     fp >> inst_op;
     temp_inst.SetOp(static_cast<unsigned char>(inst_op));
-    ret->genome[i] = temp_inst;
+    ret->genome.SetInstruction(i, temp_inst);
     // @CAO add something here to load arguments for instructions.
   }
   

Modified: branches/interrupt/source/classification/cInjectGenotype.cc
===================================================================
--- branches/interrupt/source/classification/cInjectGenotype.cc	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/classification/cInjectGenotype.cc	2008-07-31 17:03:14 UTC (rev 2737)
@@ -68,7 +68,7 @@
   fp << genome.GetSize() << " ";
 
   for (int i = 0; i < genome.GetSize(); i++) {
-    fp << ((int) genome[i].GetOp()) << " ";
+    fp << ((int) genome.GetOp(i)) << " ";
   }
 
   return true;
@@ -87,7 +87,7 @@
     int inst_op;
     fp >> inst_op;
     temp_inst.SetOp(static_cast<unsigned char>(inst_op));
-    genome[i] = temp_inst;
+    genome.SetInstruction(i, temp_inst);
     // @CAO add something here to load arguments for instructions.
   }
 

Modified: branches/interrupt/source/classification/cSpecies.cc
===================================================================
--- branches/interrupt/source/classification/cSpecies.cc	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/classification/cSpecies.cc	2008-07-31 17:03:14 UTC (rev 2737)
@@ -128,10 +128,10 @@
 
   for (int i = 0; i < overlap; i++) {
     // If this position has changed, check if crossovers here are viable.
-    if (test_genome[i] != genome[i]) {
+    if (test_genome.GetInstruction(i) != genome.GetInstruction(i)) {
       // Continue crossing over on each side...
-      cross_genome1[i] = test_genome[i];
-      cross_genome2[i] = genome[i];
+      cross_genome1.GetInstruction(i) = test_genome.GetInstruction(i);
+      cross_genome2.GetInstruction(i) = genome.GetInstruction(i);
    
       // Run each side, and determine viability...
       testcpu->TestGenome(ctx, test_info, cross_genome1);

Modified: branches/interrupt/source/cpu/cCPUMemory.cc
===================================================================
--- branches/interrupt/source/cpu/cCPUMemory.cc	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/cpu/cCPUMemory.cc	2008-07-31 17:03:14 UTC (rev 2737)
@@ -102,7 +102,7 @@
 
   // Fill in the new information...
   for (int i = 0; i < active_size; i++) {
-    genome[i] = other_genome[i];
+    genome[i] = other_genome.GetInstruction(i);
     flag_array[i] = 0;
   }
 }
@@ -175,7 +175,7 @@
 
   SloppyInsert(pos, in_genome.GetSize());
   for (int i = 0; i < in_genome.GetSize(); i++) {
-    genome[i+pos] = in_genome[i];
+    genome[i+pos] = in_genome.GetInstruction(i);
     flag_array[i+pos] = 0;
   }
 }
@@ -186,14 +186,19 @@
   assert(pos >= 0);                       // Removal must be in genome.
   assert(pos + num_insts <= active_size); // Cannot extend past end of genome.
 
-  const int new_size = active_size - num_insts;
+	int new_size = active_size - num_insts;
   for (int i = pos; i < new_size; i++) {
-    genome[i] = genome[i + num_insts];
-    flag_array[i] = flag_array[i + num_insts];
+		if(FlagProtected(i)) { // instruction cannot be removed
+			new_size++;
+		} else {
+			genome[i] = genome[i + num_insts];
+			flag_array[i] = flag_array[i + num_insts];
+		}
   }
   SloppyResize(new_size);
 }
 
+// Not really sure what this function does
 void cCPUMemory::Replace(int pos, int num_insts, const cGenome & in_genome)
 {
   assert(pos >= 0);                       // Replace must be in genome.
@@ -208,7 +213,18 @@
 
   // Now just copy everything over!
   for (int i = 0; i < in_genome.GetSize(); i++) {
-    genome[i + pos] = in_genome[i];
+    genome[i + pos] = in_genome.GetInstruction(i);
     flag_array[i + pos] = 0;
   }
 }
+
+
+void cCPUMemory::SetInstruction(int pos, const cInstruction& new_inst)
+{
+	if(!FlagProtected(pos)) {
+		genome[pos] = new_inst;
+//		ClearFlagProtected(pos);
+	} else {
+		std::cerr << "HERE\n";
+	}
+}

Modified: branches/interrupt/source/cpu/cCPUMemory.h
===================================================================
--- branches/interrupt/source/cpu/cCPUMemory.h	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/cpu/cCPUMemory.h	2008-07-31 17:03:14 UTC (rev 2737)
@@ -37,14 +37,14 @@
 class cCPUMemory : public cGenome
 {
 private:
-	static const unsigned char MASK_COPIED   = 0x01;
-	static const unsigned char MASK_MUTATED  = 0x02;
-	static const unsigned char MASK_EXECUTED = 0x04;
-	static const unsigned char MASK_BREAK    = 0x08;
-	static const unsigned char MASK_POINTMUT = 0x10;
-	static const unsigned char MASK_COPYMUT  = 0x20;
-	static const unsigned char MASK_INJECTED = 0x40;
-	static const unsigned char MASK_UNUSED   = 0x80; // unused bit
+	static const unsigned char MASK_COPIED    = 0x01;
+	static const unsigned char MASK_MUTATED   = 0x02;
+	static const unsigned char MASK_EXECUTED  = 0x04;
+	static const unsigned char MASK_BREAK     = 0x08;
+	static const unsigned char MASK_POINTMUT  = 0x10;
+	static const unsigned char MASK_COPYMUT   = 0x20;
+	static const unsigned char MASK_INJECTED  = 0x40;
+	static const unsigned char MASK_PROTECTED = 0x80; // instruction cannot be mutated
   
   tArray<unsigned char> flag_array;
   
@@ -57,16 +57,26 @@
 public:
   explicit cCPUMemory(int _size=1)  : cGenome(_size), 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()) { ; }
+  cCPUMemory(const cGenome& in_genome) : cGenome(in_genome), flag_array(in_genome.GetSize()) { ClearFlags(); }
+  cCPUMemory(const cString& in_string) : cGenome(in_string), flag_array(in_string.GetSize()) { ClearFlags(); }
   //! Construct a cCPUMemory object from a cInstruction range.
   cCPUMemory(cInstruction* begin, cInstruction* end) : cGenome(begin, end), flag_array(GetSize()) { ClearFlags(); }
   ~cCPUMemory() { ; }
 
   void operator=(const cCPUMemory& other_memory);
   void operator=(const cGenome& other_genome);
+
+	/***********************/
+	// DO NOT overload the [] operator.  Doing so will break instruction protection.
+	// Use the get and set functions below.
+	/***********************/
+	
   void Copy(int to, int from);
 
+	void SetOpt(int pos, int opt) { if(!FlagProtected(pos)) genome[pos].SetOp(opt); } //otherwise its protected
+	void SetInstruction(int pos, const cInstruction& new_inst);
+	
+	
   void Clear()
 	{
 		for (int i = 0; i < active_size; i++) {
@@ -79,30 +89,34 @@
   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]; }
+  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]; }
+  bool FlagProtected(int pos) const  { return MASK_PROTECTED & 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 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 SetFlagProtected(int pos)  { flag_array[pos] |= MASK_PROTECTED; }
+
+	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 ClearFlagProtected(int pos)  { flag_array[pos] &= ~MASK_PROTECTED; }
+
 	
-	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);

Modified: branches/interrupt/source/cpu/cHardwareBase.cc
===================================================================
--- branches/interrupt/source/cpu/cHardwareBase.cc	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/cpu/cHardwareBase.cc	2008-07-31 17:03:14 UTC (rev 2737)
@@ -172,15 +172,15 @@
         switch (m_world->GetConfig().SLIP_FILL_MODE.Get())
         {
           case 0:
-          child_genome[from+i] = child_copy[to+i];
+          child_genome.SetInstruction(from+i, child_copy.GetInstruction(to+i));
           break;
           
           case 1:        
-          child_genome[from+i] = m_inst_set->GetInst("nop-X");
+          child_genome.SetInstruction(from+i, m_inst_set->GetInst("nop-X"));
           break;
           
           case 2:        
-          child_genome[from+i] = m_inst_set->GetRandomInst(ctx);
+          child_genome.SetInstruction(from+i, m_inst_set->GetRandomInst(ctx));
           break;
           
           //Randomized order of instructions
@@ -201,7 +201,7 @@
               }
               test++;
             }
-            child_genome[from+i] = child_genome[to+copy_index];
+            child_genome.SetInstruction(from+i, child_genome.GetInstruction(to+copy_index));
             copied_so_far[copy_index] = true;
           }
           break;
@@ -217,7 +217,7 @@
     if (insertion_length < 0) insertion_length = 0;
     for (int i=insertion_length; i < child_copy.GetSize() - to; i++) 
     {
-        child_genome[from+i] = child_copy[to+i];
+        child_genome.SetInstruction(from+i, child_copy.GetInstruction(to+i));
 
     }
 
@@ -233,7 +233,7 @@
   // Divide Mutations
   if (organism->TestDivideMut(ctx) && totalMutations < maxmut) {
     const unsigned int mut_line = ctx.GetRandom().GetUInt(child_genome.GetSize());
-    child_genome[mut_line] = m_inst_set->GetRandomInst(ctx);
+    child_genome.SetInstruction(mut_line, m_inst_set->GetRandomInst(ctx));
 //    ++cpu_stats.mut_stats.divide_mut_count;
     totalMutations++;
     //cerr << "Mutating HERE!!!! BAD!!!!!" << endl;
@@ -263,7 +263,7 @@
     if (num_mut > 0 && totalMutations < maxmut) {
       for (int i = 0; i < num_mut && totalMutations < maxmut; i++) {
         int site = ctx.GetRandom().GetUInt(child_genome.GetSize());
-        child_genome[site] = m_inst_set->GetRandomInst(ctx);
+        child_genome.SetInstruction(site, m_inst_set->GetRandomInst(ctx));
 //        ++cpu_stats.mut_stats.div_mut_count;
         totalMutations++;
       }
@@ -336,7 +336,7 @@
         
         if (mut < m_inst_set->GetSize()) { // point
           int site = ctx.GetRandom().GetUInt(child_genome.GetSize());
-          child_genome[site] = cInstruction(mut);
+          child_genome.SetInstruction(site, cInstruction(mut));
         } else if (mut == m_inst_set->GetSize()) { // delete
           if (child_genome.GetSize() == MIN_CREATURE_SIZE) continue;
           int site = ctx.GetRandom().GetUInt(child_genome.GetSize());
@@ -359,7 +359,7 @@
   if (organism->GetParentMutProb() > 0 && totalMutations < maxmut) {
     for (int i = 0; i < GetMemory().GetSize(); i++) {
       if (organism->TestParentMut(ctx)) {
-        GetMemory()[i] = m_inst_set->GetRandomInst(ctx);
+        GetMemory().SetInstruction(i, m_inst_set->GetRandomInst(ctx));
 //        cpu_stats.mut_stats.parent_mut_line_count++;
         totalMutations++; //Unlike the others we can't be sure this was done only on divide -- AWC 06/29/06
         
@@ -399,7 +399,7 @@
   // Divide Mutations
   if (totalMutations < maxmut) {
     const unsigned int mut_line = ctx.GetRandom().GetUInt(child_genome.GetSize());
-    child_genome[mut_line] = m_inst_set->GetRandomInst(ctx);
+    child_genome.SetInstruction(mut_line, m_inst_set->GetRandomInst(ctx));
 //    ++cpu_stats.mut_stats.divide_mut_count;
     totalMutations++;
     //cerr << "Mutating HERE!!!! BAD!!!!!" << endl;
@@ -414,7 +414,7 @@
     if (num_mut > 0 && totalMutations < maxmut) {
       for (int i = 0; i < num_mut && totalMutations < maxmut; i++) {
         int site = ctx.GetRandom().GetUInt(child_genome.GetSize());
-        child_genome[site] = m_inst_set->GetRandomInst(ctx);
+        child_genome.SetInstruction(site, m_inst_set->GetRandomInst(ctx));
 //        ++cpu_stats.mut_stats.div_mut_count;
         totalMutations++;
         cerr << "Resampling here " << totalMutations << endl;
@@ -572,7 +572,7 @@
   
   for (int i = 0; i < num_muts; i++) {
     const int pos = ctx.GetRandom().GetUInt(memory.GetSize());
-    memory[pos] = m_inst_set->GetRandomInst(ctx);
+    memory.SetInstruction(pos, m_inst_set->GetRandomInst(ctx));
     memory.SetFlagMutated(pos);
     memory.SetFlagPointMut(pos);
 //    organism->CPUStats().mut_stats.point_mut_count++;
@@ -587,7 +587,7 @@
 	
   switch (type) {
 		case nMutation::TYPE_POINT:
-			target_memory[pos] = m_inst_set->GetRandomInst(ctx);
+			target_memory.SetInstruction(pos, m_inst_set->GetRandomInst(ctx));
 			target_memory.SetFlagMutated(pos);
 			break;
 		case nMutation::TYPE_INSERT:

Modified: branches/interrupt/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/interrupt/source/cpu/cHardwareCPU.cc	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/cpu/cHardwareCPU.cc	2008-07-31 17:03:14 UTC (rev 2737)
@@ -489,7 +489,7 @@
   m_promoters_enabled = m_world->GetConfig().PROMOTERS_ENABLED.Get();
   m_constituative_regulation = m_world->GetConfig().CONSTITUTIVE_REGULATION.Get();
   
-  m_memory = in_organism->GetGenome();  // Initialize memory...
+  m_memory = static_cast<cCPUMemory>(in_organism->GetGenome());  // Initialize memory...
   Reset();                            // Setup the rest of the hardware...
 }
 
@@ -557,7 +557,7 @@
     m_promoters.Resize(0);
     for (int i=0; i< m_memory.GetSize(); i++)
     {
-      if (m_memory[i] == promoter_inst)
+      if (m_memory.GetInstruction(i) == promoter_inst)
       {
         int code = Numberate(i-1, -1, m_world->GetConfig().PROMOTER_CODE_SIZE.Get());
         m_promoters.Push( cPromoter(i,code) );
@@ -908,17 +908,17 @@
     // If we are within a label, rewind to the beginning of it and see if
     // it has the proper sub-label that we're looking for.
     
-    if (m_inst_set->IsNop(search_genome[pos])) {
+    if (m_inst_set->IsNop(search_genome.GetInstruction(pos))) {
       // Find the start and end of the label we're in the middle of.
       
       int start_pos = pos;
       int end_pos = pos + 1;
       while (start_pos > search_start &&
-             m_inst_set->IsNop( search_genome[start_pos - 1] )) {
+             m_inst_set->IsNop( search_genome.GetInstruction(start_pos - 1) )) {
         start_pos--;
       }
       while (end_pos < search_genome.GetSize() &&
-             m_inst_set->IsNop( search_genome[end_pos] )) {
+             m_inst_set->IsNop( search_genome.GetInstruction(end_pos) )) {
         end_pos++;
       }
       int test_size = end_pos - start_pos;
@@ -932,7 +932,7 @@
         int matches;
         for (matches = 0; matches < label_size; matches++) {
           if (search_label[matches] !=
-              m_inst_set->GetNopMod( search_genome[offset + matches] )) {
+              m_inst_set->GetNopMod( search_genome.GetInstruction(offset + matches) )) {
             break;
           }
         }
@@ -989,16 +989,16 @@
     // If we are within a label, rewind to the beginning of it and see if
     // it has the proper sub-label that we're looking for.
     
-    if (m_inst_set->IsNop( search_genome[pos] )) {
+    if (m_inst_set->IsNop( search_genome.GetInstruction(pos) )) {
       // Find the start and end of the label we're in the middle of.
       
       int start_pos = pos;
       int end_pos = pos + 1;
-      while (start_pos > 0 && m_inst_set->IsNop(search_genome[start_pos - 1])) {
+      while (start_pos > 0 && m_inst_set->IsNop(search_genome.GetInstruction(start_pos - 1))) {
         start_pos--;
       }
       while (end_pos < search_start &&
-             m_inst_set->IsNop(search_genome[end_pos])) {
+             m_inst_set->IsNop(search_genome.GetInstruction(end_pos))) {
         end_pos++;
       }
       int test_size = end_pos - start_pos;
@@ -1011,7 +1011,7 @@
         int matches;
         for (matches = 0; matches < label_size; matches++) {
           if (search_label[matches] !=
-              m_inst_set->GetNopMod(search_genome[offset + matches])) {
+              m_inst_set->GetNopMod(search_genome.GetInstruction(offset + matches))) {
             break;
           }
         }
@@ -1294,7 +1294,7 @@
   m_memory.Resize(new_size);
 
   for (int i = old_size; i < new_size; i++) {
-    m_memory[i] = m_inst_set->GetRandomInst(ctx);
+    m_memory.SetInstruction(i, m_inst_set->GetRandomInst(ctx));
   }
   return true;
 }
@@ -1387,8 +1387,8 @@
   
   // Since the divide will now succeed, set up the information to be sent
   // to the new organism
-  cGenome & child_genome = organism->ChildGenome();
-  child_genome = cGenomeUtil::Crop(m_memory, div_point, div_point+child_size);
+//  cCPUMemory & child_genome = organism->ChildGenome();
+  organism->ChildGenome() = static_cast<cCPUMemory>(cGenomeUtil::Crop(m_memory, div_point, div_point+child_size));
   
   // Cut off everything in this memory past the divide point.
   m_memory.Resize(div_point);
@@ -2627,7 +2627,7 @@
   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++;
+    if (child_genome.FlagExecuted(i) && (child_genome.GetInstruction(i) == transposon_inst)) tr_count++;
   }
   
   for (int i=0; i < tr_count; i++) 
@@ -2685,7 +2685,7 @@
   if (organism->GetCopyMutProb() > 0) { // Skip this if no mutations....
     for (int i = 0; i < m_memory.GetSize(); i++) {
       if (organism->TestCopyMut(ctx)) {
-        child_genome[i] = m_inst_set->GetRandomInst(ctx);
+        child_genome.SetInstruction(i, m_inst_set->GetRandomInst(ctx));
         //organism->GetPhenotype().IsMutated() = true;
       }
     }
@@ -3576,7 +3576,7 @@
           for(int i=0;i<neighbor_genome.GetSize();i++){
 
             // ...see if it is donate-gbg
-            if (neighbor_genome[i] == IP().GetInst()) {
+            if (neighbor_genome.GetInstruction(i) == IP().GetInst()) {
               found = true;
               break;
             }
@@ -3650,7 +3650,7 @@
           for(int i=0;i<neighbor_genome.GetSize();i++){
 
             // ...see if it is donate-tgb, if so, we found a target
-            if (neighbor_genome[i] == IP().GetInst()) {
+            if (neighbor_genome.GetInstruction(i) == IP().GetInst()) {
               found = true;
               break;
             }
@@ -3727,7 +3727,7 @@
           for(int i=0;i<neighbor_genome.GetSize();i++){
 
 	         // ...see if it is donate-threshgb, if so, we found a target
-            if (neighbor_genome[i] == IP().GetInst()) {
+            if (neighbor_genome.GetInstruction(i) == IP().GetInst()) {
               found = true;
               break;
             }
@@ -3824,7 +3824,7 @@
           for(int i=0;i<neighbor_genome.GetSize();i++){
 
 	         // ...see if it is donate-quantagb, if so, we found a target
-            if (neighbor_genome[i] == IP().GetInst()) {
+            if (neighbor_genome.GetInstruction(i) == IP().GetInst()) {
               found = true;
               break;
             }
@@ -4964,7 +4964,7 @@
   assert(j < m_memory.GetSize());
   while (code_size < _num_bits)
   {
-    unsigned int inst_code = (unsigned int) GetInstSet().GetInstructionCode(m_memory[j]);
+    unsigned int inst_code = (unsigned int) GetInstSet().GetInstructionCode(m_memory.GetInstruction(j));
     // shift bits in, one by one ... excuse the counter variable pun
     for (int code_on = 0; (code_size < _num_bits) && (code_on < m_world->GetConfig().INST_CODE_LENGTH.Get()); code_on++)
     {

Modified: branches/interrupt/source/cpu/cHardwareExperimental.cc
===================================================================
--- branches/interrupt/source/cpu/cHardwareExperimental.cc	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/cpu/cHardwareExperimental.cc	2008-07-31 17:03:14 UTC (rev 2737)
@@ -274,7 +274,7 @@
     m_promoters.Resize(0);
 
     for (int i=0; i < m_memory.GetSize(); i++) {
-      if (m_inst_set->IsPromoter(m_memory[i])) {
+      if (m_inst_set->IsPromoter(m_memory.GetInstruction(i))) {
         int code = Numberate(i - 1, -1, m_world->GetConfig().PROMOTER_CODE_SIZE.Get());
         m_promoters.Push(cPromoter(i, code));
       }
@@ -566,7 +566,7 @@
   int pos = 0;
   
   while (pos < memory.GetSize()) {
-    if (m_inst_set->IsLabel(memory[pos])) { // starting label found
+    if (m_inst_set->IsLabel(memory.GetInstruction(pos))) { // starting label found
       pos++;
       
       // Check for direct matched label pattern, can be substring of 'label'ed target
@@ -574,7 +574,7 @@
       // - extra NOPs in 'label'ed target are ignored
       int size_matched = 0;
       while (size_matched < search_label.GetSize() && pos < memory.GetSize()) {
-        if (!m_inst_set->IsNop(memory[pos]) || search_label[size_matched] != m_inst_set->GetNopMod(memory[pos])) break;
+        if (!m_inst_set->IsNop(memory.GetInstruction(pos)) || search_label[size_matched] != m_inst_set->GetNopMod(memory.GetInstruction(pos))) break;
         size_matched++;
         pos++;
       }
@@ -866,7 +866,7 @@
   m_memory.Resize(new_size);
   
   for (int i = old_size; i < new_size; i++) {
-    m_memory[i] = m_inst_set->GetRandomInst(ctx);
+    m_memory.SetInstruction(i, m_inst_set->GetRandomInst(ctx));
   }
   return true;
 }
@@ -1714,7 +1714,7 @@
   assert(j < m_memory.GetSize());
   while (code_size < _num_bits)
   {
-    unsigned int inst_code = (unsigned int) GetInstSet().GetInstructionCode(m_memory[j]);
+    unsigned int inst_code = (unsigned int) GetInstSet().GetInstructionCode(m_memory.GetInstruction(j));
     // shift bits in, one by one ... excuse the counter variable pun
     for (int code_on = 0; (code_size < _num_bits) && (code_on < m_world->GetConfig().INST_CODE_LENGTH.Get()); code_on++)
     {
@@ -1808,7 +1808,7 @@
   // Perform Copy Mutations...
   if (organism->GetCopyMutProb() > 0) { // Skip this if no mutations....
     for (int i = 0; i < m_memory.GetSize(); i++) {
-      if (organism->TestCopyMut(ctx)) child_genome[i] = m_inst_set->GetRandomInst(ctx);
+      if (organism->TestCopyMut(ctx)) child_genome.SetInstruction(i, m_inst_set->GetRandomInst(ctx));
     }
   }
   

Modified: branches/interrupt/source/cpu/cHardwareGX.cc
===================================================================
--- branches/interrupt/source/cpu/cHardwareGX.cc	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/cpu/cHardwareGX.cc	2008-07-31 17:03:14 UTC (rev 2737)
@@ -346,7 +346,7 @@
     // These specify the range of instructions that will be used to create a new
     // programid.  The range of instructions used to create a programid is:
     // [begin, end), that is, the instruction pointed to by end is *not* copied.
-    cInstruction* begin=&genome[0];
+    cInstruction* begin=&genome.GetInstruction(0);
     cInstruction* end=&begin[genome.GetSize()];
     cInstruction* i=0;
     // Find the first instance of a PROGRAMID instruction.
@@ -755,17 +755,17 @@
     // If we are within a label, rewind to the beginning of it and see if
     // it has the proper sub-label that we're looking for.
     
-    if (m_inst_set->IsNop(search_genome[pos])) {
+    if (m_inst_set->IsNop(search_genome.GetInstruction(pos))) {
       // Find the start and end of the label we're in the middle of.
       
       int start_pos = pos;
       int end_pos = pos + 1;
       while (start_pos > search_start &&
-             m_inst_set->IsNop( search_genome[start_pos - 1] )) {
+             m_inst_set->IsNop( search_genome.GetInstruction(start_pos - 1) )) {
         start_pos--;
       }
       while (end_pos < search_genome.GetSize() &&
-             m_inst_set->IsNop( search_genome[end_pos] )) {
+             m_inst_set->IsNop( search_genome.GetInstruction(end_pos) )) {
         end_pos++;
       }
       int test_size = end_pos - start_pos;
@@ -779,7 +779,7 @@
         int matches;
         for (matches = 0; matches < label_size; matches++) {
           if (search_label[matches] !=
-              m_inst_set->GetNopMod( search_genome[offset + matches] )) {
+              m_inst_set->GetNopMod( search_genome.GetInstruction(offset + matches) )) {
             break;
           }
         }
@@ -836,16 +836,16 @@
     // If we are within a label, rewind to the beginning of it and see if
     // it has the proper sub-label that we're looking for.
     
-    if (m_inst_set->IsNop( search_genome[pos] )) {
+    if (m_inst_set->IsNop( search_genome.GetInstruction(pos) )) {
       // Find the start and end of the label we're in the middle of.
       
       int start_pos = pos;
       int end_pos = pos + 1;
-      while (start_pos > 0 && m_inst_set->IsNop(search_genome[start_pos - 1])) {
+      while (start_pos > 0 && m_inst_set->IsNop(search_genome.GetInstruction(start_pos - 1))) {
         start_pos--;
       }
       while (end_pos < search_start &&
-             m_inst_set->IsNop(search_genome[end_pos])) {
+             m_inst_set->IsNop(search_genome.GetInstruction(end_pos))) {
         end_pos++;
       }
       int test_size = end_pos - start_pos;
@@ -858,7 +858,7 @@
         int matches;
         for (matches = 0; matches < label_size; matches++) {
           if (search_label[matches] !=
-              m_inst_set->GetNopMod(search_genome[offset + matches])) {
+              m_inst_set->GetNopMod(search_genome.GetInstruction(offset + matches))) {
             break;
           }
         }
@@ -1129,7 +1129,7 @@
   GetMemory().Resize(new_size);
   
   for (int i = old_size; i < new_size; i++) {
-    GetMemory()[i] = m_inst_set->GetRandomInst(ctx);
+    GetMemory().SetInstruction(i, m_inst_set->GetRandomInst(ctx));
   }
   return true;
 }
@@ -2706,7 +2706,7 @@
           for(int i=0;i<neighbor_genome.GetSize();i++){
 
             // ...see if it is donate-gbg
-            if (neighbor_genome[i] == IP().GetInst()) {
+            if (neighbor_genome.GetInstruction(i) == IP().GetInst()) {
               found = true;
               break;
             }
@@ -2780,7 +2780,7 @@
           for(int i=0;i<neighbor_genome.GetSize();i++){
 
             // ...see if it is donate-tgb, if so, we found a target
-            if (neighbor_genome[i] == IP().GetInst()) {
+            if (neighbor_genome.GetInstruction(i) == IP().GetInst()) {
               found = true;
               break;
             }
@@ -2857,7 +2857,7 @@
           for(int i=0;i<neighbor_genome.GetSize();i++){
 
 	         // ...see if it is donate-threshgb, if so, we found a target
-            if (neighbor_genome[i] == IP().GetInst()) {
+            if (neighbor_genome.GetInstruction(i) == IP().GetInst()) {
               found = true;
               break;
             }
@@ -2954,7 +2954,7 @@
           for(int i=0;i<neighbor_genome.GetSize();i++){
 
 	         // ...see if it is donate-quantagb, if so, we found a target
-            if (neighbor_genome[i] == IP().GetInst()) {
+            if (neighbor_genome.GetInstruction(i) == IP().GetInst()) {
               found = true;
               break;
             }
@@ -4320,21 +4320,21 @@
   {
     // Check what flags should be set on this programid.
     for(int i=0; i<m_memory.GetSize();) {
-      if(m_memory[i]==GetInst("PROGRAMID")) { 
+      if(m_memory.GetInstruction(i)==GetInst("PROGRAMID")) { 
         m_memory.Remove(i);
         continue;
       }
-      if(m_memory[i]==GetInst("EXECUTABLE")) { 
+      if(m_memory.GetInstruction(i)==GetInst("EXECUTABLE")) { 
         m_memory.Remove(i); 
         m_executable=true;
         continue;
       }
-      if(m_memory[i]==GetInst("BINDABLE")) { 
+      if(m_memory.GetInstruction(i)==GetInst("BINDABLE")) { 
         m_memory.Remove(i);
         m_bindable=true;
         continue;
       }
-      if(m_memory[i]==GetInst("READABLE")) { 
+      if(m_memory.GetInstruction(i)==GetInst("READABLE")) { 
         m_memory.Remove(i);
         m_readable=true;
         continue;

Modified: branches/interrupt/source/cpu/cHardwareSMT.cc
===================================================================
--- branches/interrupt/source/cpu/cHardwareSMT.cc	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/cpu/cHardwareSMT.cc	2008-07-31 17:03:14 UTC (rev 2737)
@@ -142,7 +142,7 @@
 	
   m_mem_array[0] = in_organism->GetGenome();  // Initialize memory...
   m_mem_array[0].Resize(m_mem_array[0].GetSize() + 1);
-  m_mem_array[0][m_mem_array[0].GetSize() - 1] = cInstruction();
+  m_mem_array[0].SetInstruction(m_mem_array[0].GetSize() - 1, cInstruction());
   Reset();                            // Setup the rest of the hardware...
 }
 
@@ -435,17 +435,17 @@
     // If we are within a label, rewind to the beginning of it and see if
     // it has the proper sub-label that we're looking for.
 		
-    if (m_inst_set->IsNop(search_genome[pos])) {
+    if (m_inst_set->IsNop(search_genome.GetInstruction(pos))) {
       // Find the start and end of the label we're in the middle of.
 			
       int start_pos = pos;
       int end_pos = pos + 1;
       while (start_pos > search_start &&
-						 m_inst_set->IsNop( search_genome[start_pos - 1] )) {
+						 m_inst_set->IsNop( search_genome.GetInstruction(start_pos - 1) )) {
 				start_pos--;
       }
       while (end_pos < search_genome.GetSize() &&
-						 m_inst_set->IsNop( search_genome[end_pos] )) {
+						 m_inst_set->IsNop( search_genome.GetInstruction(end_pos) )) {
 				end_pos++;
       }
       int test_size = end_pos - start_pos;
@@ -459,7 +459,7 @@
 				int matches;
 				for (matches = 0; matches < label_size; matches++) {
 					if (search_label[matches] !=
-							m_inst_set->GetNopMod( search_genome[offset + matches] )) {
+							m_inst_set->GetNopMod( search_genome.GetInstruction(offset + matches) )) {
 						break;
 					}
 				}
@@ -514,16 +514,16 @@
     // If we are within a label, rewind to the beginning of it and see if
     // it has the proper sub-label that we're looking for.
 		
-    if (m_inst_set->IsNop( search_genome[pos] )) {
+    if (m_inst_set->IsNop( search_genome.GetInstruction(pos) )) {
       // Find the start and end of the label we're in the middle of.
 			
       int start_pos = pos;
       int end_pos = pos + 1;
-      while (start_pos > 0 && m_inst_set->IsNop(search_genome[start_pos - 1])) {
+      while (start_pos > 0 && m_inst_set->IsNop(search_genome.GetInstruction(start_pos - 1))) {
 				start_pos--;
       }
       while (end_pos < search_start &&
-						 m_inst_set->IsNop(search_genome[end_pos])) {
+						 m_inst_set->IsNop(search_genome.GetInstruction(end_pos))) {
 				end_pos++;
       }
       int test_size = end_pos - start_pos;
@@ -536,7 +536,7 @@
 				int matches;
 				for (matches = 0; matches < label_size; matches++) {
 					if (search_label[matches] !=
-							m_inst_set->GetNopMod(search_genome[offset + matches])) {
+							m_inst_set->GetNopMod(search_genome.GetInstruction(offset + matches))) {
 						break;
 					}
 				}
@@ -848,7 +848,7 @@
     if( num_mut > 0 ){
       for (int i = 0; i < num_mut; i++) {
 				int site = ctx.GetRandom().GetUInt(injected_code.GetSize());
-				injected_code[site] = m_inst_set->GetRandomInst(ctx);
+				injected_code.SetInstruction(site, m_inst_set->GetRandomInst(ctx));
       }
     }
   }
@@ -899,7 +899,7 @@
   if (organism->GetParentMutProb() > 0) {
     for (int i = 0; i < m_mem_array[0].GetSize(); i++) {
       if (organism->TestParentMut(ctx)) {
-				m_mem_array[0][i] = m_inst_set->GetRandomInst(ctx);
+				m_mem_array[0].SetInstruction(i, m_inst_set->GetRandomInst(ctx));
       }
     }
   }

Modified: branches/interrupt/source/cpu/cHardwareTransSMT.cc
===================================================================
--- branches/interrupt/source/cpu/cHardwareTransSMT.cc	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/cpu/cHardwareTransSMT.cc	2008-07-31 17:03:14 UTC (rev 2737)
@@ -141,7 +141,7 @@
 	
   m_mem_array[0] = in_organism->GetGenome();  // Initialize memory...
   m_mem_array[0].Resize(m_mem_array[0].GetSize() + 1);
-  m_mem_array[0][m_mem_array[0].GetSize() - 1] = cInstruction();
+  m_mem_array[0].SetInstruction(m_mem_array[0].GetSize() - 1, cInstruction());
   Reset();                            // Setup the rest of the hardware...
 }
 
@@ -436,17 +436,17 @@
     // If we are within a label, rewind to the beginning of it and see if
     // it has the proper sub-label that we're looking for.
 		
-    if (m_inst_set->IsNop(search_genome[pos])) {
+    if (m_inst_set->IsNop(search_genome.GetInstruction(pos))) {
       // Find the start and end of the label we're in the middle of.
 			
       int start_pos = pos;
       int end_pos = pos + 1;
       while (start_pos > search_start &&
-						 m_inst_set->IsNop( search_genome[start_pos - 1] )) {
+						 m_inst_set->IsNop( search_genome.GetInstruction(start_pos - 1) )) {
 				start_pos--;
       }
       while (end_pos < search_genome.GetSize() &&
-						 m_inst_set->IsNop( search_genome[end_pos] )) {
+						 m_inst_set->IsNop( search_genome.GetInstruction(end_pos) )) {
 				end_pos++;
       }
       int test_size = end_pos - start_pos;
@@ -460,7 +460,7 @@
 				int matches;
 				for (matches = 0; matches < label_size; matches++) {
 					if (search_label[matches] !=
-							m_inst_set->GetNopMod( search_genome[offset + matches] )) {
+							m_inst_set->GetNopMod( search_genome.GetInstruction(offset + matches) )) {
 						break;
 					}
 				}
@@ -516,16 +516,16 @@
     // If we are within a label, rewind to the beginning of it and see if
     // it has the proper sub-label that we're looking for.
 		
-    if (m_inst_set->IsNop( search_genome[pos] )) {
+    if (m_inst_set->IsNop( search_genome.GetInstruction(pos) )) {
       // Find the start and end of the label we're in the middle of.
 			
       int start_pos = pos;
       int end_pos = pos + 1;
-      while (start_pos > 0 && m_inst_set->IsNop(search_genome[start_pos - 1])) {
+      while (start_pos > 0 && m_inst_set->IsNop(search_genome.GetInstruction(start_pos - 1))) {
 				start_pos--;
       }
       while (end_pos < search_start &&
-						 m_inst_set->IsNop(search_genome[end_pos])) {
+						 m_inst_set->IsNop(search_genome.GetInstruction(end_pos))) {
 				end_pos++;
       }
       int test_size = end_pos - start_pos;
@@ -538,7 +538,7 @@
 				int matches;
 				for (matches = 0; matches < label_size; matches++) {
 					if (search_label[matches] !=
-							m_inst_set->GetNopMod(search_genome[offset + matches])) {
+							m_inst_set->GetNopMod(search_genome.GetInstruction(offset + matches))) {
 						break;
 					}
 				}
@@ -851,7 +851,7 @@
     if( num_mut > 0 ){
       for (int i = 0; i < num_mut; i++) {
 				int site = ctx.GetRandom().GetUInt(injected_code.GetSize());
-				injected_code[site] = m_inst_set->GetRandomInst(ctx);
+				injected_code.SetInstruction(site, m_inst_set->GetRandomInst(ctx));
       }
     }
   }
@@ -902,7 +902,7 @@
   if (organism->GetParentMutProb() > 0) {
     for (int i = 0; i < m_mem_array[0].GetSize(); i++) {
       if (organism->TestParentMut(ctx)) {
-				m_mem_array[0][i] = m_inst_set->GetRandomInst(ctx);
+				m_mem_array[0].SetInstruction(i, m_inst_set->GetRandomInst(ctx));
       }
     }
   }

Modified: branches/interrupt/source/cpu/cHeadCPU.h
===================================================================
--- branches/interrupt/source/cpu/cHeadCPU.h	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/cpu/cHeadCPU.h	2008-07-31 17:03:14 UTC (rev 2737)
@@ -87,11 +87,11 @@
   inline void Advance() { m_position++; Adjust(); }
   inline void Retreat() { m_position--; Adjust(); }
 
-  inline const cInstruction& GetInst() const { return GetMemory()[m_position]; }
-  inline const cInstruction& GetInst(int offset) const { return GetMemory()[m_position + offset]; }
+  inline const cInstruction GetInst() const { return GetMemory().GetInstruction(m_position); }
+  inline const cInstruction GetInst(int offset) const { return GetMemory().GetInstruction(m_position + offset); }
   inline cInstruction GetNextInst() const;
 
-  inline void SetInst(const cInstruction& value) { GetMemory()[m_position] = value; }
+  inline void SetInst(const cInstruction& value) { GetMemory().SetInstruction(m_position, value); }
   inline void InsertInst(const cInstruction& inst) { GetMemory().Insert(m_position, inst); }
   inline void RemoveInst() { GetMemory().Remove(m_position); }
 
@@ -162,7 +162,7 @@
 
 inline cInstruction cHeadCPU::GetNextInst() const
 {
-  return (AtEnd()) ? m_hardware->GetInstSet().GetInstError() : GetMemory()[m_position + 1];
+  return (AtEnd()) ? m_hardware->GetInstSet().GetInstError() : GetMemory().GetInstruction(m_position + 1);
 }
 
 

Modified: branches/interrupt/source/main/cBirthChamber.cc
===================================================================
--- branches/interrupt/source/main/cBirthChamber.cc	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/main/cBirthChamber.cc	2008-07-31 17:03:14 UTC (rev 2737)
@@ -518,11 +518,8 @@
   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 cGenome& child_genome, cOrganism& parent,
+                                    tArray<cOrganism*>& child_array, tArray<cMerit>& merit_array)
 {
   cPhenotype& parent_phenotype = parent.GetPhenotype();
 

Modified: branches/interrupt/source/main/cGenome.cc
===================================================================
--- branches/interrupt/source/main/cGenome.cc	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/main/cGenome.cc	2008-07-31 17:03:14 UTC (rev 2737)
@@ -37,7 +37,7 @@
 cGenome::cGenome(const cGenome & in_genome)
   : genome(in_genome.GetSize()), active_size(in_genome.GetSize())
 {
-  for (int i = 0; i < active_size; i++)  genome[i] = in_genome[i];
+  for (int i = 0; i < active_size; i++)  genome[i] = in_genome.GetInstruction(i);
 }
 
 cGenome::cGenome(const cString & in_string)
@@ -82,11 +82,10 @@
   // 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];
+    genome[i] = other_genome.GetInstruction(i);
   }
 }
 
-
 bool cGenome::operator==(const cGenome & other_genome) const
 {
   // Make sure the sizes are the same.
@@ -94,12 +93,11 @@
 
   // Then go through line by line.
   for (int i = 0; i < active_size; i++)
-    if (genome[i] != other_genome[i]) return false;
+    if (genome[i] != other_genome.GetInstruction(i)) return false;
 
   return true;
 }
 
-
 void cGenome::Copy(int to, int from)
 {
   assert(to   >= 0   && to   < active_size);

Modified: branches/interrupt/source/main/cGenome.h
===================================================================
--- branches/interrupt/source/main/cGenome.h	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/main/cGenome.h	2008-07-31 17:03:14 UTC (rev 2737)
@@ -65,11 +65,22 @@
   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]; }
+	/***********************/
+	// DO NOT overload the [] operator.  Doing so will break instruction protection, which is a part of the subclass cCPUMemory.
+	// Use the get and set functions below.
+	// 
+	//	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);
+	int GetSymbol(int pos) const { return genome[pos].GetSymbol(); }
+	int GetOp(int pos) const { return genome[pos].GetOp(); }
+	virtual void SetOp(int pos, int opt) { return genome[pos].SetOp(opt); }
+	cInstruction GetInstruction(int pos) const { return genome[pos]; }
+	virtual void SetInstruction(int pos, const cInstruction& new_inst) { genome[pos] = new_inst; }
 
+	virtual void Copy(int to, int from);
+	
   bool OK() const;
    
   int GetSize() const { return active_size; }

Modified: branches/interrupt/source/main/cGenomeUtil.cc
===================================================================
--- branches/interrupt/source/main/cGenomeUtil.cc	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/main/cGenomeUtil.cc	2008-07-31 17:03:14 UTC (rev 2737)
@@ -31,6 +31,7 @@
 #include "cInstSet.h"
 #include "functions.h"
 
+#include "cCPUMemory.h"
 
 using namespace std;
 
@@ -41,7 +42,7 @@
   assert(start_index < gen.GetSize());  // Starting search after genome end.
 
   for(int i = start_index; i < gen.GetSize(); i++) {
-    if (gen[i] == inst) return i;
+    if (gen.GetInstruction(i) == inst) return i;
   }
 
   // Search failed
@@ -74,7 +75,7 @@
 
   // Cycle through the overlap adding all differences to the distance.
   for (int i = 0; i < overlap; i++) {
-    if (gen1[start1 + i] != gen2[start2 + i])  hamming_distance++;
+    if (gen1.GetInstruction(start1 + i) != gen2.GetInstruction(start2 + i))  hamming_distance++;
   }
 
   return hamming_distance;
@@ -138,13 +139,13 @@
   // Loop through each subsequent character in the test code
   for (int i = 0; i < size2; i++) {
     // Initialize the first entry in cur_row.
-    if (gen1[0] == gen2[i]) cur_row[0] = i;
+    if (gen1.GetInstruction(0) == gen2.GetInstruction(i)) cur_row[0] = i;
     else cur_row[0] = (i < prev_row[0]) ? (i+1) : (prev_row[0] + 1);
 
     // Move down the cur_row and fill it out.
     for (int j = 1; j < size1; j++) {
       // If the values are equal, keep the value in the upper left.
-      if (gen1[j] == gen2[i]) {
+      if (gen1.GetInstruction(j) == gen2.GetInstruction(i)) {
 	cur_row[j] = prev_row[j-1];
       }
 
@@ -187,7 +188,7 @@
   const int out_length = end - start;
   cGenome out_genome(out_length);
   for (int i = 0; i < out_length; i++) {
-    out_genome[i] = in_genome[i+start];
+    out_genome.SetInstruction(i, in_genome.GetInstruction(i+start));
   }
 
   return out_genome;
@@ -207,10 +208,10 @@
 
   cGenome out_genome(out_length);
   for (int i = 0; i < start; i++) {
-    out_genome[i] = in_genome[i];
+    out_genome.SetInstruction(i, in_genome.GetInstruction(i));
   }
   for (int i = start; i < out_length; i++) {
-    out_genome[i] = in_genome[i+cut_length];
+    out_genome.SetInstruction(i, in_genome.GetInstruction(i+cut_length));
   }
 
   return out_genome;
@@ -225,10 +226,10 @@
 
   cGenome out_genome(out_length);
   for (int i = 0; i < length1; i++) {
-    out_genome[i] = genome1[i];
+    out_genome.SetInstruction(i, genome1.GetInstruction(i));
   }
   for (int i = 0; i < length2; i++) {
-    out_genome[i+length1] = genome2[i];
+    out_genome.SetInstruction(i+length1, genome2.GetInstruction(i));
   }
 
   return out_genome;
@@ -252,24 +253,33 @@
   if (!input_file.WasOpened()) return false;
   
   // Setup the code array...
-  cGenome new_genome(input_file.GetNumLines());
+  cCPUMemory new_genome(input_file.GetNumLines());
   
   for (int line_num = 0; line_num < new_genome.GetSize(); line_num++) {
     cString cur_line = input_file.GetLine(line_num);
-    new_genome[line_num] = inst_set.GetInst(cur_line);
+		
+		cString current_inst = cur_line.GetWord();
+		cString current_inst_protection = cur_line.GetWordAt(current_inst.GetSize());
+		
+    new_genome.SetInstruction(line_num, inst_set.GetInst(current_inst));
+		if(current_inst_protection == "protected")
+			new_genome.SetFlagProtected(line_num);
+		else
+			new_genome.ClearFlagProtected(line_num);
     
-    if (new_genome[line_num] == inst_set.GetInstError()) {
+    if (new_genome.GetInstruction(line_num) == inst_set.GetInstError()) {
       // You're using the wrong instruction set!  YOU FOOL!
       if (success) {
         cerr << "Error: Cannot load organism '" << filename << "'" << endl;
         success = false;
       }
-      cerr << "       Unknown line: " << cur_line << " (best match is '" << inst_set.FindBestMatch(cur_line) << "')" << endl;
+      cerr << "       Unknown line: " << current_inst << " (best match is '" << inst_set.FindBestMatch(current_inst) << "')" << endl;
     }
   }
   
   if (new_genome.GetSize() == 0) cerr << "Warning: Genome size is 0!" << endl;
-  if (success) out_genome = new_genome;
+  if (success)
+		out_genome = new_genome;
   return success;
 }
 
@@ -288,9 +298,9 @@
   
   for (int line_num = 0; line_num < new_genome.GetSize(); line_num++) {
     fp >> cur_line;
-    new_genome[line_num] = inst_set.GetInst(cur_line);
+    new_genome.SetInstruction(line_num, inst_set.GetInst(cur_line));
     
-    if (new_genome[line_num] == inst_set.GetInstError()) {
+    if (new_genome.GetInstruction(line_num) == inst_set.GetInstError()) {
       // You're using the wrong instruction set!  YOU FOOL!
       cerr << "Cannot load creature from stream:" << endl
       << "       Unknown line: " << cur_line << endl;
@@ -303,7 +313,7 @@
                            const cGenome & gen)
 {
   for (int i = 0; i < gen.GetSize(); i++) {
-    fp << inst_set.GetName(gen[i]) << endl;
+    fp << inst_set.GetName(gen.GetInstruction(i)) << endl;
   }
 }
 
@@ -319,7 +329,7 @@
 {
   cGenome genome(length);
   for (int i = 0; i < length; i++) {
-    genome[i] = inst_set.GetRandomInst(ctx);
+    genome.SetInstruction(i, inst_set.GetRandomInst(ctx));
   }
   return genome;
 }
@@ -331,9 +341,9 @@
 	  cInstruction inst = inst_set.GetRandomInst(ctx);
 	  while (inst_set.GetRedundancy(inst)==0)
 		  inst = inst_set.GetRandomInst(ctx);
-    genome[i] = inst;
+    genome.SetInstruction(i, inst);
   }
-  genome[length] = inst_set.GetInst("repro");
+  genome.SetInstruction(length, inst_set.GetInst("repro"));
   return genome;
 }
 
@@ -344,9 +354,9 @@
 	  cInstruction inst = inst_set.GetRandomInst(ctx);
 	  while (inst_set.GetRedundancy(inst)==0)
 		  inst = inst_set.GetRandomInst(ctx);
-    genome[i] = inst;
+    genome.SetInstruction(i, inst);
   }
-  genome[length] = inst_set.GetInst("repro-sex");
+  genome.SetInstruction(length, inst_set.GetInst("repro-sex"));
   return genome;
 }
 

Modified: branches/interrupt/source/main/cLandscape.cc
===================================================================
--- branches/interrupt/source/main/cLandscape.cc	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/main/cLandscape.cc	2008-07-31 17:03:14 UTC (rev 2737)
@@ -180,13 +180,13 @@
   
   // Loop through all the lines of genome, testing trying all combinations.
   for (int line_num = start_line; line_num < max_line; line_num++) {
-    int cur_inst = base_genome[line_num].GetOp();
+    int cur_inst = base_genome.GetOp(line_num);
     
     // Loop through all instructions...
     for (int inst_num = 0; inst_num < inst_size; inst_num++) {
       if (cur_inst == inst_num) continue;
       
-      mod_genome[line_num].SetOp(inst_num);
+      mod_genome.SetOp(line_num, inst_num);
       if (cur_distance <= 1) {
         ProcessGenome(ctx, testcpu, mod_genome);
         if (test_info.GetColonyFitness() >= neut_min) site_count[line_num]++;
@@ -195,7 +195,7 @@
       }
     }
     
-    mod_genome[line_num].SetOp(cur_inst);
+    mod_genome.SetOp(line_num, cur_inst);
   }
   
 }
@@ -218,7 +218,7 @@
   
   // Loop through all the lines of genome, testing trying all combinations.
   for (int line_num = 0; line_num < max_line; line_num++) {
-    int cur_inst = base_genome[line_num].GetOp();
+    int cur_inst = base_genome.GetOp(line_num);
     df.Write(cur_inst, "Original Instruction");
 
     // Loop through all instructions...
@@ -227,14 +227,14 @@
       if (cur_inst == inst_num) {
         fitness = base_fitness;
       } else {
-        mod_genome[line_num].SetOp(inst_num);
+        mod_genome.SetOp(line_num, inst_num);
         fitness = ProcessGenome(ctx, testcpu, mod_genome);
       }
       df.Write(fitness, "Mutation Fitness (instruction = column_number - 2)");
     }
 
     df.Endl();
-    mod_genome[line_num].SetOp(cur_inst);
+    mod_genome.SetOp(line_num, cur_inst);
   }
   
   delete testcpu;
@@ -254,7 +254,7 @@
   
   // Loop through all the lines of genome, testing all deletions.
   for (int line_num = 0; line_num < max_line; line_num++) {
-    int cur_inst = base_genome[line_num].GetOp();
+    int cur_inst = base_genome.GetOp(line_num);
     mod_genome.Remove(line_num);
     ProcessGenome(ctx, testcpu, mod_genome);
     if (test_info.GetColonyFitness() >= neut_min) site_count[line_num]++;
@@ -440,7 +440,7 @@
   
   for (int row = 0; row < genome_size; row++) {
     double max_line_fitness = 1.0;
-    int base_inst = base_genome[row].GetOp();
+    int base_inst = base_genome.GetOp(row);
     for (int col = 0; col < inst_size; col++) {
       if (col == base_inst) continue; // Only consider changes to line!
       double & cur_fitness = fitness_chart(row, col);
@@ -495,7 +495,7 @@
       ctx.GetRandom().Choose(genome_size, mut_lines);
       test_fitness = 1.0;
       for (int j = 0; j < num_muts && test_fitness != 0.0; j++) {	
-        int base_inst = base_genome[ mut_lines[j] ].GetOp();
+        int base_inst = base_genome.GetOp(mut_lines[j]);
         int mut_inst = ctx.GetRandom().GetUInt(inst_size);
         while (mut_inst == base_inst) mut_inst = ctx.GetRandom().GetUInt(inst_size);
         test_fitness *= fitness_chart(mut_lines[j], mut_inst);
@@ -557,7 +557,7 @@
   
   // Loop through all the lines of genome, testing each line.
   for (int line_num = 0; line_num < genome_size; line_num++) {
-    cInstruction cur_inst( base_genome[line_num] );
+    cInstruction cur_inst( base_genome.GetInstruction(line_num) );
     
     for (int i = 0; i < trials; i++) {
       // Choose the new instruction for that line...
@@ -565,11 +565,11 @@
       if (cur_inst == new_inst) { i--; continue; }
       
       // Make the change, and test it!
-      mod_genome[line_num] = new_inst;
+      mod_genome.SetInstruction(line_num, new_inst);
       ProcessGenome(ctx, testcpu, mod_genome);
     }
     
-    mod_genome[line_num] = cur_inst;
+    mod_genome.SetInstruction(line_num, cur_inst);
   }
   
   delete testcpu;
@@ -599,13 +599,13 @@
     // Choose the new instructions for those lines...
     for (mut_num = 0; mut_num < distance; mut_num++) {
       const cInstruction new_inst( inst_set.GetRandomInst(ctx) );
-      const cInstruction & cur_inst = base_genome[ mut_lines[mut_num] ];
+      const cInstruction & cur_inst = base_genome.GetInstruction(mut_lines[mut_num] );
       if (cur_inst == new_inst) {
         mut_num--;
         continue;
       }
       
-      mod_genome[ mut_lines[mut_num] ] = new_inst;
+      mod_genome.SetInstruction(mut_lines[mut_num], new_inst);
     }
     
     // And test it!
@@ -615,7 +615,7 @@
     
     // And reset the genome.
     for (mut_num = 0; mut_num < distance; mut_num++) {
-      mod_genome[ mut_lines[mut_num] ] = base_genome[ mut_lines[mut_num] ];
+      mod_genome.SetInstruction(mut_lines[mut_num], base_genome.GetInstruction(mut_lines[mut_num]));
     }
   }
   
@@ -637,7 +637,7 @@
   
   // Loop through all the lines of genome, testing trying all combinations.
   for (int line_num = 0; line_num < max_line; line_num++) {
-    int cur_inst = base_genome[line_num].GetOp();
+    int cur_inst = base_genome.GetOp(line_num);
     
     // Loop through all instructions...
     for (int inst_num = 0; inst_num < inst_size; inst_num++) {
@@ -646,12 +646,12 @@
         continue;
       }
       
-      mod_genome[line_num].SetOp(inst_num);
+      mod_genome.SetOp(line_num, inst_num);
       ProcessGenome(ctx, testcpu, mod_genome);
       fitness_chart(line_num, inst_num) = test_info.GetColonyFitness();
     }
     
-    mod_genome[line_num].SetOp(cur_inst);
+    mod_genome.SetOp(line_num, cur_inst);
   }
 }
 
@@ -678,7 +678,7 @@
     // Choose the new instructions for those lines...
     for (int mut_num = 0; mut_num < 2; mut_num++) {
       const cInstruction new_inst( inst_set.GetRandomInst(ctx) );
-      const cInstruction& cur_inst = base_genome[ mut_lines[mut_num] ];
+      const cInstruction& cur_inst = base_genome.GetInstruction( mut_lines[mut_num] );
       if (cur_inst == new_inst) {
         mut_num--;
         continue;
@@ -714,10 +714,10 @@
       // Loop through all instructions...
       for (int inst1_num = 0; inst1_num < inst_size; inst1_num++) {
         inst1.SetOp(inst1_num);
-        if (inst1 == base_genome[line1_num]) continue;
+        if (inst1 == base_genome.GetInstruction(line1_num)) continue;
         for (int inst2_num = 0; inst2_num < inst_size; inst2_num++) {
           inst2.SetOp(inst2_num);
-          if (inst2 == base_genome[line2_num]) continue;
+          if (inst2 == base_genome.GetInstruction(line2_num)) continue;
           TestMutPair(ctx, testcpu, mod_genome, line1_num, line2_num, inst1, inst2);
         } // inst2_num loop
       } //inst1_num loop;
@@ -768,7 +768,7 @@
     // Try all deletion mutations.
     
     for (int line_num = 0; line_num < max_line; line_num++) {
-      int cur_inst = cur_genome[line_num].GetOp();
+      int cur_inst = cur_genome.GetOp(line_num);
       mod_genome.Remove(line_num);
       ProcessGenome(ctx, testcpu, mod_genome);
       mod_genome.Insert(line_num, cInstruction(cur_inst));
@@ -803,13 +803,13 @@
 double cLandscape::TestMutPair(cAvidaContext& ctx, cTestCPU* testcpu, cGenome& mod_genome, int line1, int line2,
                                const cInstruction& mut1, const cInstruction& mut2)
 {
-  mod_genome[line1] = mut1;
-  mod_genome[line2] = mut2;
+  mod_genome.SetInstruction(line1, mut1);
+  mod_genome.SetInstruction(line2, mut2);
   testcpu->TestGenome(ctx, test_info, mod_genome);
   double combo_fitness = test_info.GetColonyFitness() / base_fitness;
   
-  mod_genome[line1] = base_genome[line1];
-  mod_genome[line2] = base_genome[line2];
+  mod_genome.SetInstruction(line1, base_genome.GetInstruction(line1));
+  mod_genome.SetInstruction(line2, base_genome.GetInstruction(line2));
   
   double mut1_fitness = fitness_chart(line1, mut1.GetOp()) / base_fitness;
   double mut2_fitness = fitness_chart(line2, mut2.GetOp()) / base_fitness;

Modified: branches/interrupt/source/main/cMxCodeArray.cc
===================================================================
--- branches/interrupt/source/main/cMxCodeArray.cc	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/main/cMxCodeArray.cc	2008-07-31 17:03:14 UTC (rev 2737)
@@ -104,7 +104,7 @@
   data = new cInstruction[max_size];
 
   for (int i = 0; i < size; i++) {
-    data[i] = in_code[i];
+    data[i] = in_code.GetInstruction(i);
   }
 }
 
@@ -276,7 +276,7 @@
   other_code = cGenome(size);
 
   for (int i = 0; i < size; i++) {
-    other_code[i] = data[i];
+    other_code.SetInstruction(i, data[i]);
   }
 }
 

Modified: branches/interrupt/source/main/cOrganism.h
===================================================================
--- branches/interrupt/source/main/cOrganism.h	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/main/cOrganism.h	2008-07-31 17:03:14 UTC (rev 2737)
@@ -104,7 +104,7 @@
 	int cclade_id;				                  // @MRR Coalescence clade information (set in cPopulation)
  
 	// Other stats
-  cCPUMemory m_child_genome; // Child genome, while under construction.
+	cCPUMemory m_child_genome; // Child genome, while under construction.
 //  sCPUStats m_cpu_stats;     // Info for statistics
 
   // Input and Output with the environment

Modified: branches/interrupt/source/main/cPopulation.cc
===================================================================
--- branches/interrupt/source/main/cPopulation.cc	2008-07-31 13:06:36 UTC (rev 2736)
+++ branches/interrupt/source/main/cPopulation.cc	2008-07-31 17:03:14 UTC (rev 2737)
@@ -254,7 +254,7 @@
   
   // Load a clone if one is provided, otherwise setup start organism.
   if (m_world->GetConfig().CLONE_FILE.Get() == "-" || m_world->GetConfig().CLONE_FILE.Get() == "") {
-    cGenome start_org(0);
+    cCPUMemory start_org(0);
     const cString& filename = m_world->GetConfig().START_CREATURE.Get();
     
     if (filename != "-" && filename != "") {
@@ -551,7 +551,7 @@
   }
   else{
     for(int i = 1; i <= genome_length; i++){
-      if(in_organism->GetGenome()[i-1].GetOp() == rewarded_instruction){
+      if(in_organism->GetGenome().GetOp(i-1) == rewarded_instruction){
         num_rewarded_instructions++;
       }  
     } 
@@ -1386,7 +1386,7 @@
     if(m_world->GetConfig().GERMLINE_COPY_MUT.Get() > 0.0) {
       for(int i=0; i<next_germ.GetSize(); ++i) {
         if(m_world->GetRandom().P(m_world->GetConfig().GERMLINE_COPY_MUT.Get())) {
-          next_germ[i] = instset.GetRandomInst(ctx);
+          next_germ.SetInstruction(i, instset.GetRandomInst(ctx));
         }
       }
     }
@@ -1431,7 +1431,7 @@
     if(m_world->GetConfig().GERMLINE_COPY_MUT.Get() > 0.0) {
       for(int i=0; i<new_genome.GetSize(); ++i) {
         if(m_world->GetRandom().P(m_world->GetConfig().GERMLINE_COPY_MUT.Get())) {
-          new_genome[i] = instset.GetRandomInst(ctx);
+          new_genome.SetInstruction(i, instset.GetRandomInst(ctx));
         }
       }
     }
@@ -4306,7 +4306,7 @@
   }
   
   cAvidaContext& ctx = m_world->GetDefaultContext();
-  
+	
   cOrganism* new_organism = new cOrganism(m_world, ctx, new_genotype->GetGenome());
   
   //Coalescense Clade Setup




More information about the Avida-cvs mailing list