[Avida-SVN] r2201 - in branches/energy: Avida.xcodeproj source/cpu source/main
grabow38 at myxo.css.msu.edu
grabow38 at myxo.css.msu.edu
Wed Nov 14 10:51:13 PST 2007
Author: grabow38
Date: 2007-11-14 13:51:13 -0500 (Wed, 14 Nov 2007)
New Revision: 2201
Modified:
branches/energy/Avida.xcodeproj/project.pbxproj
branches/energy/source/cpu/cHardwareCPU.cc
branches/energy/source/cpu/cHardwareCPU.h
branches/energy/source/main/cPopulation.cc
Log:
Added new sense-cell-data instruction to energy branch for follow-the-leader.
Modified: branches/energy/Avida.xcodeproj/project.pbxproj
===================================================================
--- branches/energy/Avida.xcodeproj/project.pbxproj 2007-11-13 23:12:43 UTC (rev 2200)
+++ branches/energy/Avida.xcodeproj/project.pbxproj 2007-11-14 18:51:13 UTC (rev 2201)
@@ -214,23 +214,6 @@
};
/* End PBXBuildRule section */
-/* Begin PBXBuildStyle section */
- B55F38D40CE1069F006750F9 /* Development */ = {
- isa = PBXBuildStyle;
- buildSettings = {
- COPY_PHASE_STRIP = NO;
- };
- name = Development;
- };
- B55F38D50CE1069F006750F9 /* Deployment */ = {
- isa = PBXBuildStyle;
- buildSettings = {
- COPY_PHASE_STRIP = YES;
- };
- name = Deployment;
- };
-/* End PBXBuildStyle section */
-
/* Begin PBXContainerItemProxy section */
56F555DA0C3B36FC00E2E929 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
@@ -1804,12 +1787,6 @@
DCC30C4D0762532C008F7A48 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 702442D70859E0B00059BD9B /* Build configuration list for PBXProject "Avida" */;
- buildSettings = {
- };
- buildStyles = (
- B55F38D40CE1069F006750F9 /* Development */,
- B55F38D50CE1069F006750F9 /* Deployment */,
- );
hasScannedForEncodings = 0;
mainGroup = DCC30C490762532C008F7A48;
productRefGroup = DCC3164E07626CF3008F7A48 /* Products */;
Modified: branches/energy/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/energy/source/cpu/cHardwareCPU.cc 2007-11-13 23:12:43 UTC (rev 2200)
+++ branches/energy/source/cpu/cHardwareCPU.cc 2007-11-14 18:51:13 UTC (rev 2201)
@@ -237,6 +237,7 @@
tInstLibEntry<tMethod>("move", &cHardwareCPU::Inst_Move),
// Addition for follow-the-leader
tInstLibEntry<tMethod>("sense3-and-rotate", &cHardwareCPU::Inst_Sense3andRotate),
+ tInstLibEntry<tMethod>("sense-cell-data", &cHardwareCPU::Inst_SenseCellData),
// Threading instructions
tInstLibEntry<tMethod>("fork-th", &cHardwareCPU::Inst_ForkThread),
@@ -3841,8 +3842,34 @@
return true;
}
+// More follow-the-leader; separate out sensing, @ LMG
+// The instruction reads the label following the instruction (if any), and senses the data in the cell specified by the
+// nop label:
+// nop-A: left cell
+// nop-C: right cell
+// nop-B or none: faced (center) cell
+bool cHardwareCPU::Inst_SenseCellData(cAvidaContext& ctx)
+{
+ int cell_value;
+ cPopulationCell mycell;
+ const int label = FindModifiedRegister(REG_BX);
+
+ // Get the current cell ID
+ mycell = m_world->GetPopulation().GetCell(organism->GetCellID());
+
+ // changed to use registers enum
+ // Sense the appropriate cell according to the label
+ if ( label == REG_AX) { cell_value = mycell.ConnectionList ().GetLast()->GetCellData(); } // nop-A, sense left
+ else if ( label == REG_CX) { cell_value = mycell.ConnectionList().GetFirst()->GetCellData(); } // nop-C, sense right
+ else { cell_value = mycell.GetCellFaced().GetCellData(); } // default, sense faced
+ // cout << "Label = " << label << " Cell data = " << cell_value << endl;
+
+ GetRegister(REG_BX) = cell_value;
+ return true;
+}
+
// @WRE addition for movement
// Tumble sets the organism and cell to a new random facing
//
Modified: branches/energy/source/cpu/cHardwareCPU.h
===================================================================
--- branches/energy/source/cpu/cHardwareCPU.h 2007-11-13 23:12:43 UTC (rev 2200)
+++ branches/energy/source/cpu/cHardwareCPU.h 2007-11-14 18:51:13 UTC (rev 2201)
@@ -483,7 +483,7 @@
bool Inst_Move(cAvidaContext& ctx);
// Additions for follow-the-leader
bool Inst_Sense3andRotate(cAvidaContext& ctx);
-
+ bool Inst_SenseCellData(cAvidaContext& ctx); // @ LMG, more follow-the-leader
// Multi-threading...
bool Inst_ForkThread(cAvidaContext& ctx);
Modified: branches/energy/source/main/cPopulation.cc
===================================================================
--- branches/energy/source/main/cPopulation.cc 2007-11-13 23:12:43 UTC (rev 2200)
+++ branches/energy/source/main/cPopulation.cc 2007-11-14 18:51:13 UTC (rev 2201)
@@ -809,6 +809,13 @@
//cout << "SwapCells: clearing cell contents" << endl;
cOrganism * org1 = cell1.RemoveOrganism();
cOrganism * org2 = cell2.RemoveOrganism();
+ // @WRE additions for movement logging
+ int x = 0;
+ int y = 0;
+ int x1 = 0;
+ int y1 = 0;
+ int cid = 0;
+
//cout << "SwapCells: organism 2 is non-null, fix up source cell" << endl;
if (org2 != NULL) {
cell1.InsertOrganism(org2);
@@ -820,6 +827,22 @@
if (org1 != NULL) {
cell2.InsertOrganism(org1);
schedule->Adjust(cell2.GetID(), org1->GetPhenotype().GetMerit());
+ // @WRE additions for movement logging
+ cell1.GetPosition(x1,y1);
+ cell2.GetPosition(x,y);
+ cid = org1->GetID();
+
+ // Output some information
+ ofstream movelog;
+ movelog.open("data/movelog.txt",ios::app);
+ // By columns: org ID, from cell xy, to cell xy
+ movelog << cid << " " <<
+ x1 << " " <<
+ y1 << " " <<
+ x << " " <<
+ y << " " << endl;
+ movelog.close();
+
} else {
schedule->Adjust(cell2.GetID(), cMerit(0));
}
More information about the Avida-cvs
mailing list