[Avida-SVN] r2774 - development/source/actions

beckma24 at myxo.css.msu.edu beckma24 at myxo.css.msu.edu
Fri Sep 12 08:28:01 PDT 2008


Author: beckma24
Date: 2008-09-12 11:28:01 -0400 (Fri, 12 Sep 2008)
New Revision: 2774

Modified:
   development/source/actions/EnvironmentActions.cc
Log:
Altered seasonal sleep so resource does not go negative

Modified: development/source/actions/EnvironmentActions.cc
===================================================================
--- development/source/actions/EnvironmentActions.cc	2008-09-10 15:23:45 UTC (rev 2773)
+++ development/source/actions/EnvironmentActions.cc	2008-09-12 15:28:01 UTC (rev 2774)
@@ -577,12 +577,14 @@
 		if (largs.GetSize()) m_scale = largs.PopWord().AsDouble();
 	}
 		
-	static const cString GetDescription() { return "Arguments: <string reaction_name>"; }
+	static const cString GetDescription() { return "Arguments: <string reaction_name> <double scale>"; }
 	
 	void Process(cAvidaContext& ctx)
 	{
 		int time = m_world->GetStats().GetUpdate();
 		double m_res_count = -1*(tanh((time-182500)/50000)+1)*(0.5*sin(time/58.091)+0.5)+1;
+		if(m_res_count < 0.0)
+			m_res_count = 0.0;
 		cResource* res = m_world->GetEnvironment().GetResourceLib().GetResource(m_res_name);
 		if (res != NULL)
 			m_world->GetPopulation().SetResource(res->GetID(), m_res_count * m_scale);			
@@ -613,6 +615,8 @@
 	{
 		int time = m_world->GetStats().GetUpdate();
 		double m_res_count = -1*(tanh((time-1825000)/500000)+1)*(0.5*sin(time/58.091)+0.5)+1;
+		if(m_res_count < 0.0)
+			m_res_count = 0.0;
 		cResource* res = m_world->GetEnvironment().GetResourceLib().GetResource(m_res_name);
 		if (res != NULL)
 			m_world->GetPopulation().SetResource(res->GetID(), m_res_count* m_scale);			




More information about the Avida-cvs mailing list