[Avida-cvs] [avida-svn] r525 - in branches/jeffdev/source: cpu main

jclune@myxo.css.msu.edu jclune at myxo.css.msu.edu
Fri Mar 24 13:18:44 PST 2006


Author: jclune
Date: 2006-03-24 16:18:38 -0500 (Fri, 24 Mar 2006)
New Revision: 525

Modified:
   branches/jeffdev/source/cpu/cHardwareCPU.cc
   branches/jeffdev/source/cpu/cHardwareCPU.h
   branches/jeffdev/source/main/cConfig.cc
   branches/jeffdev/source/main/cConfig.h
   branches/jeffdev/source/main/cPhenotype.cc
   branches/jeffdev/source/main/cPhenotype.h
   branches/jeffdev/source/main/cPopulation.cc
Log:
Changed all donation instructions to only count a donation attempts below max_donates. Also added quanta_donate.

Modified: branches/jeffdev/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/jeffdev/source/cpu/cHardwareCPU.cc	2006-03-24 13:02:33 UTC (rev 524)
+++ branches/jeffdev/source/cpu/cHardwareCPU.cc	2006-03-24 21:18:38 UTC (rev 525)
@@ -214,6 +214,7 @@
     cInstEntryCPU("donate-gbg",  &cHardwareCPU::Inst_DonateGreenBeardGene),
     cInstEntryCPU("donate-tgb",  &cHardwareCPU::Inst_DonateTrueGreenBeard),
     cInstEntryCPU("donate-threshgb",  &cHardwareCPU::Inst_DonateThreshGreenBeard),
+    cInstEntryCPU("donate-quantagb",  &cHardwareCPU::Inst_DonateQuantaThreshGreenBeard),
     cInstEntryCPU("donate-NUL",  &cHardwareCPU::Inst_DonateNULL),
 
     cInstEntryCPU("rotate-l",  &cHardwareCPU::Inst_RotateL),
@@ -2898,13 +2899,15 @@
 bool cHardwareCPU::Inst_DonateRandom()
 {
   cPhenotype & phenotype = organism->GetPhenotype();
-  phenotype.IncDonates();
-  phenotype.SetIsDonorRand();
+  cGenotype * genotype = organism->GetGenotype();
 
   if (phenotype.GetCurNumDonates() > cConfig::GetMaxDonates()) {
     return false;
   }
 
+  phenotype.IncDonates();
+  phenotype.SetIsDonorRand();
+
   // Turn to a random neighbor, get it, and turn back...
   int neighbor_id = g_random.GetInt(organism->GetNeighborhoodSize());
   for (int i = 0; i < neighbor_id; i++) organism->Rotate(1);
@@ -2914,6 +2917,14 @@
   // Donate only if we have found a neighbor.
   if (neighbor != NULL) {
     DoDonate(neighbor);
+    
+    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();
   }
 
@@ -2924,13 +2935,14 @@
 bool cHardwareCPU::Inst_DonateKin()
 {
   cPhenotype & phenotype = organism->GetPhenotype();
-  phenotype.IncDonates();
-  phenotype.SetIsDonorKin();
 
   if (organism->GetPhenotype().GetCurNumDonates() > cConfig::GetMaxDonates()) {
     return false;
   }
 
+  phenotype.IncDonates();
+  phenotype.SetIsDonorKin();
+
   // Find the target as the first Kin found in the neighborhood.
   const int num_neighbors = organism->GetNeighborhoodSize();
 
@@ -2972,13 +2984,14 @@
 bool cHardwareCPU::Inst_DonateEditDist()
 {
   cPhenotype & phenotype = organism->GetPhenotype();
-  phenotype.IncDonates();
-  phenotype.SetIsDonorEdit();
 
   if (organism->GetPhenotype().GetCurNumDonates() > cConfig::GetMaxDonates()) {
     return false;
   }
 
+  phenotype.IncDonates();
+  phenotype.SetIsDonorEdit();
+
   // Find the target as the first Kin found in the neighborhood.
   const int num_neighbors = organism->GetNeighborhoodSize();
 
@@ -3027,13 +3040,14 @@
   //in their genome (see Dawkins 1976, The Selfish Gene, for 
   //the history of the theory and the name 'green beard'
   cPhenotype & phenotype = organism->GetPhenotype();
-  phenotype.IncDonates();
-  phenotype.SetIsDonorGbg();
 
   if (organism->GetPhenotype().GetCurNumDonates() > cConfig::GetMaxDonates()) {
     return false;
   }
 
+  phenotype.IncDonates();
+  phenotype.SetIsDonorGbg();
+
   // Find the target as the first match found in the neighborhood.
 
   //get the neighborhood size
@@ -3101,13 +3115,14 @@
   //the history of the theory and the name 'green beard'
   //  cout << "i am about to donate to a green beard" << endl;
   cPhenotype & phenotype = organism->GetPhenotype();
-  phenotype.IncDonates();
-  phenotype.SetIsDonorTrueGb();
 
   if (organism->GetPhenotype().GetCurNumDonates() > cConfig::GetMaxDonates()) {
     return false;
   }
 
+  phenotype.IncDonates();
+  phenotype.SetIsDonorTrueGb();
+
   // Find the target as the first match found in the neighborhood.
 
   //get the neighborhood size
@@ -3175,14 +3190,16 @@
   //the history of the theory and the name 'green beard'
   //  cout << "i am about to donate to a green beard" << endl;
   cPhenotype & phenotype = organism->GetPhenotype();
-  phenotype.IncDonates();
-  phenotype.SetIsDonorThreshGb();
-  phenotype.IncNumThreshGbDonations();
 
   if (organism->GetPhenotype().GetCurNumDonates() > cConfig::GetMaxDonates()) {
     return false;
   }
 
+
+  phenotype.IncDonates();
+  phenotype.SetIsDonorThreshGb();
+  phenotype.IncNumThreshGbDonations();
+
   // Find the target as the first match found in the neighborhood.
 
   //get the neighborhood size
@@ -3236,7 +3253,7 @@
   if (neighbor != NULL) {
     DoDonate(neighbor);
     neighbor->GetPhenotype().SetIsReceiverThreshGb();
-    cout << "************ neighbor->GetPhenotype().GetNumThreshGbDonationsLast() is " << neighbor->GetPhenotype().GetNumThreshGbDonationsLast() << endl;
+    // cout << "************ neighbor->GetPhenotype().GetNumThreshGbDonationsLast() is " << neighbor->GetPhenotype().GetNumThreshGbDonationsLast() << endl;
     
   }
 
@@ -3245,6 +3262,103 @@
 }
 
 
+bool cHardwareCPU::Inst_DonateQuantaThreshGreenBeard()
+{
+  // this donates to organisms that have this instruction anywhere
+  // in their genome AND their parents excuted it more than a
+  // THRESHOLD number of times where that threshold depend on the
+  // number of times the individual's parents attempted to donate
+  // 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 = organism->GetPhenotype();
+
+  if (phenotype.GetCurNumDonates() > cConfig::GetMaxDonates()) {
+    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 = organism->GetNeighborhoodSize();
+
+  // Turn to face a random neighbor
+  int neighbor_id = g_random.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;
+
+  // Get the quanta (step size) between threshold levels.
+  const int donate_quanta = cConfig::GetDonateThreshQuanta();
+  
+  // 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;
+  cout << " phenotype.GetNumQuantaThreshGbDonationsLast() is " << phenotype.GetNumQuantaThreshGbDonationsLast();
+  cout << " quanta thresh=  " << quanta_donate_thresh;
+  // rotate through orgs in neighborhood  
+  while (neighbor_id < max_id) {
+      neighbor = 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;
+      }
+  
+      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().SetIsReceiverQuantaThreshGb();
+    cout << " ************ neighbor->GetPhenotype().GetNumQuantaThreshGbDonationsLast() is " << neighbor->GetPhenotype().GetNumQuantaThreshGbDonationsLast();
+    
+  }
+
+  return true;
+  
+}
+
+
 bool cHardwareCPU::Inst_DonateNULL()
 {
   cPhenotype & phenotype = organism->GetPhenotype();

Modified: branches/jeffdev/source/cpu/cHardwareCPU.h
===================================================================
--- branches/jeffdev/source/cpu/cHardwareCPU.h	2006-03-24 13:02:33 UTC (rev 524)
+++ branches/jeffdev/source/cpu/cHardwareCPU.h	2006-03-24 21:18:38 UTC (rev 525)
@@ -406,6 +406,7 @@
   bool Inst_DonateGreenBeardGene();
   bool Inst_DonateTrueGreenBeard();
   bool Inst_DonateThreshGreenBeard();
+  bool Inst_DonateQuantaThreshGreenBeard();
   bool Inst_DonateNULL();
 
   bool Inst_SearchF();

Modified: branches/jeffdev/source/main/cConfig.cc
===================================================================
--- branches/jeffdev/source/main/cConfig.cc	2006-03-24 13:02:33 UTC (rev 524)
+++ branches/jeffdev/source/main/cConfig.cc	2006-03-24 21:18:38 UTC (rev 525)
@@ -67,6 +67,7 @@
 int cConfig::max_donate_kin_distance;
 int cConfig::max_donate_edit_distance;
 int cConfig::min_gb_donate_threshold;
+int cConfig::donate_thresh_quanta;
 int cConfig::max_donates;
 int cConfig::num_tasks;
 int cConfig::num_reactions;
@@ -301,6 +302,8 @@
                   "Limit on genetic (edit) distance for donate; -1=no max");
   time_group->Add(min_gb_donate_threshold, "-1", "MIN_GB_DONATE_THRESHOLD",
                   "threshold green beard donates only to orgs above this donation attempt threshold; -1=no thresh");
+  time_group->Add(donate_thresh_quanta, "10", "DONATE_THRESH_QUANTA",
+                  "The size of steps between quanta donate thresholds.");
   time_group->Add(max_donates, "1000000", "MAX_DONATES",
                   "Limit on number of donates organisms are allowed.");
   

Modified: branches/jeffdev/source/main/cConfig.h
===================================================================
--- branches/jeffdev/source/main/cConfig.h	2006-03-24 13:02:33 UTC (rev 524)
+++ branches/jeffdev/source/main/cConfig.h	2006-03-24 21:18:38 UTC (rev 525)
@@ -224,6 +224,7 @@
   static int max_donate_kin_distance;
   static int max_donate_edit_distance;
   static int min_gb_donate_threshold;
+  static int donate_thresh_quanta;
   static int max_donates;
 
   // Methodology
@@ -365,6 +366,7 @@
   static int GetMaxDonateKinDistance() { return max_donate_kin_distance; }
   static int GetMaxDonateEditDistance() { return max_donate_edit_distance; }
   static int GetMinGBDonateTreshold() { return min_gb_donate_threshold; }
+  static int GetDonateThreshQuanta() { return donate_thresh_quanta; }
   static int GetMaxDonates() { return max_donates; }
 
   static int GetNumTasks() { return num_tasks; }

Modified: branches/jeffdev/source/main/cPhenotype.cc
===================================================================
--- branches/jeffdev/source/main/cPhenotype.cc	2006-03-24 13:02:33 UTC (rev 524)
+++ branches/jeffdev/source/main/cPhenotype.cc	2006-03-24 21:18:38 UTC (rev 525)
@@ -134,6 +134,11 @@
   neutral_metric  = parent_phenotype.neutral_metric + g_random.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;
+
   // Setup flags...
   is_injected   = false;
   is_parasite   = false;
@@ -153,18 +158,22 @@
   is_donor_truegb_last = parent_phenotype.is_donor_truegb_last;
   is_donor_threshgb  = false;
   is_donor_threshgb_last = parent_phenotype.is_donor_threshgb_last;
-  num_thresh_gb_donations = 0;
-  num_thresh_gb_donations_last = parent_phenotype.num_thresh_gb_donations_last;
+  is_donor_quanta_threshgb  = false;
+  is_donor_quanta_threshgb_last = parent_phenotype.is_donor_quanta_threshgb_last;
   is_receiver   = false;
   is_receiver_last = parent_phenotype.is_receiver_last;
   is_receiver_rand   = false;
   is_receiver_kin    = false;
+  is_receiver_kin_last    = parent_phenotype.is_receiver_kin_last;
   is_receiver_edit   = false;
+  is_receiver_edit_last    = parent_phenotype.is_receiver_edit_last;
   is_receiver_gbg    = false;
   is_receiver_truegb = false;
   is_receiver_truegb_last = parent_phenotype.is_receiver_truegb_last;
   is_receiver_threshgb = false;
   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_modified   = false;
   is_fertile    = parent_phenotype.last_child_fertile;
@@ -238,6 +247,11 @@
   neutral_metric  = 0;
   life_fitness    = 0; 
 
+  num_thresh_gb_donations = 0;
+  num_thresh_gb_donations_last = 0;
+  num_quanta_thresh_gb_donations = 0;
+  num_quanta_thresh_gb_donations_last = 0;
+
   // Setup flags...
   is_injected   = true;
   is_parasite   = false;
@@ -257,18 +271,22 @@
   is_donor_truegb_last = false;
   is_donor_threshgb = false;
   is_donor_threshgb_last = false;
-  num_thresh_gb_donations = 0;
-  num_thresh_gb_donations_last = 0;
+  is_donor_quanta_threshgb = false;
+  is_donor_quanta_threshgb_last = false;
   is_receiver   = false;
   is_receiver_last   = false;
   is_receiver_rand   = false;
   is_receiver_kin   = false;
+  is_receiver_kin_last   = false;
   is_receiver_edit   = false;
+  is_receiver_edit_last   = false;
   is_receiver_gbg   = false;
   is_receiver_truegb   = false;
   is_receiver_truegb_last   = false;
   is_receiver_threshgb   = false;
   is_receiver_threshgb_last   = false;
+  is_receiver_quanta_threshgb   = false;
+  is_receiver_quanta_threshgb_last   = false;
   is_modifier   = false;
   is_modified   = false;
   is_fertile    = true;
@@ -341,6 +359,11 @@
   (void) neutral_metric;
   life_fitness = fitness; 
 
+  num_thresh_gb_donations_last = num_thresh_gb_donations;
+  num_thresh_gb_donations = 0;
+  num_quanta_thresh_gb_donations_last = num_quanta_thresh_gb_donations;
+  num_quanta_thresh_gb_donations = 0;
+
   // Leave flags alone...
   (void) is_injected;
   (void) is_parasite;
@@ -360,18 +383,22 @@
   is_donor_truegb = false;
   is_donor_threshgb_last = is_donor_threshgb;
   is_donor_threshgb = false;
-  num_thresh_gb_donations_last = num_thresh_gb_donations;
-  num_thresh_gb_donations = 0;
+  is_donor_quanta_threshgb_last = is_donor_quanta_threshgb;
+  is_donor_quanta_threshgb = false;
   is_receiver_last = is_receiver;
   is_receiver = false;
   is_receiver_rand = false;
+  is_receiver_kin_last = is_receiver_kin;
   is_receiver_kin = false;
+  is_receiver_edit_last = is_receiver_edit;
   is_receiver_edit = false;
   is_receiver_gbg = false;
   is_receiver_truegb_last = is_receiver_truegb;
   is_receiver_truegb = false;
   is_receiver_threshgb_last = is_receiver_threshgb;
   is_receiver_threshgb = false;
+  is_receiver_quanta_threshgb_last = is_receiver_quanta_threshgb;
+  is_receiver_quanta_threshgb = false;
   (void) is_modifier;
   (void) is_modified;
   (void) is_fertile;
@@ -454,6 +481,11 @@
   (void) neutral_metric;
   life_fitness = fitness; 
 
+  num_thresh_gb_donations_last = num_thresh_gb_donations;
+  num_thresh_gb_donations = 0;
+  num_quanta_thresh_gb_donations_last = num_quanta_thresh_gb_donations;
+  num_quanta_thresh_gb_donations = 0;
+
   // Leave flags alone...
   (void) is_injected;
   (void) is_parasite;
@@ -473,18 +505,22 @@
   is_donor_truegb = false;
   is_donor_threshgb_last = is_donor_threshgb;
   is_donor_threshgb = false;
-  num_thresh_gb_donations_last = num_thresh_gb_donations;
-  num_thresh_gb_donations = 0;
+  is_donor_quanta_threshgb_last = is_donor_quanta_threshgb;
+  is_donor_quanta_threshgb = false;
   is_receiver_last = is_receiver;
   is_receiver = false;
   is_receiver_rand = false;
+  is_receiver_kin_last = is_receiver_kin;
   is_receiver_kin = false;
+  is_receiver_edit_last = is_receiver_edit;
   is_receiver_edit = false;
   is_receiver_gbg = false;
   is_receiver_truegb_last = is_receiver_truegb;
   is_receiver_truegb = false;
   is_receiver_threshgb_last = is_receiver_threshgb;
   is_receiver_threshgb = false;
+  is_receiver_quanta_threshgb_last = is_receiver_quanta_threshgb;
+  is_receiver_quanta_threshgb = false;
   (void) is_modifier;
   (void) is_modified;
   (void) is_fertile;
@@ -564,6 +600,11 @@
   neutral_metric  = clone_phenotype.neutral_metric + g_random.GetRandNormal();
   life_fitness    = fitness; 
 
+  num_thresh_gb_donations_last = clone_phenotype.num_thresh_gb_donations_last;
+  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;
+
   // Setup flags...
   is_injected   = false;
   is_parasite   = false;
@@ -583,18 +624,22 @@
   is_donor_truegb  = clone_phenotype.is_donor_truegb;
   is_donor_threshgb_last = clone_phenotype.is_donor_threshgb_last;
   is_donor_threshgb  = clone_phenotype.is_donor_threshgb;
-  num_thresh_gb_donations_last = clone_phenotype.num_thresh_gb_donations_last;
-  num_thresh_gb_donations  = clone_phenotype.num_thresh_gb_donations;
+  is_donor_quanta_threshgb_last = clone_phenotype.is_donor_quanta_threshgb_last;
+  is_donor_quanta_threshgb  = clone_phenotype.is_donor_quanta_threshgb;
   is_receiver = clone_phenotype.is_receiver;
   is_receiver_last = clone_phenotype.is_receiver_last;
   is_receiver_rand = clone_phenotype.is_receiver_rand;
   is_receiver_kin = clone_phenotype.is_receiver_kin;
+  is_receiver_kin_last = clone_phenotype.is_receiver_kin_last;
   is_receiver_edit = clone_phenotype.is_receiver_edit;
+  is_receiver_edit_last = clone_phenotype.is_receiver_edit_last;
   is_receiver_gbg = clone_phenotype.is_receiver_gbg;
   is_receiver_truegb = clone_phenotype.is_receiver_truegb;
   is_receiver_truegb_last = clone_phenotype.is_receiver_truegb_last;
   is_receiver_threshgb = clone_phenotype.is_receiver_threshgb;
   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_modifier   = false;
   is_modified   = false;
   is_fertile    = clone_phenotype.last_child_fertile;
@@ -763,19 +808,27 @@
   fp << is_donor_truegb        << " ";
   fp << is_donor_threshgb_last       << " ";
   fp << is_donor_threshgb        << " ";
+  fp << is_donor_quanta_threshgb_last       << " ";
+  fp << is_donor_quanta_threshgb        << " ";
   fp << num_thresh_gb_donations_last       << " ";
   fp << num_thresh_gb_donations        << " ";
+  fp << num_quanta_thresh_gb_donations_last       << " ";
+  fp << num_quanta_thresh_gb_donations        << " ";
 
   fp << is_receiver_last         << " ";
   fp << is_receiver         << " ";
   fp << is_receiver_rand         << " ";
   fp << is_receiver_kin         << " ";
+  fp << is_receiver_kin_last         << " ";
   fp << is_receiver_edit         << " ";
+  fp << is_receiver_edit_last         << " ";
   fp << is_receiver_gbg         << " ";
   fp << is_receiver_truegb_last         << " ";
   fp << is_receiver_truegb         << " ";
   fp << is_receiver_threshgb_last         << " ";
   fp << is_receiver_threshgb         << " ";
+  fp << is_receiver_quanta_threshgb_last         << " ";
+  fp << is_receiver_quanta_threshgb         << " ";
   fp << is_modifier         << " ";
   fp << is_modified         << " ";
   fp << is_fertile          << " ";
@@ -864,18 +917,26 @@
   fp >> is_donor_truegb;
   fp >> is_donor_threshgb_last;
   fp >> is_donor_threshgb;
+  fp >> is_donor_quanta_threshgb_last;
+  fp >> is_donor_quanta_threshgb;
   fp >> num_thresh_gb_donations_last;
   fp >> num_thresh_gb_donations;
+  fp >> num_quanta_thresh_gb_donations_last;
+  fp >> num_quanta_thresh_gb_donations;
   fp >> is_receiver_last;
   fp >> is_receiver;
   fp >> is_receiver_rand;
   fp >> is_receiver_kin;
+  fp >> is_receiver_kin_last;
   fp >> is_receiver_edit;
+  fp >> is_receiver_edit_last;
   fp >> is_receiver_gbg;
   fp >> is_receiver_truegb_last;
   fp >> is_receiver_truegb;
   fp >> is_receiver_threshgb_last;
   fp >> is_receiver_threshgb;
+  fp >> is_receiver_quanta_threshgb_last;
+  fp >> is_receiver_quanta_threshgb;
   fp >> is_modifier;
   fp >> is_modified;
   fp >> is_fertile;

Modified: branches/jeffdev/source/main/cPhenotype.h
===================================================================
--- branches/jeffdev/source/main/cPhenotype.h	2006-03-24 13:02:33 UTC (rev 524)
+++ branches/jeffdev/source/main/cPhenotype.h	2006-03-24 21:18:38 UTC (rev 525)
@@ -121,18 +121,26 @@
   bool is_donor_truegb_last;// Did this org's parent truegb_donate? 
   bool is_donor_threshgb;  // Has this organism threshgb_donated (true green beard)? 
   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? 
   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? 
   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?
   bool is_receiver_kin;  // Has this organism ever received kin merit donation?
+  bool is_receiver_kin_last;  // Did this organism's parent receive a kin merit donation?
   bool is_receiver_edit; // Has this organism ever received edit donation?
+  bool is_receiver_edit_last; // Did this organism's parent receive an edit donation?
   bool is_receiver_gbg;  // Has this organism ever received gbg donation?
   bool is_receiver_truegb;// Has this organism ever received truegb donation?
   bool is_receiver_truegb_last;// Did this organism's parent receive a truegb donation?
   bool is_receiver_threshgb;// Has this organism ever received a threshgb donation?
   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_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?
@@ -271,6 +279,10 @@
     { assert(initialized == true); return neutral_metric; }
   double GetLifeFitness() const
     { assert(initialized == true); return life_fitness; }
+  int  GetNumThreshGbDonations() const { assert(initialized == true); return num_thresh_gb_donations; }
+  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; }
 
   bool IsInjected() const { assert(initialized == true); return is_injected; }
   bool IsParasite() const { assert(initialized == true); return is_parasite; }
@@ -288,18 +300,22 @@
   bool IsDonorTrueGbLast() const { assert(initialized == true); return is_donor_truegb_last; }
   bool IsDonorThreshGb() const { assert(initialized == true); return is_donor_threshgb; }
   bool IsDonorThreshGbLast() const { assert(initialized == true); return is_donor_threshgb_last; }
-  int  GetNumThreshGbDonations() const { assert(initialized == true); return num_thresh_gb_donations; }
-  int  GetNumThreshGbDonationsLast() const { assert(initialized == true); return num_thresh_gb_donations_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 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; }
   bool IsReceiverKin() const { assert(initialized == true); return is_receiver_kin; }
+  bool IsReceiverKinLast() const { assert(initialized == true); return is_receiver_kin_last; }
   bool IsReceiverEdit() const { assert(initialized == true); return is_receiver_edit; }
+  bool IsReceiverEditLast() const { assert(initialized == true); return is_receiver_edit_last; }
   bool IsReceiverGbg() const { assert(initialized == true); return is_receiver_gbg; }
   bool IsReceiverTrueGb() const { assert(initialized == true); return is_receiver_truegb; }
   bool IsReceiverTrueGbLast() const { assert(initialized == true); return is_receiver_truegb_last; }
   bool IsReceiverThreshGb() const { assert(initialized == true); return is_receiver_threshgb; }
   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 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; }
@@ -342,6 +358,7 @@
   void SetIsDonorGbg() { SetIsDonorCur(); is_donor_gbg = true; }
   void SetIsDonorTrueGb() { SetIsDonorCur(); is_donor_truegb = true; }
   void SetIsDonorThreshGb() { SetIsDonorCur(); is_donor_threshgb = true; }
+  void SetIsDonorQuantaThreshGb() { SetIsDonorCur(); is_donor_quanta_threshgb = true; }
   void SetIsReceiver() { is_receiver = true; } 
   void SetIsReceiverRand() { SetIsReceiver(); is_receiver_rand = true; } 
   void SetIsReceiverKin() { SetIsReceiver(); is_receiver_kin = true; } 
@@ -349,12 +366,14 @@
   void SetIsReceiverGbg() { SetIsReceiver(); is_receiver_gbg = true; } 
   void SetIsReceiverTrueGb() { SetIsReceiver(); is_receiver_truegb = true; } 
   void SetIsReceiverThreshGb() { SetIsReceiver(); is_receiver_threshgb = true; } 
+  void SetIsReceiverQuantaThreshGb() { SetIsReceiver(); is_receiver_quanta_threshgb = true; } 
   
 
   void IncCurInstCount(int _inst_num)  { assert(initialized == true); cur_inst_count[_inst_num]++; } 
   void DecCurInstCount(int _inst_num)  { assert(initialized == true); cur_inst_count[_inst_num]--; } 
 
   void IncNumThreshGbDonations() { assert(initialized == true); num_thresh_gb_donations++; }
+  void IncNumQuantaThreshGbDonations() { assert(initialized == true); num_quanta_thresh_gb_donations++; }
   void IncAge()      { assert(initialized == true); age++; }
   void IncTimeUsed() { assert(initialized == true); time_used++; }
   void IncErrors()   { assert(initialized == true); cur_num_errors++; }

Modified: branches/jeffdev/source/main/cPopulation.cc
===================================================================
--- branches/jeffdev/source/main/cPopulation.cc	2006-03-24 13:02:33 UTC (rev 524)
+++ branches/jeffdev/source/main/cPopulation.cc	2006-03-24 21:18:38 UTC (rev 525)
@@ -882,13 +882,23 @@
   cDoubleSum donation_makers;
   cDoubleSum donation_receivers;
   cDoubleSum donation_cheaters;
-  cDoubleSum truegb_donation_makers;
-  cDoubleSum truegb_donation_receivers;
-  cDoubleSum truegb_donation_cheaters;
+
+  cDoubleSum edit_donation_makers;
+  cDoubleSum edit_donation_receivers;
+  cDoubleSum edit_donation_cheaters;
+
+  cDoubleSum kin_donation_makers;
+  cDoubleSum kin_donation_receivers;
+  cDoubleSum kin_donation_cheaters;
+
   cDoubleSum threshgb_donation_makers;
   cDoubleSum threshgb_donation_receivers;
   cDoubleSum threshgb_donation_cheaters;
 
+  cDoubleSum quanta_threshgb_donation_makers;
+  cDoubleSum quanta_threshgb_donation_receivers;
+  cDoubleSum quanta_threshgb_donation_cheaters;
+
   cDataFile & dn_donors = stats.GetDataFile("donations.dat");
   dn_donors.WriteComment("Info about organisms giving donations in the population");
   dn_donors.WriteTimeStamp();
@@ -909,15 +919,24 @@
           donation_cheaters.Add(1);                             //found a receiver whose parent did not give
         }
       }
-      // truegb donors & receivers
-      if (phenotype.IsDonorTrueGbLast()) truegb_donation_makers.Add(1);       //found a truegb donor
-      if (phenotype.IsReceiverTrueGbLast()){
-        truegb_donation_receivers.Add(1);                              //found a truegb receiver
-        if (phenotype.IsDonorTrueGbLast()==0){
-          truegb_donation_cheaters.Add(1);                             //found a truegb receiver whose parent did...
-        }                                                              //...not make a truegb donation
+      // edit donors & receivers
+      if (phenotype.IsDonorEditLast()) edit_donation_makers.Add(1);       //found a edit donor
+      if (phenotype.IsReceiverEditLast()){
+        edit_donation_receivers.Add(1);                              //found a edit receiver
+        if (phenotype.IsDonorEditLast()==0){
+          edit_donation_cheaters.Add(1);                             //found a edit receiver whose parent did...
+        }                                                              //...not make a edit donation
       }
 
+      // kin donors & receivers
+      if (phenotype.IsDonorKinLast()) kin_donation_makers.Add(1);       //found a kin donor
+      if (phenotype.IsReceiverKinLast()){
+        kin_donation_receivers.Add(1);                              //found a kin receiver
+        if (phenotype.IsDonorKinLast()==0){
+          kin_donation_cheaters.Add(1);                             //found a kin receiver whose parent did...
+        }                                                              //...not make a kin donation
+      }
+
       // threshgb donors & receivers
       if (phenotype.IsDonorThreshGbLast()) threshgb_donation_makers.Add(1); //found a threshgb donor
       if (phenotype.IsReceiverThreshGbLast()){
@@ -927,17 +946,32 @@
         }                                                              //...not make a threshgb donation
       }
 
+      // quanta_threshgb donors & receivers
+      if (phenotype.IsDonorQuantaThreshGbLast()) quanta_threshgb_donation_makers.Add(1); //found a quanta threshgb donor
+      if (phenotype.IsReceiverQuantaThreshGbLast()){
+        quanta_threshgb_donation_receivers.Add(1);                              //found a quanta threshgb receiver
+        if (phenotype.IsDonorQuantaThreshGbLast()==0){
+          quanta_threshgb_donation_cheaters.Add(1);                             //found a quanta threshgb receiver whose parent did...
+        }                                                              //...not make a quanta threshgb donation
+      }
+
     }
 
   dn_donors.Write(donation_makers.Sum(), "parent made at least one donation");
   dn_donors.Write(donation_receivers.Sum(), "parent received at least one donation");
   dn_donors.Write(donation_cheaters.Sum(),  "parent received at least one donation but did not make one");
-  dn_donors.Write(truegb_donation_makers.Sum(), "parent made at least one truegb_donation");
-  dn_donors.Write(truegb_donation_receivers.Sum(), "parent received at least one truegb_donation");
-  dn_donors.Write(truegb_donation_cheaters.Sum(),  "parent received at least one truegb_donation but did not make one");
+  dn_donors.Write(edit_donation_makers.Sum(), "parent made at least one edit_donation");
+  dn_donors.Write(edit_donation_receivers.Sum(), "parent received at least one edit_donation");
+  dn_donors.Write(edit_donation_cheaters.Sum(),  "parent received at least one edit_donation but did not make one");
+  dn_donors.Write(kin_donation_makers.Sum(), "parent made at least one kin_donation");
+  dn_donors.Write(kin_donation_receivers.Sum(), "parent received at least one kin_donation");
+  dn_donors.Write(kin_donation_cheaters.Sum(),  "parent received at least one kin_donation but did not make one");
   dn_donors.Write(threshgb_donation_makers.Sum(), "parent made at least one threshgb_donation");
   dn_donors.Write(threshgb_donation_receivers.Sum(), "parent received at least one threshgb_donation");
   dn_donors.Write(threshgb_donation_cheaters.Sum(),  "parent received at least one threshgb_donation but did not make one");
+  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.Endl();
 




More information about the Avida-cvs mailing list