[Avida-SVN] r3508 - in branches/parasites: . Avida.xcodeproj source/cpu source/drivers source/main source/targets/avida-viewer

zaman at myxo.css.msu.edu zaman at myxo.css.msu.edu
Tue Oct 27 12:46:35 PDT 2009


Author: zaman
Date: 2009-10-27 15:46:35 -0400 (Tue, 27 Oct 2009)
New Revision: 3508

Modified:
   branches/parasites/
   branches/parasites/Avida.xcodeproj/
   branches/parasites/source/cpu/cHardwareTransSMT.cc
   branches/parasites/source/drivers/cDefaultRunDriver.cc
   branches/parasites/source/main/cAvidaConfig.h
   branches/parasites/source/main/cPhenotype.cc
   branches/parasites/source/main/cPopulation.cc
   branches/parasites/source/targets/avida-viewer/cSymbolUtil.cc
Log:
Adding initial parasite code to branch.


Property changes on: branches/parasites
___________________________________________________________________
Name: svn:ignore
   + build



Property changes on: branches/parasites/Avida.xcodeproj
___________________________________________________________________
Name: svn:ignore
   + zamanlui.mode1v3
zamanlui.pbxuser


Modified: branches/parasites/source/cpu/cHardwareTransSMT.cc
===================================================================
--- branches/parasites/source/cpu/cHardwareTransSMT.cc	2009-10-27 19:37:05 UTC (rev 3507)
+++ branches/parasites/source/cpu/cHardwareTransSMT.cc	2009-10-27 19:46:35 UTC (rev 3508)
@@ -131,7 +131,7 @@
 	
   return new tInstLib<tMethod>(f_size, s_f_array, n_names, nop_mods, functions, def, null_inst);
 }
- 
+
 cHardwareTransSMT::cHardwareTransSMT(cAvidaContext& ctx, cWorld* world, cOrganism* in_organism,
                                      cInstSet* in_inst_set, int inst_set_id)
 : cHardwareBase(world, in_organism, in_inst_set, inst_set_id), m_mem_array(1)
@@ -159,7 +159,7 @@
   // Reset that single thread.
   m_threads[0].Reset(this, 0);
   m_cur_thread = 0;
-		
+  
   // Reset all stacks (local and global)
   for(int i = 0; i < NUM_STACKS; i++) {
 		Stack(i).Clear();
@@ -200,7 +200,7 @@
     // Setup the hardware for the next instruction to be executed.
     m_cur_thread++;
     if (m_cur_thread >= m_threads.GetSize()) m_cur_thread = 0;
-
+    
     if (!ThreadIsRunning()) continue;
     
     AdvanceIP() = true;
@@ -331,13 +331,13 @@
 	<< endl;
 	
   fp << "  R-Head:(" << GetHead(nHardware::HEAD_READ).GetMemSpace() << ", " 
-		<< GetHead(nHardware::HEAD_READ).GetPosition() << ")  " 
-		<< "W-Head:(" << GetHead(nHardware::HEAD_WRITE).GetMemSpace()  << ", "
-		<< GetHead(nHardware::HEAD_WRITE).GetPosition() << ")  "
-		<< "F-Head:(" << GetHead(nHardware::HEAD_FLOW).GetMemSpace()   << ",  "
-		<< GetHead(nHardware::HEAD_FLOW).GetPosition() << ")  "
-		<< "RL:" << GetReadLabel().AsString() << "   "
-    << endl;
+  << GetHead(nHardware::HEAD_READ).GetPosition() << ")  " 
+  << "W-Head:(" << GetHead(nHardware::HEAD_WRITE).GetMemSpace()  << ", "
+  << GetHead(nHardware::HEAD_WRITE).GetPosition() << ")  "
+  << "F-Head:(" << GetHead(nHardware::HEAD_FLOW).GetMemSpace()   << ",  "
+  << GetHead(nHardware::HEAD_FLOW).GetPosition() << ")  "
+  << "RL:" << GetReadLabel().AsString() << "   "
+  << endl;
 	
   for (int i = 0; i < m_mem_array.GetSize(); i++) {
     const cCPUMemory& mem = m_mem_array[i];
@@ -415,7 +415,7 @@
 // memory.  Return the first line _after_ the the found label.  It is okay
 // to find search label's match inside another label.
 int cHardwareTransSMT::FindLabel_Forward(const cCodeLabel& search_label,
-                                    const cGenome& search_genome, int pos)
+                                         const cGenome& search_genome, int pos)
 {
   assert (pos < search_genome.GetSize() && pos >= 0);
 	
@@ -496,7 +496,7 @@
 // memory.  Return the first line _after_ the the found label.  It is okay
 // to find search label's match inside another label.
 int cHardwareTransSMT::FindLabel_Backward(const cCodeLabel & search_label,
-                                     const cGenome & search_genome, int pos)
+                                          const cGenome & search_genome, int pos)
 {
   assert (pos < search_genome.GetSize());
 	
@@ -648,8 +648,12 @@
 bool cHardwareTransSMT::InjectHost(const cCodeLabel& in_label, const cGenome& inject_code)
 {
   // Inject fails if the memory space is already in use or thread exists
-  if (MemorySpaceExists(in_label) || FindThreadLabel(in_label) != -1) return false;
-
+  if (MemorySpaceExists(in_label) || FindThreadLabel(in_label) != -1) 
+  {
+    cout <<"memory space exists - " << in_label.AsString() << endl;
+    return false;
+  }
+  
   // Otherwise create the memory space and copy in the genome
   int mem_space_used = FindMemorySpaceLabel(in_label, -1);
   assert(mem_space_used != -1);
@@ -657,7 +661,7 @@
   
   // Create a thread for this parasite
   if (!ThreadCreate(in_label, mem_space_used)) return false; // Partially failed injection, could not create thread
-
+  
   return true;
 }
 
@@ -716,7 +720,7 @@
   // Add new thread entry
   m_threads.Resize(thread_id + 1);
   m_thread_lbls.Add(hash_key, thread_id);
-    
+  
   // Setup this thread into the current selected memory space (Flow Head)
   m_threads[thread_id].Reset(this, mem_space);
 	
@@ -726,7 +730,7 @@
 bool cHardwareTransSMT::ThreadKill(const int thread_id)
 {
   if (thread_id < 1 || thread_id >= m_threads.GetSize()) return false;
-
+  
   // Increment thread, if killing current thread
   if (m_cur_thread == thread_id) ThreadNext();
   
@@ -840,59 +844,50 @@
   m_organism->GetPhenotype().SetDivType(mut_multiplier);
 	
   // Divide Mutations (per site)
-  if(m_organism->GetDivMutProb() > 0){
-    int num_mut = ctx.GetRandom().GetRandBinomial(injected_code.GetSize(), 
-																					 m_organism->GetInjectMutProb() / mut_multiplier);
-    // If we have lines to mutate...
-    if( num_mut > 0 ){
-      for (int i = 0; i < num_mut; i++) {
-				int site = ctx.GetRandom().GetUInt(injected_code.GetSize());
-				injected_code[site] = m_inst_set->GetRandomInst(ctx);
-      }
+  int num_mut = ctx.GetRandom().GetRandBinomial(injected_code.GetSize(), 
+                                                m_organism->GetInjectMutProb() / mut_multiplier);
+  // If we have lines to mutate...
+  if( num_mut > 0 ){
+    for (int i = 0; i < num_mut; i++) {
+      int site = ctx.GetRandom().GetUInt(injected_code.GetSize());
+      injected_code[site] = m_inst_set->GetRandomInst(ctx);
     }
   }
 	
-	
   // Insert Mutations (per site)
-  if(m_organism->GetDivInsProb() > 0){
-    int num_mut = ctx.GetRandom().GetRandBinomial(injected_code.GetSize(),
-																					 m_organism->GetInjectInsProb());
-    // If would make creature to big, insert up to MAX_CREATURE_SIZE
-    if( num_mut + injected_code.GetSize() > MAX_CREATURE_SIZE ){
-      num_mut = MAX_CREATURE_SIZE - injected_code.GetSize();
+  num_mut = ctx.GetRandom().GetRandBinomial(injected_code.GetSize(),
+                                            m_organism->GetInjectInsProb());
+  // If would make creature to big, insert up to MAX_CREATURE_SIZE
+  if( num_mut + injected_code.GetSize() > MAX_CREATURE_SIZE )
+    num_mut = MAX_CREATURE_SIZE - injected_code.GetSize();
+  // If we have lines to insert...
+  if( num_mut > 0 ){
+    // Build a list of the sites where mutations occured
+    static int mut_sites[MAX_CREATURE_SIZE];
+    for (int i = 0; i < num_mut; i++) {
+      mut_sites[i] = ctx.GetRandom().GetUInt(injected_code.GetSize() + 1);
     }
-    // If we have lines to insert...
-    if( num_mut > 0 ){
-      // Build a list of the sites where mutations occured
-      static int mut_sites[MAX_CREATURE_SIZE];
-      for (int i = 0; i < num_mut; i++) {
-				mut_sites[i] = ctx.GetRandom().GetUInt(injected_code.GetSize() + 1);
-      }
-      // Sort the list
-      qsort( (void*)mut_sites, num_mut, sizeof(int), &IntCompareFunction );
-      // Actually do the mutations (in reverse sort order)
-      for(int i = num_mut-1; i >= 0; i--) {
-				injected_code.Insert(mut_sites[i], m_inst_set->GetRandomInst(ctx));
-      }
+    // Sort the list
+    qsort( (void*)mut_sites, num_mut, sizeof(int), &IntCompareFunction );
+    // Actually do the mutations (in reverse sort order)
+    for(int i = num_mut-1; i >= 0; i--) {
+      injected_code.Insert(mut_sites[i], m_inst_set->GetRandomInst(ctx));
     }
   }
 	
-	
   // Delete Mutations (per site)
-  if( m_organism->GetDivDelProb() > 0 ){
-    int num_mut = ctx.GetRandom().GetRandBinomial(injected_code.GetSize(),
-																					 m_organism->GetInjectDelProb());
-    // If would make creature too small, delete down to MIN_CREATURE_SIZE
-    if (injected_code.GetSize() - num_mut < MIN_CREATURE_SIZE) {
-      num_mut = injected_code.GetSize() - MIN_CREATURE_SIZE;
-    }
-		
-    // If we have lines to delete...
-    for (int i = 0; i < num_mut; i++) {
-      int site = ctx.GetRandom().GetUInt(injected_code.GetSize());
-      injected_code.Remove(site);
-    }
+  num_mut = ctx.GetRandom().GetRandBinomial(injected_code.GetSize(),
+                                            m_organism->GetInjectDelProb());
+  // If would make creature too small, delete down to MIN_CREATURE_SIZE
+  if (injected_code.GetSize() - num_mut < MIN_CREATURE_SIZE) {
+    num_mut = injected_code.GetSize() - MIN_CREATURE_SIZE;
   }
+  
+  // If we have lines to delete...
+  for (int i = 0; i < num_mut; i++) {
+    int site = ctx.GetRandom().GetUInt(injected_code.GetSize());
+    injected_code.Remove(site);
+  }
 	
   // Mutations in the parent's genome
   if (m_organism->GetParentMutProb() > 0) {
@@ -906,6 +901,7 @@
 }
 
 
+
 bool cHardwareTransSMT::Divide_Main(cAvidaContext& ctx, double mut_multiplier)
 {
   const int mem_space_used = GetHead(nHardware::HEAD_WRITE).GetMemSpace();
@@ -913,7 +909,7 @@
   
   // Make sure the memory space we're using exists
   if (m_mem_array.GetSize() <= mem_space_used) return false;
-  	
+  
   // Make sure this divide will produce a viable offspring.
   m_cur_child = mem_space_used; // save current child memory space for use by dependent functions (e.g. calcCopiedSize())
   if (!Divide_CheckViable(ctx, m_mem_array[0].GetSize(), write_head_pos)) return false;
@@ -954,13 +950,13 @@
       case DIVIDE_METHOD_SPLIT:
         Reset(ctx);  // This will wipe out all parasites on a divide.
         break;
-      
+        
       case DIVIDE_METHOD_BIRTH:
         // Reset only the calling thread's state
         for(int x = 0; x < nHardware::NUM_HEADS; x++) GetHead(x).Reset(this, 0);
         for(int x = 0; x < NUM_LOCAL_STACKS; x++) Stack(x).Clear();
         break;
-      
+        
       case DIVIDE_METHOD_OFFSPRING:
       default:
         break;
@@ -1142,7 +1138,7 @@
 {
   const int head_id = FindModifiedHead(nHardware::HEAD_WRITE);
   const int src = FindModifiedStack(STACK_AX);
-
+  
   cHeadCPU & active_head = GetHead(head_id);
   int mem_space_used = active_head.GetMemSpace();
   
@@ -1451,7 +1447,7 @@
 bool cHardwareTransSMT::Inst_CallFlow(cAvidaContext& ctx)
 {
   const int dst = FindModifiedStack(STACK_AX);
-
+  
   const int location = IP().GetPosition() & 0xFFFF;
   const int mem_space = IP().GetMemSpace() << 8;
   const int ra  = location | mem_space;

Modified: branches/parasites/source/drivers/cDefaultRunDriver.cc
===================================================================
--- branches/parasites/source/drivers/cDefaultRunDriver.cc	2009-10-27 19:37:05 UTC (rev 3507)
+++ branches/parasites/source/drivers/cDefaultRunDriver.cc	2009-10-27 19:46:35 UTC (rev 3508)
@@ -46,7 +46,7 @@
 
 
 cDefaultRunDriver::cDefaultRunDriver(cWorld* world) : m_world(world), m_done(false), 
-      m_fastforward(false),m_last_generation(0),  m_generation_same_update_count(0) 
+m_fastforward(false),m_last_generation(0),  m_generation_same_update_count(0) 
 {
   cDriverManager::Register(this);
   world->SetDriver(this);
@@ -110,7 +110,7 @@
       // Process the update.
       const int UD_size = ave_time_slice * population.GetNumOrganisms();
       const double step_size = 1.0 / (double) UD_size;
-    
+      
       for (int i = 0; i < UD_size; i++) {
         if (population.GetNumOrganisms() == 0) {
           m_done = true;
@@ -122,21 +122,21 @@
     
     // end of update stats...
     population.ProcessPostUpdate(ctx);
-        
+    
     // No viewer; print out status for this update....
     if (m_world->GetVerbosity() > VERBOSE_SILENT) {
       cout.setf(ios::left);
       cout.setf(ios::showpoint);
       cout << "UD: " << setw(6) << stats.GetUpdate() << "  "
-        << "Gen: " << setw(9) << setprecision(7) << stats.SumGeneration().Average() << "  "
-        << "Fit: " << setw(9) << setprecision(7) << stats.GetAveFitness() << "  "
+      << "Gen: " << setw(9) << setprecision(7) << stats.SumGeneration().Average() << "  "
+      << "Fit: " << setw(9) << setprecision(7) << stats.GetAveFitness() << "  "
       //  << "Energy: " << setw(9) << setprecision(7) << stats.GetAveEnergy() << "  "
-//        << "Merit: " << setw(9) << setprecision(7) << stats.GetAveMerit() << "  "
-        << "Orgs: " << setw(6) << population.GetNumOrganisms() << "  ";
-//        << "Spec: " << setw(6) << setprecision(4) << stats.GetAveSpeculative() << "  "
-//        << "SWst: " << setw(6) << setprecision(4) << (((double)stats.GetSpeculativeWaste() / (double)UD_size) * 100.0) << "%"
-//        << "Thrd: " << setw(6) << stats.GetNumThreads() << "  "
-//        << "Para: " << stats.GetNumParasites()
+      << "Merit: " << setw(9) << setprecision(7) << stats.GetAveMerit() << "  "
+      << "Orgs: " << setw(6) << population.GetNumOrganisms() << "  "
+      //        << "Spec: " << setw(6) << setprecision(4) << stats.GetAveSpeculative() << "  "
+      //        << "SWst: " << setw(6) << setprecision(4) << (((double)stats.GetSpeculativeWaste() / (double)UD_size) * 100.0) << "%"
+      << "Thrd: " << setw(6) << stats.GetNumThreads() << "  "
+      << "Para: " << stats.GetNumParasites();
       if (m_world->GetPopulation().GetNumDemes() > 1) cout << "Demes: " << setw(4) << stats.GetNumOccupiedDemes() << " ";
       cout << endl;
     }
@@ -153,7 +153,7 @@
     
     // Keep track of changes in generation for fast-forward purposes
     UpdateFastForward(stats.GetGeneration(),stats.GetNumCreatures());
-      
+    
     // Exit conditons...
     if (population.GetNumOrganisms() == 0) m_done = true;
   }
@@ -184,11 +184,11 @@
 {
   if (bool(m_population_fastforward_threshold))
   {
-	if (population >= m_population_fastforward_threshold) m_fastforward = true;
-	else m_fastforward = false;
+    if (population >= m_population_fastforward_threshold) m_fastforward = true;
+    else m_fastforward = false;
   }
   if (!m_generation_update_fastforward_threshold) return;
-
+  
   if (inGeneration == m_last_generation)
   {
     m_generation_same_update_count++;

Modified: branches/parasites/source/main/cAvidaConfig.h
===================================================================
--- branches/parasites/source/main/cAvidaConfig.h	2009-10-27 19:37:05 UTC (rev 3507)
+++ branches/parasites/source/main/cAvidaConfig.h	2009-10-27 19:46:35 UTC (rev 3508)
@@ -81,21 +81,21 @@
 #define CONFIG_ADD_VAR(NAME, TYPE, DEFAULT, DESC)                     /* 1 */ \
 class cEntry_ ## NAME : public cBaseConfigEntry {                     /* 2 */ \
 private:                                                                      \
-  TYPE value;                                                         /* 3 */ \
+TYPE value;                                                         /* 3 */ \
 public:                                                                       \
-  void LoadString(const cString& str_value) {                         /* 4 */ \
-    value = cStringUtil::Convert(str_value, value);                           \
-  }                                                                           \
-  bool EqualsString(const cString& str_value) const {                 /* 5 */ \
-    return (value == cStringUtil::Convert(str_value, value));                 \
-  }                                                                           \
-  cEntry_ ## NAME() : cBaseConfigEntry(#NAME,#TYPE,#DEFAULT,DESC) {   /* 6 */ \
-    LoadString(GetDefault());                                         /* 7 */ \
-    global_group_list.GetLast()->AddEntry(this);                      /* 8 */ \
-  }                                                                           \
-  TYPE Get() const { return value; }                                  /* 9 */ \
-  void Set(TYPE in_value) { value = in_value; }                               \
-  cString AsString() const { return cStringUtil::Convert(value); }    /* 10 */\
+void LoadString(const cString& str_value) {                         /* 4 */ \
+value = cStringUtil::Convert(str_value, value);                           \
+}                                                                           \
+bool EqualsString(const cString& str_value) const {                 /* 5 */ \
+return (value == cStringUtil::Convert(str_value, value));                 \
+}                                                                           \
+cEntry_ ## NAME() : cBaseConfigEntry(#NAME,#TYPE,#DEFAULT,DESC) {   /* 6 */ \
+LoadString(GetDefault());                                         /* 7 */ \
+global_group_list.GetLast()->AddEntry(this);                      /* 8 */ \
+}                                                                           \
+TYPE Get() const { return value; }                                  /* 9 */ \
+void Set(TYPE in_value) { value = in_value; }                               \
+cString AsString() const { return cStringUtil::Convert(value); }    /* 10 */\
 } NAME                                                                /* 11 */\
 
 
@@ -108,7 +108,7 @@
 #define CONFIG_ADD_GROUP(NAME, DESC)                                       \
 class cGroup_ ## NAME : public cBaseConfigGroup {                          \
 public:                                                                    \
-  cGroup_ ## NAME() : cBaseConfigGroup(#NAME, DESC) { ; }                  \
+cGroup_ ## NAME() : cBaseConfigGroup(#NAME, DESC) { ; }                  \
 } NAME                                                                     \
 
 
@@ -116,16 +116,16 @@
 #define CONFIG_ADD_CUSTOM_FORMAT(NAME, DESC)                               \
 class cCustomFormat_ ## NAME : public cBaseConfigCustomFormat {            \
 public:                                                                    \
-  cCustomFormat_ ## NAME() : cBaseConfigCustomFormat(#NAME, DESC) { ; }    \
+cCustomFormat_ ## NAME() : cBaseConfigCustomFormat(#NAME, DESC) { ; }    \
 } NAME
 
 
 #define CONFIG_ADD_FORMAT_VAR(NAME, DESC)                                  \
 private:                                                                   \
-  class cFormatEntry_ ## NAME : public cBaseConfigFormatEntry {            \
-  public:                                                                  \
-    cFormatEntry_ ## NAME() : cBaseConfigFormatEntry(#NAME, DESC) { ; }    \
-  } NAME;                                                                  \
+class cFormatEntry_ ## NAME : public cBaseConfigFormatEntry {            \
+public:                                                                  \
+cFormatEntry_ ## NAME() : cBaseConfigFormatEntry(#NAME, DESC) { ; }    \
+} NAME;                                                                  \
 public:                                                                    \
 
 
@@ -151,7 +151,7 @@
     
   public:
     cBaseConfigEntry(const cString& _name, const cString& _type,
-		     const cString& _def, const cString& _desc);
+                     const cString& _def, const cString& _desc);
     virtual ~cBaseConfigEntry() { ; }
     
     virtual void LoadString(const cString& str_value) = 0;
@@ -175,7 +175,7 @@
     tList<cBaseConfigEntry> entry_list;
   public:
     cBaseConfigGroup(const cString& _name, const cString& _desc)
-      : group_name(_name), description(_desc) { global_group_list.PushRear(this); }
+    : group_name(_name), description(_desc) { global_group_list.PushRear(this); }
     ~cBaseConfigGroup() { ; }
     
     const cString& GetName() const { return group_name; }
@@ -195,10 +195,10 @@
     cString m_description;
     tList<cBaseConfigFormatEntry> m_entry_list;
     cStringList m_value;
-  
+    
   public:
     cBaseConfigCustomFormat(const cString& _name, const cString& _desc)
-      : m_format_name(_name), m_description(_desc) { global_format_list.PushRear(this); }
+    : m_format_name(_name), m_description(_desc) { global_format_list.PushRear(this); }
     ~cBaseConfigCustomFormat() { ; }
     
     const cString& GetName() const { return m_format_name; }
@@ -207,11 +207,11 @@
     const tList<cBaseConfigFormatEntry>& GetEntryList() const { return m_entry_list; }
     
     void AddEntry(cBaseConfigFormatEntry* _entry) { m_entry_list.PushRear(_entry); }
-  
+    
     const cStringList& Get() const { return m_value; }
     void Add(const cString& value) { m_value.PushRear(value); }
   };
-
+  
   // The cConfigFormatEntry class is a bass class for all configuration entries.
   // It is used to manage the various types of entries in a dynamic fashion.
   class cBaseConfigFormatEntry {
@@ -222,7 +222,7 @@
     
   public:
     cBaseConfigFormatEntry(const cString& _name, const cString& _desc)
-      : m_name(_name), m_description(_desc), m_format(global_format_list.GetLast())
+    : m_name(_name), m_description(_desc), m_format(global_format_list.GetLast())
     {
       m_format->AddEntry(this);
     }
@@ -247,8 +247,8 @@
   static tList<cBaseConfigCustomFormat> global_format_list;
   tList<cBaseConfigGroup> m_group_list;
   tList<cBaseConfigCustomFormat> m_format_list;
-
-
+  
+  
 public:
   cAvidaConfig()
   {
@@ -257,7 +257,7 @@
     global_list_mutex.Unlock();
   }
   ~cAvidaConfig() { ; }
-
+  
 #ifdef OVERRIDE_CONFIG
 #include "config_overrides.h"
 #else
@@ -339,7 +339,7 @@
   CONFIG_ADD_VAR(DEMES_PREFER_EMPTY, int, 0, "Give empty demes preference as targets of deme replication?");
   CONFIG_ADD_VAR(DEMES_PROTECTION_POINTS, int, 0, "The number of points a deme receives for each suicide.");
 	CONFIG_ADD_VAR(POINT_DECAY_PERCENT, int, 0, "The percentage of points decayed each time cActionDecayPoints is called.");
-
+  
   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\n8 = Next grid cell (id+1)\n9 = Largest energy used in entire population\n10 = Largest energy used in neighborhood\n11 = Local neighborhood dispersal");
   CONFIG_ADD_VAR(PREFER_EMPTY, int, 1, "Give empty cells preference in offsping placement?");
@@ -355,6 +355,10 @@
   CONFIG_ADD_VAR(GENERATION_INC_METHOD, int, 1, "0 = Only the generation of the child is\n    increased on divide.\n1 = Both the generation of the mother and child are\n    increased on divide (good with DIVIDE_METHOD 1).");
   CONFIG_ADD_VAR(RESET_INPUTS_ON_DIVIDE, int, 0, "Reset environment inputs of parent upon successful divide.");
   CONFIG_ADD_VAR(REPRO_METHOD, int, 1, "Replace existing organism: 1=yes");
+  
+  
+  CONFIG_ADD_VAR(INJECT_PROB_FROM_TASKS, int, 1, "Inject occurs based on probability from performing tasks");
+  CONFIG_ADD_VAR(INJECT_PROB_SIGMOID, int, 1, "Inject Probs follow a psuedo-sigmoid path - only works if task probs are turned on");
 	
   CONFIG_ADD_GROUP(RECOMBINATION_GROUP, "Sexual Recombination and Modularity");
   CONFIG_ADD_VAR(RECOMBINATION_PROB, double, 1.0, "probability of recombination in div-sex");
@@ -366,7 +370,7 @@
   CONFIG_ADD_VAR(SAME_LENGTH_SEX, int, 0, "0 = recombine with any genome\n1 = only recombine w/ same length");
   CONFIG_ADD_VAR(ALLOW_MATE_SELECTION, bool, 0, "Allow organisms to select mates (requires instruction set support)");
   CONFIG_ADD_VAR(LEGACY_GRID_LOCAL_SELECTION, bool, 0, "Enable legacy grid local mate selection (ignores population structure)");
-
+  
   CONFIG_ADD_GROUP(DIVIDE_GROUP, "Divide Restrictions");
   CONFIG_ADD_VAR(CHILD_SIZE_RANGE, double, 2.0, "Maximal differential between child and parent sizes.\n(Checked BEFORE mutations applied on divide.)");
   CONFIG_ADD_VAR(MIN_COPIED_LINES, double, 0.5, "Code fraction which must be copied before divide.");
@@ -387,13 +391,13 @@
   
   CONFIG_ADD_GROUP(MUTATION_GROUP, "Mutations");
   CONFIG_ADD_VAR(POINT_MUT_PROB, double, 0.0, "Mutation rate (per-location per update)");
-
+  
   CONFIG_ADD_VAR(COPY_MUT_PROB, double, 0.0075, "Mutation rate (per copy)");
   CONFIG_ADD_VAR(COPY_INS_PROB, double, 0.0, "Insertion rate (per copy)");
   CONFIG_ADD_VAR(COPY_DEL_PROB, double, 0.0, "Deletion rate (per copy)");
   CONFIG_ADD_VAR(COPY_UNIFORM_PROB, double, 0.0, "Uniform mutation probability (per copy)\n- Randomly applies any of the three classes of mutations (ins, del, point).");
   CONFIG_ADD_VAR(COPY_SLIP_PROB, double, 0.0, "Slip rate (per copy)");
-
+  
   CONFIG_ADD_VAR(DIV_MUT_PROB, double, 0.0, "Mutation rate (per site, applied on divide)");
   CONFIG_ADD_VAR(DIV_INS_PROB, double, 0.0, "Insertion rate (per site, applied on divide)");
   CONFIG_ADD_VAR(DIV_DEL_PROB, double, 0.0, "Deletion rate (per site, applied on divide)");
@@ -409,9 +413,9 @@
   CONFIG_ADD_VAR(DIVIDE_POISSON_INS_MEAN, double, 0.0, "Insertion rate (Poisson distributed, per divide)");
   CONFIG_ADD_VAR(DIVIDE_POISSON_DEL_MEAN, double, 0.0, "Deletion rate (Poisson distributed, per divide)");
   CONFIG_ADD_VAR(DIVIDE_POISSON_SLIP_MEAN, double, 0.0, "Slip rate (Poisson distributed, per divide)");
-
+  
   CONFIG_ADD_VAR(DIVIDE_UNIFORM_PROB, double, 0.0, "Uniform mutation probability (per divide)\n- Randomly applies any of the three classes of mutations (ins, del, point).");
-
+  
   CONFIG_ADD_VAR(DEATH_PROB, double, 0.0, "Death rate (parent organism, per divide)");
   
   CONFIG_ADD_VAR(INJECT_INS_PROB, double, 0.0, "Insertion rate (per site, applied on inject)");
@@ -426,7 +430,7 @@
   CONFIG_ADD_VAR(META_STD_DEV, double, 0.0, "Standard deviation of meta mutation size.");
   CONFIG_ADD_VAR(MUT_RATE_SOURCE, int, 1, "1 = Mutation rates determined by environment.\n2 = Mutation rates inherited from parent.");
   CONFIG_ADD_VAR(MIGRATION_RATE, double, 0.0, "Uniform probability of offspring migrating to a new deme.");
- 
+  
   CONFIG_ADD_GROUP(REVERSION_GROUP, "Mutation Reversion\nThese slow down avida a lot, and should be set to 0.0 normally.");
   CONFIG_ADD_VAR(REVERT_FATAL, double, 0.0, "Should any mutations be reverted on birth?");
   CONFIG_ADD_VAR(REVERT_DETRIMENTAL, double, 0.0, "  0.0 to 1.0; Probability of reversion.");
@@ -474,7 +478,7 @@
   CONFIG_ADD_VAR(FASTFORWARD_UPDATES, int, 0, "Fast-forward if the average generation has not changed in this many updates. (0 = off)");
   CONFIG_ADD_VAR(FASTFORWARD_NUM_ORGS, int, 0, "Fast-forward if population is equal to this");
   CONFIG_ADD_VAR(GENOTYPE_PHENPLAST_CALC, int, 100, "Number of times to test a genotype's\nplasticity during runtime.");
-
+  
   CONFIG_ADD_GROUP(GENEOLOGY_GROUP, "Geneology");
   CONFIG_ADD_VAR(TRACK_MAIN_LINEAGE, int, 1, "Keep all ancestors of the active population?\n0=no, 1=yes, 2=yes,w/sexual population");
   CONFIG_ADD_VAR(THRESHOLD, int, 3, "Number of organisms in a genotype needed for it\n  to be considered viable.");
@@ -507,7 +511,7 @@
   CONFIG_ADD_VAR(MESSAGE_SEND_BUFFER_SIZE, bool, 1, "Size of message send buffer (stores messages that were sent)\nTASKS NOT CHECKED ON 0!\n-1=inf, default=1.");
   CONFIG_ADD_VAR(MESSAGE_RECV_BUFFER_SIZE, bool, 8, "Size of message receive buffer (stores messages that are received); -1=inf, default=8.");
 	CONFIG_ADD_VAR(MESSAGE_RECV_BUFFER_BEHAVIOR, bool, 0, "Behavior of message receive buffer; 0=drop oldest (default), 1=drop incoming");
-
+  
   CONFIG_ADD_GROUP(BUY_SELL_GROUP, "Buying and Selling Parameters");
   CONFIG_ADD_VAR(SAVE_RECEIVED, bool, 0, "Enable storage of all inputs bought from other orgs");
   CONFIG_ADD_VAR(BUY_PRICE, int, 0, "price offered by organisms attempting to buy");
@@ -561,7 +565,7 @@
   CONFIG_ADD_GROUP(SECOND_PASS_GROUP, "Tracking metrics known after the running experiment previously");
   CONFIG_ADD_VAR(TRACK_CCLADES, int, 0, "Enable tracking of coalescence clades");
   CONFIG_ADD_VAR(TRACK_CCLADES_IDS, cString, "coalescence.ids", "File storing coalescence IDs");
-
+  
   CONFIG_ADD_GROUP(GX_GROUP, "Gene Expression CPU Settings");
   CONFIG_ADD_VAR(MAX_PROGRAMIDS, int, 16, "Maximum number of programids an organism can create.");
   CONFIG_ADD_VAR(MAX_PROGRAMID_AGE, int, 2000, "Max number of CPU cycles a programid executes before it is removed.");
@@ -570,7 +574,7 @@
   CONFIG_ADD_VAR(IMPLICIT_TURNOVER_RATE, double, 0.0, "Number of programids recycled per CPU cycle. 0 = OFF");
   CONFIG_ADD_VAR(IMPLICIT_MAX_PROGRAMID_LENGTH, int, 0, "Creation of an executable programid terminates after this many instructions. 0 = disabled");
   //  CONFIG_ADD_VAR(CLEAR_ON_OUTPUT, int, 0, "Reset input buffer every time output called?"); @JEB Not fully implemented
-
+  
   CONFIG_ADD_GROUP(PROMOTER_GROUP, "Promoters");
   CONFIG_ADD_VAR(PROMOTERS_ENABLED, int, 0, "Use the promoter/terminator execution scheme.\nCertain instructions must also be included.");
   CONFIG_ADD_VAR(PROMOTER_INST_MAX, int, 0, "Maximum number of instructions to execute before terminating. 0 = off");
@@ -585,7 +589,7 @@
   CONFIG_ADD_VAR(INST_CODE_LENGTH, int, 3, "Instruction binary code length (number of bits)");
   CONFIG_ADD_VAR(INST_CODE_DEFAULT_TYPE, int, 0, "Default value of instruction binary code value.\n0 = All zeros\n1 = Based off the instruction number");
   CONFIG_ADD_VAR(CONSTITUTIVE_REGULATION, int, 0, "Sense a new regulation value before each CPU cycle?");
-
+  
   CONFIG_ADD_GROUP(COLORS_GROUP, "Output colors for when data files are printed in HTML mode.\nThere are two sets of these; the first are for lineages,\nand the second are for mutation tests.");
   CONFIG_ADD_VAR(COLOR_DIFF, cString, "CCCCFF", "Color to flag stat that has changed since parent.");
   CONFIG_ADD_VAR(COLOR_SAME, cString, "FFFFFF", "Color to flag stat that has NOT changed since parent.");
@@ -593,12 +597,12 @@
   CONFIG_ADD_VAR(COLOR_NEG1, cString, "FFCCCC", "Color to flag stat that is minorly worse than parent.");
   CONFIG_ADD_VAR(COLOR_POS1, cString, "CCFFCC", "Color to flag stat that is minorly better than parent.");
   CONFIG_ADD_VAR(COLOR_POS2, cString, "00FF00", "Color to flag stat that is significantly better than parent.");
-
+  
   CONFIG_ADD_VAR(COLOR_MUT_POS,    cString, "00FF00", "Color to flag stat that has changed since parent.");
   CONFIG_ADD_VAR(COLOR_MUT_NEUT,   cString, "FFFFFF", "Color to flag stat that has changed since parent.");
   CONFIG_ADD_VAR(COLOR_MUT_NEG,    cString, "FFFF00", "Color to flag stat that has changed since parent.");
   CONFIG_ADD_VAR(COLOR_MUT_LETHAL, cString, "FF0000", "Color to flag stat that has changed since parent.");
-
+  
   // @WRE: Additions for approaching various features of biological organisms
   CONFIG_ADD_GROUP(BIOMIMETIC_GROUP, "Biomimetic Features Settings");
   CONFIG_ADD_VAR(BIOMIMETIC_REFRACTORY_PERIOD, double, 0.0, "Number of updates affected by refractory period");
@@ -607,7 +611,7 @@
   CONFIG_ADD_VAR(BIOMIMETIC_MOVEMENT_FACTOR, double, 1.0, "Scale merit bonus due to movement (m<1.0 applies a cost)");
   CONFIG_ADD_VAR(BIOMIMETIC_EVAL_ON_MOVEMENT, int, 0, "Force task evaluation on each movement step");
   CONFIG_ADD_VAR(BIOMIMETIC_K, int, 0, "Carrying capacity in number of organisms");
-
+  
   // BDC: Additions for pheromones
   CONFIG_ADD_GROUP(PHEROMONE_GROUP, "Pheromone Settings");
   CONFIG_ADD_VAR(PHEROMONE_ENABLED, bool, 0, "Enable pheromone usage. 0/1 (off/on)");
@@ -631,7 +635,7 @@
 	// -------- Consensus config options --------
   CONFIG_ADD_GROUP(CONSENSUS_GROUP, "Consensus settings");	
 	CONFIG_ADD_VAR(CONSENSUS_HOLD_TIME, int, 1, "Number of updates that consensus must be held for.");
-		
+  
   CONFIG_ADD_CUSTOM_FORMAT(INST_SET_NEW, "Instruction Set Definition");
   CONFIG_ADD_FORMAT_VAR(INST, "Instruction entry in the instruction set");
 	
@@ -670,7 +674,7 @@
 	CONFIG_ADD_VAR(HGT_DIFFUSION_METHOD, int, 0, "Method to use for diffusion of genome\nfragments (0=none [default]).");
 	CONFIG_ADD_VAR(HGT_MUTATION_P, double, 0.0, "Probability that an HGT mutation will occur on divide (default=0.0).");
 	CONFIG_ADD_VAR(HGT_INSERTION_MUT_P, double, 0.5, "Probability that an HGT mutation will result in an insertion (default=0.5); replacement if false.");
-
+  
   CONFIG_ADD_GROUP(INST_RES_GROUP, "Resource-Dependent Instructions Settings");
   CONFIG_ADD_VAR(INST_RES, cString, "", "Resource upon which the execution of certain instruction depends");
   CONFIG_ADD_VAR(INST_RES_FLOOR, double, 0.0, "Assumed lower level of resource in environment.  Used for probability dist.");

Modified: branches/parasites/source/main/cPhenotype.cc
===================================================================
--- branches/parasites/source/main/cPhenotype.cc	2009-10-27 19:37:05 UTC (rev 3507)
+++ branches/parasites/source/main/cPhenotype.cc	2009-10-27 19:46:35 UTC (rev 3508)
@@ -41,34 +41,34 @@
 
 
 cPhenotype::cPhenotype(cWorld* world)
-  : m_world(world)
-  , initialized(false)
-  , cur_task_count(m_world->GetEnvironment().GetNumTasks())
-  , cur_internal_task_count(m_world->GetEnvironment().GetNumTasks())
-  , eff_task_count(m_world->GetEnvironment().GetNumTasks())
-  , cur_task_quality(m_world->GetEnvironment().GetNumTasks())  
-  , cur_task_value(m_world->GetEnvironment().GetNumTasks())  
-  , cur_internal_task_quality(m_world->GetEnvironment().GetNumTasks())
-  , cur_rbins_total(m_world->GetEnvironment().GetResourceLib().GetSize())
-  , cur_rbins_avail(m_world->GetEnvironment().GetResourceLib().GetSize())
-  , cur_collect_spec_counts(m_world->GetNumResourceSpecs())
-  , cur_reaction_count(m_world->GetEnvironment().GetReactionLib().GetSize())
-  , cur_reaction_add_reward(m_world->GetEnvironment().GetReactionLib().GetSize())
-  , cur_sense_count(m_world->GetStats().GetSenseSize())
-  , sensed_resources(m_world->GetEnvironment().GetResourceLib().GetSize())
-  , cur_task_time(m_world->GetEnvironment().GetNumTasks())   // Added for tracking time; WRE 03-18-07
-  , m_reaction_result(NULL)
-  , last_task_count(m_world->GetEnvironment().GetNumTasks())
-  , last_internal_task_count(m_world->GetEnvironment().GetNumTasks())
-  , last_task_quality(m_world->GetEnvironment().GetNumTasks())
-  , last_task_value(m_world->GetEnvironment().GetNumTasks())
-  , last_internal_task_quality(m_world->GetEnvironment().GetNumTasks())
-  , last_rbins_total(m_world->GetEnvironment().GetResourceLib().GetSize())
-  , last_rbins_avail(m_world->GetEnvironment().GetResourceLib().GetSize())
-  , last_collect_spec_counts()
-  , last_reaction_count(m_world->GetEnvironment().GetReactionLib().GetSize())
-  , last_reaction_add_reward(m_world->GetEnvironment().GetReactionLib().GetSize())  
-  , last_sense_count(m_world->GetStats().GetSenseSize())
+: m_world(world)
+, initialized(false)
+, cur_task_count(m_world->GetEnvironment().GetNumTasks())
+, cur_internal_task_count(m_world->GetEnvironment().GetNumTasks())
+, eff_task_count(m_world->GetEnvironment().GetNumTasks())
+, cur_task_quality(m_world->GetEnvironment().GetNumTasks())  
+, cur_task_value(m_world->GetEnvironment().GetNumTasks())  
+, cur_internal_task_quality(m_world->GetEnvironment().GetNumTasks())
+, cur_rbins_total(m_world->GetEnvironment().GetResourceLib().GetSize())
+, cur_rbins_avail(m_world->GetEnvironment().GetResourceLib().GetSize())
+, cur_collect_spec_counts(m_world->GetNumResourceSpecs())
+, cur_reaction_count(m_world->GetEnvironment().GetReactionLib().GetSize())
+, cur_reaction_add_reward(m_world->GetEnvironment().GetReactionLib().GetSize())
+, cur_sense_count(m_world->GetStats().GetSenseSize())
+, sensed_resources(m_world->GetEnvironment().GetResourceLib().GetSize())
+, cur_task_time(m_world->GetEnvironment().GetNumTasks())   // Added for tracking time; WRE 03-18-07
+, m_reaction_result(NULL)
+, last_task_count(m_world->GetEnvironment().GetNumTasks())
+, last_internal_task_count(m_world->GetEnvironment().GetNumTasks())
+, last_task_quality(m_world->GetEnvironment().GetNumTasks())
+, last_task_value(m_world->GetEnvironment().GetNumTasks())
+, last_internal_task_quality(m_world->GetEnvironment().GetNumTasks())
+, last_rbins_total(m_world->GetEnvironment().GetResourceLib().GetSize())
+, last_rbins_avail(m_world->GetEnvironment().GetResourceLib().GetSize())
+, last_collect_spec_counts()
+, last_reaction_count(m_world->GetEnvironment().GetReactionLib().GetSize())
+, last_reaction_add_reward(m_world->GetEnvironment().GetReactionLib().GetSize())  
+, last_sense_count(m_world->GetStats().GetSenseSize())
 {
 }
 
@@ -107,7 +107,7 @@
   copied_size              = in_phen.copied_size;          
   executed_size            = in_phen.executed_size;       
   gestation_time           = in_phen.gestation_time;       
-                  
+  
   gestation_start          = in_phen.gestation_start;     
   fitness                  = in_phen.fitness;           
   div_type                 = in_phen.div_type;          
@@ -133,7 +133,7 @@
   sensed_resources         = in_phen.sensed_resources;            
   cur_task_time            = in_phen.cur_task_time;   
   cur_child_germline_propensity = in_phen.cur_child_germline_propensity;
-
+  
   // Dynamically allocated m_task_states requires special handling
   tList<cTaskState*> hash_values;
   tList<void*>       hash_keys;
@@ -169,7 +169,7 @@
   total_energy_donated     = in_phen.total_energy_donated;
   total_energy_received    = in_phen.total_energy_received;
   total_energy_applied     = in_phen.total_energy_applied;
-
+  
   // 4. Records from this organisms life...
   num_divides              = in_phen.num_divides;      
   generation               = in_phen.generation;        
@@ -245,7 +245,7 @@
   total_energy_donated    = in_phen.total_energy_donated;
   total_energy_received   = in_phen.total_energy_received;
   total_energy_applied    = in_phen.total_energy_applied;
-
+  
   // 6. Child information...
   copy_true               = in_phen.copy_true;       
   divide_sex              = in_phen.divide_sex;       
@@ -254,10 +254,10 @@
   child_fertile           = in_phen.child_fertile;  
   last_child_fertile      = in_phen.last_child_fertile; 
   child_copied_size       = in_phen.child_copied_size;
-
+  
   // 7. Permanent information...
   permanent_germline_propensity = in_phen.permanent_germline_propensity;
-         
+  
   return *this;
 }
 
@@ -306,7 +306,7 @@
     executionRatio = 1.0;
   else 
     executionRatio = parent_phenotype.executionRatio;
-    
+  
   energy_store    = min(energy_store, m_world->GetConfig().ENERGY_CAP.Get());
   energy_tobe_applied = 0.0;
   energy_testament = 0.0;
@@ -320,12 +320,12 @@
   cpu_cycles_used = 0;
   fitness         = parent_phenotype.fitness;
   div_type        = parent_phenotype.div_type;
-
+  
   assert(genome_length > 0);
   assert(copied_size > 0);
   assert(gestation_time >= 0); //@JEB 0 valid for some fitness methods
   assert(div_type > 0);
-
+  
   // Initialize current values, as neeeded.
   cur_bonus       = m_world->GetConfig().DEFAULT_BONUS.Get();
   cur_energy_bonus = 0.0;
@@ -341,7 +341,7 @@
   // parent's resources have already been halved in DivideReset;
   // offspring gets that value too.
   for (int i = 0; i < cur_rbins_avail.GetSize(); i++)
-        cur_rbins_avail[i] = parent_phenotype.cur_rbins_avail[i];
+    cur_rbins_avail[i] = parent_phenotype.cur_rbins_avail[i];
   cur_collect_spec_counts.SetAll(0);
   cur_reaction_count.SetAll(0);
   cur_reaction_add_reward.SetAll(0);
@@ -349,14 +349,14 @@
   cur_sense_count.SetAll(0);  
   cur_task_time.SetAll(0.0);  // Added for time tracking; WRE 03-18-07
   for (int j = 0; j < sensed_resources.GetSize(); j++)
-	      sensed_resources[j] =  parent_phenotype.sensed_resources[j];
+    sensed_resources[j] =  parent_phenotype.sensed_resources[j];
   cur_trial_fitnesses.Resize(0); 
   cur_trial_bonuses.Resize(0); 
   cur_trial_times_used.Resize(0); 
   trial_time_used = 0;
   trial_cpu_cycles_used = 0;
   cur_child_germline_propensity = m_world->GetConfig().DEMES_DEFAULT_GERMLINE_PROPENSITY.Get();
-
+  
   // Copy last values from parent
   last_merit_base           = parent_phenotype.last_merit_base;
   last_bonus                = parent_phenotype.last_bonus;
@@ -377,7 +377,7 @@
   last_sense_count          = parent_phenotype.last_sense_count;
   last_fitness              = CalcFitness(last_merit_base, last_bonus, gestation_time, last_cpu_cycles_used);
   last_child_germline_propensity = parent_phenotype.last_child_germline_propensity;   // chance of child being a germline cell; @JEB
-
+  
   // Setup other miscellaneous values...
   num_divides     = 0;
   generation      = parent_phenotype.generation;
@@ -446,7 +446,7 @@
   parent_cross_num    = parent_phenotype.cross_num;
   to_die = false;
   to_delete = false;
-
+  
   is_energy_requestor = false;
   is_energy_donor = false;
   is_energy_receiver = false;
@@ -455,7 +455,7 @@
   total_energy_donated = 0.0;
   total_energy_received = 0.0; 
   total_energy_applied = 0.0;
-
+  
   // Setup child info...
   copy_true          = false;
   divide_sex         = false;
@@ -464,10 +464,10 @@
   last_child_fertile = is_fertile;
   child_fertile      = true;
   child_copied_size  = 0;
-
+  
   // permanently set germline propensity of org (since DivideReset is called first, it is now in the "last" slot...)
   permanent_germline_propensity  = parent_phenotype.last_child_germline_propensity;
-
+  
   initialized = true;
 }
 
@@ -497,7 +497,7 @@
   gestation_start = 0;
   fitness         = 0;
   div_type	  = 1;
-
+  
   // Initialize current values, as neeeded.
   cur_bonus       = m_world->GetConfig().DEFAULT_BONUS.Get();
   cur_energy_bonus = 0.0;
@@ -524,7 +524,7 @@
   trial_time_used = 0;
   trial_cpu_cycles_used = 0;
   cur_child_germline_propensity = m_world->GetConfig().DEMES_DEFAULT_GERMLINE_PROPENSITY.Get();
-
+  
   // New organism has no parent and so cannot use its last values; initialize as needed
   last_merit_base = genome_length;
   last_bonus      = 1;
@@ -544,7 +544,7 @@
   last_inst_count.SetAll(0);
   last_sense_count.SetAll(0);
   last_child_germline_propensity = m_world->GetConfig().DEMES_DEFAULT_GERMLINE_PROPENSITY.Get();
-
+  
   // Setup other miscellaneous values...
   num_divides     = 0;
   generation      = 0;
@@ -556,7 +556,7 @@
   life_fitness    = 0;
   exec_time_born  = 0;
   birth_update     = m_world->GetStats().GetUpdate();
-
+  
   num_thresh_gb_donations = 0;
   num_thresh_gb_donations_last = 0;
   num_quanta_thresh_gb_donations = 0;
@@ -621,7 +621,7 @@
   total_energy_donated = 0.0;
   total_energy_received = 0.0;
   total_energy_applied = 0.0;
-
+  
   // Setup child info...
   copy_true         = false;
   divide_sex        = false;
@@ -630,9 +630,9 @@
   child_fertile     = true;
   last_child_fertile = true;
   child_copied_size = 0;
-
+  
   permanent_germline_propensity = m_world->GetConfig().DEMES_DEFAULT_GERMLINE_PROPENSITY.Get();
-
+  
   initialized = true;
 }
 
@@ -640,12 +640,12 @@
 /**
  * This function is run whenever an organism executes a successful divide.
  **/
- 
- void cPhenotype::DivideReset(const cGenome & _genome)
+
+void cPhenotype::DivideReset(const cGenome & _genome)
 {
   assert(time_used >= 0);
   assert(initialized == true);
-
+  
   // Update these values as needed...
   int cur_merit_base = CalcSizeMerit();
   
@@ -668,12 +668,12 @@
   gestation_time  = time_used - gestation_start;
   gestation_start = time_used;
   fitness = CalcFitness( cur_merit_base, cur_bonus, gestation_time, cpu_cycles_used); 
-
+  
   // Lock in cur values as last values.
   last_merit_base           = cur_merit_base;
   last_bonus                = cur_bonus;
   last_cpu_cycles_used      = cpu_cycles_used;
-//TODO?  last_energy         = cur_energy_bonus;
+  //TODO?  last_energy         = cur_energy_bonus;
   last_num_errors           = cur_num_errors;
   last_num_donates          = cur_num_donates;
   last_task_count           = cur_task_count;
@@ -689,7 +689,7 @@
   last_inst_count           = cur_inst_count;
   last_sense_count          = cur_sense_count;
   last_child_germline_propensity = cur_child_germline_propensity;
-
+  
   // Reset cur values.
   cur_bonus       = m_world->GetConfig().DEFAULT_BONUS.Get();
   cpu_cycles_used = 0;
@@ -712,7 +712,7 @@
   cur_sense_count.SetAll(0);
   cur_task_time.SetAll(0.0);
   cur_child_germline_propensity = m_world->GetConfig().DEMES_DEFAULT_GERMLINE_PROPENSITY.Get();
-
+  
   // Setup other miscellaneous values...
   num_divides++;
   (void) generation;
@@ -723,7 +723,7 @@
   life_fitness = fitness; 
   exec_time_born += gestation_time;  //@MRR Treating organism as sibling
   birth_update = m_world->GetStats().GetUpdate();   
-
+  
   num_thresh_gb_donations_last = num_thresh_gb_donations;
   num_thresh_gb_donations = 0;
   num_quanta_thresh_gb_donations_last = num_quanta_thresh_gb_donations;
@@ -777,7 +777,7 @@
   (void) parent_true;
   (void) parent_sex;
   (void) parent_cross_num;
-
+  
   // Reset child info...
   (void) copy_true;
   (void) divide_sex;
@@ -786,16 +786,16 @@
   last_child_fertile = child_fertile;
   child_fertile     = true;
   (void) child_copied_size;;
-
+  
   // A few final changes if the parent was supposed to be be considered
   // a second child on the divide.
-  if (m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT) {
+  if ((m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT) || (m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_BIRTH)) {
     gestation_start = 0;
     cpu_cycles_used = 0;
     time_used = 0;
     neutral_metric += m_world->GetRandom().GetRandNormal();
   }
-
+  
   if (m_world->GetConfig().GENERATION_INC_METHOD.Get() == GENERATION_INC_BOTH) generation++;
   
   // Reset Task States
@@ -815,7 +815,7 @@
 {
   assert(time_used > 0);
   assert(initialized == true);
-
+  
   // Update these values as needed...
   int cur_merit_base = CalcSizeMerit();
   const int merit_default_bonus = m_world->GetConfig().MERIT_DEFAULT_BONUS.Get();
@@ -823,7 +823,7 @@
     cur_bonus = merit_default_bonus;
   }
   merit = cur_merit_base * cur_bonus;
-
+  
   genome_length   = _genome.GetSize();
   (void) copied_size;                            // Unchanged
   (void) executed_size;                          // Unchanged
@@ -831,7 +831,7 @@
   gestation_start = time_used;
   fitness         = CalcFitness(cur_merit_base, cur_bonus, gestation_time, cpu_cycles_used);
   (void) div_type; 				// Unchanged
-
+  
   // Lock in cur values as last values.
   last_merit_base           = cur_merit_base;
   last_bonus                = cur_bonus;
@@ -879,7 +879,7 @@
   trial_time_used = 0;
   trial_cpu_cycles_used = 0;
   cur_child_germline_propensity = m_world->GetConfig().DEMES_DEFAULT_GERMLINE_PROPENSITY.Get();
-
+  
   // Setup other miscellaneous values...
   num_divides++;
   generation++;
@@ -890,7 +890,7 @@
   life_fitness = fitness; 
   exec_time_born += gestation_time;  //@MRR See DivideReset 
   birth_update  = m_world->GetStats().GetUpdate();
-
+  
   num_thresh_gb_donations_last = num_thresh_gb_donations;
   num_thresh_gb_donations = 0;
   num_quanta_thresh_gb_donations_last = num_quanta_thresh_gb_donations;
@@ -944,7 +944,7 @@
   (void) parent_true;
   (void) parent_sex;
   (void) parent_cross_num;
-
+  
   // Reset child info...
   (void) copy_true;
   (void) divide_sex;
@@ -974,12 +974,12 @@
   energy_tobe_applied = 0.0;
   energy_testament = 0.0;
   energy_received_buffer = 0.0;
-
+  
   if(m_world->GetConfig().INHERIT_EXE_RATE.Get() == 0)
     executionRatio = 1.0;
   else 
     executionRatio = clone_phenotype.executionRatio;
-
+  
   genome_length   = clone_phenotype.genome_length;
   copied_size     = clone_phenotype.copied_size;
   // copied_size     = clone_phenotype.child_copied_size;
@@ -988,12 +988,12 @@
   gestation_start = 0;
   fitness         = clone_phenotype.fitness;
   div_type        = clone_phenotype.div_type;
-
+  
   assert(genome_length > 0);
   assert(copied_size > 0);
   assert(gestation_time >= 0); //@JEB 0 valid for some fitness methods
   assert(div_type > 0);
-
+  
   // Initialize current values, as neeeded.
   cur_bonus       = m_world->GetConfig().DEFAULT_BONUS.Get();
   cpu_cycles_used = 0;
@@ -1011,14 +1011,14 @@
   cur_sense_count.SetAll(0);  
   cur_task_time.SetAll(0.0);
   for (int j = 0; j < sensed_resources.GetSize(); j++)
-	      sensed_resources[j] =  clone_phenotype.sensed_resources[j];
+    sensed_resources[j] =  clone_phenotype.sensed_resources[j];
   cur_trial_fitnesses.Resize(0); 
   cur_trial_bonuses.Resize(0); 
   cur_trial_times_used.Resize(0); 
   trial_time_used = 0;
   trial_cpu_cycles_used = 0;
   cur_child_germline_propensity = m_world->GetConfig().DEMES_DEFAULT_GERMLINE_PROPENSITY.Get();
-
+  
   // Copy last values from parent
   last_merit_base          = clone_phenotype.last_merit_base;
   last_bonus               = clone_phenotype.last_bonus;
@@ -1036,7 +1036,7 @@
   last_sense_count         = clone_phenotype.last_sense_count;  
   last_fitness             = CalcFitness(last_merit_base, last_bonus, gestation_time, last_cpu_cycles_used);
   last_child_germline_propensity = clone_phenotype.last_child_germline_propensity;
-
+  
   // Setup other miscellaneous values...
   num_divides     = 0;
   generation      = clone_phenotype.generation;
@@ -1049,7 +1049,7 @@
   life_fitness    = fitness; 
   exec_time_born  = 0;
   birth_update    = m_world->GetStats().GetUpdate();
-
+  
   num_thresh_gb_donations_last = clone_phenotype.num_thresh_gb_donations_last;
   num_thresh_gb_donations  = clone_phenotype.num_thresh_gb_donations;
   num_quanta_thresh_gb_donations_last = clone_phenotype.num_quanta_thresh_gb_donations_last;
@@ -1111,7 +1111,7 @@
   is_energy_receiver = false;
   has_used_donated_energy = false;
   has_open_energy_request = false;
-
+  
   // Setup child info...
   copy_true          = false;
   divide_sex         = false;
@@ -1121,7 +1121,7 @@
   child_fertile      = true;
   child_copied_size  = 0;
   permanent_germline_propensity = clone_phenotype.permanent_germline_propensity;
-
+  
   initialized = true;
 }
 
@@ -1136,35 +1136,35 @@
 }
 
 bool cPhenotype::TestOutput(cAvidaContext& ctx, cTaskContext& taskctx,
-			    const tArray<double>& res_in, const tArray<double>& rbins_in, tArray<double>& res_change,
-			    tArray<int>& insts_triggered)
+                            const tArray<double>& res_in, const tArray<double>& rbins_in, tArray<double>& res_change,
+                            tArray<int>& insts_triggered)
 {
   assert(initialized == true);
   taskctx.SetTaskStates(&m_task_states);
-
+  
   const cEnvironment& env = m_world->GetEnvironment();
   const int num_resources = env.GetResourceLib().GetSize();
   const int num_tasks = env.GetNumTasks();
   const int num_reactions = env.GetReactionLib().GetSize();
-
+  
   // For refractory period @WRE 03-20-07
   const int cur_update_time = m_world->GetStats().GetUpdate();
   const double biomimetic_refractory_period = m_world->GetConfig().BIOMIMETIC_REFRACTORY_PERIOD.Get();
   double refract_factor;
-
+  
   if (!m_reaction_result) m_reaction_result = new cReactionResult(num_resources, num_tasks, num_reactions);
   cReactionResult& result = *m_reaction_result;
   
   // Run everything through the environment.
   bool found = env.TestOutput(ctx, result, taskctx, eff_task_count, cur_reaction_count, res_in, rbins_in); //NEED different eff_task_count and cur_reaction_count for deme resource
-
+  
   // If nothing was found, stop here.
   if (found == false) {
     result.Invalidate();
     res_change.SetAll(0.0);
     return false;  // Nothing happened.
   }
-
+  
   // Update the phenotype with the results...
   // Start with updating task and reaction counters
   for (int i = 0; i < num_tasks; i++) {
@@ -1184,7 +1184,7 @@
       //cerr << "eff: " << eff_task_count[i] << endl;
       if(result.UsedEnvResource() == false) { cur_internal_task_count[i]++; }
     }
-
+    
     if (result.TaskQuality(i) > 0) 
     {
     	cur_task_quality[i] += result.TaskQuality(i) * refract_factor;
@@ -1209,14 +1209,14 @@
 		  m_world->GetStats().AddOtherTaskCounts(i, prev_num_tasks, cur_num_tasks);
 	  }
   }
-
+  
   for (int i = 0; i < num_reactions; i++) {
-//    if (result.ReactionTriggered(i) == true) cur_reaction_count[i]++;  // moved into cEnvironment::TestOutput to allow reaction requisites to be satisified at the time a reaction is completed
+    //    if (result.ReactionTriggered(i) == true) cur_reaction_count[i]++;  // moved into cEnvironment::TestOutput to allow reaction requisites to be satisified at the time a reaction is completed
     cur_reaction_add_reward[i] += result.GetReactionAddBonus(i);
-	if (result.ReactionTriggered(i) && last_reaction_count[i]==0) 
-		m_world->GetStats().AddNewReactionCount(i); 
+    if (result.ReactionTriggered(i) && last_reaction_count[i]==0) 
+      m_world->GetStats().AddNewReactionCount(i); 
   }
-
+  
   // Update the merit bonus
   cur_bonus *= result.GetMultBonus();
   cur_bonus += result.GetAddBonus();
@@ -1229,7 +1229,7 @@
   // no deme object.  Don't touch deme merit if there is no deme frac component.
   cDeme* deme = taskctx.GetOrganism()->GetDeme();
   if (deme) {
-  
+    
     if (result.GetActiveDeme()) {
       double deme_bonus = deme->GetHeritableDemeMerit().GetDouble();
       deme_bonus *= result.GetMultDemeBonus();
@@ -1245,7 +1245,7 @@
       if (result.ReactionTriggered(i) == true) deme->AddCurReaction(i);
     }
   }
-    
+  
   // Update the energy bonus
   cur_energy_bonus += result.GetAddEnergy();
   
@@ -1253,7 +1253,7 @@
   for (int i = 0; i < res_in.GetSize(); i++) {
     res_change[i] = result.GetProduced(i) - result.GetConsumed(i);
   }
-
+  
   // Update rbins as necessary
   if(result.UsedEnvResource() == false)
   {
@@ -1265,18 +1265,18 @@
   		if(rbin_diff > 0) { cur_rbins_total[i] += rbin_diff; }
   	}
   }
-
+  
   // Save the instructions that should be triggered...
   insts_triggered = result.GetInstArray();
-
+  
   //Put in detected resources
   for (int j = 0; j < res_in.GetSize(); j++)
 	  if(result.GetDetected(j) != -1.0)
-	      sensed_resources[j] = result.GetDetected(j);
-
+      sensed_resources[j] = result.GetDetected(j);
+  
   //Kill any cells that did lethal reactions
   to_die = result.GetLethal();
-
+  
   // Sterilize organisms that have performed a sterilizing task.
   if(result.GetSterilize()) {
     is_fertile = false;
@@ -1286,13 +1286,14 @@
   return true;
 }
 
+
 void cPhenotype::PrintStatus(ostream& fp) const
 {
   fp << "  MeritBase:"
-     << CalcSizeMerit()
-     << " Bonus:" << cur_bonus
-     << " Errors:" << cur_num_errors
-     << " Donates:" << cur_num_donates;
+  << CalcSizeMerit()
+  << " Bonus:" << cur_bonus
+  << " Errors:" << cur_num_errors
+  << " Donates:" << cur_num_donates;
   fp << endl;
   
   fp << "  Task Count (Quality):";
@@ -1321,48 +1322,48 @@
 {
   assert(genome_length > 0);
   assert(copied_size > 0);
-
+  
   int out_size;
-
+  
   switch (m_world->GetConfig().BASE_MERIT_METHOD.Get()) {
-  case BASE_MERIT_COPIED_SIZE:
-    out_size = copied_size;
-    break;
-  case BASE_MERIT_EXE_SIZE:
-    out_size = executed_size;
-    break;
-  case BASE_MERIT_FULL_SIZE:
-    out_size = genome_length;
-    break;
-  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 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 BASE_MERIT_NUM_BONUS_INST:
-    if(m_world->GetConfig().FITNESS_VALLEY.Get()){
-      if (bonus_instruction_count >= m_world->GetConfig().FITNESS_VALLEY_START.Get() && 
-          bonus_instruction_count <= m_world->GetConfig().FITNESS_VALLEY_STOP.Get()){
-         out_size = 1;
-         break;
-      }            
-    }
-    if (m_world->GetConfig().MERIT_BONUS_EFFECT.Get()>0) {out_size = 1 + bonus_instruction_count;}
-    else if (m_world->GetConfig().MERIT_BONUS_EFFECT.Get()<0) {out_size = genome_length - (bonus_instruction_count -1);}
-    else {out_size = 1;}  //the extra 1 point in all these case is so the orgs are not jilted by the scheduler        
-    break;
-  case BASE_MERIT_CONST:
-  default:
-    out_size = m_world->GetConfig().BASE_CONST_MERIT.Get();
-    break;
+    case BASE_MERIT_COPIED_SIZE:
+      out_size = copied_size;
+      break;
+    case BASE_MERIT_EXE_SIZE:
+      out_size = executed_size;
+      break;
+    case BASE_MERIT_FULL_SIZE:
+      out_size = genome_length;
+      break;
+    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 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 BASE_MERIT_NUM_BONUS_INST:
+      if(m_world->GetConfig().FITNESS_VALLEY.Get()){
+        if (bonus_instruction_count >= m_world->GetConfig().FITNESS_VALLEY_START.Get() && 
+            bonus_instruction_count <= m_world->GetConfig().FITNESS_VALLEY_STOP.Get()){
+          out_size = 1;
+          break;
+        }            
+      }
+      if (m_world->GetConfig().MERIT_BONUS_EFFECT.Get()>0) {out_size = 1 + bonus_instruction_count;}
+      else if (m_world->GetConfig().MERIT_BONUS_EFFECT.Get()<0) {out_size = genome_length - (bonus_instruction_count -1);}
+      else {out_size = 1;}  //the extra 1 point in all these case is so the orgs are not jilted by the scheduler        
+      break;
+    case BASE_MERIT_CONST:
+    default:
+      out_size = m_world->GetConfig().BASE_CONST_MERIT.Get();
+      break;
   }
-
+  
   return out_size;
 } 
 
@@ -1383,10 +1384,10 @@
   switch (m_world->GetConfig().FITNESS_METHOD.Get())
   {
     case 0: // Normal
-    assert(_gestation_time > 0);
-    out_fitness = _merit_base * _bonus / _gestation_time;
-    break;
-
+      assert(_gestation_time > 0);
+      out_fitness = _merit_base * _bonus / _gestation_time;
+      break;
+      
     case 1: // Sigmoidal returns (should be used with an additive reward)
     {
       assert(_gestation_time > 0);
@@ -1395,19 +1396,19 @@
       double converted_bonus = (_bonus - m_world->GetConfig().DEFAULT_BONUS.Get()) * m_world->GetConfig().FITNESS_COEFF_2.Get() / (1 + _bonus * m_world->GetConfig().FITNESS_COEFF_2.Get() ) ;
       out_fitness = _merit_base * exp(converted_bonus * log(m_world->GetConfig().FITNESS_COEFF_1.Get())) / _gestation_time;
     }
-    break;
-    
+      break;
+      
     case 2: //Activity of one enzyme in pathway altered (with diminishing returns and a cost for each executed instruction)
     {
       out_fitness = 0;
       double net_bonus = _bonus +  - m_world->GetConfig().DEFAULT_BONUS.Get();
       out_fitness = net_bonus / (net_bonus + 1)* exp (_gestation_time * log(1 - m_world->GetConfig().FITNESS_COEFF_1.Get())); 
     }
-    break;
-     
+      break;
+      
     default:
-    cout << "Unknown FITNESS_METHOD!" << endl;
-    exit(1);
+      cout << "Unknown FITNESS_METHOD!" << endl;
+      exit(1);
   }
   
   return out_fitness;
@@ -1435,7 +1436,7 @@
 
 
 /**
-Credit organism with energy reward, but only update energy store if APPLY_ENERGY_METHOD = "on task completion" (1)
+ Credit organism with energy reward, but only update energy store if APPLY_ENERGY_METHOD = "on task completion" (1)
  */
 void cPhenotype::RefreshEnergy() {
   if(cur_energy_bonus > 0) {
@@ -1471,7 +1472,7 @@
 
 void cPhenotype::ApplyDonatedEnergy() {
   double energy_cap = m_world->GetConfig().ENERGY_CAP.Get();
-
+  
   if((energy_store + energy_received_buffer) >= energy_cap) {
     IncreaseEnergyApplied(energy_cap - energy_store);
     SetEnergy(energy_store + (energy_cap - energy_received_buffer));
@@ -1519,7 +1520,7 @@
   assert(GetStoredEnergy()>0.0);
   // adjust energy in parent
   ReduceEnergy(child_energy - 2*energy_given_at_birth); // 2*energy_given_at_birth: 1 in child_energy & 1 for parent
-    
+  
   //TODO: add energy_given_at_birth to Stored_energy
   cMerit parentMerit(ConvertEnergyToMerit(GetStoredEnergy() * GetEnergyUsageRatio()));
 	if(parentMerit.GetDouble() > 0.0)
@@ -1542,7 +1543,7 @@
   cur_trial_fitnesses.Push(fitness);
   cur_trial_bonuses.Push(GetCurBonus());
   cur_trial_times_used.Push(trial_time_used);
-
+  
   //The rest of the function, resets the phenotype like DivideReset(), but without
   //incrementing the generation or child statistics.
   
@@ -1566,21 +1567,21 @@
   energy_store += cur_energy_bonus;
   energy_store = m_world->GetConfig().ENERGY_GIVEN_AT_BIRTH.Get(); // We reset to what they had at birth
   cur_energy_bonus = 0;
-      // to be perfectly accurate, this should be from a last_energy value??
-
+  // to be perfectly accurate, this should be from a last_energy value??
   
- // genome_length   = _genome.GetSize();  //No child! @JEB
+  
+  // genome_length   = _genome.GetSize();  //No child! @JEB
   (void) copied_size;          // Unchanged
   (void) executed_size;        // Unchanged
   gestation_time  = time_used - gestation_start;  //Keep gestation referring to actual replication time! @JEB
   gestation_start = time_used;                    //Keep gestation referring to actual replication time! @JEB
- // fitness         = merit.GetDouble() / gestation_time; //Use fitness measure that is per-trial @JEB
-
+  // fitness         = merit.GetDouble() / gestation_time; //Use fitness measure that is per-trial @JEB
+  
   // Lock in cur values as last values.
   last_merit_base           = cur_merit_base;
   last_bonus                = cur_bonus;
   last_cpu_cycles_used      = cpu_cycles_used;
-//TODO?  last_energy         = cur_energy_bonus;
+  //TODO?  last_energy         = cur_energy_bonus;
   last_num_errors           = cur_num_errors;
   last_num_donates          = cur_num_donates;
   last_task_count           = cur_task_count;
@@ -1595,7 +1596,7 @@
   last_reaction_add_reward  = cur_reaction_add_reward;
   last_inst_count           = cur_inst_count;
   last_sense_count          = cur_sense_count;
-
+  
   // Reset cur values.
   cur_bonus       = m_world->GetConfig().DEFAULT_BONUS.Get();
   cpu_cycles_used = 0;
@@ -1618,7 +1619,7 @@
   //cur_trial_fitnesses.Resize(0); Don't throw out the trial fitnesses! @JEB
   trial_time_used = 0;
   trial_cpu_cycles_used = 0;
-
+  
   // Setup other miscellaneous values...
   num_divides++;
   (void) generation;
@@ -1628,7 +1629,7 @@
   (void) neutral_metric;
   life_fitness = fitness; 
   
-
+  
   num_thresh_gb_donations_last = num_thresh_gb_donations;
   num_thresh_gb_donations = 0;
   num_quanta_thresh_gb_donations_last = num_quanta_thresh_gb_donations;
@@ -1691,11 +1692,11 @@
  * This function is run to reset an organism whose task counts (etc) have already been moved from cur to last
  * by another call (like NewTrial). It is a subset of DivideReset @JEB
  **/
- 
+
 void cPhenotype::TrialDivideReset(const cGenome & _genome)
 {
   int cur_merit_base = CalcSizeMerit();
-
+  
   // 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();
@@ -1703,17 +1704,17 @@
     cur_bonus = merit_default_bonus;
   }
   merit = cur_merit_base * cur_bonus;
-
+  
   SetEnergy(energy_store + cur_energy_bonus);
   m_world->GetStats().SumEnergyTestamentAcceptedByOrganisms().Add(energy_testament);
   energy_testament = 0.0;
-    
+  
   genome_length   = _genome.GetSize();
   gestation_start = time_used;
   cur_trial_fitnesses.Resize(0); 
   cur_trial_bonuses.Resize(0); 
   cur_trial_times_used.Resize(0); 
-
+  
   // Reset child info...
   (void) copy_true;
   (void) divide_sex;
@@ -1722,16 +1723,16 @@
   last_child_fertile = child_fertile;
   child_fertile     = true;
   (void) child_copied_size;
-
+  
   // A few final changes if the parent was supposed to be be considered
   // a second child on the divide.
-  if (m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT) {    
+  if ((m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT) || (m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_BIRTH)) {    
     gestation_start = 0;
     cpu_cycles_used = 0;
     time_used = 0;
     neutral_metric += m_world->GetRandom().GetRandNormal();
   }
-
+  
   if (m_world->GetConfig().GENERATION_INC_METHOD.Get() == GENERATION_INC_BOTH) generation++;
 }
 

Modified: branches/parasites/source/main/cPopulation.cc
===================================================================
--- branches/parasites/source/main/cPopulation.cc	2009-10-27 19:37:05 UTC (rev 3507)
+++ branches/parasites/source/main/cPopulation.cc	2009-10-27 19:46:35 UTC (rev 3508)
@@ -121,7 +121,7 @@
       case nGeometry::PARTIAL: { cout << "Geometry: Partial" << endl; break; }
 			case nGeometry::RANDOM_CONNECTED: { cout << "Geometry: Random connected" << endl; break; }
       case nGeometry::SCALE_FREE: { cout << "Geometry: Scale-free" << endl; break; }
-
+        
       default:
         cout << "Unknown geometry!" << endl;
         assert(false);
@@ -220,10 +220,10 @@
 				break;
 			case nGeometry::SCALE_FREE:
 				build_scale_free(&cell_array.begin()[i], &cell_array.begin()[i+deme_size],
-													world->GetConfig().SCALE_FREE_M.Get(),
-													world->GetConfig().SCALE_FREE_ALPHA.Get(),
-													world->GetConfig().SCALE_FREE_ZERO_APPEAL.Get(),
-													m_world->GetRandom());
+                         world->GetConfig().SCALE_FREE_M.Get(),
+                         world->GetConfig().SCALE_FREE_ALPHA.Get(),
+                         world->GetConfig().SCALE_FREE_ZERO_APPEAL.Get(),
+                         m_world->GetRandom());
 				break;
       default:
         assert(false);
@@ -545,7 +545,92 @@
   
   if (child_cpu.GetNumThreads() == m_world->GetConfig().MAX_CPU_THREADS.Get()) return false;
   
+  tArray<int> task_counts = target_organism->GetPhenotype().GetCurTaskCount();
   
+  int random_int = m_world->GetRandom().GetUInt(100);
+  
+  if (m_world->GetConfig().INJECT_PROB_FROM_TASKS.Get())
+  {
+    
+    int last_task_count = target_organism->GetPhenotype().GetLastTaskCount()[0];
+    int total_count;
+    int task_count = last_task_count;
+    
+    cout << last_task_count << endl;
+    cout << task_counts[1] << endl;
+    cout << endl << endl << endl;
+    
+    if (task_count < task_counts[0])
+    {  
+      task_count = task_counts[0];
+    }
+    
+    if (task_counts[1] > 0 && task_counts[1] <= 10)
+    {
+      task_count -= task_counts[1];
+    }
+    
+    total_count = task_count;
+    
+    //cout << endl << total_count << endl;
+    
+    if (total_count > 0)
+    {
+      if (m_world->GetConfig().INJECT_PROB_SIGMOID.Get())
+      {
+        switch (total_count) {
+          case 1:
+            if(random_int > 10)
+              return false;
+            break;
+          case  2:
+            if(random_int > 30)
+              return false;
+            break;
+          case 3:
+            if(random_int > 50)
+              return false;
+            break;
+          case 4:
+            if(random_int > 70)
+              return false;
+            break;
+          case 5:
+            if (random_int > 75)
+              return false;
+            break;
+          case 6:
+            if (random_int > 80)
+              return false;
+            break;
+          case  7:
+            if(random_int > 85)
+              return false;
+            break;
+          case 8:
+            if(random_int > 90)
+              return false;
+            break;
+          case 9:
+            if(random_int > 95)
+              return false;
+            break;
+          case 10:
+            break;
+        }
+      }
+      else
+      {
+        if (random_int > (total_count * 10))
+          return false;
+      }
+    }
+    
+    else
+      return false;
+    
+  }
+  
   if (target_organism->InjectHost(label, injected_code)) {
     cInjectGenotype* child_genotype = parent_genotype;
     
@@ -1336,7 +1421,7 @@
 			
 			// better have more than deme tournament size, otherwise something is *really* screwed up:
 			if(m_world->GetConfig().DEMES_TOURNAMENT_SIZE.Get() > static_cast<int>(deme_ids.size())) {
-				 m_world->GetDriver().RaiseFatalException(-1, "The number of demes that can participate in a tournament is less than the deme tournament size.");
+        m_world->GetDriver().RaiseFatalException(-1, "The number of demes that can participate in a tournament is less than the deme tournament size.");
 			}
 			
 			// Run the tournaments.
@@ -4767,7 +4852,7 @@
     /* depth */       cur_line.PopWord();
     cString name = cStringUtil::Stringf("org-%d", tmp.id_num);
     cGenome genome(cur_line.PopWord());
-        
+    
     // Process resident cell ids
     cString cellstr(cur_line.PopWord());
     while (cellstr.GetSize()) tmp.cells.Push(cellstr.Pop(',').AsInt());

Modified: branches/parasites/source/targets/avida-viewer/cSymbolUtil.cc
===================================================================
--- branches/parasites/source/targets/avida-viewer/cSymbolUtil.cc	2009-10-27 19:37:05 UTC (rev 3507)
+++ branches/parasites/source/targets/avida-viewer/cSymbolUtil.cc	2009-10-27 19:46:35 UTC (rev 3508)
@@ -29,7 +29,7 @@
 {
   if (cell.IsOccupied() == false) return ' ';
   const cOrganism & organism = *(cell.GetOrganism());
-
+  
   cSpecies * cur_species = organism.GetGenotype()->GetSpecies();
   if (cur_species == NULL) return '.';    // no species
   return cur_species->GetSymbol();        // symbol!
@@ -39,13 +39,13 @@
 {
   if (cell.IsOccupied() == false) return ' ';
   const cOrganism & organism = *(cell.GetOrganism());
-
+  
   const bool modifier = organism.GetPhenotype().IsModifier();
   const bool modified = organism.GetPhenotype().IsModified();
-
+  
   // 'I' = Injector     'H' = Host (Injected into)
   // 'B' = Both         '-' = Neither
-
+  
   if (modifier == true && modified == true)  return 'B';
   if (modifier == true) return 'I'-6;
   if (modified == true) return 'H'-6;
@@ -63,14 +63,14 @@
 {
   if (cell.IsOccupied() == false) return ' ';
   const cOrganism & organism = *(cell.GetOrganism());
-
+  
   const int age = organism.GetPhenotype().GetAge();
   if (age < 0) return '-';
   if (age < 10) return (char) ('0' + age);
   if (age < 20) return 'X';
   if (age < 80) return 'L';
   if (age < 200) return 'C';
-
+  
   return '+';
 }
 
@@ -78,7 +78,7 @@
 {
   if (cell.IsOccupied() == false) return ' ';
   const cOrganism & organism = *(cell.GetOrganism());
-
+  
   if (organism.GetPhenotype().ParentTrue() == true) return '*';
   return '-';
 }
@@ -87,8 +87,8 @@
 {
   if (cell.IsOccupied() == false) return ' ';
   const cOrganism & organism = *(cell.GetOrganism());
-
-  if (organism.GetNumParasites()) return '*';
+  
+  if (organism.GetNumParasites()) return 'A';
   return '-';
 }
 
@@ -96,7 +96,7 @@
 {
   if (cell.IsOccupied() == false) return ' ';
   const cOrganism & organism = *(cell.GetOrganism());
-
+  
   if (organism.GetPhenotype().IsMutated() == true) return '*';
   return '-';
 }
@@ -111,7 +111,7 @@
 {
   if (cell.IsOccupied() == false) return ' ';
   const cOrganism & organism = *(cell.GetOrganism());
-
+  
   return 'A' + (organism.GetLineageLabel() % 12);
 }
 




More information about the Avida-cvs mailing list