[Avida-SVN] r2001 - in branches/energy: Avida.xcodeproj source/cpu
beckma24 at myxo.css.msu.edu
beckma24 at myxo.css.msu.edu
Fri Aug 24 06:38:48 PDT 2007
Author: beckma24
Date: 2007-08-24 09:38:48 -0400 (Fri, 24 Aug 2007)
New Revision: 2001
Modified:
branches/energy/Avida.xcodeproj/project.pbxproj
branches/energy/source/cpu/cHardwareCPU.cc
branches/energy/source/cpu/cHardwareCPU.h
Log:
Added get-cell-xy and dist-from-diag instructions.
Modified: branches/energy/Avida.xcodeproj/project.pbxproj
===================================================================
--- branches/energy/Avida.xcodeproj/project.pbxproj 2007-08-24 02:23:23 UTC (rev 2000)
+++ branches/energy/Avida.xcodeproj/project.pbxproj 2007-08-24 13:38:48 UTC (rev 2001)
@@ -377,7 +377,7 @@
565121C60C3B055F009CBD3F /* cCoreView_Info.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cCoreView_Info.cc; sourceTree = "<group>"; };
565121C70C3B055F009CBD3F /* cCoreView_Info.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cCoreView_Info.h; sourceTree = "<group>"; };
565121C80C3B055F009CBD3F /* LAYOUT */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = LAYOUT; sourceTree = "<group>"; };
- 56F555D00C3B364E00E2E929 /* avida-text */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = "avida-text"; sourceTree = BUILT_PRODUCTS_DIR; };
+ 56F555D00C3B364E00E2E929 /* avida-text */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "avida-text"; sourceTree = BUILT_PRODUCTS_DIR; };
56F555DF0C3B402A00E2E929 /* cDriver_TextViewer.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cDriver_TextViewer.cc; sourceTree = "<group>"; };
56F555E00C3B402A00E2E929 /* cDriver_TextViewer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cDriver_TextViewer.h; sourceTree = "<group>"; };
56F555E30C3B402A00E2E929 /* LAYOUT */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = LAYOUT; sourceTree = "<group>"; };
Modified: branches/energy/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/energy/source/cpu/cHardwareCPU.cc 2007-08-24 02:23:23 UTC (rev 2000)
+++ branches/energy/source/cpu/cHardwareCPU.cc 2007-08-24 13:38:48 UTC (rev 2001)
@@ -49,6 +49,7 @@
#include <climits>
#include <fstream>
+#include <cmath>
using namespace std;
@@ -224,6 +225,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>("dist-from-diag", &cHardwareCPU::Inst_GetDistanceFromDiagonal),
// @WRE additions for movement
tInstLibEntry<tMethod>("tumble", &cHardwareCPU::Inst_Tumble),
tInstLibEntry<tMethod>("move", &cHardwareCPU::Inst_Move),
@@ -4238,7 +4241,32 @@
return true;
}
+bool cHardwareCPU::Inst_GetCellPosition(cAvidaContext& ctx) {
+ int absolute_cell_ID = organism->GetOrgInterface().GetCellID();
+ int deme_id = organism->GetOrgInterface().GetDemeID();
+ std::pair<int, int> pos = m_world->GetPopulation().GetDeme(deme_id).GetCellPosition(absolute_cell_ID);
+ const int xreg = FindModifiedRegister(REG_BX);
+ const int yreg = FindNextRegister(xreg);
+ GetRegister(xreg) = pos.first;
+ 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();
+ std::pair<int, int> pos = m_world->GetPopulation().GetDeme(deme_id).GetCellPosition(absolute_cell_ID);
+ const int reg = FindModifiedRegister(REG_BX);
+
+ if(pos.first > pos.second) {
+ GetRegister(reg) = (int)ceil((pos.first - pos.second)/2.0);
+ } else {
+ GetRegister(reg) = (int)floor((pos.first - pos.second)/2.0);
+ }
+// std::cerr<<"x = "<<pos.first<<" y = "<<pos.second<<" ans = "<<GetRegister(reg)<<std::endl;
+ return true;
+}
+
//// Promoter Model ////
// Starting at the current position reads a promoter pattern
Modified: branches/energy/source/cpu/cHardwareCPU.h
===================================================================
--- branches/energy/source/cpu/cHardwareCPU.h 2007-08-24 02:23:23 UTC (rev 2000)
+++ branches/energy/source/cpu/cHardwareCPU.h 2007-08-24 13:38:48 UTC (rev 2001)
@@ -454,6 +454,8 @@
bool Inst_RotateLabel(cAvidaContext& ctx);
bool Inst_SetCopyMut(cAvidaContext& ctx);
bool Inst_ModCopyMut(cAvidaContext& ctx);
+ bool Inst_GetCellPosition(cAvidaContext& ctx);
+ bool Inst_GetDistanceFromDiagonal(cAvidaContext& ctx);
// @WRE additions for movement
bool Inst_Tumble(cAvidaContext& ctx);
bool Inst_Move(cAvidaContext& ctx);
More information about the Avida-cvs
mailing list