[Avida-cvs] [avida-svn] r496 - in branches/jeffdev: Avida2.xcodeproj source/cpu source/main source/support

jclune@myxo.css.msu.edu jclune at myxo.css.msu.edu
Sat Mar 4 22:11:14 PST 2006


Author: jclune
Date: 2006-03-05 01:11:13 -0500 (Sun, 05 Mar 2006)
New Revision: 496

Modified:
   branches/jeffdev/Avida2.xcodeproj/project.pbxproj
   branches/jeffdev/source/cpu/cHardwareCPU.cc
   branches/jeffdev/source/cpu/cHardwareCPU.h
   branches/jeffdev/source/main/cAvidaConfig.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
   branches/jeffdev/source/support/avida.cfg
Log:
Added a greenbeard instruction that only fires if the target has made >= threshold donation attempts

Modified: branches/jeffdev/Avida2.xcodeproj/project.pbxproj
===================================================================
--- branches/jeffdev/Avida2.xcodeproj/project.pbxproj	2006-03-05 00:35:01 UTC (rev 495)
+++ branches/jeffdev/Avida2.xcodeproj/project.pbxproj	2006-03-05 06:11:13 UTC (rev 496)
@@ -1427,7 +1427,7 @@
 		DCC31614076253A5008F7A48 /* viewers.pro */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = viewers.pro; sourceTree = "<group>"; };
 		DCC31615076253A5008F7A48 /* zoom_screen.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = zoom_screen.cc; sourceTree = "<group>"; };
 		DCC31616076253A5008F7A48 /* zoom_screen.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = zoom_screen.hh; sourceTree = "<group>"; };
-		DCC3164D07626CF3008F7A48 /* primitive */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = primitive; sourceTree = BUILT_PRODUCTS_DIR; };
+		DCC3164D07626CF3008F7A48 /* primitive */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = primitive; sourceTree = BUILT_PRODUCTS_DIR; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */

Modified: branches/jeffdev/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/jeffdev/source/cpu/cHardwareCPU.cc	2006-03-05 00:35:01 UTC (rev 495)
+++ branches/jeffdev/source/cpu/cHardwareCPU.cc	2006-03-05 06:11:13 UTC (rev 496)
@@ -213,6 +213,7 @@
     cInstEntryCPU("donate-edt",  &cHardwareCPU::Inst_DonateEditDist),
     cInstEntryCPU("donate-gbg",  &cHardwareCPU::Inst_DonateGreenBeardGene),
     cInstEntryCPU("donate-tgb",  &cHardwareCPU::Inst_DonateTrueGreenBeard),
+    cInstEntryCPU("donate-threshgb",  &cHardwareCPU::Inst_DonateThreshGreenBeard),
     cInstEntryCPU("donate-NUL",  &cHardwareCPU::Inst_DonateNULL),
 
     cInstEntryCPU("rotate-l",  &cHardwareCPU::Inst_RotateL),
@@ -3055,17 +3056,16 @@
       if (neighbor != NULL) {
           const cGenome & neighbor_genome = neighbor->GetGenome();
 
-	  // for each instruction in the genome...
+          // for each instruction in the genome...
           for(int i=0;i<neighbor_genome.GetSize();i++){
 
-	    // ...see if it is donate-gbg
+            // ...see if it is donate-gbg
             if (neighbor_genome[i] == IP().GetInst()) {
-	      // if (GetInstSet().GetName(neighbor_genome[i].GetOp())=="donate-gbg"){
-	      found = true;
-	      break;
-	    }
+              found = true;
+              break;
+            }
 	    
-	  }
+          }
       }
       
       // stop searching through the neighbors if we already found one
@@ -3125,20 +3125,20 @@
   // rotate through orgs in neighborhood  
   while (neighbor_id < max_id) {
       neighbor = organism->GetNeighbor();
-      //if neighbor exists, AND if their parent donated,
+      //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 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
+            // ...see if it is donate-tgb, if so, we found a target
             if (neighbor_genome[i] == IP().GetInst()) {
-	      found = true;
-	      break;
-	    }
+              found = true;
+              break;
+            }
 	    
-	  }
+          }
       }
       
       // stop searching through the neighbors if we already found one
@@ -3166,7 +3166,82 @@
   
 }
 
+bool cHardwareCPU::Inst_DonateThreshGreenBeard()
+{
+  //this donates to organisms that have this instruction anywhere
+  //in their genome AND their parents excuted it >=THRESHOLD number of times
+  //(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();
+  phenotype.IncDonates();
+  phenotype.SetIsDonorThreshGb();
+  phenotype.IncNumThreshGbDonations();
 
+  if (organism->GetPhenotype().GetCurNumDonates() > cConfig::GetMaxDonates()) {
+    return false;
+  }
+
+  // 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;
+
+  // 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().GetNumThreshGbDonationsLast()>=cConfig::GetMinGBDonateTreshold() ) {
+          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;
+      }
+  
+      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().SetIsReceiverThreshGb();
+  }
+
+  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-05 00:35:01 UTC (rev 495)
+++ branches/jeffdev/source/cpu/cHardwareCPU.h	2006-03-05 06:11:13 UTC (rev 496)
@@ -405,6 +405,7 @@
   bool Inst_DonateEditDist();
   bool Inst_DonateGreenBeardGene();
   bool Inst_DonateTrueGreenBeard();
+  bool Inst_DonateThreshGreenBeard();
   bool Inst_DonateNULL();
 
   bool Inst_SearchF();

Modified: branches/jeffdev/source/main/cAvidaConfig.h
===================================================================
--- branches/jeffdev/source/main/cAvidaConfig.h	2006-03-05 00:35:01 UTC (rev 495)
+++ branches/jeffdev/source/main/cAvidaConfig.h	2006-03-05 06:11:13 UTC (rev 496)
@@ -238,6 +238,7 @@
   CONFIG_ADD_VAR(MERIT_RECEIVED, double, 0.0, "Multiplier of merit given with 'donate' command");
   CONFIG_ADD_VAR(MAX_DONATE_KIN_DIST, int, -1, "Limit on distance of relation for donate; -1=no max");
   CONFIG_ADD_VAR(MAX_DONATE_EDIT_DIST, int, -1, "Limit on genetic (edit) distance for donate; -1=no max");
+  CONFIG_ADD_VAR(MIN_GB_DONATE_THRESHOLD, int, -1, "threshold green beard donates only to orgs above this donation attempt threshold; -1=no thresh");
   CONFIG_ADD_VAR(MAX_DONATES, int, 1000000, "Limit on number of donates organisms are allowed.");
   
   CONFIG_ADD_GROUP(GENEOLOGY_GROUP, "Geneology");

Modified: branches/jeffdev/source/main/cConfig.cc
===================================================================
--- branches/jeffdev/source/main/cConfig.cc	2006-03-05 00:35:01 UTC (rev 495)
+++ branches/jeffdev/source/main/cConfig.cc	2006-03-05 06:11:13 UTC (rev 496)
@@ -66,6 +66,7 @@
 double cConfig::merit_received;
 int cConfig::max_donate_kin_distance;
 int cConfig::max_donate_edit_distance;
+int cConfig::min_gb_donate_threshold;
 int cConfig::max_donates;
 int cConfig::num_tasks;
 int cConfig::num_reactions;
@@ -298,6 +299,8 @@
                   "Limit on distance of relation for donate; -1=no max");
   time_group->Add(max_donate_edit_distance, "-1", "MAX_DONATE_EDIT_DIST",
                   "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(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-05 00:35:01 UTC (rev 495)
+++ branches/jeffdev/source/main/cConfig.h	2006-03-05 06:11:13 UTC (rev 496)
@@ -223,6 +223,7 @@
   static double merit_received;
   static int max_donate_kin_distance;
   static int max_donate_edit_distance;
+  static int min_gb_donate_threshold;
   static int max_donates;
 
   // Methodology
@@ -363,6 +364,7 @@
   static double GetMeritReceived() { return merit_received; }
   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 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-05 00:35:01 UTC (rev 495)
+++ branches/jeffdev/source/main/cPhenotype.cc	2006-03-05 06:11:13 UTC (rev 496)
@@ -151,6 +151,10 @@
   is_donor_gbg_last = parent_phenotype.is_donor_gbg_last;
   is_donor_truegb  = false;
   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_receiver   = false;
   is_receiver_last = parent_phenotype.is_receiver_last;
   is_receiver_rand   = false;
@@ -159,6 +163,8 @@
   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_modifier   = false;
   is_modified   = false;
   is_fertile    = parent_phenotype.last_child_fertile;
@@ -249,6 +255,10 @@
   is_donor_gbg_last = false;
   is_donor_truegb = false;
   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_receiver   = false;
   is_receiver_last   = false;
   is_receiver_rand   = false;
@@ -257,6 +267,8 @@
   is_receiver_gbg   = false;
   is_receiver_truegb   = false;
   is_receiver_truegb_last   = false;
+  is_receiver_threshgb   = false;
+  is_receiver_threshgb_last   = false;
   is_modifier   = false;
   is_modified   = false;
   is_fertile    = true;
@@ -346,6 +358,10 @@
   is_donor_gbg = false;
   is_donor_truegb_last = is_donor_truegb;
   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_receiver_last = is_receiver;
   is_receiver = false;
   is_receiver_rand = false;
@@ -354,6 +370,8 @@
   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;
   (void) is_modifier;
   (void) is_modified;
   (void) is_fertile;
@@ -453,6 +471,10 @@
   is_donor_gbg = false;
   is_donor_truegb_last = is_donor_truegb;
   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_receiver_last = is_receiver;
   is_receiver = false;
   is_receiver_rand = false;
@@ -461,6 +483,8 @@
   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;
   (void) is_modifier;
   (void) is_modified;
   (void) is_fertile;
@@ -557,6 +581,10 @@
   is_donor_gbg  = clone_phenotype.is_donor_gbg;
   is_donor_truegb_last = clone_phenotype.is_donor_truegb_last;
   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_receiver = false;
   is_receiver_last = false;
   is_receiver_rand = false;
@@ -565,6 +593,8 @@
   is_receiver_gbg = false;
   is_receiver_truegb = false;
   is_receiver_truegb_last = false;
+  is_receiver_threshgb = false;
+  is_receiver_threshgb_last = false;
   is_modifier   = false;
   is_modified   = false;
   is_fertile    = clone_phenotype.last_child_fertile;
@@ -731,6 +761,10 @@
   fp << is_donor_gbg        << " ";
   fp << is_donor_truegb_last       << " ";
   fp << is_donor_truegb        << " ";
+  fp << is_donor_threshgb_last       << " ";
+  fp << is_donor_threshgb        << " ";
+  fp << num_thresh_gb_donations_last       << " ";
+  fp << num_thresh_gb_donations        << " ";
 
   fp << is_receiver_last         << " ";
   fp << is_receiver         << " ";
@@ -740,6 +774,8 @@
   fp << is_receiver_gbg         << " ";
   fp << is_receiver_truegb_last         << " ";
   fp << is_receiver_truegb         << " ";
+  fp << is_receiver_threshgb_last         << " ";
+  fp << is_receiver_threshgb         << " ";
   fp << is_modifier         << " ";
   fp << is_modified         << " ";
   fp << is_fertile          << " ";
@@ -826,6 +862,10 @@
   fp >> is_donor_gbg;
   fp >> is_donor_truegb_last;
   fp >> is_donor_truegb;
+  fp >> is_donor_threshgb_last;
+  fp >> is_donor_threshgb;
+  fp >> num_thresh_gb_donations_last;
+  fp >> num_thresh_gb_donations;
   fp >> is_receiver_last;
   fp >> is_receiver;
   fp >> is_receiver_rand;
@@ -834,6 +874,8 @@
   fp >> is_receiver_gbg;
   fp >> is_receiver_truegb_last;
   fp >> is_receiver_truegb;
+  fp >> is_receiver_threshgb_last;
+  fp >> is_receiver_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-05 00:35:01 UTC (rev 495)
+++ branches/jeffdev/source/main/cPhenotype.h	2006-03-05 06:11:13 UTC (rev 496)
@@ -112,21 +112,27 @@
   bool is_donor_null;    // Has this organism attempted a null donation?
   bool is_donor_null_last;// Did this org's parent attempt a null donation?
   bool is_donor_kin;     // Has this organism kin_donated?
-  bool is_donor_kin_last;// Did this org's parent kin_donated?
+  bool is_donor_kin_last;// Did this org's parent kin_donate?
   bool is_donor_edit;    // Has this organism edit_donated?
-  bool is_donor_edit_last; // Did this org's parent edit_donated?
+  bool is_donor_edit_last; // Did this org's parent edit_donate?
   bool is_donor_gbg;     //  Has this organism gbg_donated (green beard gene)?
-  bool is_donor_gbg_last;// Did this org's parent gbg_donated?
+  bool is_donor_gbg_last;// Did this org's parent gbg_donate?
   bool is_donor_truegb;  // Has this organism truegb_donated (true green beard)? 
-  bool is_donor_truegb_last;// Did this org's parent gbg_donated? 
+  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? 
+  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? 
   bool is_receiver;      // Has this organism ever received merit donation?
-  bool is_receiver_last;      // 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_edit; // Has this organism ever received 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;// 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_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?
@@ -280,6 +286,10 @@
   bool IsDonorGbgLast() const { assert(initialized == true); return is_donor_gbg_last; }
   bool IsDonorTrueGb() const { assert(initialized == true); return is_donor_truegb; }
   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 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; }
@@ -288,6 +298,8 @@
   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 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; }
@@ -329,17 +341,20 @@
   void SetIsDonorEdit() { SetIsDonorCur(); is_donor_edit = true; }
   void SetIsDonorGbg() { SetIsDonorCur(); is_donor_gbg = true; }
   void SetIsDonorTrueGb() { SetIsDonorCur(); is_donor_truegb = true; }
+  void SetIsDonorThreshGb() { SetIsDonorCur(); is_donor_threshgb = true; }
   void SetIsReceiver() { is_receiver = true; } 
   void SetIsReceiverRand() { SetIsReceiver(); is_receiver_rand = true; } 
   void SetIsReceiverKin() { SetIsReceiver(); is_receiver_kin = true; } 
   void SetIsReceiverEdit() { SetIsReceiver(); is_receiver_edit = true; } 
   void SetIsReceiverGbg() { SetIsReceiver(); is_receiver_gbg = true; } 
   void SetIsReceiverTrueGb() { SetIsReceiver(); is_receiver_truegb = true; } 
+  void SetIsReceiverThreshGb() { SetIsReceiver(); is_receiver_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 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-05 00:35:01 UTC (rev 495)
+++ branches/jeffdev/source/main/cPopulation.cc	2006-03-05 06:11:13 UTC (rev 496)
@@ -885,6 +885,9 @@
   cDoubleSum truegb_donation_makers;
   cDoubleSum truegb_donation_receivers;
   cDoubleSum truegb_donation_cheaters;
+  cDoubleSum threshgb_donation_makers;
+  cDoubleSum threshgb_donation_receivers;
+  cDoubleSum threshgb_donation_cheaters;
 
   cDataFile & dn_donors = stats.GetDataFile("donations.dat");
   dn_donors.WriteComment("Info about organisms giving donations in the population");
@@ -915,6 +918,15 @@
         }                                                              //...not make a truegb donation
       }
 
+      // threshgb donors & receivers
+      if (phenotype.IsDonorThreshGbLast()) threshgb_donation_makers.Add(1); //found a threshgb donor
+      if (phenotype.IsReceiverThreshGbLast()){
+        threshgb_donation_receivers.Add(1);                              //found a threshgb receiver
+        if (phenotype.IsDonorThreshGbLast()==0){
+          threshgb_donation_cheaters.Add(1);                             //found a threshgb receiver whose parent did...
+        }                                                              //...not make a threshgb donation
+      }
+
     }
 
   dn_donors.Write(donation_makers.Sum(), "parent made at least one donation");
@@ -923,6 +935,9 @@
   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(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.Endl();
 

Modified: branches/jeffdev/source/support/avida.cfg
===================================================================
--- branches/jeffdev/source/support/avida.cfg	2006-03-05 00:35:01 UTC (rev 495)
+++ branches/jeffdev/source/support/avida.cfg	2006-03-05 06:11:13 UTC (rev 496)
@@ -140,6 +140,7 @@
 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
+MIN_GB_DONATE_THRESHOLD -1 # threshold green beard donates only to orgs above this donation attempt threshold; -1=no thresh
 MAX_DONATES 1000000      # Limit on number of donates organisms are allowed.
 
 ### GENEOLOGY_GROUP ###




More information about the Avida-cvs mailing list