[Avida-SVN] r2833 - branches/hjg-dev/source/cpu
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Fri Oct 10 15:50:48 PDT 2008
Author: hjg
Date: 2008-10-10 18:50:47 -0400 (Fri, 10 Oct 2008)
New Revision: 2833
Modified:
branches/hjg-dev/source/cpu/cHardwareCPU.cc
branches/hjg-dev/source/cpu/cHardwareCPU.h
Log:
added fake donation instruction (donation-scam)
Modified: branches/hjg-dev/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/hjg-dev/source/cpu/cHardwareCPU.cc 2008-10-10 19:09:26 UTC (rev 2832)
+++ branches/hjg-dev/source/cpu/cHardwareCPU.cc 2008-10-10 22:50:47 UTC (rev 2833)
@@ -456,6 +456,9 @@
tInstLibEntry<tMethod>("get-neighbors-reputation", &cHardwareCPU::Inst_GetNeighborsReputation, nInstFlag::STALL),
tInstLibEntry<tMethod>("get-reputation", &cHardwareCPU::Inst_GetReputation, nInstFlag::STALL),
tInstLibEntry<tMethod>("get-raw-mat-amount", &cHardwareCPU::Inst_GetAmountOfRawMaterials, nInstFlag::STALL),
+ tInstLibEntry<tMethod>("donation-scam", &cHardwareCPU::Inst_DonationScam, nInstFlag::STALL),
+
+
// Must always be the last instruction in the array
@@ -6741,6 +6744,24 @@
}
+
+/* An organism artificially increases its reputation without donating. */
+bool cHardwareCPU::Inst_DonationScam(cAvidaContext& ctx)
+{
+ // update reputation to include this phony donation.
+ // get the current reputation; increment by 1.
+ if (organism->HasOpinion()) {
+ int opinion = organism->GetOpinion().first + 1;
+ organism->SetOpinion(opinion);
+ } else {
+ organism->SetOpinion(1);
+ }
+
+ return true;
+}
+
+
+
/*! An organism's reputation is stored as an opinion. This instruction
uses Inst_GetNeighborsOpinion to do the heavy lifting, but includes
default behavior suitable for reputations. Specifically, if an
@@ -6795,3 +6816,6 @@
return true;
}
+
+
+
Modified: branches/hjg-dev/source/cpu/cHardwareCPU.h
===================================================================
--- branches/hjg-dev/source/cpu/cHardwareCPU.h 2008-10-10 19:09:26 UTC (rev 2832)
+++ branches/hjg-dev/source/cpu/cHardwareCPU.h 2008-10-10 22:50:47 UTC (rev 2833)
@@ -684,7 +684,8 @@
bool Inst_GetReputation(cAvidaContext& ctx);
// Get the organism's raw material level
bool Inst_GetAmountOfRawMaterials(cAvidaContext& ctx);
-
+ // Pretend to donate
+ bool Inst_DonationScam(cAvidaContext& ctx);
};
More information about the Avida-cvs
mailing list