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

hjg at myxo.css.msu.edu hjg at myxo.css.msu.edu
Fri Nov 7 07:01:31 PST 2008


Author: hjg
Date: 2008-11-07 10:01:31 -0500 (Fri, 07 Nov 2008)
New Revision: 2924

Modified:
   branches/hjg-dev/source/cpu/cHardwareCPU.cc
   branches/hjg-dev/source/cpu/cHardwareCPU.h
   branches/hjg-dev/source/main/cTaskLib.cc
Log:
Added a new instruction if-donor

Modified: branches/hjg-dev/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/hjg-dev/source/cpu/cHardwareCPU.cc	2008-11-06 13:51:30 UTC (rev 2923)
+++ branches/hjg-dev/source/cpu/cHardwareCPU.cc	2008-11-07 15:01:31 UTC (rev 2924)
@@ -472,6 +472,7 @@
 		tInstLibEntry<tMethod>("rotate-to-rep", &cHardwareCPU::Inst_RotateToGreatestReputation, nInstFlag::STALL),
 		tInstLibEntry<tMethod>("rotate-to-rep-k", &cHardwareCPU::Inst_RotateToReputationK, nInstFlag::STALL),
 		tInstLibEntry<tMethod>("rotate-to-rep-and-donate", &cHardwareCPU::Inst_RotateToGreatestReputationAndDonate, nInstFlag::STALL),
+		tInstLibEntry<tMethod>("if-donor",  &cHardwareCPU::Inst_IfDonor, nInstFlag::STALL),
 //		bool Inst_DonateIfDonor(cAvidaContext& ctx);	
 	
 
@@ -7098,9 +7099,28 @@
 }
 
 /* Increase the lower reputation bar */
-bool cHardwareCPU:: Inst_IncK(cAvidaContext& ctx)
+bool cHardwareCPU::Inst_IncK(cAvidaContext& ctx)
 {
 	organism->IncK();
 	return true;
 }
+ 
+/* Execute the next instruction if the neighbor was a donor. */ 
+bool cHardwareCPU::Inst_IfDonor(cAvidaContext& ctx) 
+{
+	bool donor = false;
+	cOrganism * neighbor = organism->GetNeighbor();
+	if (neighbor != NULL) {
+		// check if the neighbor was a donor
+		if (organism->IsDonor(neighbor->GetID())) {
+			donor = true;
+		}
+	}
+  if (!donor)  IP().Advance();
+	
+  return true; 
+
+}
+
+ 
  
\ No newline at end of file

Modified: branches/hjg-dev/source/cpu/cHardwareCPU.h
===================================================================
--- branches/hjg-dev/source/cpu/cHardwareCPU.h	2008-11-06 13:51:30 UTC (rev 2923)
+++ branches/hjg-dev/source/cpu/cHardwareCPU.h	2008-11-07 15:01:31 UTC (rev 2924)
@@ -694,6 +694,9 @@
   bool Inst_GetNeighborsReputation(cAvidaContext& ctx);
   // Get the organism's reputation
   bool Inst_GetReputation(cAvidaContext& ctx);	
+	// Execute the following instruction if the facing neighbor was a donor
+	bool Inst_IfDonor(cAvidaContext& ctx);
+
 	
 	
 	// Donation to facing neighbor with a probability that it is reciprocated

Modified: branches/hjg-dev/source/main/cTaskLib.cc
===================================================================
--- branches/hjg-dev/source/main/cTaskLib.cc	2008-11-06 13:51:30 UTC (rev 2923)
+++ branches/hjg-dev/source/main/cTaskLib.cc	2008-11-07 15:01:31 UTC (rev 2924)
@@ -428,6 +428,7 @@
     NewTask(name, "Consume raw materials", &cTaskLib::Task_ConsumeRawMaterials);			
   else if(name == "save_raw_mat")
     NewTask(name, "Save raw materials", &cTaskLib::Task_SaveRawMaterials);	
+	
 
   // event tasks
   if(name == "move_to_event")




More information about the Avida-cvs mailing list