[Avida-SVN] r1410 - branches/energy/source/actions

beckma24 at myxo.css.msu.edu beckma24 at myxo.css.msu.edu
Mon Mar 19 11:24:25 PDT 2007


Author: beckma24
Date: 2007-03-19 14:24:25 -0400 (Mon, 19 Mar 2007)
New Revision: 1410

Modified:
   branches/energy/source/actions/EnvironmentActions.cc
Log:
Bounded periodic resource between 0 and 1

Modified: branches/energy/source/actions/EnvironmentActions.cc
===================================================================
--- branches/energy/source/actions/EnvironmentActions.cc	2007-03-19 15:59:16 UTC (rev 1409)
+++ branches/energy/source/actions/EnvironmentActions.cc	2007-03-19 18:24:25 UTC (rev 1410)
@@ -296,9 +296,9 @@
   void Process(cAvidaContext& ctx)
   {
     int time = m_world->GetStats().GetUpdate();
-    m_res_count = amplitude * sin(M_PI/frequency * time - phaseShift * M_PI) + initY;
-//    std::cout << "Update " << time << " Y = " << m_res_count << std::endl;
-//    std::cout << m_res_count <<" = " << amplitude <<" * sin("<<frequency <<" * " << time <<" - "<< phaseShift<<") + "<<initY<<std::endl;
+    m_res_count = (amplitude * sin(M_PI/frequency * time - phaseShift * M_PI) + initY) / 2;
+    //    std::cout << "Update " << time << " Y = " << m_res_count << std::endl;
+    //    std::cout << m_res_count <<" = " << amplitude <<" * sin("<<frequency <<" * " << time <<" - "<< phaseShift<<") + "<<initY<<std::endl;
     cResource* res = m_world->GetEnvironment().GetResourceLib().GetResource(m_res_name);
     if (res != NULL) m_world->GetPopulation().SetResource(res->GetID(), m_res_count);
 




More information about the Avida-cvs mailing list