[Avida-SVN] r3247 - in development: source/actions source/cpu source/main tests tests/shaded_green_beard_instructions tests/shaded_green_beard_instructions/config tests/shaded_green_beard_instructions/expected tests/shaded_green_beard_instructions/expected/data tests/shaded_green_beard_instructions/expected/data/archive

hjg at myxo.css.msu.edu hjg at myxo.css.msu.edu
Wed May 20 06:09:38 PDT 2009


Author: hjg
Date: 2009-05-20 09:09:38 -0400 (Wed, 20 May 2009)
New Revision: 3247

Added:
   development/tests/shaded_green_beard_instructions/
   development/tests/shaded_green_beard_instructions/config/
   development/tests/shaded_green_beard_instructions/config/avida.cfg
   development/tests/shaded_green_beard_instructions/config/envZeroResources.cfg
   development/tests/shaded_green_beard_instructions/config/eventsFullPopTest.cfg
   development/tests/shaded_green_beard_instructions/config/inst_set.SexDonateGbshadedEdtKinRndNopx
   development/tests/shaded_green_beard_instructions/config/organism.sexDefault
   development/tests/shaded_green_beard_instructions/expected/
   development/tests/shaded_green_beard_instructions/expected/data/
   development/tests/shaded_green_beard_instructions/expected/data/archive/
   development/tests/shaded_green_beard_instructions/expected/data/archive/100-aaaaa.org
   development/tests/shaded_green_beard_instructions/expected/data/average.dat
   development/tests/shaded_green_beard_instructions/expected/data/count.dat
   development/tests/shaded_green_beard_instructions/expected/data/dominant.dat
   development/tests/shaded_green_beard_instructions/expected/data/donations.dat
   development/tests/shaded_green_beard_instructions/expected/data/instruction.dat
   development/tests/shaded_green_beard_instructions/expected/data/resource.dat
   development/tests/shaded_green_beard_instructions/expected/data/shadedaltruists.dat
   development/tests/shaded_green_beard_instructions/expected/data/stats.dat
   development/tests/shaded_green_beard_instructions/expected/data/tasks.dat
   development/tests/shaded_green_beard_instructions/expected/data/time.dat
   development/tests/shaded_green_beard_instructions/test_list
Removed:
   development/tests/green_beard_instructions/
Modified:
   development/source/actions/PrintActions.cc
   development/source/cpu/cHardwareCPU.cc
   development/source/cpu/cHardwareCPU.h
   development/source/main/cAvidaConfig.h
   development/source/main/cPhenotype.cc
   development/source/main/cPhenotype.h
   development/source/main/cPopulation.cc
   development/source/main/cStats.cc
   development/source/main/cStats.h
Log:
Updated the code for the green beard project. This includes modifying the original donate instructions, adding a new donate instruction (shaded-gb), adding additional stats tracking.  Lastly, a new greenbeard test was created and added whereas the original was removed.

Modified: development/source/actions/PrintActions.cc
===================================================================
--- development/source/actions/PrintActions.cc	2009-05-20 12:39:24 UTC (rev 3246)
+++ development/source/actions/PrintActions.cc	2009-05-20 13:09:38 UTC (rev 3247)
@@ -133,6 +133,7 @@
 
 // reputation
 STATS_OUT_FILE(PrintReputationData,         reputation.dat);
+STATS_OUT_FILE(PrintShadedAltruists,         shadedaltruists.dat);
 STATS_OUT_FILE(PrintDirectReciprocityData,         reciprocity.dat);
 STATS_OUT_FILE(PrintStringMatchData,         stringmatch.dat);
 
@@ -3144,6 +3145,8 @@
   action_lib->Register<cActionPrintReputationData>("PrintReputationData");
 	action_lib->Register<cActionPrintDirectReciprocityData>("PrintDirectReciprocityData");
   action_lib->Register<cActionPrintStringMatchData>("PrintStringMatchData");
+	action_lib->Register<cActionPrintShadedAltruists>("PrintShadedAltruists");
 
+	
   action_lib->Register<cActionSetVerbose>("VERBOSE");
 }

Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc	2009-05-20 12:39:24 UTC (rev 3246)
+++ development/source/cpu/cHardwareCPU.cc	2009-05-20 13:09:38 UTC (rev 3247)
@@ -237,6 +237,7 @@
     tInstLibEntry<tMethod>("donate-edt", &cHardwareCPU::Inst_DonateEditDist),
     tInstLibEntry<tMethod>("donate-gbg",  &cHardwareCPU::Inst_DonateGreenBeardGene),
     tInstLibEntry<tMethod>("donate-tgb",  &cHardwareCPU::Inst_DonateTrueGreenBeard),
+		tInstLibEntry<tMethod>("donate-shadedgb",  &cHardwareCPU::Inst_DonateShadedGreenBeard),
     tInstLibEntry<tMethod>("donate-threshgb",  &cHardwareCPU::Inst_DonateThreshGreenBeard),
     tInstLibEntry<tMethod>("donate-quantagb",  &cHardwareCPU::Inst_DonateQuantaThreshGreenBeard),
     tInstLibEntry<tMethod>("donate-NUL", &cHardwareCPU::Inst_DonateNULL),
@@ -3824,10 +3825,10 @@
   if (m_organism->GetPhenotype().GetCurNumDonates() > m_world->GetConfig().MAX_DONATES.Get()) {
     return false;
   }
-
+	
   m_organism->GetPhenotype().IncDonates();
   m_organism->GetPhenotype().SetIsDonorRand();
-
+	
   // Turn to a random neighbor, get it, and turn back...
   int neighbor_id = ctx.GetRandom().GetInt(m_organism->GetNeighborhoodSize());
   for (int i = 0; i < neighbor_id; i++) m_organism->Rotate(1);
@@ -3838,19 +3839,46 @@
   if (neighbor != NULL) {
     DoDonate(neighbor);
     
+		// Code to track the edit distance between kin donors and recipients
+		const int edit_dist = cGenomeUtil::FindEditDistance(m_organism->GetGenome(),neighbor->GetGenome());
+		
+		/*static ofstream rand_file("rand_dists.dat");*/
+		static int num_rand_donates = 0;
+		static int num_rand_donates_15_dist = 0;
+		static int tot_dist_rand_donate = 0;
+		
+		num_rand_donates++;
+		if (edit_dist > 15) num_rand_donates_15_dist++;
+		tot_dist_rand_donate += edit_dist;
+		
+		if (num_rand_donates == 1000) {
+			
+			/*rand_file << num_rand_donates << " "
+			<< (double) num_rand_donates_15_dist / (double) num_rand_donates << " "
+			<< (double) tot_dist_rand_donate / (double) num_rand_donates << endl;
+			*/
+			num_rand_donates = 0;
+			num_rand_donates_15_dist = 0;
+			tot_dist_rand_donate = 0;
+		}
+		
+		
+		
     //print out how often random donations go to kin
     /*
-    static ofstream kinDistanceFile("kinDistance.dat");
-    kinDistanceFile << (genotype->GetPhyloDistance(neighbor->GetGenotype())<=1) << " ";
-    kinDistanceFile << (genotype->GetPhyloDistance(neighbor->GetGenotype())<=2) << " ";
-    kinDistanceFile << (genotype->GetPhyloDistance(neighbor->GetGenotype())<=3) << " ";
-    kinDistanceFile << genotype->GetPhyloDistance(neighbor->GetGenotype());
-    kinDistanceFile << endl; 
-    */
+		 static ofstream kinDistanceFile("kinDistance.dat");
+		 kinDistanceFile << (genotype->GetPhyloDistance(neighbor->GetGenotype())<=1) << " ";
+		 kinDistanceFile << (genotype->GetPhyloDistance(neighbor->GetGenotype())<=2) << " ";
+		 kinDistanceFile << (genotype->GetPhyloDistance(neighbor->GetGenotype())<=3) << " ";
+		 kinDistanceFile << genotype->GetPhyloDistance(neighbor->GetGenotype());
+		 kinDistanceFile << endl; 
+		 */
+		
     neighbor->GetPhenotype().SetIsReceiverRand();
   }
-
+	
   return true;
+	
 }
 
 
@@ -3862,8 +3890,8 @@
   
   m_organism->GetPhenotype().IncDonates();
   m_organism->GetPhenotype().SetIsDonorKin();
-
-
+	
+	
   // Find the target as the first Kin found in the neighborhood.
   const int num_neighbors = m_organism->GetNeighborhoodSize();
   
@@ -3882,6 +3910,31 @@
       neighbor = m_organism->GetNeighbor();
       if (neighbor != NULL &&
           genotype->GetPhyloDistance(neighbor->GetGenotype()) <= max_dist) {
+				
+				// Code to track the edit distance between kin donors and recipients
+				const int edit_dist = cGenomeUtil::FindEditDistance(m_organism->GetGenome(),neighbor->GetGenome());
+				
+				/*static ofstream kin_file("kin_dists.dat");*/
+				static int num_kin_donates = 0;
+				static int num_kin_donates_15_dist = 0;
+				static int tot_dist_kin_donate = 0;
+				
+				num_kin_donates++;
+				if (edit_dist > 15) num_kin_donates_15_dist++;
+				tot_dist_kin_donate += edit_dist;
+				
+				
+				if (num_kin_donates == 1000) {
+					/* 
+					 kin_file << num_kin_donates << " "
+					 << (double) num_kin_donates_15_dist / (double) num_kin_donates << " "
+					 << (double) tot_dist_kin_donate / (double) num_kin_donates << endl;
+					 */
+					num_kin_donates = 0;
+					num_kin_donates_15_dist = 0;
+					tot_dist_kin_donate = 0;
+				}
+				
         found = true;
         break;
       }
@@ -3907,7 +3960,7 @@
   if (m_organism->GetPhenotype().GetCurNumDonates() > m_world->GetConfig().MAX_DONATES.Get()) {
     return false;
   }
-
+	
   m_organism->GetPhenotype().IncDonates();
   m_organism->GetPhenotype().SetIsDonorEdit();
   
@@ -3933,6 +3986,32 @@
       }
       if (edit_dist <= max_dist) {
         found = true;
+				
+				// Code to track the edit distance between edt donors and recipients
+				const int edit_dist = cGenomeUtil::FindEditDistance(m_organism->GetGenome(),neighbor->GetGenome());
+				
+				/*static ofstream edit_file("edit_dists.dat");*/
+				static int num_edit_donates = 0;
+				static int num_edit_donates_15_dist = 0;
+				static int tot_dist_edit_donate = 0;
+				
+				num_edit_donates++;
+				if (edit_dist > 15) num_edit_donates_15_dist++;
+				tot_dist_edit_donate += edit_dist;
+				
+				if (num_edit_donates == 1000) {
+					/*
+					 edit_file << num_edit_donates << " "
+					 << (double) num_edit_donates_15_dist / (double) num_edit_donates << " "
+					 << (double) tot_dist_edit_donate / (double) num_edit_donates << endl;
+					 */
+					
+					num_edit_donates = 0;
+					num_edit_donates_15_dist = 0;
+					tot_dist_edit_donate = 0;
+				}
+				
+				
         break;
       }
       m_organism->Rotate(1);
@@ -3950,6 +4029,7 @@
     neighbor->GetPhenotype().SetIsReceiverEdit();
   }
   return true;
+	
 }
 
 bool cHardwareCPU::Inst_DonateGreenBeardGene(cAvidaContext& ctx)
@@ -3958,61 +4038,64 @@
   //in their genome (see Dawkins 1976, The Selfish Gene, for 
   //the history of the theory and the name 'green beard'
   cPhenotype & phenotype = m_organism->GetPhenotype();
-
+	
   if (m_organism->GetPhenotype().GetCurNumDonates() > m_world->GetConfig().MAX_DONATES.Get()) {
     return false;
   }
-
+	
   phenotype.IncDonates();
   phenotype.SetIsDonorGbg();
-
+	
   // Find the target as the first match found in the neighborhood.
-
+	
   //get the neighborhood size
   const int num_neighbors = m_organism->GetNeighborhoodSize();
-
+	
   // Turn to face a random neighbor
   int neighbor_id = ctx.GetRandom().GetInt(num_neighbors);
   for (int i = 0; i < neighbor_id; i++) m_organism->Rotate(1);
   cOrganism * neighbor = m_organism->GetNeighbor();
-
+	
+	
   int max_id = neighbor_id + num_neighbors;
- 
+	
   //we have not found a match yet
   bool found = false;
-
+	
   // rotate through orgs in neighborhood  
   while (neighbor_id < max_id) {
-      neighbor = m_organism->GetNeighbor();
-
-      //if neighbor exists, do they have the green beard gene?
-      if (neighbor != NULL) {
-          const cGenome & neighbor_genome = neighbor->GetGenome();
-
-          // for each instruction in the genome...
-          for(int i=0;i<neighbor_genome.GetSize();i++){
-
-            // ...see if it is donate-gbg
-            if (neighbor_genome[i] == IP().GetInst()) {
-              found = true;
-              break;
-            }
-	    
-          }
-      }
-      
-      // stop searching through the neighbors if we already found one
-      if (found == true) break;
-  
-      m_organism->Rotate(1);
-      neighbor_id++;
+		neighbor = m_organism->GetNeighbor();
+		
+		//if neighbor exists, do they have the green beard gene?
+		if (neighbor != NULL) {
+			const cGenome & neighbor_genome = neighbor->GetGenome();
+			
+			// for each instruction in the genome...
+			for(int i=0;i<neighbor_genome.GetSize();i++){
+				
+				// ...see if it is donate-gbg
+				if (neighbor_genome[i] == IP().GetInst()) {
+					found = true;
+					break;
+				}
+				
+			}
+		}
+		
+		// stop searching through the neighbors if we already found one
+		if (found == true){
+    	break;
+		}
+		
+		m_organism->Rotate(1);
+		neighbor_id++;
   }
-
-    if (found == false) neighbor = NULL;
-
+	
+	if (found == false) neighbor = NULL;
+	
   // Put the facing back where it was.
   for (int i = 0; i < neighbor_id; i++) m_organism->Rotate(-1);
-
+	
   // Donate only if we have found a close enough relative...
   if (neighbor != NULL) {
     DoDonate(neighbor);
@@ -4023,6 +4106,130 @@
   
 }
 
+/* This instruction donates to other organisms that have at least
+ as many donate-shaded-greenbeard instructions in their organism 
+ as this organism does. */
+bool cHardwareCPU::Inst_DonateShadedGreenBeard(cAvidaContext& ctx)
+{
+	cPhenotype & phenotype = m_organism->GetPhenotype();
+	
+	// Determine if this m_organism is below the threshold and thus eligible to donate.
+  if (m_organism->GetPhenotype().GetCurNumDonates() > m_world->GetConfig().MAX_DONATES.Get()) {
+    return false;
+  }
+	
+	// Identify how many green beard donations the parent of this organism made
+	
+	// Identify how many shaded green beard donations this organisms made
+	// First figure out what number instruction donate-shadedgb is
+	cInstSet& inst_set = m_world->GetHardwareManager().GetInstSet();
+	const int num_inst = m_world->GetNumInstructions();
+	int shade_of_gb = 0;
+	int neighbor_shade_of_gb = 0;
+	int inst_number = 0;
+	for (int i = 0; i < num_inst; i++) { 
+		if ((inst_set.GetName(i) == "donate-shadedgb") && 
+				(phenotype.GetTestCPUInstCount().GetSize() > 0)) {
+			shade_of_gb = phenotype.GetTestCPUInstCount()[i];
+			inst_number = i;
+		}
+	}
+	
+	
+	// Update stats.
+	phenotype.IncDonates();
+  phenotype.SetIsDonorShadedGb();
+  phenotype.IncNumShadedGbDonations();
+	
+  // Find the target as the first match found in the neighborhood.
+  //get the neighborhood size
+  const int num_neighbors = m_organism->GetNeighborhoodSize();
+	
+  // Turn to face a random neighbor
+	// Part of the reason the donates fail so frequently is that this code
+	// although it randomizes the neighbor, does not take into account whether
+	// a neigbhor is there or not. 
+  int neighbor_id = ctx.GetRandom().GetInt(num_neighbors);
+  for (int i = 0; i < neighbor_id; i++) m_organism->Rotate(1);
+  cOrganism * neighbor = m_organism->GetNeighbor();
+	
+  int max_id = neighbor_id + num_neighbors;
+	
+  //we have not found a match yet
+  bool found = false;
+	
+  // rotate through orgs in neighborhood  
+  while (neighbor_id < max_id) {
+		neighbor = m_organism->GetNeighbor();
+		//if neighbor exists, AND if their parent attempted to donate >= shaded of green beard,
+		if (neighbor != NULL) {
+			
+			// Get the neighbor's shade
+			neighbor_shade_of_gb = 0; 
+			if (neighbor->GetPhenotype().GetTestCPUInstCount().GetSize() > 0) { 
+				neighbor_shade_of_gb = neighbor->GetPhenotype().GetTestCPUInstCount()[inst_number];
+			}
+			
+			// Changing this line makes shaded gb ONLY donate to organisms with the exact same 
+			// shade (color/number of donations)
+			//			if (neighbor_shade_of_gb >=  shade_of_gb) {
+			if (neighbor_shade_of_gb ==  shade_of_gb) {
+				
+				// Code to track the edit distance between shaded donors and recipients
+				const int edit_dist = cGenomeUtil::FindEditDistance(m_organism->GetGenome(),neighbor->GetGenome());
+				
+				/*static ofstream gb_file("shaded_gb_dists.dat");*/
+				static int num_gb_donates = 0;
+				static int num_gb_donates_15_dist = 0;
+				static int tot_dist_gb_donate = 0;
+				
+				num_gb_donates++;
+				if (edit_dist > 15) num_gb_donates_15_dist++;
+				tot_dist_gb_donate += edit_dist;
+				
+				if (num_gb_donates == 1000) {
+					/*
+					 gb_file << num_gb_donates << " "
+					 << (double) num_gb_donates_15_dist / (double) num_gb_donates << " "
+					 << (double) tot_dist_gb_donate / (double) num_gb_donates << endl;
+					 */
+					
+					num_gb_donates = 0;
+					num_gb_donates_15_dist = 0;
+					tot_dist_gb_donate = 0;
+				}
+				
+				found = true;
+			}
+		}
+		
+		// stop searching through the neighbors if we already found one
+		if (found == true){
+    	break;
+		}
+		
+		m_organism->Rotate(1);
+		neighbor_id++;
+  }
+	
+	if (found == false) neighbor = NULL;
+	
+  // Put the facing back where it was.
+  for (int i = 0; i < neighbor_id; i++) m_organism->Rotate(-1);
+	
+  // Donate only if we have found a close enough relative...
+  if (neighbor != NULL) {
+    DoDonate(neighbor);
+    neighbor->GetPhenotype().SetIsReceiverShadedGb();
+    
+  }
+	
+  return true;
+	
+}
+
+
+
 bool cHardwareCPU::Inst_DonateTrueGreenBeard(cAvidaContext& ctx)
 {
   //this donates to organisms that have this instruction anywhere
@@ -4031,68 +4238,69 @@
   //the history of the theory and the name 'green beard'
   //  cout << "i am about to donate to a green beard" << endl;
   cPhenotype & phenotype = m_organism->GetPhenotype();
-
+	
   if (m_organism->GetPhenotype().GetCurNumDonates() > m_world->GetConfig().MAX_DONATES.Get()) {
     return false;
   }
-
+	
   phenotype.IncDonates();
   phenotype.SetIsDonorTrueGb();
-
+	
   // Find the target as the first match found in the neighborhood.
-
+	
   //get the neighborhood size
   const int num_neighbors = m_organism->GetNeighborhoodSize();
-
+	
+	// Get greenbeard instruction number
+	cInstSet& inst_set = m_world->GetHardwareManager().GetInstSet();
+	const int num_inst = m_world->GetNumInstructions();
+	int inst_number = 0;
+	for (int i = 0; i < num_inst; i++) { 
+		if (inst_set.GetName(i) == "donate-tgb") {
+			inst_number = i;
+		}
+	}
+	
   // Turn to face a random neighbor
   int neighbor_id = ctx.GetRandom().GetInt(num_neighbors);
   for (int i = 0; i < neighbor_id; i++) m_organism->Rotate(1);
   cOrganism * neighbor = m_organism->GetNeighbor();
-
+	
   int max_id = neighbor_id + num_neighbors;
- 
+	
   //we have not found a match yet
   bool found = false;
-
+	
   // rotate through orgs in neighborhood  
   while (neighbor_id < max_id) {
-      neighbor = m_organism->GetNeighbor();
-      //if neighbor exists, AND if their parent attempted to donate,
-      if (neighbor != NULL && neighbor->GetPhenotype().IsDonorTrueGbLast()) {
-          const cGenome & neighbor_genome = neighbor->GetGenome();
-
-          // for each instruction in the genome...
-          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()) {
-              found = true;
-              break;
-            }
-	    
-          }
-      }
-      
-      // stop searching through the neighbors if we already found one
-      if (found == true) break;
-  
-      m_organism->Rotate(1);
-      neighbor_id++;
+		neighbor = m_organism->GetNeighbor();
+		//if neighbor is a green beard
+		if (neighbor->GetPhenotype().GetTestCPUInstCount()[inst_number]) {
+			found = true;
+		}
+		
+		// stop searching through the neighbors if we already found one
+		if (found == true){
+    	break;
+		}
+		
+		m_organism->Rotate(1);
+		neighbor_id++;
   }
-
-    if (found == false) neighbor = NULL;
-
+	
+	if (found == false) neighbor = NULL;
+	
   // Put the facing back where it was.
   for (int i = 0; i < neighbor_id; i++) m_organism->Rotate(-1);
-
+	
   // Donate only if we have found a close enough relative...
   if (neighbor != NULL) {
     DoDonate(neighbor);
     neighbor->GetPhenotype().SetIsReceiverTrueGb();
   }
-
+	
   
-  return true;
+  return true;	
   
 }
 
@@ -4104,62 +4312,111 @@
   //the history of the theory and the name 'green beard'
   //  cout << "i am about to donate to a green beard" << endl;
   cPhenotype & phenotype = m_organism->GetPhenotype();
-
+	
   if (m_organism->GetPhenotype().GetCurNumDonates() > m_world->GetConfig().MAX_DONATES.Get()) {
     return false;
   }
-
-
+	
+	
   phenotype.IncDonates();
   phenotype.SetIsDonorThreshGb();
   phenotype.IncNumThreshGbDonations();
-
+	
+	
+	// Identify how many thresh green beard donations this organisms made
+	// First figure out what number instruction donate-threshgb is	
+	cInstSet& inst_set = m_world->GetHardwareManager().GetInstSet();
+	const int num_inst = m_world->GetNumInstructions();
+	int neighbor_thresh_of_gb = 0;
+	int inst_number = 0;
+	for (int i = 0; i < num_inst; i++) { 
+		if ((inst_set.GetName(i) == "donate-threshgb") && 
+				(phenotype.GetTestCPUInstCount().GetSize() > 0)) {
+			inst_number = i;
+		}
+	}
+	
   // Find the target as the first match found in the neighborhood.
-
+	
   //get the neighborhood size
   const int num_neighbors = m_organism->GetNeighborhoodSize();
-
+	
   // Turn to face a random neighbor
   int neighbor_id = ctx.GetRandom().GetInt(num_neighbors);
   for (int i = 0; i < neighbor_id; i++) m_organism->Rotate(1);
   cOrganism * neighbor = m_organism->GetNeighbor();
-
+	
   int max_id = neighbor_id + num_neighbors;
- 
+	
   //we have not found a match yet
   bool found = false;
-
+	
   // rotate through orgs in neighborhood  
   while (neighbor_id < max_id) {
-      neighbor = m_organism->GetNeighbor();
-      //if neighbor exists, AND if their parent attempted to donate >= threshhold,
-      if (neighbor != NULL && neighbor->GetPhenotype().GetNumThreshGbDonationsLast()>= m_world->GetConfig().MIN_GB_DONATE_THRESHOLD.Get() ) {
-          const cGenome & neighbor_genome = neighbor->GetGenome();
-
-          // for each instruction in the genome...
-          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()) {
-              found = true;
-              break;
-            }
-	    
-          }
-      }
-      
-      // stop searching through the neighbors if we already found one
-      if (found == true) break;
-  
-      m_organism->Rotate(1);
-      neighbor_id++;
+		neighbor = m_organism->GetNeighbor();
+		//if neighbor exists, AND if their parent attempted to donate >= threshhold,
+		if (neighbor != NULL) {
+			
+			// Get neighbor threshold
+			neighbor_thresh_of_gb = 0; 
+			if (neighbor->GetPhenotype().GetTestCPUInstCount().GetSize() > 0) { 
+				neighbor_thresh_of_gb = neighbor->GetPhenotype().GetTestCPUInstCount()[inst_number];
+			}
+			
+			if (neighbor_thresh_of_gb >= m_world->GetConfig().MIN_GB_DONATE_THRESHOLD.Get() ) {
+				const cGenome & neighbor_genome = neighbor->GetGenome();
+				
+				// Code to track the edit distance between tgb donors and recipients
+				const int edit_dist = cGenomeUtil::FindEditDistance(m_organism->GetGenome(),neighbor->GetGenome());
+				
+				/*static ofstream tgb_file("thresh_gb_dists.dat");*/
+				static int num_tgb_donates = 0;
+				static int num_tgb_donates_15_dist = 0;
+				static int tot_dist_tgb_donate = 0;
+				
+				num_tgb_donates++;
+				if (edit_dist > 15) num_tgb_donates_15_dist++;
+				tot_dist_tgb_donate += edit_dist;
+				
+				if (num_tgb_donates == 1000) {
+					/*
+					 tgb_file << num_tgb_donates << " "
+					 << (double) num_tgb_donates_15_dist / (double) num_tgb_donates << " "
+					 << (double) tot_dist_tgb_donate / (double) num_tgb_donates << endl;
+					 */
+					
+					num_tgb_donates = 0;
+					num_tgb_donates_15_dist = 0;
+					tot_dist_tgb_donate = 0;
+				}
+				
+				// for each instruction in the genome...
+				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()) {
+						found = true;
+						break;
+					}
+					
+				}
+			}
+		}
+		
+		// stop searching through the neighbors if we already found one
+		if (found == true){
+    	break;
+		}
+		
+		m_organism->Rotate(1);
+		neighbor_id++;
   }
-
-    if (found == false) neighbor = NULL;
-
+	
+	if (found == false) neighbor = NULL;
+	
   // Put the facing back where it was.
   for (int i = 0; i < neighbor_id; i++) m_organism->Rotate(-1);
-
+	
   // Donate only if we have found a close enough relative...
   if (neighbor != NULL) {
     DoDonate(neighbor);
@@ -4167,9 +4424,8 @@
     // cout << "************ neighbor->GetPhenotype().GetNumThreshGbDonationsLast() is " << neighbor->GetPhenotype().GetNumThreshGbDonationsLast() << endl;
     
   }
-
+	
   return true;
-  
 }
 
 
@@ -4182,79 +4438,81 @@
   // using this instruction.  The threshold levels are multiples of
   // the quanta value set in genesis, and the highest level that
   // the donor qualifies for is the one used.
-
+	
   // (see Dawkins 1976, The Selfish Gene, for 
   // the history of the theory and the name 'green beard'
   //  cout << "i am about to donate to a green beard" << endl;
   cPhenotype & phenotype = m_organism->GetPhenotype();
-
+	
   if (phenotype.GetCurNumDonates() > m_world->GetConfig().MAX_DONATES.Get()) {
     return false;
   }
-
+	
   phenotype.IncDonates();
   phenotype.SetIsDonorQuantaThreshGb();
   phenotype.IncNumQuantaThreshGbDonations();
   //cout << endl << "quanta_threshgb attempt.. " ;
-
-
+	
+	
   // Find the target as the first match found in the neighborhood.
-
+	
   //get the neighborhood size
   const int num_neighbors = m_organism->GetNeighborhoodSize();
-
+	
   // Turn to face a random neighbor
   int neighbor_id = ctx.GetRandom().GetInt(num_neighbors);
   for (int i = 0; i < neighbor_id; i++) m_organism->Rotate(1);
   cOrganism * neighbor = m_organism->GetNeighbor();
-
+	
   int max_id = neighbor_id + num_neighbors;
- 
+	
   //we have not found a match yet
   bool found = false;
-
+	
   // Get the quanta (step size) between threshold levels.
   const int donate_quanta = m_world->GetConfig().DONATE_THRESH_QUANTA.Get();
   
   // Calculate what quanta level we should be at for this individual.  We do a
   // math trick to make sure its the next lowest event multiple of donate_quanta.
   const int quanta_donate_thresh =
-    (phenotype.GetNumQuantaThreshGbDonationsLast() / donate_quanta) * donate_quanta;
+	(phenotype.GetNumQuantaThreshGbDonationsLast() / donate_quanta) * donate_quanta;
   //cout << " phenotype.GetNumQuantaThreshGbDonationsLast() is " << phenotype.GetNumQuantaThreshGbDonationsLast();
   //cout << " quanta thresh=  " << quanta_donate_thresh;
   // rotate through orgs in neighborhood  
   while (neighbor_id < max_id) {
-      neighbor = m_organism->GetNeighbor();
-      //if neighbor exists, AND if their parent attempted to donate >= threshhold,
-      if (neighbor != NULL &&
-	  neighbor->GetPhenotype().GetNumQuantaThreshGbDonationsLast() >= quanta_donate_thresh) {
-
-          const cGenome & neighbor_genome = neighbor->GetGenome();
-
-          // for each instruction in the genome...
-          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()) {
-              found = true;
-              break;
-            }
-	    
-          }
-      }
-      
-      // stop searching through the neighbors if we already found one
-      if (found == true) break;
-  
-      m_organism->Rotate(1);
-      neighbor_id++;
+		neighbor = m_organism->GetNeighbor();
+		//if neighbor exists, AND if their parent attempted to donate >= threshhold,
+		if (neighbor != NULL &&
+				neighbor->GetPhenotype().GetNumQuantaThreshGbDonationsLast() >= quanta_donate_thresh) {
+			
+			const cGenome & neighbor_genome = neighbor->GetGenome();
+			
+			// for each instruction in the genome...
+			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()) {
+					found = true;
+					break;
+				}
+				
+			}
+		}
+		
+		// stop searching through the neighbors if we already found one
+		if (found == true);{
+    	break;
+		}
+		
+		m_organism->Rotate(1);
+		neighbor_id++;
   }
-
-    if (found == false) neighbor = NULL;
-
+	
+	if (found == false) neighbor = NULL;
+	
   // Put the facing back where it was.
   for (int i = 0; i < neighbor_id; i++) m_organism->Rotate(-1);
-
+	
   // Donate only if we have found a close enough relative...
   if (neighbor != NULL) {
     DoDonate(neighbor);
@@ -4262,7 +4520,7 @@
     //cout << " ************ neighbor->GetPhenotype().GetNumQuantaThreshGbDonationsLast() is " << neighbor->GetPhenotype().GetNumQuantaThreshGbDonationsLast();
     
   }
-
+	
   return true;
   
 }

Modified: development/source/cpu/cHardwareCPU.h
===================================================================
--- development/source/cpu/cHardwareCPU.h	2009-05-20 12:39:24 UTC (rev 3246)
+++ development/source/cpu/cHardwareCPU.h	2009-05-20 13:09:38 UTC (rev 3247)
@@ -507,6 +507,7 @@
   bool Inst_DonateEditDist(cAvidaContext& ctx);
   bool Inst_DonateGreenBeardGene(cAvidaContext& ctx);
   bool Inst_DonateTrueGreenBeard(cAvidaContext& ctx);
+	bool Inst_DonateShadedGreenBeard(cAvidaContext& ctx);
   bool Inst_DonateThreshGreenBeard(cAvidaContext& ctx);
   bool Inst_DonateQuantaThreshGreenBeard(cAvidaContext& ctx);
   bool Inst_DonateNULL(cAvidaContext& ctx);

Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h	2009-05-20 12:39:24 UTC (rev 3246)
+++ development/source/main/cAvidaConfig.h	2009-05-20 13:09:38 UTC (rev 3247)
@@ -457,7 +457,7 @@
   CONFIG_ADD_VAR(MIN_GB_DONATE_THRESHOLD, int, -1, "threshold green beard donates only to orgs above this\ndonation attempt threshold; -1=no thresh");
   CONFIG_ADD_VAR(DONATE_THRESH_QUANTA, int, 10, "The size of steps between quanta donate thresholds");
   CONFIG_ADD_VAR(MAX_DONATES, int, 1000000, "Limit on number of donates organisms are allowed.");
-  CONFIG_ADD_VAR(PRECALC_PHENOTYPE, int, 0, "0 = Disabled\n 1 = Assign precalculated merit at birth (unlimited resources only)\n 2 = Assign precalculated gestation time\n 3 = Assign precalculated merit AND gestation time.\nFitness will be evaluated for organism based on these settings.");
+  CONFIG_ADD_VAR(PRECALC_PHENOTYPE, int, 0, "0 = Disabled\n 1 = Assign precalculated merit at birth (unlimited resources only)\n 2 = Assign precalculated gestation time\n 3 = Assign precalculated merit AND gestation time.\n 4 = Assign last instruction counts \n 5 = Assign last instruction counts and merit\n 6 = Assign last instruction counts and gestation time \n 7 = Assign everything currently supported\nFitness will be evaluated for organism based on these settings.");
   CONFIG_ADD_VAR(FASTFORWARD_UPDATES, int, 0, "Fast-forward if the average generation has not changed in this many updates. (0 = off)");
   CONFIG_ADD_VAR(FASTFORWARD_NUM_ORGS, int, 0, "Fast-forward if population is equal to this");
   CONFIG_ADD_VAR(GENOTYPE_PHENPLAST_CALC, int, 100, "Number of times to test a genotype's\nplasticity during runtime.");
@@ -622,7 +622,7 @@
 	
 	
 	//--------- Reputation config options --------------
-	CONFIG_ADD_CUSTOM_FORMAT(REPUTATION_GROUP, "Reputation Settings");
+	CONFIG_ADD_GROUP(REPUTATION_GROUP, "Reputation Settings");
   CONFIG_ADD_VAR(RAW_MATERIAL_AMOUNT, int, 100, "Number of raw materials an organism starts with");
   CONFIG_ADD_VAR(AUTO_REPUTATION, int, 0, "Is an organism's reputation automatically computed based on its donations\n0=no\n1=increment for each donation + standing\n2=+1 for donations given -1 for donations received\n3=1 for donors -1 for recivers who have not donated\n4=+1 for donors\n5=+1 for donors during task check");
   CONFIG_ADD_VAR(ALT_BENEFIT, int, 1.00, "Number multiplied by the number of raw materials received from another organism to compute reward");

Modified: development/source/main/cPhenotype.cc
===================================================================
--- development/source/main/cPhenotype.cc	2009-05-20 12:39:24 UTC (rev 3246)
+++ development/source/main/cPhenotype.cc	2009-05-20 13:09:38 UTC (rev 3247)
@@ -202,10 +202,14 @@
   is_donor_threshgb_last  = in_phen.is_donor_threshgb_last;
   is_donor_quanta_threshgb        = in_phen.is_donor_quanta_threshgb;  
   is_donor_quanta_threshgb_last   = in_phen.is_donor_quanta_threshgb_last;
-  num_thresh_gb_donations         = in_phen.num_thresh_gb_donations;  
+	is_donor_shadedgb       = in_phen.is_donor_shadedgb;  
+  is_donor_shadedgb_last  = in_phen.is_donor_shadedgb_last;	
+	num_thresh_gb_donations         = in_phen.num_thresh_gb_donations;  
   num_thresh_gb_donations_last    = in_phen.num_thresh_gb_donations_last;  
   num_quanta_thresh_gb_donations = in_phen.num_quanta_thresh_gb_donations;
   num_quanta_thresh_gb_donations_last = in_phen.num_quanta_thresh_gb_donations_last;
+	num_shaded_gb_donations         = in_phen.num_shaded_gb_donations;  
+  num_shaded_gb_donations_last    = in_phen.num_shaded_gb_donations_last; 
   is_receiver             = in_phen.is_receiver;   
   is_receiver_last        = in_phen.is_receiver_last;      
   is_receiver_rand        = in_phen.is_receiver_rand;
@@ -220,6 +224,8 @@
   is_receiver_threshgb_last    = in_phen.is_receiver_threshgb_last;
   is_receiver_quanta_threshgb  = in_phen.is_receiver_quanta_threshgb;
   is_receiver_quanta_threshgb_last = in_phen.is_receiver_quanta_threshgb_last;
+	is_receiver_shadedgb    = in_phen.is_receiver_shadedgb;
+  is_receiver_shadedgb_last    = in_phen.is_receiver_shadedgb_last;	
   is_modifier             = in_phen.is_modifier;      
   is_modified             = in_phen.is_modified;      
   is_fertile              = in_phen.is_fertile;      
@@ -387,7 +393,9 @@
   num_thresh_gb_donations_last = parent_phenotype.num_thresh_gb_donations_last;
   num_quanta_thresh_gb_donations = 0;
   num_quanta_thresh_gb_donations_last = parent_phenotype.num_thresh_gb_donations_last;
-
+	num_shaded_gb_donations = 0;
+  num_shaded_gb_donations_last = parent_phenotype.num_shaded_gb_donations_last;
+	
   // Setup flags...
   is_injected   = false;
   is_donor_cur  = false;
@@ -408,7 +416,9 @@
   is_donor_threshgb_last = parent_phenotype.is_donor_threshgb_last;
   is_donor_quanta_threshgb  = false;
   is_donor_quanta_threshgb_last = parent_phenotype.is_donor_quanta_threshgb_last;
-  is_receiver   = false;
+  is_donor_shadedgb  = false;
+  is_donor_shadedgb_last = parent_phenotype.is_donor_shadedgb_last;	
+	is_receiver   = false;
   is_receiver_last = parent_phenotype.is_receiver_last;
   is_receiver_rand   = false;
   is_receiver_kin    = false;
@@ -422,7 +432,9 @@
   is_receiver_threshgb_last = parent_phenotype.is_receiver_threshgb_last;
   is_receiver_quanta_threshgb = false;
   is_receiver_quanta_threshgb_last = parent_phenotype.is_receiver_quanta_threshgb_last;
-  is_modifier   = false;
+	is_receiver_shadedgb = false;
+  is_receiver_shadedgb_last = parent_phenotype.is_receiver_shadedgb_last;	
+	is_modifier   = false;
   is_modified   = false;
   is_fertile    = parent_phenotype.last_child_fertile;
   is_mutated    = false;
@@ -547,7 +559,9 @@
   num_thresh_gb_donations_last = 0;
   num_quanta_thresh_gb_donations = 0;
   num_quanta_thresh_gb_donations_last = 0;
-
+  num_shaded_gb_donations = 0;
+  num_shaded_gb_donations_last = 0;	
+	
   // Setup flags...
   is_injected   = true;
   is_donor_last = false;
@@ -568,6 +582,8 @@
   is_donor_threshgb_last = false;
   is_donor_quanta_threshgb = false;
   is_donor_quanta_threshgb_last = false;
+	is_donor_shadedgb = false;
+  is_donor_shadedgb_last = false;	
   is_receiver   = false;
   is_receiver_last   = false;
   is_receiver_rand   = false;
@@ -582,6 +598,8 @@
   is_receiver_threshgb_last   = false;
   is_receiver_quanta_threshgb   = false;
   is_receiver_quanta_threshgb_last   = false;
+	is_receiver_shadedgb   = false;
+  is_receiver_shadedgb_last   = false;	
   is_modifier   = false;
   is_modified   = false;
   is_fertile    = true;
@@ -708,7 +726,9 @@
   num_thresh_gb_donations = 0;
   num_quanta_thresh_gb_donations_last = num_quanta_thresh_gb_donations;
   num_quanta_thresh_gb_donations = 0;
-
+	num_shaded_gb_donations_last = num_shaded_gb_donations;
+  num_shaded_gb_donations = 0;	
+	
   // Leave flags alone...
   (void) is_injected;
   is_donor_last = is_donor_cur;
@@ -729,6 +749,8 @@
   is_donor_threshgb = false;
   is_donor_quanta_threshgb_last = is_donor_quanta_threshgb;
   is_donor_quanta_threshgb = false;
+	is_donor_shadedgb_last = is_donor_shadedgb;
+  is_donor_shadedgb = false;	
   is_receiver_last = is_receiver;
   is_receiver = false;
   is_receiver_rand = false;
@@ -743,6 +765,8 @@
   is_receiver_threshgb = false;
   is_receiver_quanta_threshgb_last = is_receiver_quanta_threshgb;
   is_receiver_quanta_threshgb = false;
+	is_receiver_shadedgb_last = is_receiver_shadedgb;
+  is_receiver_shadedgb = false;	
   (void) is_modifier;
   (void) is_modified;
   (void) is_fertile;
@@ -869,7 +893,9 @@
   num_thresh_gb_donations = 0;
   num_quanta_thresh_gb_donations_last = num_quanta_thresh_gb_donations;
   num_quanta_thresh_gb_donations = 0;
-
+	num_shaded_gb_donations_last = num_shaded_gb_donations;
+  num_shaded_gb_donations = 0;
+	
   // Leave flags alone...
   (void) is_injected;
   is_donor_last = is_donor_cur;
@@ -890,6 +916,8 @@
   is_donor_threshgb = false;
   is_donor_quanta_threshgb_last = is_donor_quanta_threshgb;
   is_donor_quanta_threshgb = false;
+	is_donor_shadedgb_last = is_donor_shadedgb;
+  is_donor_shadedgb = false;	
   is_receiver_last = is_receiver;
   is_receiver = false;
   is_receiver_rand = false;
@@ -904,6 +932,8 @@
   is_receiver_threshgb = false;
   is_receiver_quanta_threshgb_last = is_receiver_quanta_threshgb;
   is_receiver_quanta_threshgb = false;
+  is_receiver_shadedgb_last = is_receiver_shadedgb;
+  is_receiver_shadedgb = false;	
   (void) is_modifier;
   (void) is_modified;
   (void) is_fertile;
@@ -1022,7 +1052,9 @@
   num_thresh_gb_donations  = clone_phenotype.num_thresh_gb_donations;
   num_quanta_thresh_gb_donations_last = clone_phenotype.num_quanta_thresh_gb_donations_last;
   num_quanta_thresh_gb_donations  = clone_phenotype.num_quanta_thresh_gb_donations;
-
+	num_shaded_gb_donations_last = clone_phenotype.num_shaded_gb_donations_last;
+  num_shaded_gb_donations  = clone_phenotype.num_shaded_gb_donations;
+	
   // Setup flags...
   is_injected   = false;
   is_donor_last = clone_phenotype.is_donor_last;
@@ -1044,6 +1076,8 @@
   is_donor_threshgb  = clone_phenotype.is_donor_threshgb;
   is_donor_quanta_threshgb_last = clone_phenotype.is_donor_quanta_threshgb_last;
   is_donor_quanta_threshgb  = clone_phenotype.is_donor_quanta_threshgb;
+	is_donor_shadedgb_last = clone_phenotype.is_donor_shadedgb_last;
+  is_donor_shadedgb  = clone_phenotype.is_donor_shadedgb;	
   is_receiver = clone_phenotype.is_receiver;
   is_receiver_last = clone_phenotype.is_receiver_last;
   is_receiver_rand = clone_phenotype.is_receiver_rand;
@@ -1058,6 +1092,8 @@
   is_receiver_threshgb_last = clone_phenotype.is_receiver_threshgb_last;
   is_receiver_quanta_threshgb = clone_phenotype.is_receiver_quanta_threshgb;
   is_receiver_quanta_threshgb_last = clone_phenotype.is_receiver_quanta_threshgb_last;
+	is_receiver_shadedgb = clone_phenotype.is_receiver_shadedgb;
+  is_receiver_shadedgb_last = clone_phenotype.is_receiver_shadedgb_last;	
   is_modifier   = false;
   is_modified   = false;
   is_fertile    = clone_phenotype.last_child_fertile;
@@ -1570,7 +1606,9 @@
   num_thresh_gb_donations = 0;
   num_quanta_thresh_gb_donations_last = num_quanta_thresh_gb_donations;
   num_quanta_thresh_gb_donations = 0;
-
+	num_shaded_gb_donations_last = num_shaded_gb_donations;
+  num_shaded_gb_donations = 0;
+	
   // Leave flags alone...
   (void) is_injected;
   is_donor_last = is_donor_cur;
@@ -1591,6 +1629,8 @@
   is_donor_threshgb = false;
   is_donor_quanta_threshgb_last = is_donor_quanta_threshgb;
   is_donor_quanta_threshgb = false;
+	is_donor_shadedgb_last = is_donor_shadedgb;
+  is_donor_shadedgb = false;	
   is_receiver_last = is_receiver;
   is_receiver = false;
   is_receiver_rand = false;
@@ -1605,6 +1645,8 @@
   is_receiver_threshgb = false;
   is_receiver_quanta_threshgb_last = is_receiver_quanta_threshgb;
   is_receiver_quanta_threshgb = false;
+	is_receiver_shadedgb_last = is_receiver_shadedgb;
+  is_receiver_shadedgb = false;	
   is_energy_requestor = false;
   is_energy_donor = false;
   is_energy_receiver = false;

Modified: development/source/main/cPhenotype.h
===================================================================
--- development/source/main/cPhenotype.h	2009-05-20 12:39:24 UTC (rev 3246)
+++ development/source/main/cPhenotype.h	2009-05-20 13:09:38 UTC (rev 3247)
@@ -179,6 +179,8 @@
   int exec_time_born;    // @MRR number of instructions since seed ancestor start
   double gmu_exec_time_born; //@MRR mutation-rate and gestation time scaled time of birth
   int birth_update;      // @MRR update *organism* born
+	tArray<int> testCPU_inst_count;	  // Instruction exection counter as calculated by Test CPU
+
   
   // 5. Status Flags...  (updated at each divide)
   bool to_die;		 // Has organism has triggered something fatal?
@@ -202,6 +204,8 @@
   bool is_donor_threshgb_last;// Did this org's parent threshgbg_donate? 
   bool is_donor_quanta_threshgb;  // Has this organism quanta_threshgb_donated (true green beard)? 
   bool is_donor_quanta_threshgb_last;// Did this org's parent quanta_threshgbg_donate? 
+	bool is_donor_shadedgb; // Has this organism shaded_gb_donated (true shaded green beard)? 
+	bool is_donor_shadedgb_last; // Did this org's parent shaded_gb_donate? 
   bool is_energy_requestor; // Has this organism requested energy?
   bool is_energy_donor; // Has this organism donated energy?
   bool is_energy_receiver;  // Has this organism received an energy donation?
@@ -211,6 +215,8 @@
   int num_thresh_gb_donations_last; // Num times this org's parent thresh_donated? 
   int num_quanta_thresh_gb_donations;  // Num times this organism threshgb_donated (thresh green beard)? 
   int num_quanta_thresh_gb_donations_last; // Num times this org's parent thresh_donated? 
+	int num_shaded_gb_donations; // Num times this org shaded_gb_donated? 
+	int num_shaded_gb_donations_last; // Num times this org's parent shaded_gb_donated?
   bool is_receiver;      // Has this organism ever received merit donation?
   bool is_receiver_last;      // Did this organism's parent receive a merit donation?
   bool is_receiver_rand; // Has this organism ever received random merit donation?
@@ -225,6 +231,8 @@
   bool is_receiver_threshgb_last;// Did this organism's parent receive a threshgb donation?
   bool is_receiver_quanta_threshgb;// Has this organism ever received a quanta_threshgb donation?
   bool is_receiver_quanta_threshgb_last;// Did this organism's parent receive a quanta_threshgb donation?
+	bool is_receiver_shadedgb; // Has this organism ever received a shaded_gb donation? 
+	bool is_receiver_shadedgb_last; // Did this organism's parent receive a shaded gb donation?
   bool is_modifier;      // Has this organism modified another?
   bool is_modified;      // Has this organism been modified by another?
   bool is_fertile;       // Do we allow this organisms to produce offspring?
@@ -357,7 +365,8 @@
   double GetSensedResource(int _in) { assert(initialized == true); return sensed_resources[_in]; }
   const tArray<int>& GetCurCollectSpecCounts() const { assert(initialized == true); return cur_collect_spec_counts; }
   const int GetCurCollectSpecCount(int spec_id) const { assert(initialized == true); return cur_collect_spec_counts[spec_id]; }
-  
+	const tArray<int>& GetTestCPUInstCount() const { assert(initialized == true); return testCPU_inst_count; }
+
   void  NewTrial(); //Save the current fitness, and reset the bonus. @JEB
   void  TrialDivideReset(const cGenome & _genome); //Subset of resets specific to division not done by NewTrial. @JEB
   const tArray<double>& GetTrialFitnesses() { return cur_trial_fitnesses; }; //Return list of trial fitnesses. @JEB
@@ -399,6 +408,8 @@
   int  GetNumThreshGbDonationsLast() const { assert(initialized == true); return num_thresh_gb_donations_last; }
   int  GetNumQuantaThreshGbDonations() const { assert(initialized == true); return num_quanta_thresh_gb_donations; }
   int  GetNumQuantaThreshGbDonationsLast() const { assert(initialized == true); return num_quanta_thresh_gb_donations_last; }
+	int  GetNumShadedGbDonations() const { assert(initialized == true); return num_shaded_gb_donations; }
+  int  GetNumShadedGbDonationsLast() const { assert(initialized == true); return num_shaded_gb_donations_last; }	
 
 
   bool IsInjected() const { assert(initialized == true); return is_injected; }
@@ -418,6 +429,8 @@
   bool IsDonorThreshGbLast() const { assert(initialized == true); return is_donor_threshgb_last; }
   bool IsDonorQuantaThreshGb() const { assert(initialized == true); return is_donor_quanta_threshgb; }
   bool IsDonorQuantaThreshGbLast() const { assert(initialized == true); return is_donor_quanta_threshgb_last; }
+	bool IsDonorShadedGb() const { assert(initialized == true); return is_donor_shadedgb; }
+  bool IsDonorShadedGbLast() const { assert(initialized == true); return is_donor_shadedgb_last; }	
   bool IsEnergyRequestor() const { assert(initialized == true); return is_energy_requestor; }
   bool IsEnergyDonor() const { assert(initialized == true); return is_energy_donor; }
   bool IsEnergyReceiver() const { assert(initialized == true); return is_energy_receiver; }
@@ -437,6 +450,8 @@
   bool IsReceiverThreshGbLast() const { assert(initialized == true); return is_receiver_threshgb_last; }
   bool IsReceiverQuantaThreshGb() const { assert(initialized == true); return is_receiver_quanta_threshgb; }
   bool IsReceiverQuantaThreshGbLast() const { assert(initialized == true); return is_receiver_quanta_threshgb_last; }
+  bool IsReceiverShadedGb() const { assert(initialized == true); return is_receiver_shadedgb; }
+  bool IsReceiverShadedGbLast() const { assert(initialized == true); return is_receiver_shadedgb_last; }
   bool IsModifier() const { assert(initialized == true); return is_modifier; }
   bool IsModified() const { assert(initialized == true); return is_modified; }
   bool IsFertile() const  { assert(initialized == true); return is_fertile; }
@@ -475,6 +490,7 @@
   void SetCrossNum(int _cross_num) { cross_num = _cross_num; }
   void SetToDie() { to_die = true; }
   void SetToDelete() { to_delete = true; }
+	void SetTestCPUInstCount(const tArray<int>& in_counts) { testCPU_inst_count = in_counts; }
   void IncreaseEnergyDonated(double amount) { assert(amount >=0); total_energy_donated += amount; }
   void IncreaseEnergyReceived(double amount) { assert(amount >=0); total_energy_received += amount; }
   void IncreaseEnergyApplied(double amount) { assert(amount >=0); total_energy_applied += amount; }
@@ -506,6 +522,7 @@
   void SetIsDonorTrueGb() { SetIsDonorCur(); is_donor_truegb = true; }
   void SetIsDonorThreshGb() { SetIsDonorCur(); is_donor_threshgb = true; }
   void SetIsDonorQuantaThreshGb() { SetIsDonorCur(); is_donor_quanta_threshgb = true; }
+	void SetIsDonorShadedGb() { SetIsDonorCur(); is_donor_shadedgb = true; }
   void SetIsReceiver() { is_receiver = true; } 
   void SetIsReceiverRand() { SetIsReceiver(); is_receiver_rand = true; } 
   void SetIsReceiverKin() { SetIsReceiver(); is_receiver_kin = true; } 
@@ -514,6 +531,7 @@
   void SetIsReceiverTrueGb() { SetIsReceiver(); is_receiver_truegb = true; } 
   void SetIsReceiverThreshGb() { SetIsReceiver(); is_receiver_threshgb = true; } 
   void SetIsReceiverQuantaThreshGb() { SetIsReceiver(); is_receiver_quanta_threshgb = true; } 
+	void SetIsReceiverShadedGb() { SetIsReceiver(); is_receiver_shadedgb = true; } 	
   void SetIsEnergyRequestor() { is_energy_requestor = true; }
   void SetIsEnergyDonor() { is_energy_donor = true; }
   void SetIsEnergyReceiver() { is_energy_receiver = true; }
@@ -529,6 +547,7 @@
   
   void IncNumThreshGbDonations() { assert(initialized == true); num_thresh_gb_donations++; }
   void IncNumQuantaThreshGbDonations() { assert(initialized == true); num_quanta_thresh_gb_donations++; }
+  void IncNumShadedGbDonations() { assert(initialized == true); num_shaded_gb_donations++; }	
 
   void IncAge()      { assert(initialized == true); age++; }
   void IncCPUCyclesUsed() { assert(initialized == true); cpu_cycles_used++; trial_cpu_cycles_used++; }

Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc	2009-05-20 12:39:24 UTC (rev 3246)
+++ development/source/main/cPopulation.cc	2009-05-20 13:09:38 UTC (rev 3247)
@@ -403,7 +403,10 @@
         if (pc_phenotype & 2) {   // If we must update the gestation time
           parent_phenotype.SetGestationTime(test_info.GetTestPhenotype().GetGestationTime());
         }
-        parent_phenotype.SetFitness(parent_phenotype.GetMerit().CalcFitness(parent_phenotype.GetGestationTime())); // Update fitness
+        if (pc_phenotype & 4) {   // If we must update the last instruction counts
+					parent_phenotype.SetTestCPUInstCount(test_info.GetTestPhenotype().GetLastInstCount());
+				}
+				parent_phenotype.SetFitness(parent_phenotype.GetMerit().CalcFitness(parent_phenotype.GetGestationTime())); // Update fitness
         delete test_cpu;
       }
     }

Modified: development/source/main/cStats.cc
===================================================================
--- development/source/main/cStats.cc	2009-05-20 12:39:24 UTC (rev 3246)
+++ development/source/main/cStats.cc	2009-05-20 13:09:38 UTC (rev 3247)
@@ -2329,3 +2329,94 @@
 	
   df.Endl();
 } 
+
+/* 	
+  Cycle through the population -- count the number of altruists in each bin. 
+  Also average their shaded donations.
+  Check how many prefer the shaded strategy
+ 
+ */
+void cStats::PrintShadedAltruists(const cString& filename) {
+	cDataFile& df = m_world->GetDataFile(filename);
+	df.WriteComment("The number of organisms in different bins of shaded altruism");
+	
+	// Cycle through the population -- count the number of altruists in each bin. 
+	// Also average their shaded donations.
+	// Check how many prefer the shaded strategy
+	
+	//int num_shaded_pref = 0; //!num orgs that prefer shaded
+	int pop = m_world->GetPopulation().GetSize(); //!the population size for convenience
+	int shaded_100 = 0; 
+	int shaded_90 = 0; 
+	int shaded_80 = 0;
+	int shaded_70 = 0;
+	int shaded_60 = 0; 
+	int shaded_50 = 0;
+	int shaded_40 = 0;
+	int shaded_30 = 0;
+	int shaded_20 = 0;
+	int shaded_10 = 0;
+	int shaded_0 = 0;
+	int total_shaded = 0;
+	
+	//int other_donations = 0;
+	int shade_of_gb;
+	cOrganism* org; 
+	
+	
+	for(int i=0; i<m_world->GetPopulation().GetSize(); ++i) {
+		shade_of_gb = 0;
+    cPopulationCell& cell = m_world->GetPopulation().GetCell(i);
+		org = cell.GetOrganism();
+		
+    if(cell.IsOccupied()) {
+			org = cell.GetOrganism();
+			
+			cInstSet& inst_set = m_world->GetHardwareManager().GetInstSet();
+			const int num_inst = m_world->GetNumInstructions();
+			for (int i = 0; i < num_inst; i++) { 
+				if ((inst_set.GetName(i) == "donate-shadedgb") && 
+						(org->GetPhenotype().GetTestCPUInstCount().GetSize() > 0)) {
+					shade_of_gb = org->GetPhenotype().GetTestCPUInstCount()[i];
+				} 
+			}
+			if (shade_of_gb == 100) shaded_100++;
+			if (shade_of_gb > 90) shaded_90++;
+			if (shade_of_gb > 80) shaded_80++;
+			if (shade_of_gb > 70) shaded_70++;
+			if (shade_of_gb > 60) shaded_60++;
+			if (shade_of_gb > 50)	shaded_50++;
+			if (shade_of_gb > 40)	shaded_40++;
+			if (shade_of_gb > 30)	shaded_30++;
+			if (shade_of_gb > 20)	shaded_20++;
+			if (shade_of_gb > 10)	shaded_10++;
+			if (shade_of_gb > 0) shaded_0++;
+			total_shaded += shade_of_gb;
+		}
+	}
+	
+	float high_alt = (float) shaded_90/pop;
+	float avg_shade = (float) total_shaded/pop;
+	
+	df.WriteComment("Bins of orgs of shaded strategies.");
+	df.WriteTimeStamp();
+	df.Write(m_update,   "Update [update]");	
+	df.Write(pop, "Population [population]");
+	df.Write(shaded_100, "shaded-100 [shaded100]");
+	df.Write(shaded_90, "shaded-90 [shaded90]");
+	df.Write(shaded_80, "shaded-80 [shaded80]");
+	df.Write(shaded_70, "shaded-70 [shaded70]");
+	df.Write(shaded_60, "shaded-60 [shaded60]");
+	df.Write(shaded_50, "shaded-50 [shaded50]");
+	df.Write(shaded_40, "shaded-40 [shaded40]");
+	df.Write(shaded_30, "shaded-30 [shaded30]");
+	df.Write(shaded_20, "shaded-20 [shaded20]");
+	df.Write(shaded_10, "shaded-10 [shaded10]");
+	df.Write(shaded_0, "shaded-0 [shaded0]");
+	df.Write(high_alt, "percent-high-alt [highalt]");
+	df.Write(avg_shade, "avg-shade [avgshade]");
+	df.Endl();
+	
+}
+
+

Modified: development/source/main/cStats.h
===================================================================
--- development/source/main/cStats.h	2009-05-20 12:39:24 UTC (rev 3246)
+++ development/source/main/cStats.h	2009-05-20 13:09:38 UTC (rev 3247)
@@ -917,7 +917,8 @@
 	void AddTag(int tag, int value) { m_tags[tag] = m_tags[tag] + value; }
 	void IncPerfectMatch(int amount) { m_perfect_match.Add(amount); }
 	void IncPerfectMatchOrg() { m_perfect_match_org.Add(1); }
-	
+	void PrintShadedAltruists(const cString& filename);
+
 protected: 
 	int m_donate_to_donor; 
 	int m_donate_to_facing;

Added: development/tests/shaded_green_beard_instructions/config/avida.cfg
===================================================================
--- development/tests/shaded_green_beard_instructions/config/avida.cfg	                        (rev 0)
+++ development/tests/shaded_green_beard_instructions/config/avida.cfg	2009-05-20 13:09:38 UTC (rev 3247)
@@ -0,0 +1,167 @@
+#############################################################################
+# This file includes all the basic run-time defines for avida.
+# For more information, see doc/genesis.html
+#############################################################################
+
+VERSION_ID 2.0b7   # Do not change this value.
+
+### Architecture Variables ###
+MAX_UPDATES -1        # Maximum updates to run experiment (-1 = no limit)
+MAX_GENERATIONS -1    # Maximum generations to run experiment (-1 = no limit)
+END_CONDITION_MODE 0  # End run when ...
+                      # 0 = MAX_UPDATES _OR_ MAX_GENERATIONS is reached
+                      # 1 = MAX_UPDATES _AND_ MAX_GENERATIONS is reached
+WORLD_X 10           # Width of the Avida world
+WORLD_Y 10           # Height of the Avida world
+WORLD_GEOMETRY 2      # 1 = Bounded Grid
+                      # 2 = Torus
+NUM_DEMES 0           # Number of independed groups in the population; 0=off
+RANDOM_SEED 0         # Random number seed (0 for based on time)
+HARDWARE_TYPE 0       # 0 = Original CPUs
+                      # 1 = New, Stack-based CPUs
+
+### Configuration Files ###
+DEFAULT_DIR ../work/              # Directory in which config files are found
+INST_SET inst_set.SexDonateGbshadedGbthreshEdtKinRndNopx     
+# File containing instruction set
+EVENT_FILE eventsFullPopTest.cfg  # File containing list of events during run
+ANALYZE_FILE analyze.cfg          # File used for analysis mode
+ENVIRONMENT_FILE envZeroResources.cfg  # File that describes the environment
+START_CREATURE organism.sexDefault   # Organism to seed the soup
+
+### Birth and Death ###
+BIRTH_METHOD 4           # 0 = Replace random organism in neighborhood
+                         # 1 = Replace oldest organism in neighborhood
+                         # 2 = Replace largest Age/Merit in neighborhood
+                         # 3 = Place only in empty cells in neighborhood
+                         # 4 = Replace random from population (Mass Action)
+                         # 5 = Replace oldest in entire population (like Tierra)
+                         # 6 = Replace random within deme
+PREFER_EMPTY 1           # Are empty cells given preference in offsping placement?
+DEATH_METHOD 2           # 0 = Never die of old age.
+                         # 1 = Die when inst executed = AGE_LIMIT (+deviation)
+                         # 2 = Die when inst executed = length*AGE_LIMIT (+dev)
+AGE_LIMIT 20             # Modifies DEATH_METHOD
+AGE_DEVIATION 0          # Creates a distribution around AGE_LIMIT
+ALLOC_METHOD 0           # 0 = Allocated space is set to default instruction.
+                         # 1 = Set to section of dead genome (Necrophilia)
+                         # 2 = Allocated space is set to random instruction.
+DIVIDE_METHOD 1          # 0 = Divide leaves state of mother untouched.
+                         # 1 = Divide resets state of mother (after the divide, we have 2 children)
+                         # 2 = Divide resets state of current thread only(does not touch possible parasite threads)
+GENERATION_INC_METHOD 1  # 0 = Only the generation of the child is
+                         #     increased on divide.
+                         # 1 = Both the generation of the mother and child are
+                         #     increased on divide (good with DIVIDE_METHOD 1).
+RECOMBINATION_PROB 1     # probability that recombination will happen when div-sex is used
+MODULE_NUM 0             # number of modules in the genome
+CONT_REC_REGS 1          # are (modular) recombination regions continuous
+CORESPOND_REC_REGS 1     # are (modular) recombination regions swapped at random or with corresponding ones, by location
+TWO_FOLD_COST_SEX 0      # 1 = only one recombined offspring is born.
+                         # 2 = both offspring are born
+
+### Divide Restrictions ###
+CHILD_SIZE_RANGE 1.0  # Maximal differential between child and parent sizes.
+MIN_COPIED_LINES 0.5  # Code fraction which must be copied before divide.
+MIN_EXE_LINES 0.5     # Code fraction which must be executed before divide.
+REQUIRE_ALLOCATE 1    # Is a an allocate required before a divide? (0/1)
+REQUIRED_TASK -1      # Task ID required for successful divide.
+REQUIRED_REACTION -1  # Reaction ID required for successful divide.
+
+### Mutations ###
+POINT_MUT_PROB 0.0    # Mutation rate (per-location per update)
+COPY_MUT_PROB 0.0075  # Mutation rate (per copy)
+INS_MUT_PROB 0.0      # Insertion rate (per site, applied on divide)
+DEL_MUT_PROB 0.0      # Deletion rate (per site, applied on divide)
+DIV_MUT_PROB 0.0      # Mutation rate (per site, applied on divide)
+DIVIDE_MUT_PROB 0.0   # Mutation rate (per divide)
+DIVIDE_INS_PROB 0.0   # Insertion rate (per divide)
+DIVIDE_DEL_PROB 0.0   # Deletion rate (per divide)
+PARENT_MUT_PROB 0.0   # Per-site, in parent, on divide
+SPECIAL_MUT_LINE -1   # If this is >= 0, ONLY this line is mutated
+
+### Mutation Reversion ###
+# These slow down avida a lot, and should be set to 0.0 normally.
+REVERT_FATAL 0.0           # Should any mutations be reverted on birth?
+REVERT_DETRIMENTAL 0.0     #   0.0 to 1.0; Probability of reversion.
+REVERT_NEUTRAL 0.0         # 
+REVERT_BENEFICIAL 0.0      # 
+STERILIZE_FATAL 0.0        # Should any mutations clear (kill) the organism?
+STERILIZE_DETRIMENTAL 0.0  #   0.0 to 1.0; Probability of reset.
+STERILIZE_NEUTRAL 0.0      # 
+STERILIZE_BENEFICIAL 0.0   # 
+FAIL_IMPLICIT 0            # Should copies that failed *not* due to mutations
+                           # be eliminated?
+
+### Time Slicing ###
+AVE_TIME_SLICE 30        # Ave number of insts per org per update
+SLICING_METHOD 2         # 0 = CONSTANT: all organisms get default...
+                         # 1 = PROBABILISTIC: Run _prob_ proportional to merit.
+                         # 2 = INTEGRATED: Perfectly integrated deterministic.
+SIZE_MERIT_METHOD 0      # 0 = off (merit is independent of size)
+                         # 1 = Merit proportional to copied size
+                         # 2 = Merit prop. to executed size
+                         # 3 = Merit prop. to full size
+                         # 4 = Merit prop. to min of executed or copied size
+                         # 5 = Merit prop. to sqrt of the minimum size
+TASK_MERIT_METHOD 1      # 0 = No task bonuses
+                         # 1 = Bonus just equals the task bonus
+MAX_CPU_THREADS 1        # Number of Threads a CPU can spawn
+THREAD_SLICING_METHOD 0  # Formula for and organism's thread slicing -> 1 + (num_organism_threads-1) * THREAD_SLICING_METHOD.
+                         # 0 = One thread executed per time slice.
+                         # 1 = All threads executed each time slice.
+MAX_LABEL_EXE_SIZE 1     # Max nops marked as executed when labels are used
+BASE_SIZE_MERIT 100      # Base merit when size is *not* used
+DEFAULT_BONUS 1          # The bonus an organism gets before it has completed any tasks
+MERIT_TIME 0             # 0 = Merit Calculated when task completed
+                         # 1 = Merit Calculated on Divide
+MERIT_GIVEN  0.0     # Fraction of merit donated with 'donate' command
+MERIT_RECEIVED 0.0     # Multiplier of merit given with 'donate' command
+MAX_DONATE_KIN_DIST -1   # Limit on distance of relation for donate; -1=no max
+MAX_DONATE_EDIT_DIST -1  # Limit on genetic (edit) distance for donate; -1=no max
+MAX_DONATES 1000000           # Limit on number of donates organisms are allowed.
+
+### Geneology ###
+TRACK_MAIN_LINEAGE 0  # Keep all ancestors of the active population?
+                      # 0=no, 1=yes, 2=yes,w/sexual population
+THRESHOLD 3           # Number of organisms in a genotype needed for it
+                      #   to be considered viable.
+GENOTYPE_PRINT 0      # 0/1 (off/on) Print out all threshold genotypes?
+GENOTYPE_PRINT_DOM 0  # Print out a genotype if it stays dominant for
+                      #   this many updates. (0 = off)
+SPECIES_THRESHOLD 2   # max failure count for organisms to be same species
+SPECIES_RECORDING 0   # 1 = full, 2 = limited search (parent only)
+SPECIES_PRINT 0       # 0/1 (off/on) Print out all species?
+TEST_CPU_TIME_MOD 20  # Time allocated in test CPUs (multiple of length)
+
+### Log Files ###
+LOG_CREATURES 0  # 0/1 (off/on) toggle to print file.
+LOG_GENOTYPES 0  # 0 = off, 1 = print ALL, 2 = print threshold ONLY.
+LOG_THRESHOLD 0  # 0/1 (off/on) toggle to print file.
+LOG_SPECIES 0    # 0/1 (off/on) toggle to print file.
+LOG_LANDSCAPE 0  # 0/1 (off/on) toggle to print file.
+
+### Viewer Settings ###
+VIEW_MODE 0  # Initial viewer screen
+
+### Lineage ###
+# NOTE: This should probably be called "Clade"
+# This one can slow down avida a lot. It is used to get an idea of how
+# often an advantageous mutation arises, and where it goes afterwards.
+# Lineage creation options are.  Works only when LOG_LINEAGES is set to 1.
+#   0 = manual creation (on inject, use successive integers as lineage labels).
+#   1 = when a child's (potential) fitness is higher than that of its parent.
+#   2 = when a child's (potential) fitness is higher than max in population.
+#   3 = when a child's (potential) fitness is higher than max in dom. lineage
+# *and* the child is in the dominant lineage, or (2)
+#   4 = when a child's (potential) fitness is higher than max in dom. lineage
+# (and that of its own lineage)
+#   5 = same as child's (potential) fitness is higher than that of the
+#       currently dominant organism, and also than that of any organism
+#       currently in the same lineage.
+#   6 = when a child's (potential) fitness is higher than any organism
+#       currently in the same lineage.
+#   7 = when a child's (potential) fitness is higher than that of any
+#       organism in its line of descent
+LOG_LINEAGES 0             # 
+LINEAGE_CREATION_METHOD 0  # 

Added: development/tests/shaded_green_beard_instructions/config/envZeroResources.cfg
===================================================================
--- development/tests/shaded_green_beard_instructions/config/envZeroResources.cfg	                        (rev 0)
+++ development/tests/shaded_green_beard_instructions/config/envZeroResources.cfg	2009-05-20 13:09:38 UTC (rev 3247)
@@ -0,0 +1,24 @@
+##############################################################################
+#
+# This is the setup file for the task/resource system.  From here, you can
+# setup the available resources (including their inflow and outflow rates) as
+# well as the reactions that the organisms can trigger by performing tasks.
+#
+# This file is currently setup to reward 9 tasks, all of which use the
+# "infinite" resource, which is undepletable.
+#
+# For information on how to use this file, see:  doc/environment.html
+# For other sample environments, see:  source/support/config/ 
+#
+##############################################################################
+
+REACTION  NOT  not   process:value=0.0:type=pow  requisite:max_count=1
+REACTION  NAND nand  process:value=0.0:type=pow  requisite:max_count=1
+REACTION  AND  and   process:value=0.0:type=pow  requisite:max_count=1
+REACTION  ORN  orn   process:value=0.0:type=pow  requisite:max_count=1
+REACTION  OR   or    process:value=0.0:type=pow  requisite:max_count=1
+REACTION  ANDN andn  process:value=0.0:type=pow  requisite:max_count=1
+REACTION  NOR  nor   process:value=0.0:type=pow  requisite:max_count=1
+REACTION  XOR  xor   process:value=0.0:type=pow  requisite:max_count=1
+REACTION  EQU  equ   process:value=0.0:type=pow  requisite:max_count=1
+

Added: development/tests/shaded_green_beard_instructions/config/eventsFullPopTest.cfg
===================================================================
--- development/tests/shaded_green_beard_instructions/config/eventsFullPopTest.cfg	                        (rev 0)
+++ development/tests/shaded_green_beard_instructions/config/eventsFullPopTest.cfg	2009-05-20 13:09:38 UTC (rev 3247)
@@ -0,0 +1,40 @@
+  #############################################################################
+#
+# This is the setup file for the events system.  From here, you can
+# configure any actions that you want to have happen during the course of
+# an experiment, including setting the times for data collection.
+#
+# basic syntax:  [trigger]  [start:interval:stop]  [event] [arguments...]
+#
+# This file is currently setup to start off a population full of the 
+# starting organism specified in genesis, and then record key information
+# every 100 updates.
+#
+# For information on how to use this file, see:  doc/events.html
+# For other sample event configurations, see:  source/support/config/
+#
+##############################################################################
+
+# Print all of the standard data files...
+u 0 inject_all organism.sexDefault
+u 0:100 print_dom                 # Save the most abundant genotypes
+u 0:100:end print_average_data    # Save info about they average genotypes
+u 0:100:end print_dominant_data   # Save info about most abundant genotypes
+u 0:100:end print_stats_data      # Collect satistics about entire pop.
+u 0:100:end print_count_data      # Count organisms, genotypes, species, etc.
+u 0:100:end print_tasks_data      # Save organisms counts for each task.
+u 0:100:end print_time_data       # Track time conversion (generations, etc.)
+u 0:100:end print_resource_data   # Track resource abundance.
+u 100:100:end print_instruction_data
+u 100:100:end print_donation_stats
+u 100:100:end PrintShadedAltruists
+
+# A few data files not printed by default
+# u 100:100:end print_error_data      # Std. Error on averages.
+# u 100:100:end print_variance_data   # Variance on averages.
+# u 100:100:end print_totals_data     # Total counts over entire run.
+# u 100:100:end print_tasks_exe_data  # Num. times tasks have been executed.
+
+# Setup the exit time and full population data collection.
+u 100 exit                      # exit
+

Added: development/tests/shaded_green_beard_instructions/config/inst_set.SexDonateGbshadedEdtKinRndNopx
===================================================================
--- development/tests/shaded_green_beard_instructions/config/inst_set.SexDonateGbshadedEdtKinRndNopx	                        (rev 0)
+++ development/tests/shaded_green_beard_instructions/config/inst_set.SexDonateGbshadedEdtKinRndNopx	2009-05-20 13:09:38 UTC (rev 3247)
@@ -0,0 +1,73 @@
+nop-A      1   # a
+nop-B      1   # b
+nop-C      1   # c
+if-n-equ   1   # d
+if-less    1   # e
+pop        1   # f
+push       1   # g
+swap-stk   1   # h
+swap       1   # i 
+shift-r    1   # j
+shift-l    1   # k
+inc        1   # l
+dec        1   # m
+add        1   # n
+sub        1   # o
+nand       1   # p
+IO         1   # q   Puts current contents of register and gets new.
+h-alloc    1   # r   Allocate as much memory as organism can use.
+divide-sex 1   # s   Use a sexual divide
+h-copy     1   # t   Combine h-read and h-write
+h-search   1   # u   Search for matching template, set flow head & return info
+               #   #   if no template, move flow-head here, set size&offset=0.
+mov-head   1   # v   Move ?IP? head to flow control.
+jmp-head   1   # w   Move ?IP? head by fixed amount in CX.  Set old pos in CX.
+get-head   1   # x   Get position of specified head in CX.
+if-label   1   # y
+set-flow   1   # z   Move flow-head to address in ?CX? 
+
+donate-threshgb 1
+donate-shadedgb 1
+donate-edt 1
+donate-kin 1
+donate-rnd  1	
+nop-X       1
+#donate-NUL  1 #donates to a black hole. used in many pre-nature-rewrite runs
+
+#adv-head   1
+#jump-f     1
+#jump-b     1
+#call       1
+#return     1
+#if-bit-1   1
+#get        1
+#put        1
+#h-read     1
+#h-write    1
+#set-head   1
+#search-f   1
+#search-b   1
+
+
+# Works on multiple nops:  pop  push  inc  dec  IO  adv-head 
+
+# What if we add a new head.  Search will return the location of something,
+# and put the new head there.  Then set-head will move another head to that
+# point.  In the case of the copy loop, it only needs to be set once and
+# this will speed up the code quite a bit!
+
+# Search with no template returns current position (abs line number) in
+# genome.
+
+
+
+
+
+
+
+
+
+
+
+
+

Added: development/tests/shaded_green_beard_instructions/config/organism.sexDefault
===================================================================
--- development/tests/shaded_green_beard_instructions/config/organism.sexDefault	                        (rev 0)
+++ development/tests/shaded_green_beard_instructions/config/organism.sexDefault	2009-05-20 13:09:38 UTC (rev 3247)
@@ -0,0 +1,100 @@
+h-alloc    # Allocate space for child
+h-search   # Locate the end of the organism
+nop-C      #
+nop-A      #
+mov-head   # Place write-head at beginning of offspring.
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+donate-threshgb 
+donate-shadedgb 
+donate-edt 
+donate-kin 
+donate-rnd  	
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+h-search   # Mark the beginning of the copy loop
+h-copy     # Do the copy
+if-label   # If we're done copying....
+nop-C      #
+nop-A      #
+divide-sex #    ...divide!
+mov-head   # Otherwise, loop back to the beginning of the copy loop.
+nop-A      # End label.
+nop-B      #

Added: development/tests/shaded_green_beard_instructions/expected/data/archive/100-aaaaa.org
===================================================================
--- development/tests/shaded_green_beard_instructions/expected/data/archive/100-aaaaa.org	                        (rev 0)
+++ development/tests/shaded_green_beard_instructions/expected/data/archive/100-aaaaa.org	2009-05-20 13:09:38 UTC (rev 3247)
@@ -0,0 +1,134 @@
+# Tue May 19 17:13:45 2009
+# Filename........: archive/100-aaaaa.org
+# Update Output...: 100
+# Is Viable.......: 1
+# Repro Cycle Size: 0
+# Depth to Viable.: 0
+# Update Created..: -1
+# Genotype ID.....: 1
+# Parent Gen ID...: -1
+# Tree Depth......: 0
+# Parent Distance.: -1
+# 
+# Generation: 0
+# Merit...........: 97.000000
+# Gestation Time..: 389
+# Fitness.........: 0.249357
+# Errors..........: 0
+# Genome Size.....: 100
+# Copied Size.....: 100
+# Executed Size...: 97
+# Offspring.......: SELF
+# 
+# Tasks Performed:
+# not 0 (0.000000)
+# nand 0 (0.000000)
+# and 0 (0.000000)
+# orn 0 (0.000000)
+# or 0 (0.000000)
+# andn 0 (0.000000)
+# nor 0 (0.000000)
+# xor 0 (0.000000)
+# equ 0 (0.000000)
+
+
+h-alloc
+h-search
+nop-C
+nop-A
+mov-head
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+donate-threshgb
+donate-shadedgb
+donate-edt
+donate-kin
+donate-rnd
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+nop-C
+h-search
+h-copy
+if-label
+nop-C
+nop-A
+divide-sex
+mov-head
+nop-A
+nop-B

Added: development/tests/shaded_green_beard_instructions/expected/data/average.dat
===================================================================
--- development/tests/shaded_green_beard_instructions/expected/data/average.dat	                        (rev 0)
+++ development/tests/shaded_green_beard_instructions/expected/data/average.dat	2009-05-20 13:09:38 UTC (rev 3247)
@@ -0,0 +1,21 @@
+# Avida Average Data
+# Tue May 19 17:13:43 2009
+#  1: Update
+#  2: Merit
+#  3: Gestation Time
+#  4: Fitness
+#  5: Repro Rate?
+#  6: Size
+#  7: Copied Size
+#  8: Executed Size
+#  9: Abundance
+# 10: Proportion of organisms that gave birth in this update
+# 11: Proportion of Breed True Organisms
+# 12: Genotype Depth
+# 13: Generation
+# 14: Neutral Metric
+# 15: Lineage Label
+# 16: True Replication Rate (based on births/update, time-averaged)
+
+0 97.000000 389.000000 0.249357 0.000000 100.000000 100.000000 97.000000 1.000000 101.000000 101.000000 0.000000 0.000000 0.000000 0.000000 0.000000 
+100 217.423 389.71 0.247148 0 100 100 95.75 1.21951 0.12 0.1 1.95 7.64 -0.346786 0 0 

Added: development/tests/shaded_green_beard_instructions/expected/data/count.dat
===================================================================
--- development/tests/shaded_green_beard_instructions/expected/data/count.dat	                        (rev 0)
+++ development/tests/shaded_green_beard_instructions/expected/data/count.dat	2009-05-20 13:09:38 UTC (rev 3247)
@@ -0,0 +1,21 @@
+# Avida count data
+# Tue May 19 17:13:43 2009
+#  1: update
+#  2: number of insts executed this update
+#  3: number of organisms
+#  4: number of different genotypes
+#  5: number of different threshold genotypes
+#  6: number of different species
+#  7: number of different threshold species
+#  8: number of different lineages
+#  9: number of births in this update
+# 10: number of deaths in this update
+# 11: number of breed true
+# 12: number of breed true organisms?
+# 13: number of no-birth organisms
+# 14: number of single-threaded organisms
+# 15: number of multi-threaded organisms
+# 16: number of modified organisms
+
+0 30 1 1 1 0 0 0 101 1 101 1 1 1 0 0 
+100 2970 100 82 8 0 0 0 12 11 10 61 65 100 0 0 

Added: development/tests/shaded_green_beard_instructions/expected/data/dominant.dat
===================================================================
--- development/tests/shaded_green_beard_instructions/expected/data/dominant.dat	                        (rev 0)
+++ development/tests/shaded_green_beard_instructions/expected/data/dominant.dat	2009-05-20 13:09:38 UTC (rev 3247)
@@ -0,0 +1,21 @@
+# Avida Dominant Data
+# Tue May 19 17:13:43 2009
+#  1: Update
+#  2: Average Merit of the Dominant Genotype
+#  3: Average Gestation Time of the Dominant Genotype
+#  4: Average Fitness of the Dominant Genotype
+#  5: Repro Rate?
+#  6: Size of Dominant Genotype
+#  7: Copied Size of Dominant Genotype
+#  8: Executed Size of Dominant Genotype
+#  9: Abundance of Dominant Genotype
+# 10: Number of Births
+# 11: Number of Dominant Breed True?
+# 12: Dominant Gene Depth
+# 13: Dominant Breed In
+# 14: Max Fitness?
+# 15: Genotype ID of Dominant Genotype
+# 16: Name of the Dominant Genotype
+
+0 0.000000 0.000000 0.000000 0.000000 100 0.000000 0.000000 1 0 0 0 0 0.249357 1 100-aaaaa 
+100 97 389 0.249357 0.00257069 100 100 97 11 2 0 0 0 0.255579 1 100-aaaaa 

Added: development/tests/shaded_green_beard_instructions/expected/data/donations.dat
===================================================================
--- development/tests/shaded_green_beard_instructions/expected/data/donations.dat	                        (rev 0)
+++ development/tests/shaded_green_beard_instructions/expected/data/donations.dat	2009-05-20 13:09:38 UTC (rev 3247)
@@ -0,0 +1,20 @@
+# Info about organisms giving donations in the population
+# Tue May 19 17:13:45 2009
+#  1: update
+#  2: parent made at least one donation
+#  3: parent received at least one donation
+#  4: parent received at least one donation but did not make one
+#  5: parent made at least one edit_donation
+#  6: parent received at least one edit_donation
+#  7: parent received at least one edit_donation but did not make one
+#  8: parent made at least one kin_donation
+#  9: parent received at least one kin_donation
+# 10: parent received at least one kin_donation but did not make one
+# 11: parent made at least one threshgb_donation
+# 12: parent received at least one threshgb_donation
+# 13: parent received at least one threshgb_donation but did not make one
+# 14: parent made at least one quanta_threshgb_donation
+# 15: parent received at least one quanta_threshgb_donation
+# 16: parent received at least one quanta_threshgb_donation but did not make one
+
+100 100.000000 100.000000 0.000000 95.000000 81.000000 5.000000 95.000000 80.000000 2.000000 97.000000 0.000000 0.000000 0.000000 0.000000 0.000000 

Added: development/tests/shaded_green_beard_instructions/expected/data/instruction.dat
===================================================================
--- development/tests/shaded_green_beard_instructions/expected/data/instruction.dat	                        (rev 0)
+++ development/tests/shaded_green_beard_instructions/expected/data/instruction.dat	2009-05-20 13:09:38 UTC (rev 3247)
@@ -0,0 +1,37 @@
+# Avida instruction execution data
+# Tue May 19 17:13:45 2009
+#  1: Update
+#  2: nop-A
+#  3: nop-B
+#  4: nop-C
+#  5: if-n-equ
+#  6: if-less
+#  7: pop
+#  8: push
+#  9: swap-stk
+# 10: swap
+# 11: shift-r
+# 12: shift-l
+# 13: inc
+# 14: dec
+# 15: add
+# 16: sub
+# 17: nand
+# 18: IO
+# 19: h-alloc
+# 20: divide-sex
+# 21: h-copy
+# 22: h-search
+# 23: mov-head
+# 24: jmp-head
+# 25: get-head
+# 26: if-label
+# 27: set-flow
+# 28: donate-threshgb
+# 29: donate-shadedgb
+# 30: donate-edt
+# 31: donate-kin
+# 32: donate-rnd
+# 33: nop-X
+
+100 89 5 7638 1 2 4 3 5 4 9 3 10 6 4 5 12 16 100 100 10000 209 9999 0 16 10003 0 104 101 98 102 106 7 

Added: development/tests/shaded_green_beard_instructions/expected/data/resource.dat
===================================================================
--- development/tests/shaded_green_beard_instructions/expected/data/resource.dat	                        (rev 0)
+++ development/tests/shaded_green_beard_instructions/expected/data/resource.dat	2009-05-20 13:09:38 UTC (rev 3247)
@@ -0,0 +1,8 @@
+# Avida resource data
+# Tue May 19 17:13:43 2009
+# First column gives the current update, all further columns give the quantity
+# of the particular resource at that update.
+#  1: Update
+
+0 
+100 

Added: development/tests/shaded_green_beard_instructions/expected/data/shadedaltruists.dat
===================================================================
--- development/tests/shaded_green_beard_instructions/expected/data/shadedaltruists.dat	                        (rev 0)
+++ development/tests/shaded_green_beard_instructions/expected/data/shadedaltruists.dat	2009-05-20 13:09:38 UTC (rev 3247)
@@ -0,0 +1,20 @@
+# The number of organisms in different bins of shaded altruism
+# Bins of orgs of shaded strategies.
+# Tue May 19 17:13:45 2009
+#  1: Update [update]
+#  2: Population [population]
+#  3: shaded-100 [shaded100]
+#  4: shaded-90 [shaded90]
+#  5: shaded-80 [shaded80]
+#  6: shaded-70 [shaded70]
+#  7: shaded-60 [shaded60]
+#  8: shaded-50 [shaded50]
+#  9: shaded-40 [shaded40]
+# 10: shaded-30 [shaded30]
+# 11: shaded-20 [shaded20]
+# 12: shaded-10 [shaded10]
+# 13: shaded-0 [shaded0]
+# 14: percent-high-alt [highalt]
+# 15: avg-shade [avgshade]
+
+100 100 0 0 0 0 0 0 0 0 0 0 0 0.000000 0.000000 

Added: development/tests/shaded_green_beard_instructions/expected/data/stats.dat
===================================================================
--- development/tests/shaded_green_beard_instructions/expected/data/stats.dat	                        (rev 0)
+++ development/tests/shaded_green_beard_instructions/expected/data/stats.dat	2009-05-20 13:09:38 UTC (rev 3247)
@@ -0,0 +1,17 @@
+# Generic Statistics Data
+# Tue May 19 17:13:43 2009
+#  1: update
+#  2: average inferiority (energy)
+#  3: ave probability of any mutations in genome
+#  4: probability of any mutations in dom genome
+#  5: log(average fidelity)
+#  6: log(dominant fidelity)
+#  7: change in number of genotypes
+#  8: genotypic entropy
+#  9: species entropy
+# 10: depth of most reacent coalescence
+# 11: Total number of resamplings this generation
+# 12: Total number of organisms that failed to resample this generation
+
+0 0.000000 0.517712 0.517712 0.729215 0.729215 1 0.000000 0.000000 0 0 0 
+100 0.00890043 0.517712 0.517712 0.729215 0.729215 2 4.22527 0 0 0 0 

Added: development/tests/shaded_green_beard_instructions/expected/data/tasks.dat
===================================================================
--- development/tests/shaded_green_beard_instructions/expected/data/tasks.dat	                        (rev 0)
+++ development/tests/shaded_green_beard_instructions/expected/data/tasks.dat	2009-05-20 13:09:38 UTC (rev 3247)
@@ -0,0 +1,17 @@
+# Avida tasks data
+# Tue May 19 17:13:43 2009
+# First column gives the current update, next columns give the number
+# of organisms that have the particular task as a component of their merit
+#  1: Update
+#  2: Not
+#  3: Nand
+#  4: And
+#  5: OrNot
+#  6: Or
+#  7: AndNot
+#  8: Nor
+#  9: Xor
+# 10: Equals
+
+0 0 0 0 0 0 0 0 0 0 
+100 0 0 0 0 0 0 0 0 0 

Added: development/tests/shaded_green_beard_instructions/expected/data/time.dat
===================================================================
--- development/tests/shaded_green_beard_instructions/expected/data/time.dat	                        (rev 0)
+++ development/tests/shaded_green_beard_instructions/expected/data/time.dat	2009-05-20 13:09:38 UTC (rev 3247)
@@ -0,0 +1,9 @@
+# Avida time data
+# Tue May 19 17:13:43 2009
+#  1: update
+#  2: avida time
+#  3: average generation
+#  4: num_executed?
+
+0 0.000000 0.000000 30 
+100 0.471271 7.64 2970 

Added: development/tests/shaded_green_beard_instructions/test_list
===================================================================
--- development/tests/shaded_green_beard_instructions/test_list	                        (rev 0)
+++ development/tests/shaded_green_beard_instructions/test_list	2009-05-20 13:09:38 UTC (rev 3247)
@@ -0,0 +1,37 @@
+;--- Begin Test Configuration File (test_list) ---
+[main]
+; Command line arguments to pass to the application
+args = -s 1 -c avida.cfg -set INST_SET inst_set.SexDonateGbshadedEdtKinRndNopx -set MERIT_GIVEN 5 -set MERIT_RECEIVED 50 -set MAX_DONATE_KIN_DIST 1 -set MAX_DONATE_EDIT_DIST 15 -set MIN_GB_DONATE_THRESHOLD 80 -set MAX_DONATES 100 -set PRECALC_PHENOTYPE 4 -set BIRTH_METHOD 0
+
+app = %(default_app)s
+nonzeroexit = disallow   ; Exit code handling (disallow, allow, or require)
+                         ;  disallow - treat non-zero exit codes as failures
+                         ;  allow - all exit codes are acceptable
+                         ;  require - treat zero exit codes as failures, useful
+                         ;            for creating tests for app error checking
+createdby = heather goldsby; Who created the test
+email = hjg at msu.edu ; Email address for the test's creator
+
+[consistency]
+enabled = yes            ; Is this test a consistency test?
+long = no                ; Is this test a long test?
+
+[performance]
+enabled = no             ; Is this test a performance test?
+long = no                ; Is this test a long test?
+
+; The following variables can be used in constructing setting values by calling
+; them with %(variable_name)s.  For example see 'app' above.
+;
+; app 
+; builddir 
+; cpus 
+; mode 
+; perf_repeat 
+; perf_user_margin 
+; perf_wall_margin 
+; svn 
+; svnmetadir 
+; svnversion 
+; testdir 
+;--- End Test Configuration File ---




More information about the Avida-cvs mailing list