[Avida-cvs] [avida-svn] r490 - in branches/jeffdev/source: cpu main
jclune@myxo.css.msu.edu
jclune at myxo.css.msu.edu
Mon Feb 27 22:30:15 PST 2006
Author: jclune
Date: 2006-02-28 01:30:15 -0500 (Tue, 28 Feb 2006)
New Revision: 490
Modified:
branches/jeffdev/source/cpu/cHardwareCPU.cc
branches/jeffdev/source/main/cPhenotype.cc
branches/jeffdev/source/main/cPhenotype.h
Log:
added true green beard gene to jeffdev branch
Modified: branches/jeffdev/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/jeffdev/source/cpu/cHardwareCPU.cc 2006-02-27 22:24:15 UTC (rev 489)
+++ branches/jeffdev/source/cpu/cHardwareCPU.cc 2006-02-28 06:30:15 UTC (rev 490)
@@ -2897,6 +2897,8 @@
{
cPhenotype & phenotype = organism->GetPhenotype();
phenotype.IncDonates();
+ phenotype.SetIsDonorRand();
+
if (phenotype.GetCurNumDonates() > cConfig::GetMaxDonates()) {
return false;
}
@@ -2910,8 +2912,7 @@
// Donate only if we have found a neighbor.
if (neighbor != NULL) {
DoDonate(neighbor);
- phenotype.SetIsDonorRand();
- // neighbor->GetPhenotype().SetIsReceiverRand();
+ neighbor->GetPhenotype().SetIsReceiverRand();
}
return true;
@@ -2920,7 +2921,10 @@
bool cHardwareCPU::Inst_DonateKin()
{
- organism->GetPhenotype().IncDonates();
+ cPhenotype & phenotype = organism->GetPhenotype();
+ phenotype.IncDonates();
+ phenotype.SetIsDonorKin();
+
if (organism->GetPhenotype().GetCurNumDonates() > cConfig::GetMaxDonates()) {
return false;
}
@@ -2956,14 +2960,19 @@
for (int i = 0; i < neighbor_id; i++) organism->Rotate(-1);
// Donate only if we have found a close enough relative...
- if (neighbor != NULL) DoDonate(neighbor);
-
+ if (neighbor != NULL){
+ DoDonate(neighbor);
+ neighbor->GetPhenotype().SetIsReceiverKin();
+ }
return true;
}
bool cHardwareCPU::Inst_DonateEditDist()
{
- organism->GetPhenotype().IncDonates();
+ cPhenotype & phenotype = organism->GetPhenotype();
+ phenotype.IncDonates();
+ phenotype.SetIsDonorEdit();
+
if (organism->GetPhenotype().GetCurNumDonates() > cConfig::GetMaxDonates()) {
return false;
}
@@ -3002,8 +3011,10 @@
for (int i = 0; i < neighbor_id; i++) organism->Rotate(-1);
// Donate only if we have found a close enough relative...
- if (neighbor != NULL) DoDonate(neighbor);
-
+ if (neighbor != NULL){
+ DoDonate(neighbor);
+ neighbor->GetPhenotype().SetIsReceiverEdit();
+ }
return true;
}
@@ -3014,8 +3025,10 @@
//in their genome (see Dawkins 1976, The Selfish Gene, for
//the history of the theory and the name 'green beard'
// cout << "i am about to donate to a green beard" << endl;
+ cPhenotype & phenotype = organism->GetPhenotype();
+ phenotype.IncDonates();
+ phenotype.SetIsDonorGbg();
- organism->GetPhenotype().IncDonates();
if (organism->GetPhenotype().GetCurNumDonates() > cConfig::GetMaxDonates()) {
return false;
}
@@ -3071,7 +3084,10 @@
for (int i = 0; i < neighbor_id; i++) organism->Rotate(-1);
// Donate only if we have found a close enough relative...
- if (neighbor != NULL) DoDonate(neighbor);
+ if (neighbor != NULL) {
+ DoDonate(neighbor);
+ neighbor->GetPhenotype().SetIsReceiverGbg();
+ }
return true;
@@ -3084,8 +3100,10 @@
//(see Dawkins 1976, The Selfish Gene, for
//the history of the theory and the name 'green beard'
// cout << "i am about to donate to a green beard" << endl;
+ cPhenotype & phenotype = organism->GetPhenotype();
+ phenotype.IncDonates();
+ phenotype.SetIsDonorTrueGb();
- organism->GetPhenotype().IncDonates();
if (organism->GetPhenotype().GetCurNumDonates() > cConfig::GetMaxDonates()) {
return false;
}
@@ -3108,11 +3126,9 @@
// rotate through orgs in neighborhood
while (neighbor_id < max_id) {
neighbor = organism->GetNeighbor();
-
- //if neighbor exists, AND if their parent donated,
- if (neighbor != NULL && neighbor->GetPhenotype().IsDonorLast()) {
- cout << "****************************" << endl;
- cout << " neighbor->GetPhenotype().IsDonorLast() is " << neighbor->GetPhenotype().IsDonorLast() << endl;
+ //if neighbor exists, AND if their parent donated,
+ if (neighbor != NULL && neighbor->GetPhenotype().IsDonorTrueGbLast()) {
+ cout << "got inside" << endl;
const cGenome & neighbor_genome = neighbor->GetGenome();
// for each instruction in the genome...
@@ -3142,7 +3158,12 @@
for (int i = 0; i < neighbor_id; i++) organism->Rotate(-1);
// Donate only if we have found a close enough relative...
- if (neighbor != NULL) DoDonate(neighbor);
+ if (neighbor != NULL) {
+ cout << "doing donate" << endl;
+ DoDonate(neighbor);
+ neighbor->GetPhenotype().SetIsReceiverTrueGb();
+ }
+
return true;
@@ -3151,7 +3172,9 @@
bool cHardwareCPU::Inst_DonateNULL()
{
- organism->GetPhenotype().IncDonates();
+ cPhenotype & phenotype = organism->GetPhenotype();
+ phenotype.IncDonates();
+
if (organism->GetPhenotype().GetCurNumDonates() > cConfig::GetMaxDonates()) {
return false;
}
@@ -3165,6 +3188,8 @@
// Plug the current merit back into this organism and notify the scheduler.
organism->UpdateMerit(cur_merit);
+ phenotype.SetIsDonorNull();
+
return true;
}
Modified: branches/jeffdev/source/main/cPhenotype.cc
===================================================================
--- branches/jeffdev/source/main/cPhenotype.cc 2006-02-27 22:24:15 UTC (rev 489)
+++ branches/jeffdev/source/main/cPhenotype.cc 2006-02-28 06:30:15 UTC (rev 490)
@@ -139,9 +139,24 @@
is_parasite = false;
is_donor_cur = false;
is_donor_last = parent_phenotype.is_donor_last;
- is_donor_rand = false;
+ is_donor_rand = false;
is_donor_rand_last = parent_phenotype.is_donor_rand_last;
+ is_donor_null = false;
+ is_donor_null_last = parent_phenotype.is_donor_null_last;
+ is_donor_kin = false;
+ is_donor_kin_last = parent_phenotype.is_donor_kin_last;
+ is_donor_edit = false;
+ is_donor_edit_last = parent_phenotype.is_donor_edit_last;
+ is_donor_gbg = false;
+ is_donor_gbg_last = parent_phenotype.is_donor_gbg_last;
+ is_donor_truegb = false;
+ is_donor_truegb_last = parent_phenotype.is_donor_truegb_last;
is_receiver = false;
+ is_receiver_rand = false;
+ is_receiver_kin = false;
+ is_receiver_edit = false;
+ is_receiver_gbg = false;
+ is_receiver_truegb = false;
is_modifier = false;
is_modified = false;
is_fertile = parent_phenotype.last_child_fertile;
@@ -222,7 +237,22 @@
is_donor_last = false;
is_donor_rand = false;
is_donor_rand_last = false;
+ is_donor_null = false;
+ is_donor_null_last = false;
+ is_donor_kin = false;
+ is_donor_kin_last = false;
+ is_donor_edit = false;
+ is_donor_edit_last = false;
+ is_donor_gbg = false;
+ is_donor_gbg_last = false;
+ is_donor_truegb = false;
+ is_donor_truegb_last = false;
is_receiver = false;
+ is_receiver_rand = false;
+ is_receiver_kin = false;
+ is_receiver_edit = false;
+ is_receiver_gbg = false;
+ is_receiver_truegb = false;
is_modifier = false;
is_modified = false;
is_fertile = true;
@@ -302,7 +332,22 @@
is_donor_cur = false;
is_donor_rand_last = is_donor_rand;
is_donor_rand = false;
+ is_donor_null_last = is_donor_null;
+ is_donor_null = false;
+ is_donor_kin_last = is_donor_kin;
+ is_donor_kin = false;
+ is_donor_edit_last = is_donor_edit;
+ is_donor_edit = false;
+ is_donor_gbg_last = is_donor_gbg;
+ is_donor_gbg = false;
+ is_donor_truegb_last = is_donor_truegb;
+ is_donor_truegb = false;
is_receiver = false;
+ is_receiver_rand = false;
+ is_receiver_kin = false;
+ is_receiver_edit = false;
+ is_receiver_gbg = false;
+ is_receiver_truegb = false;
(void) is_modifier;
(void) is_modified;
(void) is_fertile;
@@ -392,7 +437,22 @@
is_donor_cur = false;
is_donor_rand_last = is_donor_rand;
is_donor_rand = false;
+ is_donor_null_last = is_donor_null;
+ is_donor_null = false;
+ is_donor_kin_last = is_donor_kin;
+ is_donor_kin = false;
+ is_donor_edit_last = is_donor_edit;
+ is_donor_edit = false;
+ is_donor_gbg_last = is_donor_gbg;
+ is_donor_gbg = false;
+ is_donor_truegb_last = is_donor_truegb;
+ is_donor_truegb = false;
is_receiver = false;
+ is_receiver_rand = false;
+ is_receiver_kin = false;
+ is_receiver_edit = false;
+ is_receiver_gbg = false;
+ is_receiver_truegb = false;
(void) is_modifier;
(void) is_modified;
(void) is_fertile;
@@ -479,7 +539,22 @@
is_donor_cur = clone_phenotype.is_donor_cur;
is_donor_rand_last = clone_phenotype.is_donor_rand_last;
is_donor_rand = clone_phenotype.is_donor_rand;
+ is_donor_null_last = clone_phenotype.is_donor_null_last;
+ is_donor_null = clone_phenotype.is_donor_null;
+ is_donor_kin_last = clone_phenotype.is_donor_kin_last;
+ is_donor_kin = clone_phenotype.is_donor_kin;
+ is_donor_edit_last = clone_phenotype.is_donor_edit_last;
+ is_donor_edit = clone_phenotype.is_donor_edit;
+ is_donor_gbg_last = clone_phenotype.is_donor_gbg_last;
+ is_donor_gbg = clone_phenotype.is_donor_gbg;
+ is_donor_truegb_last = clone_phenotype.is_donor_truegb_last;
+ is_donor_truegb = clone_phenotype.is_donor_truegb;
is_receiver = false;
+ is_receiver_rand = false;
+ is_receiver_kin = false;
+ is_receiver_edit = false;
+ is_receiver_gbg = false;
+ is_receiver_truegb = false;
is_modifier = false;
is_modified = false;
is_fertile = clone_phenotype.last_child_fertile;
@@ -636,8 +711,23 @@
fp << is_donor_cur << " ";
fp << is_donor_rand_last << " ";
fp << is_donor_rand << " ";
+ fp << is_donor_null_last << " ";
+ fp << is_donor_null << " ";
+ fp << is_donor_kin_last << " ";
+ fp << is_donor_kin << " ";
+ fp << is_donor_edit_last << " ";
+ fp << is_donor_edit << " ";
+ fp << is_donor_gbg_last << " ";
+ fp << is_donor_gbg << " ";
+ fp << is_donor_truegb_last << " ";
+ fp << is_donor_truegb << " ";
fp << is_receiver << " ";
+ fp << is_receiver_rand << " ";
+ fp << is_receiver_kin << " ";
+ fp << is_receiver_edit << " ";
+ fp << is_receiver_gbg << " ";
+ fp << is_receiver_truegb << " ";
fp << is_modifier << " ";
fp << is_modified << " ";
fp << is_fertile << " ";
@@ -714,7 +804,22 @@
fp >> is_donor_cur;
fp >> is_donor_rand_last;
fp >> is_donor_rand;
+ fp >> is_donor_null_last;
+ fp >> is_donor_null;
+ fp >> is_donor_kin_last;
+ fp >> is_donor_kin;
+ fp >> is_donor_edit_last;
+ fp >> is_donor_edit;
+ fp >> is_donor_gbg_last;
+ fp >> is_donor_gbg;
+ fp >> is_donor_truegb_last;
+ fp >> is_donor_truegb;
fp >> is_receiver;
+ fp >> is_receiver_rand;
+ fp >> is_receiver_kin;
+ fp >> is_receiver_edit;
+ fp >> is_receiver_gbg;
+ fp >> is_receiver_truegb;
fp >> is_modifier;
fp >> is_modified;
fp >> is_fertile;
Modified: branches/jeffdev/source/main/cPhenotype.h
===================================================================
--- branches/jeffdev/source/main/cPhenotype.h 2006-02-27 22:24:15 UTC (rev 489)
+++ branches/jeffdev/source/main/cPhenotype.h 2006-02-28 06:30:15 UTC (rev 490)
@@ -105,11 +105,26 @@
bool to_delete; // Should this organism be deleted when finished?
bool is_injected; // Was this organism injected into the population?
bool is_parasite; // Has this organism ever executed outside code?
- bool is_donor_cur; // Has this organism ever donated merit?
- bool is_donor_last; // Did this organism's parent ever donate merit?
- bool is_donor_rand; // Has this organism performed a random donation?
- bool is_donor_rand_last; // Has this orgs parent ever donated randomly
+ bool is_donor_cur; // Has this organism attempted to donate merit?
+ bool is_donor_last; // Did this organism's parent attempt to donate merit?
+ bool is_donor_rand; // Has this organism attempted a random donation?
+ bool is_donor_rand_last; // Did this org's parent attempt to donate randomly
+ bool is_donor_null; // Has this organism attempted a null donation?
+ bool is_donor_null_last;// Did this org's parent attempt a null donation?
+ bool is_donor_kin; // Has this organism kin_donated?
+ bool is_donor_kin_last;// Did this org's parent kin_donated?
+ bool is_donor_edit; // Has this organism edit_donated?
+ bool is_donor_edit_last; // Did this org's parent edit_donated?
+ bool is_donor_gbg; // Has this organism gbg_donated (green beard gene)?
+ bool is_donor_gbg_last;// Did this org's parent gbg_donated?
+ bool is_donor_truegb; // Has this organism truegb_donated (true green beard)?
+ bool is_donor_truegb_last;// Did this org's parent gbg_donated?
bool is_receiver; // Has this organism ever received merit donation?
+ bool is_receiver_rand; // Has this organism ever received random merit donation?
+ bool is_receiver_kin; // Has this organism ever received kin merit donation?
+ bool is_receiver_edit; // Has this organism ever received edit donation?
+ bool is_receiver_gbg; // Has this organism ever received gbg donation?
+ bool is_receiver_truegb;// Has this organism ever received truegb donation?
bool is_modifier; // Has this organism modified another?
bool is_modified; // Has this organism been modified by another?
bool is_fertile; // Do we allow this organisms to produce offspring?
@@ -255,7 +270,20 @@
bool IsDonorLast() const { assert(initialized == true); return is_donor_last; }
bool IsDonorRand() const { assert(initialized == true); return is_donor_rand; }
bool IsDonorRandLast() const { assert(initialized == true); return is_donor_rand_last; }
+ bool IsDonorKin() const { assert(initialized == true); return is_donor_kin; }
+ bool IsDonorKinLast() const { assert(initialized == true); return is_donor_kin_last; }
+ bool IsDonorEdit() const { assert(initialized == true); return is_donor_edit; }
+ bool IsDonorEditLast() const { assert(initialized == true); return is_donor_edit_last; }
+ bool IsDonorGbg() const { assert(initialized == true); return is_donor_gbg; }
+ bool IsDonorGbgLast() const { assert(initialized == true); return is_donor_gbg_last; }
+ bool IsDonorTrueGb() const { assert(initialized == true); return is_donor_truegb; }
+ bool IsDonorTrueGbLast() const { assert(initialized == true); return is_donor_truegb_last; }
bool IsReceiver() const { assert(initialized == true); return is_receiver; }
+ bool IsReceiverRand() const { assert(initialized == true); return is_receiver_rand; }
+ bool IsReceiverKin() const { assert(initialized == true); return is_receiver_kin; }
+ bool IsReceiverEdit() const { assert(initialized == true); return is_receiver_edit; }
+ bool IsReceiverGbg() const { assert(initialized == true); return is_receiver_gbg; }
+ bool IsReceiverTrueGb() const { assert(initialized == true); return is_receiver_truegb; }
bool IsModifier() const { assert(initialized == true); return is_modifier; }
bool IsModified() const { assert(initialized == true); return is_modified; }
bool IsFertile() const { assert(initialized == true); return is_fertile; }
@@ -292,7 +320,17 @@
void SetIsDonorCur() { is_donor_cur = true; }
void SetIsDonorRand() { SetIsDonorCur(); is_donor_rand = true; }
+ void SetIsDonorKin() { SetIsDonorCur(); is_donor_kin = true; }
+ void SetIsDonorNull() { SetIsDonorCur(); is_donor_null = true; }
+ void SetIsDonorEdit() { SetIsDonorCur(); is_donor_edit = true; }
+ void SetIsDonorGbg() { SetIsDonorCur(); is_donor_gbg = true; }
+ void SetIsDonorTrueGb() { SetIsDonorCur(); is_donor_truegb = true; }
void SetIsReceiver() { is_receiver = true; }
+ void SetIsReceiverRand() { SetIsReceiver(); is_receiver_rand = true; }
+ void SetIsReceiverKin() { SetIsReceiver(); is_receiver_kin = true; }
+ void SetIsReceiverEdit() { SetIsReceiver(); is_receiver_edit = true; }
+ void SetIsReceiverGbg() { SetIsReceiver(); is_receiver_gbg = true; }
+ void SetIsReceiverTrueGb() { SetIsReceiver(); is_receiver_truegb = true; }
void IncCurInstCount(int _inst_num) { assert(initialized == true); cur_inst_count[_inst_num]++; }
More information about the Avida-cvs
mailing list