[Avida-SVN] r2990 - branches/hjg-dev/source/cpu
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Tue Dec 2 07:40:22 PST 2008
Author: hjg
Date: 2008-12-02 10:40:22 -0500 (Tue, 02 Dec 2008)
New Revision: 2990
Modified:
branches/hjg-dev/source/cpu/cHardwareCPU.cc
Log:
modified the functionality of doante-directra to preserve organism facing
Modified: branches/hjg-dev/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/hjg-dev/source/cpu/cHardwareCPU.cc 2008-11-30 23:22:15 UTC (rev 2989)
+++ branches/hjg-dev/source/cpu/cHardwareCPU.cc 2008-12-02 15:40:22 UTC (rev 2990)
@@ -3487,30 +3487,30 @@
// Find the target as the first organism that has donated to this organims
// within the neighborhood.
- const int num_neighbors = organism->GetNeighborhoodSize();
+// const int num_neighbors = organism->GetNeighborhoodSize();
// Turn to face a random neighbor
- int neighbor_id = ctx.GetRandom().GetInt(num_neighbors);
- for (int i = 0; i < neighbor_id; i++) organism->Rotate(1);
+ /* int neighbor_id = ctx.GetRandom().GetInt(num_neighbors);
+ for (int i = 0; i < neighbor_id; i++) organism->Rotate(1);*/
cOrganism * neighbor = organism->GetNeighbor();
- int max_id = neighbor_id + num_neighbors;
+ //int max_id = neighbor_id + num_neighbors;
bool found = false;
- while (neighbor_id < max_id) {
- neighbor = organism->GetNeighbor();
+ //while (neighbor_id < max_id) {
+ // neighbor = organism->GetNeighbor();
if ((neighbor != NULL) &&
(organism->IsDonor(neighbor->GetID()))) {
found = true;
- break;
+ // break;
}
- organism->Rotate(1);
- neighbor_id++;
- }
+ // organism->Rotate(1);
+ // neighbor_id++;
+ //}
if (found == false) neighbor = NULL;
// Put the facing back where it was.
- for (int i = 0; i < neighbor_id; i++) organism->Rotate(-1);
+ //for (int i = 0; i < neighbor_id; i++) organism->Rotate(-1);
// Donate
if (neighbor != NULL){
More information about the Avida-cvs
mailing list