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

hjg at myxo.css.msu.edu hjg at myxo.css.msu.edu
Thu Oct 23 07:45:17 PDT 2008


Author: hjg
Date: 2008-10-23 10:45:17 -0400 (Thu, 23 Oct 2008)
New Revision: 2867

Modified:
   branches/hjg-dev/source/cpu/cHardwareCPU.cc
   branches/hjg-dev/source/cpu/cHardwareCPU.h
   branches/hjg-dev/source/main/cAvidaConfig.h
   branches/hjg-dev/source/main/cOrganism.cc
   branches/hjg-dev/source/main/cStats.cc
   branches/hjg-dev/source/main/cTaskLib.cc
   branches/hjg-dev/source/main/cTaskLib.h
Log:
changed to a standing reputation scheme.

Modified: branches/hjg-dev/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/hjg-dev/source/cpu/cHardwareCPU.cc	2008-10-22 11:05:45 UTC (rev 2866)
+++ branches/hjg-dev/source/cpu/cHardwareCPU.cc	2008-10-23 14:45:17 UTC (rev 2867)
@@ -6710,9 +6710,7 @@
 bool cHardwareCPU::Inst_DonateFacingRawMaterials(cAvidaContext& ctx)
 {
   
-  bool isSuccessful = false;
-  
-  // Get faced neighbor
+	// Get faced neighbor
   cOrganism * neighbor = organism->GetNeighbor();
   
   // Donate only if we have found a neighbor.
@@ -6729,21 +6727,23 @@
 			neighbor->Rotate(1);
 		}
 		
+		
+		
 		// update reputation to include this donation.
 		// get the current reputation; increment by 1.
 		if (m_world->GetConfig().AUTO_REPUTATION.Get()) {
-			if (organism->HasOpinion()) {
-				int opinion = organism->GetOpinion().first + 1;
-				organism->SetOpinion(opinion);
-			} else {
-				organism->SetOpinion(1);
-			}
+			// set rep to 1, since the organism donated
+			organism->SetReputation(1);
+			// get neighbor reputation
+			int rep = neighbor->GetReputation(); 
+			// if the organism has not yet donated, put it into bad standing
+			if (rep == 0) neighbor->SetReputation(-1);
 		}
 		
-	}
-	isSuccessful = true;
+		
+		}
   }
-  return isSuccessful;
+  return true;
 }  
 
 

Modified: branches/hjg-dev/source/cpu/cHardwareCPU.h
===================================================================
--- branches/hjg-dev/source/cpu/cHardwareCPU.h	2008-10-22 11:05:45 UTC (rev 2866)
+++ branches/hjg-dev/source/cpu/cHardwareCPU.h	2008-10-23 14:45:17 UTC (rev 2867)
@@ -678,12 +678,16 @@
   */ 
   // Donate a raw material to the neighbor
   bool Inst_DonateFacingRawMaterials(cAvidaContext& ctx);
-	// Donation to facing neighbor with a probability that it is reciprocated
-  bool Inst_DonateProbReciprocate(cAvidaContext& ctx);	
+	// Rotate to the organims with the greatest reputation
+	bool Inst_RotateToGreatestReputation(cAvidaContext& ctx);	
   // Get a neighbor's reputation
   bool Inst_GetNeighborsReputation(cAvidaContext& ctx);
   // Get the organism's reputation
-  bool Inst_GetReputation(cAvidaContext& ctx);
+  bool Inst_GetReputation(cAvidaContext& ctx);	
+	
+	
+	// Donation to facing neighbor with a probability that it is reciprocated
+  bool Inst_DonateProbReciprocate(cAvidaContext& ctx);	
   // Get the organism's raw material level
   bool Inst_GetAmountOfRawMaterials(cAvidaContext& ctx);
   // Get the number of raw materials the organism 
@@ -699,10 +703,9 @@
 	bool Inst_IncRecipProb(cAvidaContext& ctx);
 	// Decrease the reciprocation probability
 	bool Inst_DecRecipProb(cAvidaContext& ctx);
-	// Rotate to the organims with the greatest reputation
-	bool Inst_RotateToGreatestReputation(cAvidaContext& ctx);
 
 
+
 };
 
 

Modified: branches/hjg-dev/source/main/cAvidaConfig.h
===================================================================
--- branches/hjg-dev/source/main/cAvidaConfig.h	2008-10-22 11:05:45 UTC (rev 2866)
+++ branches/hjg-dev/source/main/cAvidaConfig.h	2008-10-23 14:45:17 UTC (rev 2867)
@@ -559,7 +559,8 @@
   CONFIG_ADD_CUSTOM_FORMAT(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, bool, 1, "Is an organism's reputation automatically computed based on its donations");
-  CONFIG_ADD_VAR(OTHER_RAW_MAT_MULT, double, 2.00, "Number multiplied by the number of raw materials received from another organism to compute reward");
+  CONFIG_ADD_VAR(OTHER_RAW_MAT_MULT, double, 1.00, "Number multiplied by the number of raw materials received from another organism to compute reward");
+  CONFIG_ADD_VAR(MY_RAW_MAT_MULT, double, 1.00, "Number multiplied by the number of your raw materials");
 
   
 #endif

Modified: branches/hjg-dev/source/main/cOrganism.cc
===================================================================
--- branches/hjg-dev/source/main/cOrganism.cc	2008-10-22 11:05:45 UTC (rev 2866)
+++ branches/hjg-dev/source/main/cOrganism.cc	2008-10-23 14:45:17 UTC (rev 2867)
@@ -794,10 +794,10 @@
 }
 
 /* Get an organism's reputation, which is expressed as an 
-	opinion. 5 is the default reputation (this should be refactored
+	opinion. 0 is the default reputation (this should be refactored
 	to be cleaner). */
 int cOrganism::GetReputation() {
-	int rep =5;
+	int rep =0;
 	if (HasOpinion()) {
 		rep = GetOpinion().first;
 	}

Modified: branches/hjg-dev/source/main/cStats.cc
===================================================================
--- branches/hjg-dev/source/main/cStats.cc	2008-10-22 11:05:45 UTC (rev 2866)
+++ branches/hjg-dev/source/main/cStats.cc	2008-10-23 14:45:17 UTC (rev 2867)
@@ -1734,7 +1734,7 @@
 	
 	df.WriteComment("Avida organism reputation information -- average donations, min donations, max donations");
 	df.WriteTimeStamp();
-	df.Write(m_update,   "Update");
+	df.Write(m_update,   "Update [update]");
 	
 	
   for(int i=0; i<m_world->GetPopulation().GetSize(); ++i) {
@@ -1756,17 +1756,18 @@
 	  }
 	}
 //	float rep = reputations/pop_size;
-	df.Write(reputations.Average(), "Avg. reputation");
-	df.Write(donations.Average(), "Avg. donations");
-	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(reputations.Average(), "Avg. reputation [reputation]");
+	df.Write(reputations.StdDeviation(), "Standard Deviation [repstddev]");
 //	df.Write(min_rep, "Minimum reputation");
-//	df.Write(max_rep, "Maximum reputation");
-	df.Write(num_alt, "Number of altruists");
+//	df.Write(max_rep, "Maximum reputation");	
+	df.Write(donations.Average(), "Avg. donations [donation]");
+//	df.Write(reciprocations.Average(), "Avg. reciprocations [reciprocation]");
+	df.Write(donors.Average(), "Avg. number of donor partners [partners]");
+//	df.Write(recip_prob_change.Average(), "Avg. change in reciprocation probability [recipprob]");
 
+	df.Write(num_alt, "Number of altruists [altruists]");
 
+
 	
   df.Endl();
 }  

Modified: branches/hjg-dev/source/main/cTaskLib.cc
===================================================================
--- branches/hjg-dev/source/main/cTaskLib.cc	2008-10-22 11:05:45 UTC (rev 2866)
+++ branches/hjg-dev/source/main/cTaskLib.cc	2008-10-23 14:45:17 UTC (rev 2867)
@@ -419,9 +419,7 @@
 
   // reputation based tasks
   else if(name == "use_raw_mat")
-    NewTask(name, "Use raw materials from self and other", &cTaskLib::Task_UseRawMaterials);
-	else if(name == "cont_use_raw_mat") 
-    NewTask(name, "Control task for use raw mat", &cTaskLib::Task_ControlUseRawMaterials);	
+    NewTask(name, "Use raw materials from self and other", &cTaskLib::Task_UseRawMaterials);	
   else if(name == "use_many_raw_mat")
     NewTask(name, "Use raw materials from self and other", &cTaskLib::Task_UseManyOrgsRawMaterials);		
   else if(name == "consume_raw_mat")
@@ -3077,29 +3075,21 @@
 	others. */
 double cTaskLib::Task_UseRawMaterials(cTaskContext& ctx) const {
 	double bonus = 0.0;
-	double mult_val = m_world->GetConfig().OTHER_RAW_MAT_MULT.Get();
-
+	double other_mult_val = m_world->GetConfig().OTHER_RAW_MAT_MULT.Get();
+	double my_mult_val = m_world->GetConfig().MY_RAW_MAT_MULT.Get();
+	
 	//if ((ctx.GetOrganism()->GetSelfRawMaterials() > 0) && 
 		//(ctx.GetOrganism()->GetOtherRawMaterials() > 0)) {
 		
 		// reward for own stuff
-		bonus += ctx.GetOrganism()->GetSelfRawMaterials(); 
-		bonus += (mult_val * ctx.GetOrganism()->GetOtherRawMaterials()); 
+		bonus += (my_mult_val * ctx.GetOrganism()->GetSelfRawMaterials()); 
+		bonus += (other_mult_val * ctx.GetOrganism()->GetOtherRawMaterials()); 
 		
 	//}
 	return bonus;
 }
 
 
-/* This task rewards an organism some for its own raw materials. */
-double cTaskLib::Task_ControlUseRawMaterials(cTaskContext& ctx) const {
-	double bonus = 0.0;
-	// reward for own stuff
-	bonus += ctx.GetOrganism()->GetSelfRawMaterials(); 
-	return bonus;
-}
-
-
 /* This task just checks that an organism has raw materials and that it has 
 	received a donation of raw materials from another organism. Specifically, 
 	the task rewards in proportion to the number of organisms that have

Modified: branches/hjg-dev/source/main/cTaskLib.h
===================================================================
--- branches/hjg-dev/source/main/cTaskLib.h	2008-10-22 11:05:45 UTC (rev 2866)
+++ branches/hjg-dev/source/main/cTaskLib.h	2008-10-23 14:45:17 UTC (rev 2867)
@@ -299,7 +299,6 @@
   
   // reputation
   double Task_UseRawMaterials(cTaskContext& ctx) const;
-  double Task_ControlUseRawMaterials(cTaskContext& ctx) const;
   double Task_ConsumeRawMaterials(cTaskContext& ctx) const;	
   double Task_UseManyOrgsRawMaterials(cTaskContext& ctx) const;
 




More information about the Avida-cvs mailing list