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

hjg at myxo.css.msu.edu hjg at myxo.css.msu.edu
Sat Nov 29 07:55:31 PST 2008


Author: hjg
Date: 2008-11-29 10:55:31 -0500 (Sat, 29 Nov 2008)
New Revision: 2985

Modified:
   branches/hjg-dev/source/cpu/cHardwareCPU.cc
   branches/hjg-dev/source/main/cAvidaConfig.h
   branches/hjg-dev/source/main/cOrganism.cc
   branches/hjg-dev/source/main/cOrganism.h
   branches/hjg-dev/source/main/cTaskLib.cc
Log:
New reputation strategy (5) that is evaluated when the save-mat task is checked

Modified: branches/hjg-dev/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/hjg-dev/source/cpu/cHardwareCPU.cc	2008-11-29 06:43:59 UTC (rev 2984)
+++ branches/hjg-dev/source/cpu/cHardwareCPU.cc	2008-11-29 15:55:31 UTC (rev 2985)
@@ -7207,8 +7207,7 @@
 }
 
 /* This instruction enables an organism to donate a string to its
- facing neighbor. It is sort of a meta-instruction that encapsulates
- sending a string as a message using send-message and retrieve-message. 
+ facing neighbor. 
  So that we can do fun reciprocity-style experiments it also keeps
  track of organisms that have donated strings to others. 
  */

Modified: branches/hjg-dev/source/main/cAvidaConfig.h
===================================================================
--- branches/hjg-dev/source/main/cAvidaConfig.h	2008-11-29 06:43:59 UTC (rev 2984)
+++ branches/hjg-dev/source/main/cAvidaConfig.h	2008-11-29 15:55:31 UTC (rev 2985)
@@ -561,7 +561,7 @@
 
   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, int, 1, "Is an organism's reputation automatically computed based on its donations");
+  CONFIG_ADD_VAR(AUTO_REPUTATION, int, 0, "Is an organism's reputation automatically computed based on its donations\n0=no\n1=increment for each donation + standing\n2=+1 for donations given -1 for donations received\n3=1 for donors -1 for recivers who have not donated\n4=+1 for donors\n5=+1 for donors during task check");
   CONFIG_ADD_VAR(ALT_BENEFIT, int, 1.00, "Number multiplied by the number of raw materials received from another organism to compute reward");
   CONFIG_ADD_VAR(ALT_COST, int, 1.00, "Number multiplied by the number of your raw materials");
   CONFIG_ADD_VAR(ROTATE_ON_DONATE, int, 0, "Rotate an organism to face its donor 0/1 (off/on)");

Modified: branches/hjg-dev/source/main/cOrganism.cc
===================================================================
--- branches/hjg-dev/source/main/cOrganism.cc	2008-11-29 06:43:59 UTC (rev 2984)
+++ branches/hjg-dev/source/main/cOrganism.cc	2008-11-29 15:55:31 UTC (rev 2985)
@@ -887,3 +887,23 @@
 	return make_pair(max_num_matched, org_id);
 }
 
+/* Increase the reputation of all of the organisms that donated to this
+ organism. Then, clear the donors list.*/
+void cOrganism::PraiseDonors()
+{
+	
+	const int num_neighbors = GetNeighborhoodSize();
+	cOrganism * neighbor;
+
+	for (int i = 0; i < num_neighbors; i++){
+		// Check if this neigbhor donated the string
+		neighbor = GetNeighbor();
+		
+		if ((neighbor != NULL) && (IsDonor(neighbor->GetID()))){
+			neighbor->IncReputation();
+		}
+		
+		Rotate(1);
+	}
+	donor_list.clear();
+}

Modified: branches/hjg-dev/source/main/cOrganism.h
===================================================================
--- branches/hjg-dev/source/main/cOrganism.h	2008-11-29 06:43:59 UTC (rev 2984)
+++ branches/hjg-dev/source/main/cOrganism.h	2008-11-29 15:55:31 UTC (rev 2985)
@@ -490,6 +490,8 @@
 	void ReceiveString(tBuffer<int> str, int org_id); 
 	// Return the maximum number of characters matched by the received strings
 	std::pair < int, int > MatchString(const cString& str); 
+	// Praise all donors of this organism and then clear the list
+	void PraiseDonors(); 
 	
 	
 	

Modified: branches/hjg-dev/source/main/cTaskLib.cc
===================================================================
--- branches/hjg-dev/source/main/cTaskLib.cc	2008-11-29 06:43:59 UTC (rev 2984)
+++ branches/hjg-dev/source/main/cTaskLib.cc	2008-11-29 15:55:31 UTC (rev 2985)
@@ -3167,14 +3167,11 @@
 
 /* This task rewards organisms proportional to the raw materials
 	that it has accumulated.*/
-double cTaskLib::Task_SaveRawMaterials(cTaskContext& ctx) const {
-//	double bonus = 0.0;
-//	const cString& lineage_label = ctx.GetTaskEntry()->GetArguments().GetString(0);
-
-	// check if the task only applies to a certain label...
-	//if ((lineage_label != "-1") && (lineage_label == ctx.GetOrganism()->GetLineageLabel())) { 
-	//		bonus = ctx.GetOrganism()->GetSelfRawMaterials(); 
-	//}
+double cTaskLib::Task_SaveRawMaterials(cTaskContext& ctx) const {	
+	if (m_world->GetConfig().AUTO_REPUTATION.Get() == 5) {
+		ctx.GetOrganism()->PraiseDonors();
+	}
+	
 	return ctx.GetOrganism()->GetSelfRawMaterials(); 
 }
 




More information about the Avida-cvs mailing list