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

hjg at myxo.css.msu.edu hjg at myxo.css.msu.edu
Fri Oct 17 13:38:02 PDT 2008


Author: hjg
Date: 2008-10-17 16:38:02 -0400 (Fri, 17 Oct 2008)
New Revision: 2853

Modified:
   branches/hjg-dev/source/cpu/cHardwareCPU.cc
   branches/hjg-dev/source/main/cOrganism.cc
   branches/hjg-dev/source/main/cOrganism.h
   branches/hjg-dev/source/main/cStats.cc
Log:
better stats

Modified: branches/hjg-dev/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/hjg-dev/source/cpu/cHardwareCPU.cc	2008-10-17 02:19:15 UTC (rev 2852)
+++ branches/hjg-dev/source/cpu/cHardwareCPU.cc	2008-10-17 20:38:02 UTC (rev 2853)
@@ -6764,6 +6764,9 @@
 	if (organism->SubtractSelfRawMaterials(1)) {
 		neighbor->AddOtherRawMaterials(1, organism->GetID()); 
 		
+		// track stats
+		organism->Donated();
+		
 		// rotate recipient to face donor 
 		// by rotating until the recipient faces the donor
 		// adding a new comment.
@@ -6778,6 +6781,8 @@
 		if(rand_num < recip_prob) { 
 			if (neighbor->SubtractSelfRawMaterials(1)) {
 					organism->AddOtherRawMaterials(1, neighbor->GetID()); 
+					// track stats
+					neighbor->Reciprocated();
 			}
 		}
 	}

Modified: branches/hjg-dev/source/main/cOrganism.cc
===================================================================
--- branches/hjg-dev/source/main/cOrganism.cc	2008-10-17 02:19:15 UTC (rev 2852)
+++ branches/hjg-dev/source/main/cOrganism.cc	2008-10-17 20:38:02 UTC (rev 2853)
@@ -79,6 +79,10 @@
   , m_self_raw_materials(world->GetConfig().RAW_MATERIAL_AMOUNT.Get())
   , m_other_raw_materials(0)
 	, m_recip_prob(5)	
+	, m_num_donate(0)
+	, m_num_reciprocate(0)
+	, m_max_recip_prob(5)
+	, m_min_recip_prob(5)
 {
   m_hardware = m_world->GetHardwareManager().Create(this);
 
@@ -789,6 +793,8 @@
 void cOrganism::IncRecipProb() {
 	if (m_recip_prob < 10) { 
 		m_recip_prob++;
+		
+		if (m_recip_prob > m_max_recip_prob) m_max_recip_prob = m_recip_prob;
 		if (m_world->GetConfig().AUTO_REPUTATION.Get()) {
 			SetOpinion(m_recip_prob);
 		}
@@ -800,6 +806,9 @@
 void cOrganism::DecRecipProb() { 
 	if (m_recip_prob > 0) { 
 		m_recip_prob--;
+		
+		if (m_recip_prob < m_min_recip_prob) m_min_recip_prob = m_recip_prob;
+
 		if (m_world->GetConfig().AUTO_REPUTATION.Get()) {
 			SetOpinion(m_recip_prob);
 		}

Modified: branches/hjg-dev/source/main/cOrganism.h
===================================================================
--- branches/hjg-dev/source/main/cOrganism.h	2008-10-17 02:19:15 UTC (rev 2852)
+++ branches/hjg-dev/source/main/cOrganism.h	2008-10-17 20:38:02 UTC (rev 2853)
@@ -452,8 +452,6 @@
 	int GetSelfRawMaterials() { return m_self_raw_materials; }
 	// retrieve the amount of raw materials collected from others
 	int GetOtherRawMaterials() { return m_other_raw_materials; }
-	// get the number of donations
-	int GetNumberOfDonations() { return (m_world->GetConfig().RAW_MATERIAL_AMOUNT.Get() - m_self_raw_materials); }
 	// get the organism's reputation
 	int GetReputation(); 
 	// get number of donors
@@ -464,7 +462,16 @@
 	void DecRecipProb();
 	// get reciprocation probability
 	int GetReciprocationProbability() { return m_recip_prob; }
-	// does an organism have a reputation (init here...)
+	// organism donated
+	void Donated(){m_num_donate++;}
+	// get number of donations
+	int GetNumberOfDonations() { return m_num_donate; }
+	// organism reciprocated
+	void Reciprocated() {m_num_reciprocate++;}
+	// get number of reciprocations
+	int GetNumberOfReciprocations() { return m_num_reciprocate; }
+	// get the change in reciprocal probability
+	int GetChangeInRecipProb() { return m_max_recip_prob - m_min_recip_prob; }
 
 protected:
 	// The organism's own raw materials
@@ -475,8 +482,15 @@
 	set<int> donor_list;
 	// the probability that an organism will reciprocate
 	int m_recip_prob;
+	// number of donations
+	int m_num_donate;
+	// number of reciprocations
+	int m_num_reciprocate;
+	// max-reciprocation probability
+	int m_max_recip_prob;
+	// min-reciprocation probability
+	int m_min_recip_prob;
 	
-	
   // -------- End of reputation support --------
 
 };

Modified: branches/hjg-dev/source/main/cStats.cc
===================================================================
--- branches/hjg-dev/source/main/cStats.cc	2008-10-17 02:19:15 UTC (rev 2852)
+++ branches/hjg-dev/source/main/cStats.cc	2008-10-17 20:38:02 UTC (rev 2853)
@@ -1722,7 +1722,9 @@
 	
 	cDoubleSum reputations;
 	cDoubleSum donations;
+	cDoubleSum reciprocations; 
 	cDoubleSum donors;
+	cDoubleSum recip_prob_change;
 
 	int min_rep = 100; 
 	int max_rep = 0;
@@ -1745,19 +1747,23 @@
 		if (max_rep < cur_rep) max_rep = cur_rep;
 		reputations.Add(cur_rep);
 		donations.Add(cell.GetOrganism()->GetNumberOfDonations());
+		reciprocations.Add(cell.GetOrganism()->GetNumberOfReciprocations());
 		donors.Add(cell.GetOrganism()->GetNumberOfDonors());
+		recip_prob_change.Add(cell.GetOrganism()->GetChangeInRecipProb());
 		pop_size++;
 		
-		if (cur_rep > 0) num_alt++;
+		if ((cell.GetOrganism()->GetNumberOfDonations() + cell.GetOrganism()->GetNumberOfReciprocations()) > 0) num_alt++;
 	  }
 	}
 //	float rep = reputations/pop_size;
 	df.Write(reputations.Average(), "Avg. reputation");
 	df.Write(donations.Average(), "Avg. donations");
-	df.Write(donors.Average(), "Avg. number of donors partners");
-	df.Write(reputations.StdDeviation(), "Standard Deviation");
-	df.Write(min_rep, "Minimum reputation");
-	df.Write(max_rep, "Maximum reputation");
+	df.Write(reciprocations.Average(), "Avg. reciprocations");
+	df.Write(donors.Average(), "Avg. number of donor partners");
+	df.Write(recip_prob_change.Average(), "Avg. change in reciprocation probability");
+//	df.Write(reputations.StdDeviation(), "Standard Deviation");
+//	df.Write(min_rep, "Minimum reputation");
+//	df.Write(max_rep, "Maximum reputation");
 	df.Write(num_alt, "Number of altruists");
 
 




More information about the Avida-cvs mailing list