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

beckma24 at myxo.css.msu.edu beckma24 at myxo.css.msu.edu
Wed Sep 10 08:23:49 PDT 2008


Author: beckma24
Date: 2008-09-10 11:23:45 -0400 (Wed, 10 Sep 2008)
New Revision: 2773

Modified:
   development/source/actions/EnvironmentActions.cc
Log:
added scale variable to seasonal resource

Modified: development/source/actions/EnvironmentActions.cc
===================================================================
--- development/source/actions/EnvironmentActions.cc	2008-09-09 13:53:57 UTC (rev 2772)
+++ development/source/actions/EnvironmentActions.cc	2008-09-10 15:23:45 UTC (rev 2773)
@@ -567,12 +567,14 @@
 class cActionSetSeasonalResource1Kyears_1To_1 : public cAction {
 private:
 	cString m_res_name;
+	double m_scale;
 		
 public:
-	cActionSetSeasonalResource1Kyears_1To_1(cWorld* world, const cString& args): cAction(world, args), m_res_name("")
+	cActionSetSeasonalResource1Kyears_1To_1(cWorld* world, const cString& args): cAction(world, args), m_res_name(""), m_scale(1.0)
 	{
 		cString largs(args);
 		if (largs.GetSize()) m_res_name = largs.PopWord();
+		if (largs.GetSize()) m_scale = largs.PopWord().AsDouble();
 	}
 		
 	static const cString GetDescription() { return "Arguments: <string reaction_name>"; }
@@ -583,7 +585,7 @@
 		double m_res_count = -1*(tanh((time-182500)/50000)+1)*(0.5*sin(time/58.091)+0.5)+1;
 		cResource* res = m_world->GetEnvironment().GetResourceLib().GetResource(m_res_name);
 		if (res != NULL)
-			m_world->GetPopulation().SetResource(res->GetID(), m_res_count);			
+			m_world->GetPopulation().SetResource(res->GetID(), m_res_count * m_scale);			
 	}
 };
 
@@ -594,15 +596,18 @@
 class cActionSetSeasonalResource10Kyears_1To_1 : public cAction {
 private:
 	cString m_res_name;
+	double m_scale;
 	
 public:
-	cActionSetSeasonalResource10Kyears_1To_1(cWorld* world, const cString& args): cAction(world, args), m_res_name("")
+	cActionSetSeasonalResource10Kyears_1To_1(cWorld* world, const cString& args): cAction(world, args), m_res_name(""), m_scale(1.0)
 	{
 		cString largs(args);
 		if (largs.GetSize()) m_res_name = largs.PopWord();
+		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)
 	{
@@ -610,7 +615,7 @@
 		double m_res_count = -1*(tanh((time-1825000)/500000)+1)*(0.5*sin(time/58.091)+0.5)+1;
 		cResource* res = m_world->GetEnvironment().GetResourceLib().GetResource(m_res_name);
 		if (res != NULL)
-			m_world->GetPopulation().SetResource(res->GetID(), m_res_count);			
+			m_world->GetPopulation().SetResource(res->GetID(), m_res_count* m_scale);			
 	}
 };
 




More information about the Avida-cvs mailing list