[Avida-cvs] [avida-svn] r1023 - in branches/coopcomm: Avida.xcodeproj source/actions source/main

dknoester at myxo.css.msu.edu dknoester at myxo.css.msu.edu
Sat Sep 30 20:54:55 PDT 2006


Author: dknoester
Date: 2006-09-30 23:54:55 -0400 (Sat, 30 Sep 2006)
New Revision: 1023

Modified:
   branches/coopcomm/Avida.xcodeproj/project.pbxproj
   branches/coopcomm/source/actions/PopulationActions.cc
   branches/coopcomm/source/main/cPopulationCell.cc
   branches/coopcomm/source/main/cPopulationCell.h
   branches/coopcomm/source/main/cStats.cc
   branches/coopcomm/source/main/cTaskLib.cc
Log:
Bugfix for resetting only the maxid.

Modified: branches/coopcomm/Avida.xcodeproj/project.pbxproj
===================================================================
--- branches/coopcomm/Avida.xcodeproj/project.pbxproj	2006-10-01 03:52:22 UTC (rev 1022)
+++ branches/coopcomm/Avida.xcodeproj/project.pbxproj	2006-10-01 03:54:55 UTC (rev 1023)
@@ -373,23 +373,6 @@
 		};
 /* End PBXBuildRule section */
 
-/* Begin PBXBuildStyle section */
-		B50F02EF0AC9BEC10085CE1A /* Development */ = {
-			isa = PBXBuildStyle;
-			buildSettings = {
-				COPY_PHASE_STRIP = NO;
-			};
-			name = Development;
-		};
-		B50F02F00AC9BEC10085CE1A /* Deployment */ = {
-			isa = PBXBuildStyle;
-			buildSettings = {
-				COPY_PHASE_STRIP = YES;
-			};
-			name = Deployment;
-		};
-/* End PBXBuildStyle section */
-
 /* Begin PBXCopyFilesBuildPhase section */
 		700E2B6D085DE50C00CF158A /* CopyFiles */ = {
 			isa = PBXCopyFilesBuildPhase;
@@ -1776,12 +1759,6 @@
 		DCC30C4D0762532C008F7A48 /* Project object */ = {
 			isa = PBXProject;
 			buildConfigurationList = 702442D70859E0B00059BD9B /* Build configuration list for PBXProject "Avida" */;
-			buildSettings = {
-			};
-			buildStyles = (
-				B50F02EF0AC9BEC10085CE1A /* Development */,
-				B50F02F00AC9BEC10085CE1A /* Deployment */,
-			);
 			hasScannedForEncodings = 0;
 			mainGroup = DCC30C490762532C008F7A48;
 			productRefGroup = DCC3164E07626CF3008F7A48 /* Products */;

Modified: branches/coopcomm/source/actions/PopulationActions.cc
===================================================================
--- branches/coopcomm/source/actions/PopulationActions.cc	2006-10-01 03:52:22 UTC (rev 1022)
+++ branches/coopcomm/source/actions/PopulationActions.cc	2006-10-01 03:54:55 UTC (rev 1023)
@@ -1263,13 +1263,13 @@
         // loop through the list of all cells.
         cPopulation::t_CellArray& cells = m_world->GetPopulation().GetCellArray();
         for(int i=0; i<cells.GetSize(); ++i) {
-          cells[i].ResetRandomID();
+          cells[i].ResetRandomCellID();
         }
         break;
       }
       case MAX: {
         // just reset the cell with the largest id.
-        m_world->GetPopulation().GetCell(cPopulationCell::GetMaxRandomCellID()).ResetRandomID();
+        cPopulationCell::GetMaxRandomCell()->ResetRandomCellID();
         break;
       }
       case PARTIAL: {
@@ -1282,7 +1282,7 @@
         std::set<unsigned int> reset;
         while(reset.size() < m_count) {
           unsigned int i = m_world->GetRandom().GetUInt(cells.GetSize());
-          cells[i].ResetRandomID();
+          cells[i].ResetRandomCellID();
           reset.insert(i);
         }
         break;

Modified: branches/coopcomm/source/main/cPopulationCell.cc
===================================================================
--- branches/coopcomm/source/main/cPopulationCell.cc	2006-10-01 03:52:22 UTC (rev 1022)
+++ branches/coopcomm/source/main/cPopulationCell.cc	2006-10-01 03:54:55 UTC (rev 1023)
@@ -70,7 +70,14 @@
   cell_id = in_id;
   m_x = x;
   m_y = y;
-  m_rand_id = m_world->GetRandom().GetUInt(UINT_MAX);
+  // At least to start with, guarantee that all random IDs are unique.
+  while(true) {
+    m_rand_id = m_world->GetRandom().GetUInt(UINT_MAX);
+    t_id_map::iterator i=s_rand_ids.find(m_rand_id);
+    if(i==s_rand_ids.end()) {
+      break;
+    }
+  }
   s_rand_ids.insert(std::make_pair(m_rand_id, this));
   
   if (mutation_rates == NULL)
@@ -132,7 +139,7 @@
   // Now, depending on configuration, possibly reset this cell's random ID.
   double reset_id = m_world->GetConfig().CELL_ID_RESET_PROB.Get();
   if(reset_id > 0.0 && m_world->GetRandom().P(reset_id)) {
-    ResetRandomID();
+    ResetRandomCellID();
   }
 }
 
@@ -164,6 +171,13 @@
   return s_rand_ids.rbegin()->first;
 }
 
+
+cPopulationCell* cPopulationCell::GetMaxRandomCell() 
+{
+  assert(s_rand_ids.size()>0);
+  return s_rand_ids.rbegin()->second;
+}
+
 /*! These values are chosen so as to make loops on the facing 'easy'.
 S=0, SW=-1, W=-2, NW=-3, N=-4, NE=3, E=2, SE=1.
 
@@ -207,7 +221,7 @@
 reset a cell ID.  Remember to remove the current rand id->cell mapping before
 adding the new one.
 */
-void cPopulationCell::ResetRandomID()
+void cPopulationCell::ResetRandomCellID()
 {
   s_rand_ids.erase(m_rand_id);
   m_rand_id = m_world->GetRandom().GetUInt(UINT_MAX);

Modified: branches/coopcomm/source/main/cPopulationCell.h
===================================================================
--- branches/coopcomm/source/main/cPopulationCell.h	2006-10-01 03:52:22 UTC (rev 1022)
+++ branches/coopcomm/source/main/cPopulationCell.h	2006-10-01 03:54:55 UTC (rev 1023)
@@ -89,8 +89,10 @@
   static unsigned int IsRandomCellID(unsigned int id) { return s_rand_ids.find(id)!=s_rand_ids.end(); }
   //! Returns the current maximum random cell ID.
   static unsigned int GetMaxRandomCellID();
+  //! Returns the cell with the current maximal ID.
+  static cPopulationCell* GetMaxRandomCell();
   //! Reset this cell's random ID.
-  void ResetRandomID();  
+  void ResetRandomCellID();  
 };
 
 

Modified: branches/coopcomm/source/main/cStats.cc
===================================================================
--- branches/coopcomm/source/main/cStats.cc	2006-10-01 03:52:22 UTC (rev 1022)
+++ branches/coopcomm/source/main/cStats.cc	2006-10-01 03:54:55 UTC (rev 1023)
@@ -961,7 +961,7 @@
 
   df.WriteAnonymous(m_update);
   df.WriteAnonymous(m_count_org_died);
-  df.WriteAnonymous((int)m_cell_sent_leader.size());
+  df.WriteAnonymous((unsigned int)m_cell_sent_leader.size());
   for(std::set<int>::iterator i=m_cell_sent_leader.begin(); i!=m_cell_sent_leader.end(); ++i) {
     df.WriteAnonymous(*i);
   }

Modified: branches/coopcomm/source/main/cTaskLib.cc
===================================================================
--- branches/coopcomm/source/main/cTaskLib.cc	2006-10-01 03:52:22 UTC (rev 1022)
+++ branches/coopcomm/source/main/cTaskLib.cc	2006-10-01 03:54:55 UTC (rev 1023)
@@ -1988,4 +1988,4 @@
   if(Task_SendTowardSink(ctx) == 0.0)
     return 1.0;
   return 0.0;
-}
\ No newline at end of file
+}




More information about the Avida-cvs mailing list