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

hjg at myxo.css.msu.edu hjg at myxo.css.msu.edu
Sat Jan 10 08:17:27 PST 2009


Author: hjg
Date: 2009-01-10 11:17:26 -0500 (Sat, 10 Jan 2009)
New Revision: 3096

Modified:
   branches/hjg-dev/source/cpu/cHardwareCPU.cc
   branches/hjg-dev/source/main/cTaskLib.cc
   branches/hjg-dev/source/main/cTaskLib.h
Log:
Added another task to check for meta-strings that does not reward for just storing simple strings.

Modified: branches/hjg-dev/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/hjg-dev/source/cpu/cHardwareCPU.cc	2009-01-09 04:14:26 UTC (rev 3095)
+++ branches/hjg-dev/source/cpu/cHardwareCPU.cc	2009-01-10 16:17:26 UTC (rev 3096)
@@ -7024,9 +7024,6 @@
   if (neighbor != NULL) {
 		
     // Check if the organism has enough of this string on hand.
-		int num = organism->GetNumberStringsOnHand(my_string); 
-		int num2 = organism->GetNumberStringsOnHand(0); 
-		
 		if ((organism->GetNumberStringsOnHand(my_string) >= cost) && (neighbor->CanReceiveString(my_string, cost))) { 
 			
 			// sometimes the donation will fail. 

Modified: branches/hjg-dev/source/main/cTaskLib.cc
===================================================================
--- branches/hjg-dev/source/main/cTaskLib.cc	2009-01-09 04:14:26 UTC (rev 3095)
+++ branches/hjg-dev/source/main/cTaskLib.cc	2009-01-10 16:17:26 UTC (rev 3096)
@@ -433,6 +433,8 @@
 		NewTask(name, "Produce and store strings", &cTaskLib::Task_StoreStrings);	
 	else if(name == "perfect_strings") 
 		NewTask(name, "Produce and store perfect strings", &cTaskLib::Task_CreatePerfectStrings);		
+	else if(name == "perfect_strings2") 
+		NewTask(name, "Produce and store perfect strings", &cTaskLib::Task_CreatePerfectStrings2);		
 
 
 
@@ -2010,15 +2012,11 @@
 	}
 	
 	
-	// Update the organism's tag. If the organism is a strict specialist then
-	// make sure it 
+	// Update the organism's tag. 
 	ctx.GetOrganism()->UpdateTag(tag, max_num_matched);
 	if (ctx.GetOrganism()->GetTagLabel() == tag) {
 		ctx.GetOrganism()->SetLineageLabel(ctx.GetTaskEntry()->GetArguments().GetInt(2));
-	} else if (m_world->GetConfig().SPECIALISTS.Get()) { 
-		max_num_matched = 0;
-	}
-	
+	} 
 
 			
 	// Update stats
@@ -3262,3 +3260,33 @@
 	
 	return bonus; 
 }
+
+
+
+/* This task provides major points for perfect strings, but no 
+ points for just storing stuff. (Similar to Task_CreatePerfectStrings) */
+double cTaskLib::Task_CreatePerfectStrings2(cTaskContext& ctx) const {
+	double bonus = 0.0;
+	int min = -1;
+	int temp = 0;
+	for (unsigned int i = 0; i<m_strings.size(); i++) {
+		temp = ctx.GetOrganism()->GetNumberStringsOnHand(i); 
+		
+		// Figure out what the minimum amount of a string is.
+		if ((min == -1) || (temp < min)){
+			min = temp;
+		}
+	}
+	
+	// Bonus for creating perfect strings!
+	bonus = min; 
+
+	
+	// Update stats
+	m_world->GetStats().IncPerfectMatch(min);
+	if (min > 0) m_world->GetStats().IncPerfectMatchOrg();
+	
+	return bonus; 
+}
+
+

Modified: branches/hjg-dev/source/main/cTaskLib.h
===================================================================
--- branches/hjg-dev/source/main/cTaskLib.h	2009-01-09 04:14:26 UTC (rev 3095)
+++ branches/hjg-dev/source/main/cTaskLib.h	2009-01-10 16:17:26 UTC (rev 3096)
@@ -315,6 +315,7 @@
   double Task_SaveRawMaterials(cTaskContext& ctx) const;
 	double Task_StoreStrings(cTaskContext& ctx) const;
 	double Task_CreatePerfectStrings(cTaskContext& ctx) const; 
+	double Task_CreatePerfectStrings2(cTaskContext& ctx) const; 
 
 		
 




More information about the Avida-cvs mailing list