[Avida-SVN] r2571 - branches/energy/source/cpu

connel42 at myxo.css.msu.edu connel42 at myxo.css.msu.edu
Thu May 1 15:34:29 PDT 2008


Author: connel42
Date: 2008-05-01 18:34:29 -0400 (Thu, 01 May 2008)
New Revision: 2571

Modified:
   branches/energy/source/cpu/cHardwareCPU.cc
   branches/energy/source/cpu/cHardwareCPU.h
Log:
* fixed logic error in if-pheromone
* added if-not-pheromone




Modified: branches/energy/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/energy/source/cpu/cHardwareCPU.cc	2008-05-01 20:20:37 UTC (rev 2570)
+++ branches/energy/source/cpu/cHardwareCPU.cc	2008-05-01 22:34:29 UTC (rev 2571)
@@ -259,6 +259,7 @@
     tInstLibEntry<tMethod>("if-target", &cHardwareCPU::Inst_IfTarget),
     tInstLibEntry<tMethod>("if-not-target", &cHardwareCPU::Inst_IfNotTarget),
     tInstLibEntry<tMethod>("if-pheromone", &cHardwareCPU::Inst_IfPheromone),
+    tInstLibEntry<tMethod>("if-not-pheromone", &cHardwareCPU::Inst_IfNotPheromone),
     tInstLibEntry<tMethod>("drop-pheromone", &cHardwareCPU::Inst_DropPheromone),
 
     
@@ -3701,7 +3702,7 @@
   
   for (int i = 0; i < deme_resource_count.GetSize(); i++) {
     if(strcmp(deme_resource_count.GetResName(i), "pheromone") == 0) {
-      if(cell_resources[i] > 0) {
+      if(cell_resources[i] == 0) {
         IP().Advance();
       }
     }
@@ -3712,7 +3713,31 @@
 } //End Inst_IfPheromone()
 
 
+bool cHardwareCPU::Inst_IfNotPheromone(cAvidaContext& ctx)
+{
+  int cellid = organism->GetCellID(); //absolute id of current cell
+  cPopulation& pop = m_world->GetPopulation();
+  cDeme &deme = pop.GetDeme(pop.GetCell(cellid).GetDemeID());
+  int relative_cell_id = deme.GetRelativeCellID(cellid);
 
+  cResourceCount deme_resource_count = deme.GetDemeResourceCount();
+  tArray<double> cell_resources = deme_resource_count.GetCellResources(relative_cell_id);
+
+  if(deme_resource_count.GetSize() == 0) return false;
+  
+  for (int i = 0; i < deme_resource_count.GetSize(); i++) {
+    if(strcmp(deme_resource_count.GetResName(i), "pheromone") == 0) {
+      if(cell_resources[i] > 0) {
+        IP().Advance();
+      }
+    }
+  }
+
+  return true;
+
+} //End Inst_IfNotPheromone()
+
+
 bool cHardwareCPU::Inst_DropPheromone(cAvidaContext& ctx)
 {
   cPopulation& pop = m_world->GetPopulation();

Modified: branches/energy/source/cpu/cHardwareCPU.h
===================================================================
--- branches/energy/source/cpu/cHardwareCPU.h	2008-05-01 20:20:37 UTC (rev 2570)
+++ branches/energy/source/cpu/cHardwareCPU.h	2008-05-01 22:34:29 UTC (rev 2571)
@@ -505,6 +505,7 @@
   bool Inst_IfTarget(cAvidaContext& ctx);
   bool Inst_IfNotTarget(cAvidaContext& ctx);
   bool Inst_IfPheromone(cAvidaContext& ctx);
+  bool Inst_IfNotPheromone(cAvidaContext& ctx);
   bool Inst_DropPheromone(cAvidaContext& ctx);
 
 




More information about the Avida-cvs mailing list