[Avida-SVN] r3351 - development/source/cpu

blwalker at myxo.css.msu.edu blwalker at myxo.css.msu.edu
Mon Jul 6 06:45:20 PDT 2009


Author: blwalker
Date: 2009-07-06 09:45:19 -0400 (Mon, 06 Jul 2009)
New Revision: 3351

Modified:
   development/source/cpu/cHardwareCPU.cc
   development/source/cpu/cHardwareCPU.h
Log:

Adding "nop-collect", a no-op that uses the same nop-specifications as the other "collect" instructions.


Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc	2009-07-02 19:54:35 UTC (rev 3350)
+++ development/source/cpu/cHardwareCPU.cc	2009-07-06 13:45:19 UTC (rev 3351)
@@ -234,6 +234,7 @@
     tInstLibEntry<tMethod>("collect", &cHardwareCPU::Inst_Collect, nInstFlag::STALL),
     tInstLibEntry<tMethod>("collect-no-env-remove", &cHardwareCPU::Inst_CollectNoEnvRemove, nInstFlag::STALL),
     tInstLibEntry<tMethod>("destroy", &cHardwareCPU::Inst_Destroy, nInstFlag::STALL),
+    tInstLibEntry<tMethod>("nop-collect", &cHardwareCPU::Inst_NopCollect),
 
     tInstLibEntry<tMethod>("donate-rnd", &cHardwareCPU::Inst_DonateRandom),
     tInstLibEntry<tMethod>("donate-kin", &cHardwareCPU::Inst_DonateKin),
@@ -3504,6 +3505,13 @@
  * of resources.  (Motivation: can evolve to be more specific if there is 
  * an advantage.)
  *
+ * @blw
+ * PLEASE NOTE: This does not work well (indeed, will crash) when the number
+ * of resources is not a power of the number of nops.  Until I figure out a 
+ * way to fix the mapping without introducing specification ease bias, please
+ * just put some unused dummy resources in your environment file.  This is a
+ * horrible excuse for a "fix" but it works.
+ *
  * Mostly ripped from Jeff B.'s DoSense(); meant to be a helper function for
  * DoSense, Inst_Collect, and anything else that wants to use this type of
  * resource NOP-specification.
@@ -3669,6 +3677,13 @@
   return DoCollect(ctx, true, false);
 }
 
+/* A no-op, nop-modified in the same way as the "collect" instructions:
+ * Does not remove resource from environment, does not add resource to organism */
+bool cHardwareCPU::Inst_NopCollect(cAvidaContext& ctx)
+{
+  return DoCollect(ctx, false, false);
+}
+
 /*! Sense the level of resources in this organism's cell, and if all of the 
 resources present are above the min level for that resource, execute the following
 intruction.  Otherwise, skip the following instruction.

Modified: development/source/cpu/cHardwareCPU.h
===================================================================
--- development/source/cpu/cHardwareCPU.h	2009-07-02 19:54:35 UTC (rev 3350)
+++ development/source/cpu/cHardwareCPU.h	2009-07-06 13:45:19 UTC (rev 3351)
@@ -499,7 +499,8 @@
   bool DoCollect(cAvidaContext& ctx, bool env_remove, bool internal_add);
   bool Inst_Collect(cAvidaContext& ctx);
   bool Inst_CollectNoEnvRemove(cAvidaContext& ctx);
-  bool Inst_Destroy(cAvidaContext& ctx);  
+  bool Inst_Destroy(cAvidaContext& ctx);
+  bool Inst_NopCollect(cAvidaContext& ctx);  
   bool Inst_IfResources(cAvidaContext& ctx);  //! Execute the following instruction if all resources are above their min level.
 
   // Donation




More information about the Avida-cvs mailing list