[Avida-SVN] r2805 - in branches/hjg-dev/source: cpu main

hjg at myxo.css.msu.edu hjg at myxo.css.msu.edu
Mon Sep 29 09:04:10 PDT 2008


Author: hjg
Date: 2008-09-29 12:04:08 -0400 (Mon, 29 Sep 2008)
New Revision: 2805

Modified:
   branches/hjg-dev/source/cpu/cHardwareCPU.cc
   branches/hjg-dev/source/main/cOrganism.cc
   branches/hjg-dev/source/main/cOrganism.h
Log:
modified the Inst_DonateFacingRawMaterials so that the recipient is rotated to face the donor.

Modified: branches/hjg-dev/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/hjg-dev/source/cpu/cHardwareCPU.cc	2008-09-29 12:20:07 UTC (rev 2804)
+++ branches/hjg-dev/source/cpu/cHardwareCPU.cc	2008-09-29 16:04:08 UTC (rev 2805)
@@ -6691,9 +6691,11 @@
 	if (organism->SubtractSelfRawMaterials(1)) {
 		neighbor->AddOtherRawMaterials(1); 
 		
-		// rotate recipient to face donor
-//		organism->GetWorld()->GetPopulation().GetCell(organism->GetCellID()).ConnectionList().Front().ConnectionList().Rotate(...)
-
+		// rotate recipient to face donor 
+		// by rotating until the recipient faces the donor
+		while (neighbor->GetNeighbor() != organism) {
+			neighbor->Rotate(1);
+		}
 	}
 	isSuccessful = true;
   }

Modified: branches/hjg-dev/source/main/cOrganism.cc
===================================================================
--- branches/hjg-dev/source/main/cOrganism.cc	2008-09-29 12:20:07 UTC (rev 2804)
+++ branches/hjg-dev/source/main/cOrganism.cc	2008-09-29 16:04:08 UTC (rev 2805)
@@ -767,3 +767,11 @@
 	m_other_raw_materials += amount;
 	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);
+
+}

Modified: branches/hjg-dev/source/main/cOrganism.h
===================================================================
--- branches/hjg-dev/source/main/cOrganism.h	2008-09-29 12:20:07 UTC (rev 2804)
+++ branches/hjg-dev/source/main/cOrganism.h	2008-09-29 16:04:08 UTC (rev 2805)
@@ -451,6 +451,9 @@
 	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); 
 		
 protected:
 	// Initialize reputation support




More information about the Avida-cvs mailing list