[Avida-SVN] r2134 - in branches/dkdev: Avida.xcodeproj source/cpu

dknoester at myxo.css.msu.edu dknoester at myxo.css.msu.edu
Wed Oct 10 12:31:09 PDT 2007


Author: dknoester
Date: 2007-10-10 15:31:08 -0400 (Wed, 10 Oct 2007)
New Revision: 2134

Modified:
   branches/dkdev/Avida.xcodeproj/project.pbxproj
   branches/dkdev/source/cpu/cHardwareCPU.cc
   branches/dkdev/source/cpu/cHardwareCPU.h
Log:
Added instructions to sense the dimensions of the environment.

Modified: branches/dkdev/Avida.xcodeproj/project.pbxproj
===================================================================
--- branches/dkdev/Avida.xcodeproj/project.pbxproj	2007-10-10 13:21:28 UTC (rev 2133)
+++ branches/dkdev/Avida.xcodeproj/project.pbxproj	2007-10-10 19:31:08 UTC (rev 2134)
@@ -1237,9 +1237,9 @@
 				70CA6EF208DB7F9E00068AC2 /* cInstruction.h */,
 				70CA6EC008DB7F8200068AC2 /* cInstSet.cc */,
 				70CA6EF308DB7F9E00068AC2 /* cInstSet.h */,
-				70CA6EC108DB7F8200068AC2 /* cInstUtil.cc */,
 				70CA6EF408DB7F9E00068AC2 /* cInstUtil.h */,
 				70B0865108F4974300FC65FE /* cLandscape.cc */,
+				70CA6EC108DB7F8200068AC2 /* cInstUtil.cc */,
 				70B0864808F4972600FC65FE /* cLandscape.h */,
 				70B0865408F4974300FC65FE /* cLocalMutations.cc */,
 				70B0864B08F4972600FC65FE /* cLocalMutations.h */,

Modified: branches/dkdev/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/dkdev/source/cpu/cHardwareCPU.cc	2007-10-10 13:21:28 UTC (rev 2133)
+++ branches/dkdev/source/cpu/cHardwareCPU.cc	2007-10-10 19:31:08 UTC (rev 2134)
@@ -385,9 +385,10 @@
     cInstEntryCPU("cell-two.y", &cHardwareCPU::Inst_CellTwoY),
     cInstEntryCPU("self.x", &cHardwareCPU::Inst_SelfX),
     cInstEntryCPU("self.y", &cHardwareCPU::Inst_SelfY),
+    cInstEntryCPU("env.x", &cHardwareCPU::Inst_EnvX),
+    cInstEntryCPU("env.y", &cHardwareCPU::Inst_EnvY),
     cInstEntryCPU("sorted?", &cHardwareCPU::Inst_Sorted)
 //    cInstEntryCPU("", &cHardwareCPU::Inst_),
-//    cInstEntryCPU("", &cHardwareCPU::Inst_),
   };
   
   const int n_size = sizeof(s_n_array)/sizeof(cNOPEntryCPU);
@@ -3884,6 +3885,25 @@
 }
 
 
+bool cHardwareCPU::Inst_EnvX(cAvidaContext& ctx) {
+  if(organism->GetCellID()==-1) return false;
+  cPopulationCell& cell = m_world->GetPopulation().GetCell(organism->GetCellID());
+  cDeme& deme = m_world->GetPopulation().GetDeme(cell.GetDemeID());
+  const int x = FindModifiedRegister(REG_BX);
+  GetRegister(x) = deme.GetWidth();
+  return true;
+}
+
+
+bool cHardwareCPU::Inst_EnvY(cAvidaContext& ctx) {
+  if(organism->GetCellID()==-1) return false;
+  cPopulationCell& cell = m_world->GetPopulation().GetCell(organism->GetCellID());
+  cDeme& deme = m_world->GetPopulation().GetDeme(cell.GetDemeID());
+  const int y = FindModifiedRegister(REG_BX);
+  GetRegister(y) = deme.GetHeight();
+}
+
+
 //! Executes the next instruction if all available registers are sorted in 
 bool cHardwareCPU::Inst_Sorted(cAvidaContext& ctx) {
   const int dest = FindModifiedRegister(REG_BX);

Modified: branches/dkdev/source/cpu/cHardwareCPU.h
===================================================================
--- branches/dkdev/source/cpu/cHardwareCPU.h	2007-10-10 13:21:28 UTC (rev 2133)
+++ branches/dkdev/source/cpu/cHardwareCPU.h	2007-10-10 19:31:08 UTC (rev 2134)
@@ -496,13 +496,15 @@
   
   // Two cells instructions.
   bool Inst_Region(cAvidaContext& ctx);
-  bool cHardwareCPU::Inst_CellOneX(cAvidaContext& ctx);
-  bool cHardwareCPU::Inst_CellOneY(cAvidaContext& ctx);
-  bool cHardwareCPU::Inst_CellTwoX(cAvidaContext& ctx);
-  bool cHardwareCPU::Inst_CellTwoY(cAvidaContext& ctx);
-  bool cHardwareCPU::Inst_SelfX(cAvidaContext& ctx);
-  bool cHardwareCPU::Inst_SelfY(cAvidaContext& ctx);
-  bool cHardwareCPU::Inst_Sorted(cAvidaContext& ctx);
+  bool Inst_CellOneX(cAvidaContext& ctx);
+  bool Inst_CellOneY(cAvidaContext& ctx);
+  bool Inst_CellTwoX(cAvidaContext& ctx);
+  bool Inst_CellTwoY(cAvidaContext& ctx);
+  bool Inst_SelfX(cAvidaContext& ctx);
+  bool Inst_SelfY(cAvidaContext& ctx);
+  bool Inst_EnvX(cAvidaContext& ctx);
+  bool Inst_EnvY(cAvidaContext& ctx);
+  bool Inst_Sorted(cAvidaContext& ctx);
 };
 
 




More information about the Avida-cvs mailing list