[Avida-SVN] r3243 - development/source/cpu
goingssh at myxo.css.msu.edu
goingssh at myxo.css.msu.edu
Mon May 18 16:45:45 PDT 2009
Author: goingssh
Date: 2009-05-18 19:45:45 -0400 (Mon, 18 May 2009)
New Revision: 3243
Modified:
development/source/cpu/cHardwareBase.cc
Log:
added ability to sterilize task loss without gain
Modified: development/source/cpu/cHardwareBase.cc
===================================================================
--- development/source/cpu/cHardwareBase.cc 2009-05-18 21:02:03 UTC (rev 3242)
+++ development/source/cpu/cHardwareBase.cc 2009-05-18 23:45:45 UTC (rev 3243)
@@ -152,6 +152,8 @@
const int merit_base = phenotype.CalcSizeMerit();
const double cur_fitness = merit_base * phenotype.GetCurBonus() / phenotype.GetTimeUsed();
const double fitness_ratio = cur_fitness / phenotype.GetLastFitness();
+ const tArray<int>& childtasks = phenotype.GetCurTaskCount();
+ const tArray<int>& parenttasks = phenotype.GetLastTaskCount();
bool sterilize = false;
@@ -162,9 +164,26 @@
} else {
if (ctx.GetRandom().P(m_organism->GetSterilizePos())) sterilize = true;
}
-
- if (sterilize) {
- // Don't let this organism have this or any more children!
+
+ // for sterilize task loss *SLG
+ if (ctx.GetRandom().P(m_organism->GetSterilizeTaskLoss()))
+ {
+ bool del = false;
+ bool added = false;
+ for (int i=0; i<childtasks.GetSize(); i++)
+ {
+ if (childtasks[i] > parenttasks[i]) {
+ added = true;
+ break;
+ }
+ else if (childtasks[i] < parenttasks[i])
+ del = true;
+ }
+ sterilize = (del & !added);
+ }
+
+ if (sterilize) {
+ // Don't let this organism have this or any more children!
phenotype.IsFertile() = false;
return false;
}
More information about the Avida-cvs
mailing list