[Avida-SVN] r1072 - in development/source: . actions cpu main targets/avida-viewer

ofria at myxo.css.msu.edu ofria at myxo.css.msu.edu
Sun Nov 5 08:52:54 PST 2006


Author: ofria
Date: 2006-11-05 11:52:53 -0500 (Sun, 05 Nov 2006)
New Revision: 1072

Modified:
   development/source/actions/LandscapeActions.cc
   development/source/cpu/cHardwareCPU.cc
   development/source/defs.h
   development/source/main/cAvidaConfig.h
   development/source/main/cBirthChamber.cc
   development/source/main/cPhenotype.cc
   development/source/main/cPopulation.cc
   development/source/targets/avida-viewer/cOptionsScreen.cc
Log:
Changed a number of setting names in avida.cfg:
  MERIT_GIVEN -> DONATE_SIZE (Make it clear this has to do with donates)
  MERIT_RECEIVED -> DONATE_MULT (Slightly different functionality)
  SIZE_MERIT_METHOD -> BASE_MERIT_METHOD (Since its not always based on size)
  BASE_SIZE_MERIT -> BASE_CONST_MERIT (Value used when base merit is constant)

Fixed warnings in LandscapeActions

Added new option to BIRTH_METHOD: 8 = Next Grid Cell (id+1)
This will be useful when we want offspring to always be placed in a specific
location.



Modified: development/source/actions/LandscapeActions.cc
===================================================================
--- development/source/actions/LandscapeActions.cc	2006-11-04 22:30:46 UTC (rev 1071)
+++ development/source/actions/LandscapeActions.cc	2006-11-05 16:52:53 UTC (rev 1072)
@@ -80,7 +80,7 @@
 
       cAnalyzeGenotype* genotype = NULL;
       tListIterator<cAnalyzeGenotype> batch_it(m_world->GetAnalyze().GetCurrentBatch().List());
-      while (genotype = batch_it.Next()) {
+      while ((genotype = batch_it.Next())) {
         LoadGenome(batches, genotype->GetGenome());
         depths.Push(genotype->GetDepth());
       }
@@ -225,7 +225,7 @@
       
       tListIterator<cAnalyzeGenotype> batch_it(m_world->GetAnalyze().GetCurrentBatch().List());
       cAnalyzeGenotype* genotype = NULL;
-      while (genotype = batch_it.Next()) {
+      while ((genotype = batch_it.Next())) {
         land = new cLandscape(m_world, genotype->GetGenome(), inst_set);
         land->SetDistance(m_dist);
         m_batch.PushRear(land);
@@ -245,7 +245,7 @@
     }
     
     cDataFile& df = m_world->GetDataFile(m_sfilename);
-    while (land = m_batch.Pop()) {
+    while ((land = m_batch.Pop())) {
       land->PrintStats(df, update);
       if (m_efilename.GetSize()) land->PrintEntropy(m_world->GetDataFile(m_efilename));
       if (m_cfilename.GetSize()) land->PrintSiteCount(m_world->GetDataFile(m_cfilename));
@@ -302,7 +302,7 @@
       
       tListIterator<cAnalyzeGenotype> batch_it(m_world->GetAnalyze().GetCurrentBatch().List());
       cAnalyzeGenotype* genotype = NULL;
-      while (genotype = batch_it.Next()) {
+      while ((genotype = batch_it.Next())) {
         land = new cLandscape(m_world, genotype->GetGenome(), inst_set);
         land->SetDistance(m_dist);
         m_batch.PushRear(land);
@@ -322,7 +322,7 @@
     }
     
     cDataFile& df = m_world->GetDataFile(m_sfilename);
-    while (land = m_batch.Pop()) {
+    while ((land = m_batch.Pop())) {
       land->PrintStats(df, update);
       if (m_cfilename.GetSize()) land->PrintSiteCount(m_world->GetDataFile(m_cfilename));
       delete land;
@@ -377,7 +377,7 @@
       
       tListIterator<cAnalyzeGenotype> batch_it(m_world->GetAnalyze().GetCurrentBatch().List());
       cAnalyzeGenotype* genotype = NULL;
-      while (genotype = batch_it.Next()) {
+      while ((genotype = batch_it.Next())) {
         land = new cLandscape(m_world, genotype->GetGenome(), inst_set);
         land->SetDistance(m_dist);
         m_batch.PushRear(land);
@@ -397,7 +397,7 @@
     }
     
     cDataFile& df = m_world->GetDataFile(m_sfilename);
-    while (land = m_batch.Pop()) {
+    while ((land = m_batch.Pop())) {
       land->PrintStats(df, update);
       if (m_cfilename.GetSize()) land->PrintSiteCount(m_world->GetDataFile(m_cfilename));
       delete land;
@@ -444,7 +444,7 @@
       
       tListIterator<cAnalyzeGenotype> batch_it(m_world->GetAnalyze().GetCurrentBatch().List());
       cAnalyzeGenotype* genotype = NULL;
-      while (genotype = batch_it.Next()) {
+      while ((genotype = batch_it.Next())) {
         cLandscape land(m_world, genotype->GetGenome(), inst_set);
         land.PredictWProcess(ctx, df);
       }
@@ -495,7 +495,7 @@
       
       tListIterator<cAnalyzeGenotype> batch_it(m_world->GetAnalyze().GetCurrentBatch().List());
       cAnalyzeGenotype* genotype = NULL;
-      while (genotype = batch_it.Next()) {
+      while ((genotype = batch_it.Next())) {
         cLandscape land(m_world, genotype->GetGenome(), inst_set);
         land.PredictNuProcess(ctx, df);
       }
@@ -554,7 +554,7 @@
       
       tListIterator<cAnalyzeGenotype> batch_it(m_world->GetAnalyze().GetCurrentBatch().List());
       cAnalyzeGenotype* genotype = NULL;
-      while (genotype = batch_it.Next()) {
+      while ((genotype = batch_it.Next())) {
         cLandscape* land = new cLandscape(m_world, genotype->GetGenome(), inst_set);
         land->SetDistance(m_dist);
         land->SetTrials(m_trials);
@@ -576,7 +576,7 @@
     }
     
     cDataFile& df = m_world->GetDataFile(m_filename);
-    while (land = m_batch.Pop()) {
+    while ((land = m_batch.Pop())) {
       land->PrintStats(df, update);
       delete land;
     }
@@ -626,7 +626,7 @@
       
       tListIterator<cAnalyzeGenotype> batch_it(m_world->GetAnalyze().GetCurrentBatch().List());
       cAnalyzeGenotype* genotype = NULL;
-      while (genotype = batch_it.Next()) {
+      while ((genotype = batch_it.Next())) {
         cLandscape* land = new cLandscape(m_world, genotype->GetGenome(), inst_set);
         land->SetTrials(m_trials);
         m_batch.PushRear(land);
@@ -646,7 +646,7 @@
     }
     
     cDataFile& df = m_world->GetDataFile(m_filename);
-    while (land = m_batch.Pop()) {
+    while ((land = m_batch.Pop())) {
       land->PrintStats(df, update);
       delete land;
     }
@@ -689,7 +689,7 @@
       cDataFile& df = m_world->GetDataFile(m_filename);
       tListIterator<cAnalyzeGenotype> batch_it(m_world->GetAnalyze().GetCurrentBatch().List());
       cAnalyzeGenotype* genotype = NULL;
-      while (genotype = batch_it.Next()) {
+      while ((genotype = batch_it.Next())) {
         cLandscape land(m_world, genotype->GetGenome(), inst_set);
         land.HillClimb(ctx, df);
       }
@@ -753,7 +753,7 @@
       cAnalyzeJobQueue& jobqueue = m_world->GetAnalyze().GetJobQueue();
       tListIterator<cAnalyzeGenotype> batch_it(m_world->GetAnalyze().GetCurrentBatch().List());
       cAnalyzeGenotype* genotype = NULL;
-      while (genotype = batch_it.Next()) {
+      while ((genotype = batch_it.Next())) {
         mutn = new cMutationalNeighborhood(m_world, genotype->GetGenome(), inst_set, m_target);
         m_batch.PushRear(new sBatchEntry(mutn, genotype->GetDepth()));
         jobqueue.AddJob(new tAnalyzeJob<cMutationalNeighborhood>(mutn, &cMutationalNeighborhood::Process));
@@ -775,7 +775,7 @@
     cDataFile& df = m_world->GetDataFile(m_filename);
     df.WriteComment("IMPORTANT: Mutational Neighborhood is *EXPERIMENTAL*");
     df.WriteComment("Output data and format is subject to change in future releases.");
-    while (entry = m_batch.Pop()) {
+    while ((entry = m_batch.Pop())) {
       results = new cMutationalNeighborhoodResults(entry->mutn);
       results->PrintStats(df, entry->depth);
       delete results;
@@ -828,7 +828,7 @@
       
       tListIterator<cAnalyzeGenotype> batch_it(m_world->GetAnalyze().GetCurrentBatch().List());
       cAnalyzeGenotype* genotype = NULL;
-      while (genotype = batch_it.Next()) {
+      while ((genotype = batch_it.Next())) {
         cLandscape* land = new cLandscape(m_world, genotype->GetGenome(), inst_set);
         if (m_sample_size) {
           land->SetTrials(m_sample_size);
@@ -855,7 +855,7 @@
     }
     
     cDataFile& df = m_world->GetDataFile(m_filename);
-    while (land = m_batch.Pop()) {
+    while ((land = m_batch.Pop())) {
       land->PrintStats(df, update);
       delete land;
     }
@@ -947,7 +947,7 @@
 
       cDataFile& df = m_world->GetDataFile(filename);
       cTestCPU* testcpu = (m_save_genotypes) ? m_world->GetHardwareManager().CreateTestCPU() : NULL;
-      while (orgdata = batch.Pop()) {
+      while ((orgdata = batch.Pop())) {
         cOrganism* organism = orgdata->GetOrganism();
         cGenotype* genotype = organism->GetGenotype();
         cPhenotype& phenotype = organism->GetPhenotype();

Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc	2006-11-04 22:30:46 UTC (rev 1071)
+++ development/source/cpu/cHardwareCPU.cc	2006-11-05 16:52:53 UTC (rev 1072)
@@ -2913,8 +2913,9 @@
 {
   assert(to_org != NULL);
   
-  const double merit_given = m_world->GetConfig().MERIT_GIVEN.Get();
-  const double merit_received = m_world->GetConfig().MERIT_RECEIVED.Get();
+  const double merit_given = m_world->GetConfig().DONATE_SIZE.Get();
+  const double merit_received =
+    merit_given * m_world->GetConfig().DONATE_MULT.Get();
   
   double cur_merit = organism->GetPhenotype().GetMerit().GetDouble();
   cur_merit -= merit_given; 
@@ -3048,7 +3049,7 @@
   // This is a fake donate command that causes the organism to lose merit,
   // but no one else to gain any.
   
-  const double merit_given = m_world->GetConfig().MERIT_GIVEN.Get();
+  const double merit_given = m_world->GetConfig().DONATE_SIZE.Get();
   double cur_merit = organism->GetPhenotype().GetMerit().GetDouble();
   cur_merit -= merit_given;
   

Modified: development/source/defs.h
===================================================================
--- development/source/defs.h	2006-11-04 22:30:46 UTC (rev 1071)
+++ development/source/defs.h	2006-11-05 16:52:53 UTC (rev 1072)
@@ -130,7 +130,8 @@
   POSITION_CHILD_FULL_SOUP_RANDOM,
   POSITION_CHILD_FULL_SOUP_ELDEST,
   POSITION_CHILD_DEME_RANDOM,
-  POSITION_CHILD_PARENT_FACING
+  POSITION_CHILD_PARENT_FACING,
+  POSITION_CHILD_NEXT_CELL
 };
 const int NUM_LOCAL_POSITION_CHILD = POSITION_CHILD_FULL_SOUP_RANDOM;
 
@@ -161,14 +162,14 @@
   GENERATION_INC_BOTH
 };
 
-enum tSIZE_MERIT
+enum tBASE_MERIT
 {
-  SIZE_MERIT_OFF = 0,
-  SIZE_MERIT_COPIED,
-  SIZE_MERIT_EXECUTED,
-  SIZE_MERIT_FULL,
-  SIZE_MERIT_LEAST,
-  SIZE_MERIT_SQRT_LEAST
+  BASE_MERIT_CONST = 0,
+  BASE_MERIT_COPIED_SIZE,
+  BASE_MERIT_EXE_SIZE,
+  BASE_MERIT_FULL_SIZE,
+  BASE_MERIT_LEAST_SIZE,
+  BASE_MERIT_SQRT_LEAST_SIZE
 };
 
 typedef enum eVerbosity {

Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h	2006-11-04 22:30:46 UTC (rev 1071)
+++ development/source/main/cAvidaConfig.h	2006-11-05 16:52:53 UTC (rev 1072)
@@ -174,7 +174,7 @@
   CONFIG_ADD_VAR(START_CREATURE, cString, "default-classic.org", "Organism to seed the soup");
   
   CONFIG_ADD_GROUP(REPRODUCTION_GROUP, "Birth and Death");
-  CONFIG_ADD_VAR(BIRTH_METHOD, int, 0, "Which organism should be replaced on birth?\n0 = Random organism in neighborhood\n1 = Oldest in neighborhood\n2 = Largest Age/Merit in neighborhood\n3 = None (use only empty cells in neighborhood)\n4 = Random from population (Mass Action)\n5 = Oldest in entire population\n6 = Random within deme\n7 = Organism faced by parent");
+  CONFIG_ADD_VAR(BIRTH_METHOD, int, 0, "Which organism should be replaced on birth?\n0 = Random organism in neighborhood\n1 = Oldest in neighborhood\n2 = Largest Age/Merit in neighborhood\n3 = None (use only empty cells in neighborhood)\n4 = Random from population (Mass Action)\n5 = Oldest in entire population\n6 = Random within deme\n7 = Organism faced by parent\n8 = Next grid cell (id+1)");
   CONFIG_ADD_VAR(PREFER_EMPTY, int, 1, "Give empty cells preference in offsping placement?");
   CONFIG_ADD_VAR(DEATH_METHOD, int, 2, "0 = Never die of old age.\n1 = Die when inst executed = AGE_LIMIT (+deviation)\n2 = Die when inst executed = length*AGE_LIMIT (+dev)");
   CONFIG_ADD_VAR(AGE_LIMIT, int, 20, "Modifies DEATH_METHOD");
@@ -232,16 +232,16 @@
   
   CONFIG_ADD_GROUP(TIME_GROUP, "Time Slicing");
   CONFIG_ADD_VAR(AVE_TIME_SLICE, int, 30, "Ave number of insts per org per update");
-  CONFIG_ADD_VAR(SLICING_METHOD, int, 2, "0 = CONSTANT: all organisms get default...\n1 = PROBABILISTIC: Run _prob_ proportional to merit.\n2 = INTEGRATED: Perfectly integrated deterministic.");
-  CONFIG_ADD_VAR(SIZE_MERIT_METHOD, int, 4, "0 = off (merit is independent of size)\n1 = Merit proportional to copied size\n2 = Merit prop. to executed size\n3 = Merit prop. to full size\n4 = Merit prop. to min of executed or copied size\n5 = Merit prop. to sqrt of the minimum size");
+  CONFIG_ADD_VAR(SLICING_METHOD, int, 1, "0 = CONSTANT: all organisms get default...\n1 = PROBABILISTIC: Run _prob_ proportional to merit.\n2 = INTEGRATED: Perfectly integrated deterministic.");
+  CONFIG_ADD_VAR(BASE_MERIT_METHOD, int, 4, "0 = Constant (merit independent of size)\n1 = Merit proportional to copied size\n2 = Merit prop. to executed size\n3 = Merit prop. to full size\n4 = Merit prop. to min of executed or copied size\n5 = Merit prop. to sqrt of the minimum size");
+  CONFIG_ADD_VAR(BASE_CONST_MERIT, int, 100, "Base merit when BASE_MERIT_METHOD set to 0");
+  CONFIG_ADD_VAR(DEFAULT_BONUS, double, 1.0, "Initial bonus before any tasks");
+  CONFIG_ADD_VAR(MERIT_DEFAULT_BONUS, int, 0, "Scale the merit of an offspring by the default bonus\nrather than the accumulated bonus of the parent?"); 
   CONFIG_ADD_VAR(MAX_CPU_THREADS, int, 1, "Number of Threads a CPU can spawn");
   CONFIG_ADD_VAR(THREAD_SLICING_METHOD, int, 0, "Formula for and organism's thread slicing\n  (num_threads-1) * THREAD_SLICING_METHOD + 1\n0 = One thread executed per time slice.\n1 = All threads executed each time slice.\n");
   CONFIG_ADD_VAR(MAX_LABEL_EXE_SIZE, int, 1, "Max nops marked as executed when labels are used");
-  CONFIG_ADD_VAR(BASE_SIZE_MERIT, int, 100, "Base merit when size is *not* used");
-  CONFIG_ADD_VAR(DEFAULT_BONUS, double, 1.0, "The bonus an organism gets before any tasks");
-  CONFIG_ADD_VAR(MERIT_DEFAULT_BONUS, int, 0, "Scale the merit of an offspring by the default bonus\nrather than the accumulated bonus of the parent?"); 
-  CONFIG_ADD_VAR(MERIT_GIVEN, double, 0.0, "Amount of merit donated with 'donate' command");
-  CONFIG_ADD_VAR(MERIT_RECEIVED, double, 0.0, "Amount of merit received with 'donate' command");
+  CONFIG_ADD_VAR(DONATE_SIZE, double, 5.0, "Amount of merit donated with 'donate' command");
+  CONFIG_ADD_VAR(DONATE_MULT, double, 10.0, "Multiple of merit given that the target receives.");
   CONFIG_ADD_VAR(MAX_DONATE_KIN_DIST, int, -1, "Limit on distance of relation for donate; -1=no max");
   CONFIG_ADD_VAR(MAX_DONATE_EDIT_DIST, int, -1, "Limit on edit distance for donate; -1=no max");
   CONFIG_ADD_VAR(MAX_DONATES, int, 1000000, "Limit on number of donates organisms are allowed.");

Modified: development/source/main/cBirthChamber.cc
===================================================================
--- development/source/main/cBirthChamber.cc	2006-11-04 22:30:46 UTC (rev 1071)
+++ development/source/main/cBirthChamber.cc	2006-11-05 16:52:53 UTC (rev 1072)
@@ -48,7 +48,7 @@
   // If there is no organism in the entry, return false.
   if (entry.update_in == -1) return false;
 
-  // If there is an organis, determien if it is still alive.
+  // If there is an organism, determine if it is still alive.
   const int max_wait_time = m_world->GetConfig().MAX_BIRTH_WAIT_TIME.Get();
 
   // If the max_wait_time is -1, there is no timeout, so its alive.

Modified: development/source/main/cPhenotype.cc
===================================================================
--- development/source/main/cPhenotype.cc	2006-11-04 22:30:46 UTC (rev 1071)
+++ development/source/main/cPhenotype.cc	2006-11-05 16:52:53 UTC (rev 1072)
@@ -258,12 +258,10 @@
   // If we are resetting the current merit, do it here
   // and it will also be propagated to the child
   const int merit_default_bonus = m_world->GetConfig().MERIT_DEFAULT_BONUS.Get();
-  if (merit_default_bonus)
-  {
+  if (merit_default_bonus) {
     merit = cur_merit_base * m_world->GetConfig().DEFAULT_BONUS.Get();
   }
-  else // Default
-  {
+  else { // Default
     merit = cur_merit_base * cur_bonus;
   }
   
@@ -755,30 +753,30 @@
 
   int out_size;
 
-  switch (m_world->GetConfig().SIZE_MERIT_METHOD.Get()) {
-  case SIZE_MERIT_COPIED:
+  switch (m_world->GetConfig().BASE_MERIT_METHOD.Get()) {
+  case BASE_MERIT_COPIED_SIZE:
     out_size = copied_size;
     break;
-  case SIZE_MERIT_EXECUTED:
+  case BASE_MERIT_EXE_SIZE:
     out_size = executed_size;
     break;
-  case SIZE_MERIT_FULL:
+  case BASE_MERIT_FULL_SIZE:
     out_size = genome_length;
     break;
-  case SIZE_MERIT_LEAST:
+  case BASE_MERIT_LEAST_SIZE:
     out_size = genome_length;
     if (out_size > copied_size) out_size = copied_size;
     if (out_size > executed_size)    out_size = executed_size;
     break;
-  case SIZE_MERIT_SQRT_LEAST:
+  case BASE_MERIT_SQRT_LEAST_SIZE:
     out_size = genome_length;
     if (out_size > copied_size) out_size = copied_size;
     if (out_size > executed_size)    out_size = executed_size;
     out_size = (int) sqrt((double) out_size);
     break;
-  case SIZE_MERIT_OFF:
+  case BASE_MERIT_CONST:
   default:
-    out_size = m_world->GetConfig().BASE_SIZE_MERIT.Get();
+    out_size = m_world->GetConfig().BASE_CONST_MERIT.Get();
     break;
   }
 

Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc	2006-11-04 22:30:46 UTC (rev 1071)
+++ development/source/main/cPopulation.cc	2006-11-05 16:52:53 UTC (rev 1072)
@@ -1195,6 +1195,11 @@
   else if (birth_method == POSITION_CHILD_PARENT_FACING) {
     return parent_cell.GetCellFaced();
   }
+  else if (birth_method == POSITION_CHILD_NEXT_CELL) {
+    int out_cell_id = parent_cell.GetID() + 1;
+    if (out_cell_id == cell_array.GetSize()) out_cell_id = 0;
+    return GetCell(out_cell_id);
+  }
 
   // All remaining methods require us to choose among mulitple local positions.
 

Modified: development/source/targets/avida-viewer/cOptionsScreen.cc
===================================================================
--- development/source/targets/avida-viewer/cOptionsScreen.cc	2006-11-04 22:30:46 UTC (rev 1071)
+++ development/source/targets/avida-viewer/cOptionsScreen.cc	2006-11-05 16:52:53 UTC (rev 1072)
@@ -100,20 +100,20 @@
     break;
   }
 
-  switch(info.GetConfig().SIZE_MERIT_METHOD.Get()) {
-  case SIZE_MERIT_OFF:
+  switch(info.GetConfig().BASE_MERIT_METHOD.Get()) {
+  case BASE_MERIT_CONST:
     Print(3, 55, "Off");
     break;
-  case SIZE_MERIT_COPIED:
+  case BASE_MERIT_COPIED_SIZE:
     Print(3, 55, "Copied Size");
     break;
-  case SIZE_MERIT_EXECUTED:
+  case BASE_MERIT_EXE_SIZE:
     Print(3, 55, "Executed Size");
     break;
-  case SIZE_MERIT_FULL:
+  case BASE_MERIT_FULL_SIZE:
     Print(3, 55, "Full Size");
     break;
-  case SIZE_MERIT_LEAST:
+  case BASE_MERIT_LEAST_SIZE:
     Print(3, 55, "Least Size");
     break;
   }




More information about the Avida-cvs mailing list