[Avida-SVN] r2879 - in branches/hjg-dev/source: cpu main
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Fri Oct 24 11:19:35 PDT 2008
Author: hjg
Date: 2008-10-24 14:19:35 -0400 (Fri, 24 Oct 2008)
New Revision: 2879
Modified:
branches/hjg-dev/source/cpu/cHardwareCPU.cc
branches/hjg-dev/source/cpu/cHardwareCPU.h
branches/hjg-dev/source/main/cPopulationInterface.cc
Log:
bug fix
Modified: branches/hjg-dev/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/hjg-dev/source/cpu/cHardwareCPU.cc 2008-10-24 17:59:37 UTC (rev 2878)
+++ branches/hjg-dev/source/cpu/cHardwareCPU.cc 2008-10-24 18:19:35 UTC (rev 2879)
@@ -464,6 +464,7 @@
tInstLibEntry<tMethod>("inc-recip", &cHardwareCPU::Inst_IncRecipProb, nInstFlag::STALL),
tInstLibEntry<tMethod>("dec-recip", &cHardwareCPU::Inst_DecRecipProb, nInstFlag::STALL),
tInstLibEntry<tMethod>("rotate-to-rep", &cHardwareCPU::Inst_RotateToGreatestReputation, nInstFlag::STALL),
+ tInstLibEntry<tMethod>("rotate-to-rep-and-donate", &cHardwareCPU::Inst_RotateToGreatestReputationAndDonate, nInstFlag::STALL),
// Must always be the last instruction in the array
@@ -6925,10 +6926,19 @@
return true;
}
-// move guts to organism interface.
+/* Rotate to face the organism with the highest reputation */
bool cHardwareCPU::Inst_RotateToGreatestReputation(cAvidaContext& ctx)
{
organism->GetOrgInterface().RotateToGreatestReputation();
return true;
}
+
+/* Rotate to face the organism with the highest reputation and then
+ immediately donate */
+bool cHardwareCPU::Inst_RotateToGreatestReputationAndDonate(cAvidaContext& ctx)
+{
+ Inst_RotateToGreatestReputation(ctx);
+ Inst_DonateFacingRawMaterials(ctx);
+ return true;
+}
Modified: branches/hjg-dev/source/cpu/cHardwareCPU.h
===================================================================
--- branches/hjg-dev/source/cpu/cHardwareCPU.h 2008-10-24 17:59:37 UTC (rev 2878)
+++ branches/hjg-dev/source/cpu/cHardwareCPU.h 2008-10-24 18:19:35 UTC (rev 2879)
@@ -680,6 +680,8 @@
bool Inst_DonateFacingRawMaterials(cAvidaContext& ctx);
// Rotate to the organims with the greatest reputation
bool Inst_RotateToGreatestReputation(cAvidaContext& ctx);
+ // Rotate to the organims with the greatest reputation and donate
+ bool Inst_RotateToGreatestReputationAndDonate(cAvidaContext& ctx);
// Get a neighbor's reputation
bool Inst_GetNeighborsReputation(cAvidaContext& ctx);
// Get the organism's reputation
Modified: branches/hjg-dev/source/main/cPopulationInterface.cc
===================================================================
--- branches/hjg-dev/source/main/cPopulationInterface.cc 2008-10-24 17:59:37 UTC (rev 2878)
+++ branches/hjg-dev/source/main/cPopulationInterface.cc 2008-10-24 18:19:35 UTC (rev 2879)
@@ -361,8 +361,9 @@
}
// loop to face the max reputation
- for (int i=0; i<=k; i++) {
- cell.ConnectionList().CircNext(); // or right...
+ for (int i=0; i<k; i++) {
+ cell.ConnectionList().CircNext(); // or right...
+ int test_rep = cell.ConnectionList().GetFirst()->GetOrganism()->GetReputation();
}
}
More information about the Avida-cvs
mailing list