[Avida-SVN] r2994 - branches/hjg-dev/source/cpu
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Tue Dec 2 19:44:31 PST 2008
Author: hjg
Date: 2008-12-02 22:44:31 -0500 (Tue, 02 Dec 2008)
New Revision: 2994
Modified:
branches/hjg-dev/source/cpu/cHardwareCPU.cc
Log:
modified instructions to use testcpu info
Modified: branches/hjg-dev/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/hjg-dev/source/cpu/cHardwareCPU.cc 2008-12-03 01:19:37 UTC (rev 2993)
+++ branches/hjg-dev/source/cpu/cHardwareCPU.cc 2008-12-03 03:44:31 UTC (rev 2994)
@@ -3696,6 +3696,7 @@
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;
@@ -3879,6 +3880,16 @@
//get the neighborhood size
const int num_neighbors = organism->GetNeighborhoodSize();
+
+ // Get greenbeard instruction number
+ cInstSet& inst_set = m_world->GetHardwareManager().GetInstSet();
+ const int num_inst = m_world->GetNumInstructions();
+ int inst_number = 0;
+ for (int i = 0; i < num_inst; i++) {
+ if (inst_set.GetName(i) == "donate-tgb") {
+ inst_number = i;
+ }
+ }
// Turn to face a random neighbor
int neighbor_id = ctx.GetRandom().GetInt(num_neighbors);
@@ -3893,23 +3904,9 @@
// rotate through orgs in neighborhood
while (neighbor_id < max_id) {
neighbor = organism->GetNeighbor();
- //if neighbor exists, AND if their parent attempted to donate,
- if (neighbor != NULL && neighbor->GetPhenotype().IsDonorTrueGbLast()) {
- // const cGenome & neighbor_genome = neighbor->GetGenome();
-
+ //if neighbor is a green beard
+ if (neighbor->GetPhenotype().GetTestCPUInstCount()[inst_number]) {
found = true;
-
- /*
- // for each instruction in the genome...
- for(int i=0;i<neighbor_genome.GetSize();i++){
-
- // ...see if it is donate-tgb, if so, we found a target
- if (neighbor_genome[i] == IP().GetInst()) {
- break;
- }
-
- }
- */
}
// stop searching through the neighbors if we already found one
More information about the Avida-cvs
mailing list