[Avida-SVN] r2903 - branches/collect/source/cpu
blwalker at myxo.css.msu.edu
blwalker at myxo.css.msu.edu
Thu Oct 30 21:12:35 PDT 2008
Author: blwalker
Date: 2008-10-31 00:12:35 -0400 (Fri, 31 Oct 2008)
New Revision: 2903
Modified:
branches/collect/source/cpu/cHardwareCPU.cc
Log:
Bug fix in Inst_Collect. Prevents resource counts from becoming completely random and insane as they are changed by parts of res_change that ought to have been zero but were instead junk values. Now, they are zero.
Modified: branches/collect/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/collect/source/cpu/cHardwareCPU.cc 2008-10-31 03:07:53 UTC (rev 2902)
+++ branches/collect/source/cpu/cHardwareCPU.cc 2008-10-31 04:12:35 UTC (rev 2903)
@@ -3394,6 +3394,7 @@
// Set up res_change and max total
const tArray<double> res_count = organism->GetOrgInterface().GetResources();
tArray<double> res_change(res_count.GetSize());
+ res_change.SetAll(0.0);
double total = organism->GetRBinsTotal();
double max = m_world->GetConfig().MAX_TOTAL_STORED.Get();
@@ -3403,6 +3404,8 @@
res_change[bin_used] = -1 * (res_count[bin_used] * m_world->GetConfig().ABSORB_RESOURCE_FRACTION.Get());
if(max < 0 || (total + -1 * res_change[bin_used]) <= max)
{organism->AddToRBin(bin_used, -1 * res_change[bin_used]);}
+ else
+ {res_change[bin_used] = 0.0;}
}
else
{
@@ -3411,7 +3414,9 @@
{
res_change[i] = -1 * (res_count[bin_used] * m_world->GetConfig().ABSORB_RESOURCE_FRACTION.Get() / num_bins);
if(max < 0 || (total + -1 * res_change[i]) <= max)
- {organism->AddToRBin(i, -1 * res_change[i]);}
+ {organism->AddToRBin(i, -1 * res_change[i]);}
+ else
+ {res_change[i] = 0.0;}
}
}
More information about the Avida-cvs
mailing list