[Avida-SVN] r2300 - in development: Avida.xcodeproj source/cpu source/main

beckma24 at myxo.css.msu.edu beckma24 at myxo.css.msu.edu
Tue Feb 5 06:23:03 PST 2008


Author: beckma24
Date: 2008-02-05 09:23:03 -0500 (Tue, 05 Feb 2008)
New Revision: 2300

Modified:
   development/Avida.xcodeproj/project.pbxproj
   development/source/cpu/cHardwareCPU.cc
   development/source/cpu/cHardwareCPU.h
   development/source/main/cOrganism.cc
Log:
Added get-cell-x and get-cell-y instructions to cHardwareCPU.  Fixed bug caused by not initializing global_res_change and deme_res_change is cOrganism::DoOutput

Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj	2008-02-05 13:01:29 UTC (rev 2299)
+++ development/Avida.xcodeproj/project.pbxproj	2008-02-05 14:23:03 UTC (rev 2300)
@@ -213,6 +213,23 @@
 		};
 /* End PBXBuildRule section */
 
+/* Begin PBXBuildStyle section */
+		B55E29FE0D58A22300F093BD /* Development */ = {
+			isa = PBXBuildStyle;
+			buildSettings = {
+				COPY_PHASE_STRIP = NO;
+			};
+			name = Development;
+		};
+		B55E29FF0D58A22300F093BD /* Deployment */ = {
+			isa = PBXBuildStyle;
+			buildSettings = {
+				COPY_PHASE_STRIP = YES;
+			};
+			name = Deployment;
+		};
+/* End PBXBuildStyle section */
+
 /* Begin PBXContainerItemProxy section */
 		56F555DA0C3B36FC00E2E929 /* PBXContainerItemProxy */ = {
 			isa = PBXContainerItemProxy;
@@ -1784,11 +1801,16 @@
 		DCC30C4D0762532C008F7A48 /* Project object */ = {
 			isa = PBXProject;
 			buildConfigurationList = 702442D70859E0B00059BD9B /* Build configuration list for PBXProject "Avida" */;
+			buildSettings = {
+			};
+			buildStyles = (
+				B55E29FE0D58A22300F093BD /* Development */,
+				B55E29FF0D58A22300F093BD /* Deployment */,
+			);
 			hasScannedForEncodings = 0;
 			mainGroup = DCC30C490762532C008F7A48;
 			productRefGroup = DCC3164E07626CF3008F7A48 /* Products */;
 			projectDirPath = "";
-			projectRoot = "";
 			targets = (
 				7023ED520C0A590200362B9C /* full-suite */,
 				DCC3164C07626CF3008F7A48 /* avida */,

Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc	2008-02-05 13:01:29 UTC (rev 2299)
+++ development/source/cpu/cHardwareCPU.cc	2008-02-05 14:23:03 UTC (rev 2300)
@@ -228,6 +228,8 @@
     tInstLibEntry<tMethod>("set-cmut", &cHardwareCPU::Inst_SetCopyMut),
     tInstLibEntry<tMethod>("mod-cmut", &cHardwareCPU::Inst_ModCopyMut),
     tInstLibEntry<tMethod>("get-cell-xy", &cHardwareCPU::Inst_GetCellPosition),
+    tInstLibEntry<tMethod>("get-cell-x", &cHardwareCPU::Inst_GetCellPositionX),
+    tInstLibEntry<tMethod>("get-cell-y", &cHardwareCPU::Inst_GetCellPositionY),
     tInstLibEntry<tMethod>("dist-from-diag", &cHardwareCPU::Inst_GetDistanceFromDiagonal),
     // @WRE additions for movement
     tInstLibEntry<tMethod>("tumble", &cHardwareCPU::Inst_Tumble),
@@ -4277,6 +4279,40 @@
   return true;
 }
 
+/*! This method places the calling organism's x coordinate in ?BX?.
+
+Note that this method *will not work* from within the test CPU, so we have to guard
+against that.
+*/
+bool cHardwareCPU::Inst_GetCellPositionX(cAvidaContext& ctx) {
+  int absolute_cell_ID = organism->GetCellID();
+  int deme_id = organism->GetOrgInterface().GetDemeID();
+  // Fail if we're running in the test CPU.
+  if((deme_id < 0) || (absolute_cell_ID < 0)) return false;
+  
+  std::pair<int, int> pos = m_world->GetPopulation().GetDeme(deme_id).GetCellPosition(absolute_cell_ID);  
+  const int xreg = FindModifiedRegister(REG_BX);
+  GetRegister(xreg) = pos.first;
+  return true;
+}
+
+/*! This method places the calling organism's y coordinates in ?BX?.
+
+Note that this method *will not work* from within the test CPU, so we have to guard
+against that.
+*/
+bool cHardwareCPU::Inst_GetCellPositionY(cAvidaContext& ctx) {
+  int absolute_cell_ID = organism->GetCellID();
+  int deme_id = organism->GetOrgInterface().GetDemeID();
+  // Fail if we're running in the test CPU.
+  if((deme_id < 0) || (absolute_cell_ID < 0)) return false;
+  
+  std::pair<int, int> pos = m_world->GetPopulation().GetDeme(deme_id).GetCellPosition(absolute_cell_ID);  
+  const int yreg = FindModifiedRegister(REG_BX);
+  GetRegister(yreg) = pos.second;
+  return true;
+}
+
 bool cHardwareCPU::Inst_GetDistanceFromDiagonal(cAvidaContext& ctx) {
   int absolute_cell_ID = organism->GetOrgInterface().GetCellID();
   int deme_id = organism->GetOrgInterface().GetDemeID();

Modified: development/source/cpu/cHardwareCPU.h
===================================================================
--- development/source/cpu/cHardwareCPU.h	2008-02-05 13:01:29 UTC (rev 2299)
+++ development/source/cpu/cHardwareCPU.h	2008-02-05 14:23:03 UTC (rev 2300)
@@ -474,6 +474,9 @@
   bool Inst_SetCopyMut(cAvidaContext& ctx);
   bool Inst_ModCopyMut(cAvidaContext& ctx);
   bool Inst_GetCellPosition(cAvidaContext& ctx);
+  bool Inst_GetCellPositionX(cAvidaContext& ctx);
+  bool Inst_GetCellPositionY(cAvidaContext& ctx);
+
   bool Inst_GetDistanceFromDiagonal(cAvidaContext& ctx);
   // @WRE additions for movement
   bool Inst_Tumble(cAvidaContext& ctx);

Modified: development/source/main/cOrganism.cc
===================================================================
--- development/source/main/cOrganism.cc	2008-02-05 13:01:29 UTC (rev 2299)
+++ development/source/main/cOrganism.cc	2008-02-05 14:23:03 UTC (rev 2300)
@@ -231,7 +231,9 @@
   // Do the testing of tasks performed...
   
   tArray<double> global_res_change(global_resource_count.GetSize());
+  global_res_change.SetAll(0.0);
   tArray<double> deme_res_change(deme_resource_count.GetSize());
+  deme_res_change.SetAll(0.0);
   tArray<int> insts_triggered;
   
   tBuffer<int>* received_messages_point = &m_received_messages;




More information about the Avida-cvs mailing list