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

blwalker at myxo.css.msu.edu blwalker at myxo.css.msu.edu
Sat Mar 14 10:23:49 PDT 2009


Author: blwalker
Date: 2009-03-14 13:23:48 -0400 (Sat, 14 Mar 2009)
New Revision: 3190

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

Replaced Inst_CollectNoInternalAdd with Inst_Destroy, a better name for the same functionality: remove the specified resource(s) from the environment, but do not store them in the organism, effectively destroying them.


Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc	2009-03-13 14:43:55 UTC (rev 3189)
+++ development/source/cpu/cHardwareCPU.cc	2009-03-14 17:23:48 UTC (rev 3190)
@@ -226,10 +226,11 @@
     tInstLibEntry<tMethod>("sense", &cHardwareCPU::Inst_SenseLog2, nInstFlag::STALL),           // If you add more sense instructions
     tInstLibEntry<tMethod>("sense-unit", &cHardwareCPU::Inst_SenseUnit, nInstFlag::STALL),      // and want to keep stats, also add
     tInstLibEntry<tMethod>("sense-m100", &cHardwareCPU::Inst_SenseMult100, nInstFlag::STALL),   // the names to cStats::cStats() @JEB
+
     tInstLibEntry<tMethod>("if-resources", &cHardwareCPU::Inst_IfResources, nInstFlag::STALL),
     tInstLibEntry<tMethod>("collect", &cHardwareCPU::Inst_Collect, nInstFlag::STALL),
     tInstLibEntry<tMethod>("collect-no-env-remove", &cHardwareCPU::Inst_CollectNoEnvRemove, nInstFlag::STALL),
-    tInstLibEntry<tMethod>("collect-no-internal-add", &cHardwareCPU::Inst_CollectNoInternalAdd, nInstFlag::STALL),
+    tInstLibEntry<tMethod>("destroy", &cHardwareCPU::Inst_Destroy, nInstFlag::STALL),
 
     tInstLibEntry<tMethod>("donate-rnd", &cHardwareCPU::Inst_DonateRandom),
     tInstLibEntry<tMethod>("donate-kin", &cHardwareCPU::Inst_DonateKin),
@@ -3495,10 +3496,12 @@
 }
 
 /* Helper function to reduce code redundancy in the Inst_Collect variations.
- * Does all the heavy lifting of external resource collection.  Use env_remove
- * to specify whether the collected resources should be removed from the
- * environment, and internal_add to specify whether the collected resources
- * should be added to the organism's internal resources.
+ * Does all the heavy lifting of external resource collection.
+ *
+ * env_remove   - specifies whether the collected resources should be removed from
+ *                the environment
+ * internal_add - specifies whether the collected resources should be added to 
+ *                the organism's internal resources.
  */
 bool cHardwareCPU::DoCollect(cAvidaContext& ctx, bool env_remove, bool internal_add)
 {
@@ -3592,9 +3595,10 @@
   return DoCollect(ctx, false, true);
 }
 
-/* Like Inst_Collect, but the collected resources are not added to the organism.
+/* Collects resource from the environment but does not add it to the organism,
+ * effectively destroying it.
  */
-bool cHardwareCPU::Inst_CollectNoInternalAdd(cAvidaContext& ctx)
+bool cHardwareCPU::Inst_Destroy(cAvidaContext& ctx)
 {
   return DoCollect(ctx, true, false);
 }

Modified: development/source/cpu/cHardwareCPU.h
===================================================================
--- development/source/cpu/cHardwareCPU.h	2009-03-13 14:43:55 UTC (rev 3189)
+++ development/source/cpu/cHardwareCPU.h	2009-03-14 17:23:48 UTC (rev 3190)
@@ -486,13 +486,16 @@
   bool Inst_SenseUnit(cAvidaContext& ctx);
   bool Inst_SenseMult100(cAvidaContext& ctx);
   bool DoSense(cAvidaContext& ctx, int conversion_method, double base);
+  
+  // Resources
   bool FindModifiedResource(int& start_index, int& end_index);
   bool DoCollect(cAvidaContext& ctx, bool env_remove, bool internal_add);
   bool Inst_Collect(cAvidaContext& ctx);
   bool Inst_CollectNoEnvRemove(cAvidaContext& ctx);
-  bool Inst_CollectNoInternalAdd(cAvidaContext& ctx);  //! Execute the following instruction if all resources are above their min level.
-  bool Inst_IfResources(cAvidaContext& ctx);
+  bool Inst_Destroy(cAvidaContext& ctx);  
+  bool Inst_IfResources(cAvidaContext& ctx);  //! Execute the following instruction if all resources are above their min level.
 
+  // Donation
   void DoDonate(cOrganism * to_org);
   void DoEnergyDonate(cOrganism* to_org);
   void DoEnergyDonatePercent(cOrganism* to_org, const double frac_energy_given);
@@ -549,6 +552,7 @@
   bool Inst_GetCellPositionX(cAvidaContext& ctx);
   bool Inst_GetCellPositionY(cAvidaContext& ctx);
   
+  // State Grid Sensory/Movement
   bool Inst_SGMove(cAvidaContext& ctx);
   bool Inst_SGRotateL(cAvidaContext& ctx);
   bool Inst_SGRotateR(cAvidaContext& ctx);




More information about the Avida-cvs mailing list