[Avida-SVN] r2303 - in development: Avida.xcodeproj source/actions source/main

dknoester at myxo.css.msu.edu dknoester at myxo.css.msu.edu
Wed Feb 6 11:54:03 PST 2008


Author: dknoester
Date: 2008-02-06 14:54:03 -0500 (Wed, 06 Feb 2008)
New Revision: 2303

Modified:
   development/Avida.xcodeproj/project.pbxproj
   development/source/actions/PrintActions.cc
   development/source/main/cEnvironment.cc
   development/source/main/cStats.cc
Log:
Fixed the reporting of reaction completion with limited resources.

Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj	2008-02-05 18:38:08 UTC (rev 2302)
+++ development/Avida.xcodeproj/project.pbxproj	2008-02-06 19:54:03 UTC (rev 2303)
@@ -213,23 +213,6 @@
 		};
 /* End PBXBuildRule section */
 
-/* Begin PBXBuildStyle section */
-		B55E29FE0D58A22300F093BD /* Development */ = {
-			isa = PBXBuildStyle;
-			buildSettings = {
-				COPY_PHASE_STRIP = NO;
-			};
-			name = Development;
-		};
-		B55E29FF0D58A22300F093BD /* Deployment */ = {
-			isa = PBXBuildStyle;
-			buildSettings = {
-				COPY_PHASE_STRIP = YES;
-			};
-			name = Deployment;
-		};
-/* End PBXBuildStyle section */
-
 /* Begin PBXContainerItemProxy section */
 		56F555DA0C3B36FC00E2E929 /* PBXContainerItemProxy */ = {
 			isa = PBXContainerItemProxy;
@@ -1801,12 +1784,6 @@
 		DCC30C4D0762532C008F7A48 /* Project object */ = {
 			isa = PBXProject;
 			buildConfigurationList = 702442D70859E0B00059BD9B /* Build configuration list for PBXProject "Avida" */;
-			buildSettings = {
-			};
-			buildStyles = (
-				B55E29FE0D58A22300F093BD /* Development */,
-				B55E29FF0D58A22300F093BD /* Deployment */,
-			);
 			hasScannedForEncodings = 0;
 			mainGroup = DCC30C490762532C008F7A48;
 			productRefGroup = DCC3164E07626CF3008F7A48 /* Products */;

Modified: development/source/actions/PrintActions.cc
===================================================================
--- development/source/actions/PrintActions.cc	2008-02-05 18:38:08 UTC (rev 2302)
+++ development/source/actions/PrintActions.cc	2008-02-06 19:54:03 UTC (rev 2303)
@@ -79,6 +79,7 @@
 STATS_OUT_FILE(PrintTasksExeData,           tasks_exe.dat       );
 STATS_OUT_FILE(PrintTasksQualData,          tasks_quality.dat   );
 STATS_OUT_FILE(PrintResourceData,           resource.dat        );
+STATS_OUT_FILE(PrintReactionData,           reactions.dat       );
 STATS_OUT_FILE(PrintReactionRewardData,     reaction_reward.dat );
 STATS_OUT_FILE(PrintTimeData,               time.dat            );
 STATS_OUT_FILE(PrintMutationRateData,       mutation_rates.dat  );
@@ -2616,6 +2617,7 @@
   action_lib->Register<cActionPrintTasksExeData>("PrintTasksExeData");
   action_lib->Register<cActionPrintTasksQualData>("PrintTasksQualData");
   action_lib->Register<cActionPrintResourceData>("PrintResourceData");
+  action_lib->Register<cActionPrintReactionData>("PrintReactionData");
   action_lib->Register<cActionPrintReactionRewardData>("PrintReactionRewardData");
   action_lib->Register<cActionPrintTimeData>("PrintTimeData");
   action_lib->Register<cActionPrintMutationRateData>("PrintMutationRateData");

Modified: development/source/main/cEnvironment.cc
===================================================================
--- development/source/main/cEnvironment.cc	2008-02-05 18:38:08 UTC (rev 2302)
+++ development/source/main/cEnvironment.cc	2008-02-06 19:54:03 UTC (rev 2303)
@@ -886,9 +886,8 @@
 
     // And lets process it!
     DoProcesses(ctx, cur_reaction->GetProcesses(), resource_count, task_quality, task_cnt, i, result);
-    
-    // Mark this reaction as occuring...
-    result.MarkReaction(cur_reaction->GetID());
+
+    // Note: the reaction is actually marked as being performed inside DoProcesses.
   }  
   
   return result.GetActive();
@@ -999,6 +998,9 @@
       if (cur_process->GetDepletable()) result.Consume(res_id, consumed);
     }
     
+    // Mark the reaction as having been performed if we get here.
+    result.MarkReaction(i);
+    
     // Calculate the bonus
     double bonus = consumed * cur_process->GetValue();
     

Modified: development/source/main/cStats.cc
===================================================================
--- development/source/main/cStats.cc	2008-02-05 18:38:08 UTC (rev 2302)
+++ development/source/main/cStats.cc	2008-02-06 19:54:03 UTC (rev 2303)
@@ -30,12 +30,14 @@
 #include "cHardwareManager.h"
 #include "cInstSet.h"
 #include "cPopulation.h"
+#include "cPopulationCell.h"
 #include "cStringUtil.h"
 #include "cWorld.h"
 #include "cWorldDriver.h"
 #include "tDataEntry.h"
 #include "cOrgMessage.h"
 #include "cOrgMessagePredicate.h"
+#include "cReaction.h"
 
 #include "functions.h"
 
@@ -792,10 +794,29 @@
   df.WriteComment("of currently living organisms each reaction has affected.");
 
   df.Write(m_update,   "Update");
-  for (int i = 0; i < reaction_count.GetSize(); i++) {
-    df.Write(reaction_count[i], reaction_names[i] );
-    task_exe_count[i] = 0;
+  
+  const int num_reactions=m_world->GetEnvironment().GetReactionLib().GetSize();
+  tArray<int> reactions(num_reactions);
+  reactions.SetAll(0);
+  
+  for(int i=0; i<m_world->GetPopulation().GetSize(); ++i) {
+    cPopulationCell& cell = m_world->GetPopulation().GetCell(i);
+    if(cell.IsOccupied()) {
+      const tArray<int>& org_rx = cell.GetOrganism()->GetPhenotype().GetCurReactionCount();
+      for(int j=0; j<num_reactions; ++j) {
+        reactions[j] += org_rx[j];
+      }
+    }
   }
+    
+  for(int i=0; i<num_reactions; ++i) {
+    df.Write(reactions[i], m_world->GetEnvironment().GetReactionLib().GetReaction(i)->GetName());
+  }
+  
+//    df.Write( 0.0, 
+//    df.Write(reaction_count[i], reaction_names[i] );
+//    task_exe_count[i] = 0;
+//  }
   df.Endl();
 }
 




More information about the Avida-cvs mailing list