[Avida-SVN] r3372 - in development/source: actions main
beckma24 at myxo.css.msu.edu
beckma24 at myxo.css.msu.edu
Thu Aug 20 13:27:11 PDT 2009
Author: beckma24
Date: 2009-08-20 16:27:11 -0400 (Thu, 20 Aug 2009)
New Revision: 3372
Modified:
development/source/actions/EnvironmentActions.cc
development/source/main/cEnvironment.cc
development/source/main/cEnvironment.h
development/source/main/cPhenotype.cc
Log:
Moved accounting for reaction completion into cEnvironment::TestOutput. This allows one reaction to depend on the completion of another reaction during the same "instant" in time. Previously a reaction requisite must have been completed during a previous time instant for it to be satisified. I admit this is hackish since I had to make the const from the reaction_count agrument to cEnvironment::TestOutput, however this is desirable feature. Also, changed assert in action SetResourceOutflow to allow 0% and 100% outflow. All tests pass.
Modified: development/source/actions/EnvironmentActions.cc
===================================================================
--- development/source/actions/EnvironmentActions.cc 2009-08-20 01:31:58 UTC (rev 3371)
+++ development/source/actions/EnvironmentActions.cc 2009-08-20 20:27:11 UTC (rev 3372)
@@ -490,8 +490,8 @@
cString largs(args);
if (largs.GetSize()) m_name = largs.PopWord();
if (largs.GetSize()) m_outflow = largs.PopWord().AsDouble();
- assert(m_outflow < 1.0);
- assert(m_outflow > 0.0);
+ assert(m_outflow <= 1.0);
+ assert(m_outflow >= 0.0);
}
static const cString GetDescription() { return "Arguments: <string resource_name> <int outflow>"; }
Modified: development/source/main/cEnvironment.cc
===================================================================
--- development/source/main/cEnvironment.cc 2009-08-20 01:31:58 UTC (rev 3371)
+++ development/source/main/cEnvironment.cc 2009-08-20 20:27:11 UTC (rev 3372)
@@ -1067,7 +1067,7 @@
bool cEnvironment::TestOutput(cAvidaContext& ctx, cReactionResult& result,
cTaskContext& taskctx, const tArray<int>& task_count,
- const tArray<int>& reaction_count,
+ tArray<int>& reaction_count,
const tArray<double>& resource_count,
const tArray<double>& rbins_count) const
{
@@ -1117,6 +1117,7 @@
DoProcesses(ctx, cur_reaction->GetProcesses(), resource_count, rbins_count,
task_quality, task_probability, task_cnt, i, result, taskctx);
+ if (result.ReactionTriggered(task_id) == true) reaction_count[i]++;
// Note: the reaction is actually marked as being performed inside DoProcesses.
}
Modified: development/source/main/cEnvironment.h
===================================================================
--- development/source/main/cEnvironment.h 2009-08-20 01:31:58 UTC (rev 3371)
+++ development/source/main/cEnvironment.h 2009-08-20 20:27:11 UTC (rev 3372)
@@ -148,7 +148,7 @@
const tBuffer<int>& outputs, const tArray<double>& resource_count) const;
bool TestOutput(cAvidaContext& ctx, cReactionResult& result, cTaskContext& taskctx,
- const tArray<int>& task_count, const tArray<int>& reaction_count,
+ const tArray<int>& task_count, tArray<int>& reaction_count,
const tArray<double>& resource_count, const tArray<double>& rbins_count) const;
// Accessors
Modified: development/source/main/cPhenotype.cc
===================================================================
--- development/source/main/cPhenotype.cc 2009-08-20 01:31:58 UTC (rev 3371)
+++ development/source/main/cPhenotype.cc 2009-08-20 20:27:11 UTC (rev 3372)
@@ -1191,7 +1191,7 @@
}
for (int i = 0; i < num_reactions; i++) {
- if (result.ReactionTriggered(i) == true) cur_reaction_count[i]++;
+// if (result.ReactionTriggered(i) == true) cur_reaction_count[i]++; // moved into cEnvironment::TestOutput to allow reaction requisites to be satisified at teh time a reaction is completed
cur_reaction_add_reward[i] += result.GetReactionAddBonus(i);
}
More information about the Avida-cvs
mailing list