[Avida-SVN] r1068 - branches/coopcomm/source/cpu
beckma24 at myxo.css.msu.edu
beckma24 at myxo.css.msu.edu
Wed Nov 1 14:10:10 PST 2006
Author: beckma24
Date: 2006-11-01 17:10:09 -0500 (Wed, 01 Nov 2006)
New Revision: 1068
Modified:
branches/coopcomm/source/cpu/cHardwareCPU.cc
branches/coopcomm/source/cpu/cHardwareCPU.h
Log:
Added rotate-label instruction to cHardwareCPU. This instructions rotates an organism to the direction specified by the label following it.
Modified: branches/coopcomm/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/coopcomm/source/cpu/cHardwareCPU.cc 2006-11-01 21:12:46 UTC (rev 1067)
+++ branches/coopcomm/source/cpu/cHardwareCPU.cc 2006-11-01 22:10:09 UTC (rev 1068)
@@ -228,6 +228,7 @@
cInstEntryCPU("rotate-l", &cHardwareCPU::Inst_RotateL),
cInstEntryCPU("rotate-r", &cHardwareCPU::Inst_RotateR),
cInstEntryCPU("rotate-value", &cHardwareCPU::Inst_RotateValue),
+ cInstEntryCPU("rotate-label", &cHardwareCPU::Inst_RotateLabel),
cInstEntryCPU("set-cmut", &cHardwareCPU::Inst_SetCopyMut),
cInstEntryCPU("mod-cmut", &cHardwareCPU::Inst_ModCopyMut),
@@ -3011,6 +3012,30 @@
return true;
}
+/** Written by: Ben Beckmann
+ Rotate to facing specified by following label
+*/
+bool cHardwareCPU::Inst_RotateLabel(cAvidaContext& ctx)
+{
+ int standardNeighborhoodSize, actualNeighborhoodSize, newFacing, currentFacing;
+ actualNeighborhoodSize = organism->GetNeighborhoodSize();
+
+ ReadLabel();
+ if(m_world->GetConfig().WORLD_GEOMETRY.Get() == nGeometry::TORUS || m_world->GetConfig().WORLD_GEOMETRY.Get() == nGeometry::GRID)
+ standardNeighborhoodSize = 8;
+
+ newFacing = GetLabel().AsIntGreyCode(NUM_NOPS) % standardNeighborhoodSize;
+
+ for(int i = 0; i < actualNeighborhoodSize; i++) {
+ currentFacing = organism->GetFacing();
+ if(newFacing == currentFacing)
+ break;
+ organism->Rotate(1);
+ }
+ return true;
+}
+
+
bool cHardwareCPU::Inst_SetCopyMut(cAvidaContext& ctx)
{
const int reg_used = FindModifiedRegister(REG_BX);
Modified: branches/coopcomm/source/cpu/cHardwareCPU.h
===================================================================
--- branches/coopcomm/source/cpu/cHardwareCPU.h 2006-11-01 21:12:46 UTC (rev 1067)
+++ branches/coopcomm/source/cpu/cHardwareCPU.h 2006-11-01 22:10:09 UTC (rev 1068)
@@ -401,6 +401,7 @@
bool Inst_RotateL(cAvidaContext& ctx);
bool Inst_RotateR(cAvidaContext& ctx);
bool Inst_RotateValue(cAvidaContext& ctx);
+ bool Inst_RotateLabel(cAvidaContext& ctx);
bool Inst_SetCopyMut(cAvidaContext& ctx);
bool Inst_ModCopyMut(cAvidaContext& ctx);
More information about the Avida-cvs
mailing list