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

hjg at myxo.css.msu.edu hjg at myxo.css.msu.edu
Mon Oct 13 07:42:43 PDT 2008


Author: hjg
Date: 2008-10-13 10:42:42 -0400 (Mon, 13 Oct 2008)
New Revision: 2838

Modified:
   branches/hjg-dev/source/main/cTaskLib.cc
   branches/hjg-dev/source/main/cTaskLib.h
Log:
Added task that rewards for receiving raw materials from many organisms.

Modified: branches/hjg-dev/source/main/cTaskLib.cc
===================================================================
--- branches/hjg-dev/source/main/cTaskLib.cc	2008-10-12 15:13:09 UTC (rev 2837)
+++ branches/hjg-dev/source/main/cTaskLib.cc	2008-10-13 14:42:42 UTC (rev 2838)
@@ -420,7 +420,10 @@
   // reputation based tasks
   else if(name == "use_raw_mat")
     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);		
 
+
   // event tasks
   if(name == "move_to_event")
     NewTask(name, "Moved into cell containing event", &cTaskLib::Task_MoveToEvent);
@@ -3074,3 +3077,17 @@
 	}
 	return bonus;
 }
+
+// For reputation-based work. See cOrganism.
+/* 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
+donated to it.*/
+double cTaskLib::Task_UseManyOrgsRawMaterials(cTaskContext& ctx) const {
+	double bonus = 0.0;
+	if ((ctx.GetOrganism()->GetSelfRawMaterials() > 1) && 
+		(ctx.GetOrganism()->GetNumberOfDonors() > 1)) {
+		 bonus = ctx.GetOrganism()->GetNumberOfDonors(); 
+	}
+	return bonus;
+}

Modified: branches/hjg-dev/source/main/cTaskLib.h
===================================================================
--- branches/hjg-dev/source/main/cTaskLib.h	2008-10-12 15:13:09 UTC (rev 2837)
+++ branches/hjg-dev/source/main/cTaskLib.h	2008-10-13 14:42:42 UTC (rev 2838)
@@ -299,6 +299,8 @@
   
   // reputation
   double Task_UseRawMaterials(cTaskContext& ctx) const;
+  double Task_UseManyOrgsRawMaterials(cTaskContext& ctx) const;
+
 };
 
 




More information about the Avida-cvs mailing list