[Avida-SVN] r3090 - branches/hjg-dev/source/main

hjg at myxo.css.msu.edu hjg at myxo.css.msu.edu
Sun Jan 4 16:15:12 PST 2009


Author: hjg
Date: 2009-01-04 19:15:12 -0500 (Sun, 04 Jan 2009)
New Revision: 3090

Modified:
   branches/hjg-dev/source/main/cTaskLib.cc
   branches/hjg-dev/source/main/cTaskLib.h
Log:
Separated credit for producing from the perfect string task.

Modified: branches/hjg-dev/source/main/cTaskLib.cc
===================================================================
--- branches/hjg-dev/source/main/cTaskLib.cc	2009-01-04 02:33:35 UTC (rev 3089)
+++ branches/hjg-dev/source/main/cTaskLib.cc	2009-01-05 00:15:12 UTC (rev 3090)
@@ -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);		
+	if (name == "prodstr") 
+    Load_ProduceStr(name, info, envreqs, errors);
 
 
 
@@ -3236,17 +3238,17 @@
 		}
 	}
 	
-	// Double bonus for creating perfect strings!
-	bonus = min * 4; 
+	// Bonus for creating perfect strings!
+	bonus = min; 
 	
-	// Add in some value for just creating stuff
+/*	// Add in some value for just creating stuff
 	for (unsigned int i = 0; i<m_strings.size(); i++) {
 		temp = ctx.GetOrganism()->GetNumberStringsOnHand(i); 
 		
 		if (temp > min) { 
 			bonus += (temp - min); 
 		}
-	}
+	} */
 	
 	// Update stats
 	m_world->GetStats().IncPerfectMatch(min);
@@ -3255,4 +3257,50 @@
 	return bonus; 
 }
 
+void cTaskLib::Load_ProduceStr(const cString& name, const cString& argstr, cEnvReqs& envreqs, tList<cString>* errors)
+{
+  cArgSchema schema;
+	schema.AddEntry("tag",0,-1);
+  cArgContainer* args = cArgContainer::Load(argstr, schema, errors);	
+  if (args) NewTask(name, "ProduceString", &cTaskLib::Task_ProduceStr, 0, args);
+}
 
+/* Note that this string requires a CAP.*/
+double cTaskLib::Task_ProduceStr(cTaskContext& ctx) const {
+	double bonus = 0.0;
+	int temp = 0;
+	int tag = ctx.GetTaskEntry()->GetArguments().GetInt(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;
+		}
+	}
+	
+	// Double bonus for creating perfect strings!
+	//bonus = min * 4; 
+	
+	// Add in some value for just creating stuff
+	for (unsigned int i = 0; i<m_strings.size(); i++) {
+		temp = ctx.GetOrganism()->GetNumberStringsOnHand(i); 
+		
+		if (temp > min) { 
+			bonus += (temp - min); 
+		}
+	}
+	
+	// Update stats
+	/*m_world->GetStats().IncPerfectMatch(min);
+	if (min > 0) m_world->GetStats().IncPerfectMatchOrg(); */
+	
+	temp = ctx.GetOrganism()->GetNumberStringsProduced(tag);
+/*	if (temp > m_world->GetConfig().STRING_AMOUNT_CAP.Get()) { 
+		temp = m_world->GetConfig().STRING_AMOUNT_CAP.Get(); 
+	}*/
+	bonus = (double)temp / m_world->GetConfig().STRING_AMOUNT_CAP.Get(); 
+	
+	return bonus; 
+}
\ No newline at end of file

Modified: branches/hjg-dev/source/main/cTaskLib.h
===================================================================
--- branches/hjg-dev/source/main/cTaskLib.h	2009-01-04 02:33:35 UTC (rev 3089)
+++ branches/hjg-dev/source/main/cTaskLib.h	2009-01-05 00:15:12 UTC (rev 3090)
@@ -315,7 +315,8 @@
   double Task_SaveRawMaterials(cTaskContext& ctx) const;
 	double Task_StoreStrings(cTaskContext& ctx) const;
 	double Task_CreatePerfectStrings(cTaskContext& ctx) const; 
-
+  void Load_ProduceStr(const cString& name, const cString& argstr, cEnvReqs& envreqs, tList<cString>* errors);
+  double Task_ProduceStr(cTaskContext& ctx) const;
 		
 
 };




More information about the Avida-cvs mailing list