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

beckma24 at myxo.css.msu.edu beckma24 at myxo.css.msu.edu
Fri Aug 29 06:45:25 PDT 2008


Author: beckma24
Date: 2008-08-29 09:45:24 -0400 (Fri, 29 Aug 2008)
New Revision: 2764

Modified:
   development/source/actions/EnvironmentActions.cc
Log:
added another seasonal resource action

Modified: development/source/actions/EnvironmentActions.cc
===================================================================
--- development/source/actions/EnvironmentActions.cc	2008-08-28 17:23:54 UTC (rev 2763)
+++ development/source/actions/EnvironmentActions.cc	2008-08-29 13:45:24 UTC (rev 2764)
@@ -538,30 +538,56 @@
 /**
  Sets resource availiblity to seasonal
  */
-class cActionSetSeasonalResource : public cAction
+class cActionSetSeasonalResource : public cAction {
+private:
+	cString m_res_name;
+
+public:
+	cActionSetSeasonalResource(cWorld* world, const cString& args): cAction(world, args), m_res_name("")
 	{
-	private:
-		cString m_res_name;
+		cString largs(args);
+		if (largs.GetSize()) m_res_name = largs.PopWord();
+	}
 		
-	public:
-		cActionSetSeasonalResource(cWorld* world, const cString& args): cAction(world, args), m_res_name("")
-		{
-			cString largs(args);
-			if (largs.GetSize()) m_res_name = largs.PopWord();
-		}
+	static const cString GetDescription() { return "Arguments: <string reaction_name>"; }
 		
-		static const cString GetDescription() { return "Arguments: <string reaction_name>"; }
+	void Process(cAvidaContext& ctx)
+	{
+		int time = m_world->GetStats().GetUpdate();
+		double m_res_count = -1*(0.4*tanh((time-182500)/50000)+0.5)*(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);
+	}
+};
+
+/**
+ Sets resource availiblity to seasonal 1 to -1
+ */
+class cActionSetSeasonalResource1To_1 : public cAction {
+private:
+	cString m_res_name;
 		
-		void Process(cAvidaContext& ctx)
-		{
-			int time = m_world->GetStats().GetUpdate();
-			double m_res_count = -1*(0.4*tanh((time-182500)/50000)+0.5)*(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);
-			
-		}
-	};
+public:
+	cActionSetSeasonalResource1To_1(cWorld* world, const cString& args): cAction(world, args), m_res_name("")
+	{
+		cString largs(args);
+		if (largs.GetSize()) m_res_name = largs.PopWord();
+	}
+		
+	static const cString GetDescription() { return "Arguments: <string reaction_name>"; }
+	
+	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;
+		cResource* res = m_world->GetEnvironment().GetResourceLib().GetResource(m_res_name);
+		if (res != NULL)
+			m_world->GetPopulation().SetResource(res->GetID(), m_res_count);			
+	}
+};
 
+
 /**
 Sets resource availiblity to periodic
  */
@@ -878,6 +904,7 @@
   action_lib->Register<cActionSetEnvironmentRandomMask>("SetEnvironmentRandomMask");
 
 	action_lib->Register<cActionSetSeasonalResource>("SetSeasonalResource");
+	action_lib->Register<cActionSetSeasonalResource1To_1>("SetSeasonalResource1To_1");
   action_lib->Register<cActionSetPeriodicResource>("SetPeriodicResource");
   action_lib->Register<cActionSetNumInstBefore0Energy>("SetNumInstBefore0Energy");
 




More information about the Avida-cvs mailing list