[Avida-SVN] r2963 - in branches/hjg-dev/source: cpu main

hjg at myxo.css.msu.edu hjg at myxo.css.msu.edu
Sun Nov 23 12:23:02 PST 2008


Author: hjg
Date: 2008-11-23 15:23:02 -0500 (Sun, 23 Nov 2008)
New Revision: 2963

Modified:
   branches/hjg-dev/source/cpu/cHardwareCPU.cc
   branches/hjg-dev/source/cpu/cHardwareCPU.h
   branches/hjg-dev/source/main/cPhenotype.cc
   branches/hjg-dev/source/main/cPhenotype.h
   branches/hjg-dev/source/main/cPopulation.cc
Log:
Added a shaded green bearding instruction

Modified: branches/hjg-dev/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/hjg-dev/source/cpu/cHardwareCPU.cc	2008-11-22 22:39:54 UTC (rev 2962)
+++ branches/hjg-dev/source/cpu/cHardwareCPU.cc	2008-11-23 20:23:02 UTC (rev 2963)
@@ -220,6 +220,7 @@
     tInstLibEntry<tMethod>("donate-edt", &cHardwareCPU::Inst_DonateEditDist, nInstFlag::STALL),
     tInstLibEntry<tMethod>("donate-gbg",  &cHardwareCPU::Inst_DonateGreenBeardGene, nInstFlag::STALL),
     tInstLibEntry<tMethod>("donate-tgb",  &cHardwareCPU::Inst_DonateTrueGreenBeard, nInstFlag::STALL),
+		tInstLibEntry<tMethod>("donate-shadedgb",  &cHardwareCPU::Inst_DonateShadedGreenBeard, nInstFlag::STALL),
     tInstLibEntry<tMethod>("donate-threshgb",  &cHardwareCPU::Inst_DonateThreshGreenBeard, nInstFlag::STALL),
     tInstLibEntry<tMethod>("donate-quantagb",  &cHardwareCPU::Inst_DonateQuantaThreshGreenBeard, nInstFlag::STALL),
     tInstLibEntry<tMethod>("donate-NUL", &cHardwareCPU::Inst_DonateNULL, nInstFlag::STALL),
@@ -3370,6 +3371,9 @@
   return true;
 }
 
+/* Execute the actual donation. Subtracting merit from the donator
+ and adding merit to the reciever */
+
 void cHardwareCPU::DoDonate(cOrganism* to_org)
 {
   assert(to_org != NULL);
@@ -3636,6 +3640,89 @@
   
 }
 
+
+/* 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 = organism->GetPhenotype();
+	
+	// Determine if this organism is below the threshold and thus eligible to donate.
+  if (organism->GetPhenotype().GetCurNumDonates() > m_world->GetConfig().MAX_DONATES.Get()) {
+    return false;
+  }
+	
+	// Identify how many green beard donations the parent of this organism made
+	int shade_of_gb = phenotype.GetNumShadedGbDonationsLast();
+	
+	// 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 = 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++) organism->Rotate(1);
+  cOrganism * neighbor = 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 = organism->GetNeighbor();
+		//if neighbor exists, AND if their parent attempted to donate >= shaded of green beard,
+		if (neighbor != NULL && neighbor->GetPhenotype().GetNumShadedGbDonationsLast()>=  shade_of_gb) {
+			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-shadedgb, 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;
+		}
+		
+		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++) 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
@@ -7122,3 +7209,4 @@
 	}
 	return true;
 }
+

Modified: branches/hjg-dev/source/cpu/cHardwareCPU.h
===================================================================
--- branches/hjg-dev/source/cpu/cHardwareCPU.h	2008-11-22 22:39:54 UTC (rev 2962)
+++ branches/hjg-dev/source/cpu/cHardwareCPU.h	2008-11-23 20:23:02 UTC (rev 2963)
@@ -474,6 +474,7 @@
   bool Inst_KillFacedCellEvent(cAvidaContext& ctx);
   bool Inst_CollectCellDataAndKillEvent(cAvidaContext& ctx);
 
+	// Perform the actual donation
   void DoDonate(cOrganism * to_org);
   void DoEnergyDonate(cOrganism* to_org);
   bool Inst_DonateRandom(cAvidaContext& ctx);
@@ -481,6 +482,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: branches/hjg-dev/source/main/cPhenotype.cc
===================================================================
--- branches/hjg-dev/source/main/cPhenotype.cc	2008-11-22 22:39:54 UTC (rev 2962)
+++ branches/hjg-dev/source/main/cPhenotype.cc	2008-11-23 20:23:02 UTC (rev 2963)
@@ -176,10 +176,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;
+  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;
@@ -194,6 +198,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;      
@@ -332,11 +338,14 @@
   neutral_metric  = parent_phenotype.neutral_metric + m_world->GetRandom().GetRandNormal();
   life_fitness    = fitness; 
 
+	
   num_thresh_gb_donations = 0;
   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_quanta_thresh_gb_donations_last = parent_phenotype.num_quanta_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;
@@ -357,6 +366,8 @@
   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_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;
@@ -371,6 +382,8 @@
   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_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;
@@ -474,6 +487,8 @@
   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;
@@ -495,6 +510,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;
@@ -509,6 +526,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;
@@ -613,6 +632,8 @@
   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;
@@ -634,6 +655,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;
@@ -648,6 +671,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;
@@ -761,7 +786,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;
@@ -782,6 +809,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;
@@ -796,6 +825,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;
@@ -903,6 +934,8 @@
   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;
@@ -925,6 +958,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;
@@ -939,6 +974,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;
@@ -1364,6 +1401,8 @@
   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;
@@ -1385,6 +1424,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;
@@ -1399,6 +1440,9 @@
   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;

Modified: branches/hjg-dev/source/main/cPhenotype.h
===================================================================
--- branches/hjg-dev/source/main/cPhenotype.h	2008-11-22 22:39:54 UTC (rev 2962)
+++ branches/hjg-dev/source/main/cPhenotype.h	2008-11-23 20:23:02 UTC (rev 2963)
@@ -180,10 +180,14 @@
   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? 
   int num_thresh_gb_donations;  // Num times this organism threshgb_donated (thresh green beard)? 
   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?
@@ -198,6 +202,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?
@@ -344,6 +350,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; }
@@ -363,6 +371,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 IsReceiver() const { assert(initialized == true); return is_receiver; }
   bool IsReceiverLast() const { assert(initialized == true); return is_receiver_last; }
   bool IsReceiverRand() const { assert(initialized == true); return is_receiver_rand; }
@@ -377,6 +387,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; }
@@ -425,6 +437,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; } 
@@ -432,6 +445,7 @@
   void SetIsReceiverGbg() { SetIsReceiver(); is_receiver_gbg = true; } 
   void SetIsReceiverTrueGb() { SetIsReceiver(); is_receiver_truegb = true; } 
   void SetIsReceiverThreshGb() { SetIsReceiver(); is_receiver_threshgb = true; } 
+  void SetIsReceiverShadedGb() { SetIsReceiver(); is_receiver_shadedgb = true; } 	
   void SetIsReceiverQuantaThreshGb() { SetIsReceiver(); is_receiver_quanta_threshgb = true; } 
   
   void SetCurBonus(double _bonus) { cur_bonus = _bonus; }
@@ -441,6 +455,7 @@
   void DecCurInstCount(int _inst_num)  { assert(initialized == true); cur_inst_count[_inst_num]--; } 
   
   void IncNumThreshGbDonations() { assert(initialized == true); num_thresh_gb_donations++; }
+  void IncNumShadedGbDonations() { assert(initialized == true); num_shaded_gb_donations++; }	
   void IncNumQuantaThreshGbDonations() { assert(initialized == true); num_quanta_thresh_gb_donations++; }
 
   void IncAge()      { assert(initialized == true); age++; }

Modified: branches/hjg-dev/source/main/cPopulation.cc
===================================================================
--- branches/hjg-dev/source/main/cPopulation.cc	2008-11-22 22:39:54 UTC (rev 2962)
+++ branches/hjg-dev/source/main/cPopulation.cc	2008-11-23 20:23:02 UTC (rev 2963)
@@ -2338,6 +2338,10 @@
   cDoubleSum quanta_threshgb_donation_makers;
   cDoubleSum quanta_threshgb_donation_receivers;
   cDoubleSum quanta_threshgb_donation_cheaters;
+	
+  cDoubleSum shadedgb_donation_makers;
+  cDoubleSum shadedgb_donation_receivers;
+  cDoubleSum shadedgb_donation_cheaters;
   
   cStats& stats = m_world->GetStats();
   
@@ -2397,7 +2401,18 @@
         quanta_threshgb_donation_cheaters.Add(1);                             //found a quanta threshgb receiver whose parent did...
       }                                                              //...not make a quanta threshgb donation
     }
+		
+		// shadedgb donors & receivers
+    if (phenotype.IsDonorShadedGbLast()) shadedgb_donation_makers.Add(1); //found a shadedgb donor
+    if (phenotype.IsReceiverShadedGbLast()){
+      shadedgb_donation_receivers.Add(1);                              //found a shadedgb receiver
+      if (phenotype.IsDonorShadedGbLast()==0){
+        shadedgb_donation_cheaters.Add(1);                             //found a shadedgb receiver whose parent did...
+      }                                                              //...not make a shadedgb donation
+    }
     
+   
+		
   }
   
   dn_donors.Write(donation_makers.Sum(), "parent made at least one donation");
@@ -2415,6 +2430,9 @@
   dn_donors.Write(quanta_threshgb_donation_makers.Sum(), "parent made at least one quanta_threshgb_donation");
   dn_donors.Write(quanta_threshgb_donation_receivers.Sum(), "parent received at least one quanta_threshgb_donation");
   dn_donors.Write(quanta_threshgb_donation_cheaters.Sum(),  "parent received at least one quanta_threshgb_donation but did not make one");
+	dn_donors.Write(shadedgb_donation_makers.Sum(), "parent made at least one shadedgb_donation");
+  dn_donors.Write(shadedgb_donation_receivers.Sum(), "parent received at least one shadedgb_donation");
+  dn_donors.Write(shadedgb_donation_cheaters.Sum(),  "parent received at least one shadedgb_donation but did not make one");
   
   dn_donors.Endl();
 }




More information about the Avida-cvs mailing list