[Avida-SVN] r2812 - in branches/hjg-dev/source: cpu main
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Wed Oct 1 02:56:05 PDT 2008
Author: hjg
Date: 2008-10-01 05:56:05 -0400 (Wed, 01 Oct 2008)
New Revision: 2812
Modified:
branches/hjg-dev/source/cpu/cHardwareCPU.cc
branches/hjg-dev/source/cpu/cHardwareCPU.h
branches/hjg-dev/source/main/cOrganism.cc
branches/hjg-dev/source/main/cOrganism.h
Log:
added sense its own raw materials instruction.
Modified: branches/hjg-dev/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/hjg-dev/source/cpu/cHardwareCPU.cc 2008-09-30 22:38:01 UTC (rev 2811)
+++ branches/hjg-dev/source/cpu/cHardwareCPU.cc 2008-10-01 09:56:05 UTC (rev 2812)
@@ -453,6 +453,7 @@
// Reputation instructions
tInstLibEntry<tMethod>("donate-frm", &cHardwareCPU::Inst_DonateFacingRawMaterials, nInstFlag::STALL),
tInstLibEntry<tMethod>("if-donor", &cHardwareCPU::Inst_IfDonor, nInstFlag::STALL),
+ tInstLibEntry<tMethod>("sense-self-rm", &cHardwareCPU::Inst_SenseSelfRawMaterialAmount, nInstFlag::STALL),
@@ -6718,3 +6719,16 @@
return true;
}
+/* Put the amout of raw materials this organism has into its
+?BX? register. */
+
+bool cHardwareCPU::Inst_SenseSelfRawMaterialAmount(cAvidaContext& ctx)
+{
+ const int raw_mat_reg = FindModifiedRegister(REG_BX);
+ GetRegister(raw_mat_reg) = organism->GetSelfRawMaterials();
+
+ return true;
+}
+
+
+
Modified: branches/hjg-dev/source/cpu/cHardwareCPU.h
===================================================================
--- branches/hjg-dev/source/cpu/cHardwareCPU.h 2008-09-30 22:38:01 UTC (rev 2811)
+++ branches/hjg-dev/source/cpu/cHardwareCPU.h 2008-10-01 09:56:05 UTC (rev 2812)
@@ -675,6 +675,7 @@
*/
bool Inst_DonateFacingRawMaterials(cAvidaContext& ctx);
bool Inst_IfDonor(cAvidaContext& ctx);
+ bool Inst_SenseSelfRawMaterialAmount(cAvidaContext& ctx);
};
Modified: branches/hjg-dev/source/main/cOrganism.cc
===================================================================
--- branches/hjg-dev/source/main/cOrganism.cc 2008-09-30 22:38:01 UTC (rev 2811)
+++ branches/hjg-dev/source/main/cOrganism.cc 2008-10-01 09:56:05 UTC (rev 2812)
@@ -769,17 +769,9 @@
return isSuccessful;
}
-/* Called when a orgaism receives a donation in order to turn the recipient to
-face its donor. It is designed to work in conjunction with the fact that an
-orgaism donates to the neighbor it is facing. */
-void cOrganism::RotateToFaceOrganism(cOrganism& org) {
-// this->GetWorld()->GetPopulation().GetCell(this->GetCellID()).ConnectionList().Front().ConnectionList().Rotate(org);
-}
-
-
/* Check if the id of this neighbor indicates that it has previously donated
-to the organism.*/
+to this organism.*/
bool cOrganism::IsDonor(int neighbor_id)
{
bool success = false;
Modified: branches/hjg-dev/source/main/cOrganism.h
===================================================================
--- branches/hjg-dev/source/main/cOrganism.h 2008-09-30 22:38:01 UTC (rev 2811)
+++ branches/hjg-dev/source/main/cOrganism.h 2008-10-01 09:56:05 UTC (rev 2812)
@@ -452,10 +452,7 @@
int GetSelfRawMaterials() {InitReputation(); return m_self_raw_materials; }
// retrieve the amount of raw materials collected from others
int GetOtherRawMaterials() {InitReputation(); return m_other_raw_materials; }
- // Rotate the organism to face a specific neighboring organism.
- // This functionality is used to turn the donation recipient to the donor.
- void RotateToFaceOrganism(cOrganism& org);
- // Is donor?
+ // Has previously donated to this organism
bool IsDonor(int neighbor_id);
protected:
More information about the Avida-cvs
mailing list