[Avida-SVN] r2762 - in branches/movement/source: actions analyze cpu main platform tools

grabow38 at myxo.css.msu.edu grabow38 at myxo.css.msu.edu
Wed Aug 27 06:22:24 PDT 2008


Author: grabow38
Date: 2008-08-27 09:22:23 -0400 (Wed, 27 Aug 2008)
New Revision: 2762

Modified:
   branches/movement/source/actions/EnvironmentActions.cc
   branches/movement/source/actions/PrintActions.cc
   branches/movement/source/analyze/cAnalyze.cc
   branches/movement/source/analyze/cAnalyzeGenotype.cc
   branches/movement/source/analyze/cAnalyzeGenotype.h
   branches/movement/source/cpu/cCPUTestInfo.cc
   branches/movement/source/cpu/cCPUTestInfo.h
   branches/movement/source/cpu/cHardwareExperimental.cc
   branches/movement/source/cpu/cHardwareExperimental.h
   branches/movement/source/cpu/cHardwareManager.cc
   branches/movement/source/cpu/cHardwareManager.h
   branches/movement/source/cpu/cTestCPU.cc
   branches/movement/source/main/cDemeCellEvent.cc
   branches/movement/source/main/cEnvironment.cc
   branches/movement/source/main/cLandscape.cc
   branches/movement/source/main/cOrganism.cc
   branches/movement/source/main/cOrganism.h
   branches/movement/source/main/cPhenPlastGenotype.cc
   branches/movement/source/main/cPhenPlastGenotype.h
   branches/movement/source/main/cPhenotype.cc
   branches/movement/source/main/cPhenotype.h
   branches/movement/source/main/cTaskLib.cc
   branches/movement/source/platform/platform.h
   branches/movement/source/tools/cDataFileManager.cc
Log:
Merged development changes r2749:2761 into branches/movement.

Modified: branches/movement/source/actions/EnvironmentActions.cc
===================================================================
--- branches/movement/source/actions/EnvironmentActions.cc	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/actions/EnvironmentActions.cc	2008-08-27 13:22:23 UTC (rev 2762)
@@ -536,6 +536,33 @@
 };
 
 /**
+ Sets resource availiblity to seasonal
+ */
+class cActionSetSeasonalResource : public cAction
+	{
+	private:
+		cString m_res_name;
+		
+	public:
+		cActionSetSeasonalResource(cWorld* world, const cString& args): cAction(world, args), m_res_name("")
+		{
+			cString largs(args);
+			if (largs.GetSize()) m_res_name = largs.PopWord();
+		}
+		
+		static const cString GetDescription() { return "Arguments: <string reaction_name>"; }
+		
+		void Process(cAvidaContext& ctx)
+		{
+			int time = m_world->GetStats().GetUpdate();
+			double m_res_count = -1*(0.4*tanh((time-182500)/50000)+0.5)*(0.5*sin(time/58.091)+0.5)+1;
+			cResource* res = m_world->GetEnvironment().GetResourceLib().GetResource(m_res_name);
+			if (res != NULL) m_world->GetPopulation().SetResource(res->GetID(), m_res_count);
+			
+		}
+	};
+
+/**
 Sets resource availiblity to periodic
  */
 class cActionSetPeriodicResource : public cAction
@@ -850,6 +877,7 @@
   action_lib->Register<cActionSetEnvironmentInputs>("SetEnvironmentInputs");
   action_lib->Register<cActionSetEnvironmentRandomMask>("SetEnvironmentRandomMask");
 
+	action_lib->Register<cActionSetSeasonalResource>("SetSeasonalResource");
   action_lib->Register<cActionSetPeriodicResource>("SetPeriodicResource");
   action_lib->Register<cActionSetNumInstBefore0Energy>("SetNumInstBefore0Energy");
 

Modified: branches/movement/source/actions/PrintActions.cc
===================================================================
--- branches/movement/source/actions/PrintActions.cc	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/actions/PrintActions.cc	2008-08-27 13:22:23 UTC (rev 2762)
@@ -1580,6 +1580,8 @@
     
     void Process(cAvidaContext& ctx)
     {
+      cCPUTestInfo test_info;
+      
       if (ctx.GetAnalyzeMode()){ // Analyze mode
         cString this_path = m_filename;
         ofstream& fot = m_world->GetDataFileOFStream(this_path);
@@ -1587,7 +1589,7 @@
         tListIterator<cAnalyzeGenotype> batch_it(m_world->GetAnalyze().GetCurrentBatch().List());
         cAnalyzeGenotype* genotype = NULL;
         while((genotype = batch_it.Next())){
-          const cPhenPlastGenotype* ppgen = new cPhenPlastGenotype(genotype->GetGenome(), m_num_trials, m_world, ctx);
+          const cPhenPlastGenotype* ppgen = new cPhenPlastGenotype(genotype->GetGenome(), m_num_trials, test_info, m_world, ctx);
           PrintPPG(fot, ppgen, genotype->GetID(), genotype->GetParentID());
           delete ppgen;
         }
@@ -1598,7 +1600,7 @@
         PrintHeader(fot);
         cGenotype* genotype = m_world->GetClassificationManager().GetBestGenotype();
         for (int k = 0; k < m_world->GetClassificationManager().GetGenotypeCount(); k++){
-          const cPhenPlastGenotype* ppgen = new cPhenPlastGenotype(genotype->GetGenome(), m_num_trials, m_world, ctx);
+          const cPhenPlastGenotype* ppgen = new cPhenPlastGenotype(genotype->GetGenome(), m_num_trials, test_info, m_world, ctx);
           PrintPPG(fot, ppgen, genotype->GetID(), genotype->GetParentID());
           delete ppgen;
           genotype = genotype->GetNext();

Modified: branches/movement/source/analyze/cAnalyze.cc
===================================================================
--- branches/movement/source/analyze/cAnalyze.cc	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/analyze/cAnalyze.cc	2008-08-27 13:22:23 UTC (rev 2762)
@@ -4723,7 +4723,7 @@
       fp << endl;
       
     } else { // if (file_type == FILE_TYPE_HTML) {
-             // Mark file as html
+      // Mark file as html
       fp << "<html>" << endl;
       
       // Setup any javascript macros needed...
@@ -4743,16 +4743,10 @@
       fp << "</head>" << endl;
       
       // Setup the body...
-      fp << "<body bgcolor=\"#FFFFFF\"" << endl
-        << " text=\"#000000\"" << endl
-        << " link=\"#0000AA\"" << endl
-        << " alink=\"#0000FF\"" << endl
-        << " vlink=\"#000044\">" << endl
-        << endl
-        << "<h1 align=center>Run " << batch[cur_batch].Name()
-        << ", ID " << genotype->GetID() << "</h1>" << endl
-        << "<center>" << endl
-        << endl;
+      fp << "<body>" << endl
+      << "<div align=\"center\">" << endl
+      << "<h1 align=\"center\">Run " << batch[cur_batch].Name() << ", ID " << genotype->GetID() << "</h1>" << endl
+      << endl;
       
       // Links?
       fp << "<table width=90%><tr><td align=left>";
@@ -4836,7 +4830,7 @@
       
       // Print the individual columns...
       output_it.Reset();
-      tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
+      tDataEntryCommand<cAnalyzeGenotype>* data_command = NULL;
       int cur_col = 0;
       while ((data_command = output_it.Next()) != NULL) {
         data_command->SetTarget(&test_genotype);
@@ -4844,9 +4838,6 @@
         const cFlexVar test_value = data_command->GetValue();
         int compare = CompareFlexStat(test_value, data_command->GetValue(genotype), data_command->GetCompareType());
         
-        // BUG! Either of the next two conditional print commands can
-        // cause landscaping to be triggered in a context that causes a crash, 
-        // notably, if you don't provide any column parameters to MapTasks.. @JEB
         if (file_type == FILE_TYPE_HTML) {
           HTMLPrintStat(test_value, fp, compare, data_command->GetHtmlCellFlags(), data_command->GetNull(),
                         !(data_command->HasArg("blank")));
@@ -4882,14 +4873,14 @@
       
       // And close everything up...
       fp << "</table>" << endl
-        << "</center>" << endl;
+      << "</div>" << endl;
     }
     
     delete [] col_pass_count;
     delete [] col_fail_count;
     m_world->GetDataFileManager().Remove(filename);  // Close the data file object
-    }
-    }
+  }
+}
 
 void cAnalyze::CommandAverageModularity(cString cur_string)
 {

Modified: branches/movement/source/analyze/cAnalyzeGenotype.cc
===================================================================
--- branches/movement/source/analyze/cAnalyzeGenotype.cc	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/analyze/cAnalyzeGenotype.cc	2008-08-27 13:22:23 UTC (rev 2762)
@@ -40,13 +40,15 @@
 #include "cWorld.h"
 #include "cWorldDriver.h"
 
+#include "tAutoRelease.h"
+
 #include <cmath>
 using namespace std;
 
 cAnalyzeGenotype::cAnalyzeGenotype(cWorld* world, cString symbol_string, cInstSet& in_inst_set)
   : m_world(world)
   , genome(symbol_string)
-  , inst_set(in_inst_set)
+  , m_inst_set(in_inst_set)
   , name("")
   , aligned_sequence("")
   , tag("")
@@ -81,11 +83,11 @@
     
   // Make sure that the sequences jive with the inst_set
   for (int i = 0; i < genome.GetSize(); i++) {
-    if (genome[i].GetOp() >= inst_set.GetSize()) {
+    if (genome[i].GetOp() >= m_inst_set.GetSize()) {
       cString msg("Trying to load instruction ");
       msg += genome[i].GetOp();
       msg += ".  Max in set is";
-      msg += (inst_set.GetSize() - 1);
+      msg += (m_inst_set.GetSize() - 1);
       m_world->GetDriver().RaiseException(msg);
     }
   }
@@ -94,7 +96,7 @@
 cAnalyzeGenotype::cAnalyzeGenotype(cWorld* world, const cGenome& _genome, cInstSet& in_inst_set)
   : m_world(world)
   , genome(_genome)
-  , inst_set(in_inst_set)
+  , m_inst_set(in_inst_set)
   , name("")
   , aligned_sequence("")
   , tag("")
@@ -131,7 +133,7 @@
 cAnalyzeGenotype::cAnalyzeGenotype(const cAnalyzeGenotype& _gen)
   : m_world(_gen.m_world)
   , genome(_gen.genome)
-  , inst_set(_gen.inst_set)
+  , m_inst_set(_gen.m_inst_set)
   , name(_gen.name)
   , aligned_sequence(_gen.aligned_sequence)
   , tag(_gen.tag)
@@ -212,7 +214,7 @@
   // Calculate the base fitness for the genotype we're working with...
   // (This may not have been run already, and cost negligiably more time
   // considering the number of knockouts we need to do.
-  cAnalyzeGenotype base_genotype(m_world, genome, inst_set);
+  cAnalyzeGenotype base_genotype(m_world, genome, m_inst_set);
   base_genotype.Recalculate(ctx);
   double base_fitness = base_genotype.GetFitness();
   const tArray<int> base_task_counts( base_genotype.GetTaskCounts() );
@@ -227,7 +229,7 @@
   cGenome mod_genome(genome);
   
   // Setup a NULL instruction in a special inst set.
-  cInstSet ko_inst_set(inst_set);
+  cInstSet ko_inst_set(m_inst_set);
   const cInstruction null_inst = ko_inst_set.ActivateNullInst();
   
   // If we are keeping track of the specific effects on tasks from the
@@ -347,7 +349,7 @@
 void cAnalyzeGenotype::CheckLand() const
 {
   if (m_land == NULL) {
-    m_land = new cLandscape(m_world, genome, inst_set);
+    m_land = new cLandscape(m_world, genome, m_inst_set);
     m_land->SetDistance(1);
     m_land->Process(m_world->GetDefaultContext());
   }
@@ -356,8 +358,11 @@
 void cAnalyzeGenotype::CheckPhenPlast() const
 {
   // Implicit genotype recalculation if required
-  if (m_phenplast_stats == NULL){
-    cPhenPlastGenotype pp(genome, 1000, m_world, m_world->GetDefaultContext());
+  if (m_phenplast_stats == NULL) {
+    cCPUTestInfo test_info;
+    test_info.SetInstSet(&m_inst_set);
+    
+    cPhenPlastGenotype pp(genome, 1000, test_info, m_world, m_world->GetDefaultContext());
     SummarizePhenotypicPlasticity(pp);
   }
 }
@@ -381,34 +386,26 @@
 
 void cAnalyzeGenotype::CalcLandscape(cAvidaContext& ctx)
 {
-  if (m_land == NULL) m_land = new cLandscape(m_world, genome, inst_set);
+  if (m_land == NULL) m_land = new cLandscape(m_world, genome, m_inst_set);
   m_land->SetDistance(1);
   m_land->Process(ctx);
 }
 
 void cAnalyzeGenotype::Recalculate(cAvidaContext& ctx, cCPUTestInfo* test_info, cAnalyzeGenotype* parent_genotype, int num_trials)
 {  
-  //Allocate our own test info if it wasn't provided
-  cCPUTestInfo* temp_test_info = NULL;
+  // Allocate our own test info if it wasn't provided
+  tAutoRelease<cCPUTestInfo> local_test_info;
   if (!test_info)
   {
-      temp_test_info = new cCPUTestInfo();
-      test_info = temp_test_info;
+    test_info = new cCPUTestInfo();
+    local_test_info.Set(test_info);
   }
 
-  // @DMB - This does some 'interesting' things with the instruction set
-  // Use the inst lib for this genotype... and syncrhonize environment
-  
-  // Backup old instruction set, update with new
-  cInstSet env_inst_set_backup = m_world->GetHardwareManager().GetInstSet();
-  m_world->GetHardwareManager().GetInstSet() = inst_set;
+  test_info->SetInstSet(&m_inst_set);
 
   // Handling recalculation here
   cPhenPlastGenotype recalc_data(genome, num_trials, *test_info, m_world, ctx);
  
-  // Restore the instruction set
-  m_world->GetHardwareManager().GetInstSet() = env_inst_set_backup;
-  
   // The most likely phenotype will be assigned to the phenotype stats
   const cPlasticPhenotype* likely_phenotype = recalc_data.GetMostLikelyPhenotype();
   
@@ -432,17 +429,12 @@
     fitness_ratio = GetFitness() / parent_genotype->GetFitness();
     efficiency_ratio = GetEfficiency() / parent_genotype->GetEfficiency();
     comp_merit_ratio = GetCompMerit() / parent_genotype->GetCompMerit();
-    parent_dist = cStringUtil::EditDistance(genome.AsString(),
-        parent_genotype->GetGenome().AsString(), parent_muts);
+    parent_dist = cStringUtil::EditDistance(genome.AsString(), parent_genotype->GetGenome().AsString(), parent_muts);
     ancestor_dist = parent_genotype->GetAncestorDist() + parent_dist;
   }
 
   // Summarize plasticity information if multiple recalculations performed
-  if (num_trials > 1)
-    SummarizePhenotypicPlasticity(recalc_data);
-  
-  //Deallocate if we created
-  if (temp_test_info) delete temp_test_info;
+  if (num_trials > 1) SummarizePhenotypicPlasticity(recalc_data);
 }
 
 

Modified: branches/movement/source/analyze/cAnalyzeGenotype.h
===================================================================
--- branches/movement/source/analyze/cAnalyzeGenotype.h	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/analyze/cAnalyzeGenotype.h	2008-08-27 13:22:23 UTC (rev 2762)
@@ -103,7 +103,7 @@
 private:
   cWorld* m_world;
   cGenome genome;            // Full Genome
-  cInstSet& inst_set;       // Instruction set used in this genome
+  cInstSet& m_inst_set;       // Instruction set used in this genome
   cString name;              // Name, if one was provided in loading
   cString aligned_sequence;  // Sequence (in ASCII) after alignment
   cString tag;               // All genotypes in a batch can be tagged

Modified: branches/movement/source/cpu/cCPUTestInfo.cc
===================================================================
--- branches/movement/source/cpu/cCPUTestInfo.cc	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/cpu/cCPUTestInfo.cc	2008-08-27 13:22:23 UTC (rev 2762)
@@ -33,11 +33,11 @@
 
 cCPUTestInfo::cCPUTestInfo(int max_tests)
   : generation_tests(max_tests)  // These vars not reset on Clear()
-  , trace_execution(false)
   , trace_task_order(false)
   , use_random_inputs(false)
   , use_manual_inputs(false)
   , m_tracer(NULL)
+  , m_inst_set(NULL)
   , org_array(max_tests)
   , m_res_method(RES_INITIAL)
   , m_res(NULL)
@@ -73,13 +73,6 @@
 }
  
 
-void cCPUTestInfo::SetTraceExecution(cHardwareTracer *tracer)
-{
-  trace_execution = (tracer)?(true):(false);
-  m_tracer = tracer;
-}
-
-
 double cCPUTestInfo::GetGenotypeFitness()
 {
   if (org_array[0] != NULL) return org_array[0]->GetPhenotype().GetFitness();

Modified: branches/movement/source/cpu/cCPUTestInfo.h
===================================================================
--- branches/movement/source/cpu/cCPUTestInfo.h	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/cpu/cCPUTestInfo.h	2008-08-27 13:22:23 UTC (rev 2762)
@@ -39,6 +39,7 @@
 #endif
 
 class cHardwareTracer;
+class cInstSet;
 class cOrganism;
 class cPhenotype;
 class cString;
@@ -57,12 +58,12 @@
 private:
   // Inputs...
   const int generation_tests; // Maximum depth in generations to test
-  bool trace_execution;       // Should we trace this CPU?
   bool trace_task_order;      // Should we keep track of ordering of tasks?
   bool use_random_inputs;     // Should we give the organism random inputs?
 	bool use_manual_inputs;     // Do we have inputs that we must use?
 	tArray<int> manual_inputs;  //   if so, use these.
   cHardwareTracer* m_tracer;
+  cInstSet* m_inst_set;
 
   // Outputs...
   bool is_viable;         // Is this organism colony forming?
@@ -94,7 +95,8 @@
   void UseRandomInputs(bool _rand=true) { use_random_inputs = _rand; use_manual_inputs = false; }
 	void UseManualInputs(tArray<int> inputs) {use_manual_inputs = true; use_random_inputs = false; manual_inputs = inputs;}
 	void ResetInputMode() {use_manual_inputs = false; use_random_inputs = false;}
-  void SetTraceExecution(cHardwareTracer *tracer = NULL);
+  void SetTraceExecution(cHardwareTracer* tracer = NULL) { m_tracer = tracer; }
+  void SetInstSet(cInstSet* inst_set = NULL) { m_inst_set = inst_set; }
   void SetResourceOptions(int res_method = RES_INITIAL, std::vector<std::pair<int, std::vector<double> > > * res = NULL, int update = 0, int cpu_cycle_offset = 0)
     { m_res_method = (eTestCPUResourceMethod)res_method; m_res = res; m_res_update = update; m_res_cpu_cycle_offset = cpu_cycle_offset; }
 
@@ -103,7 +105,8 @@
   int GetGenerationTests() const { return generation_tests; }
   bool GetTraceTaskOrder() const { return trace_task_order; }
   bool GetUseRandomInputs() const { return use_random_inputs; }
-  bool GetTraceExecution() const { return trace_execution; }
+  bool GetTraceExecution() const { return (m_tracer); }
+  cInstSet* GetInstSet() const { return m_inst_set; }
 	bool GetUseManualInputs() const { return use_manual_inputs; }
 	tArray<int> GetTestCPUInputs() const { return used_inputs; }
   cHardwareTracer *GetTracer() { return m_tracer; }

Modified: branches/movement/source/cpu/cHardwareExperimental.cc
===================================================================
--- branches/movement/source/cpu/cHardwareExperimental.cc	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/cpu/cHardwareExperimental.cc	2008-08-27 13:22:23 UTC (rev 2762)
@@ -503,9 +503,12 @@
   fp << organism->GetPhenotype().GetCPUCyclesUsed() << " ";
   fp << "IP:" << IP().GetPosition() << "    ";
   
+  
   for (int i = 0; i < NUM_REGISTERS; i++) {
+    sInternalValue& reg = m_threads[m_cur_thread].reg[i];
     fp << static_cast<char>('A' + i) << "X:" << GetRegister(i) << " ";
-    fp << setbase(16) << "[0x" << GetRegister(i) << "]  " << setbase(10);
+    fp << setbase(16) << "[0x" << reg.value <<  "] " << setbase(10);
+    fp << "(" << reg.from_env << " " << reg.env_component << " " << reg.originated << " " << reg.oldest_component << ")  ";
   }
   
   // Add some extra information if additional time costs are used for instructions,
@@ -520,6 +523,7 @@
     << "W-Head:" << GetHead(nHardware::HEAD_WRITE).GetPosition()  << " "
     << "F-Head:" << GetHead(nHardware::HEAD_FLOW).GetPosition()   << "  "
     << "RL:" << GetReadLabel().AsString() << "   "
+    << "Ex:" << m_last_output
     << endl;
     
   int number_of_stacks = GetNumStacks();

Modified: branches/movement/source/cpu/cHardwareExperimental.h
===================================================================
--- branches/movement/source/cpu/cHardwareExperimental.h	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/cpu/cHardwareExperimental.h	2008-08-27 13:22:23 UTC (rev 2762)
@@ -530,7 +530,7 @@
   dest.from_env = false;
   dest.originated = m_cycle_count;
   dest.oldest_component = src.oldest_component;
-  dest.env_component = src.from_env;  
+  dest.env_component = src.env_component;
 }
 
 

Modified: branches/movement/source/cpu/cHardwareManager.cc
===================================================================
--- branches/movement/source/cpu/cHardwareManager.cc	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/cpu/cHardwareManager.cc	2008-08-27 13:22:23 UTC (rev 2762)
@@ -82,22 +82,22 @@
   
 }
 
-cHardwareBase* cHardwareManager::Create(cOrganism* in_org)
+cHardwareBase* cHardwareManager::Create(cOrganism* in_org, cInstSet* inst_set)
 {
   assert(in_org != NULL);
   
   switch (m_type)
   {
     case HARDWARE_TYPE_CPU_ORIGINAL:
-      return new cHardwareCPU(m_world, in_org, m_inst_set);
+      return new cHardwareCPU(m_world, in_org, inst_set);
     case HARDWARE_TYPE_CPU_SMT:
-      return new cHardwareSMT(m_world, in_org, m_inst_set);
+      return new cHardwareSMT(m_world, in_org, inst_set);
     case HARDWARE_TYPE_CPU_TRANSSMT:
-      return new cHardwareTransSMT(m_world, in_org, m_inst_set);
+      return new cHardwareTransSMT(m_world, in_org, inst_set);
     case HARDWARE_TYPE_CPU_EXPERIMENTAL:
-      return new cHardwareExperimental(m_world, in_org, m_inst_set);
+      return new cHardwareExperimental(m_world, in_org, inst_set);
     case HARDWARE_TYPE_CPU_GX:
-      return new cHardwareGX(m_world, in_org, m_inst_set);
+      return new cHardwareGX(m_world, in_org, inst_set);
     default:
       return NULL;
   }

Modified: branches/movement/source/cpu/cHardwareManager.h
===================================================================
--- branches/movement/source/cpu/cHardwareManager.h	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/cpu/cHardwareManager.h	2008-08-27 13:22:23 UTC (rev 2762)
@@ -61,7 +61,8 @@
   cHardwareManager(cWorld* world);
   ~cHardwareManager() { ; }
   
-  cHardwareBase* Create(cOrganism* in_org);
+  cHardwareBase* Create(cOrganism* in_org, cInstSet* inst_set);
+  inline cHardwareBase* Create(cOrganism* in_org) { return Create(in_org, m_inst_set); }
   cTestCPU* CreateTestCPU() { return new cTestCPU(m_world); }
 
   const cInstSet& GetInstSet() const { return *m_inst_set; }

Modified: branches/movement/source/cpu/cTestCPU.cc
===================================================================
--- branches/movement/source/cpu/cTestCPU.cc	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/cpu/cTestCPU.cc	2008-08-27 13:22:23 UTC (rev 2762)
@@ -359,10 +359,13 @@
   if (test_info.org_array[cur_depth] != NULL) {
     delete test_info.org_array[cur_depth];
   }
-  test_info.org_array[cur_depth] = new cOrganism(m_world, ctx, genome);
-  cOrganism & organism = *( test_info.org_array[cur_depth] );
-  organism.SetOrgInterface(new cTestCPUInterface(this));
-  organism.GetPhenotype().SetupInject(genome);
+  cOrganism* organism = NULL;
+  
+  if (test_info.GetInstSet()) organism = new cOrganism(m_world, ctx, genome, test_info.GetInstSet());
+  else organism = new cOrganism(m_world, ctx, genome);
+  test_info.org_array[cur_depth] = organism;
+  organism->SetOrgInterface(new cTestCPUInterface(this));
+  organism->GetPhenotype().SetupInject(genome);
 
   // Run the current organism.
   ProcessGestation(ctx, test_info, cur_depth);
@@ -377,10 +380,10 @@
   //  4: It copied false => we must check the child.
 
   // Case 1:  ////////////////////////////////////
-  if (organism.GetPhenotype().GetNumDivides() == 0)  return false;
+  if (organism->GetPhenotype().GetNumDivides() == 0)  return false;
 
   // Case 2:  ////////////////////////////////////
-  if (organism.GetPhenotype().CopyTrue() == true) {
+  if (organism->GetPhenotype().CopyTrue() == true) {
     test_info.depth_found = cur_depth;
     test_info.is_viable = true;
     return true;
@@ -389,7 +392,7 @@
   // Case 3:  ////////////////////////////////////
   bool is_ancestor = false;
   for (int anc_depth = 0; anc_depth < cur_depth; anc_depth++) {
-    if (organism.ChildGenome() == test_info.org_array[anc_depth]->GetGenome()){
+    if (organism->ChildGenome() == test_info.org_array[anc_depth]->GetGenome()){
       is_ancestor = true;
       const int cur_cycle = cur_depth - anc_depth;
       if (test_info.max_cycle < cur_cycle) test_info.max_cycle = cur_cycle;
@@ -406,7 +409,7 @@
   // If we haven't reached maximum depth yet, check out the child.
   if (cur_depth+1 < test_info.generation_tests) {
     // Run the child's genome.
-    return TestGenome_Body(ctx, test_info, organism.ChildGenome(), cur_depth+1);
+    return TestGenome_Body(ctx, test_info, organism->ChildGenome(), cur_depth+1);
   }
 
   // All options have failed; just return false.

Modified: branches/movement/source/main/cDemeCellEvent.cc
===================================================================
--- branches/movement/source/main/cDemeCellEvent.cc	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/main/cDemeCellEvent.cc	2008-08-27 13:22:23 UTC (rev 2762)
@@ -11,11 +11,11 @@
   , m_event_width(x2-x1)
   , m_event_height(y2-y1)
   , m_active(false)
+  , m_static_pos(static_pos)
   , m_dead(false)
-  , m_static_pos(static_pos)
+  , m_id_set(false)
   , m_deme(deme)
   , m_world(world)
-  , m_id_set(false)
 {
   assert(x1 <= x2);
   assert(y1 <= y2);

Modified: branches/movement/source/main/cEnvironment.cc
===================================================================
--- branches/movement/source/main/cEnvironment.cc	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/main/cEnvironment.cc	2008-08-27 13:22:23 UTC (rev 2762)
@@ -1043,7 +1043,7 @@
       if (cur_process->GetDemeFraction()) {
         deme_bonus = cur_process->GetDemeFraction() * bonus;
         bonus = (1-cur_process->GetDemeFraction()) * bonus;
-      }
+        }
       
       // Take care of the organism's bonus:
       switch (cur_process->GetType()) {

Modified: branches/movement/source/main/cLandscape.cc
===================================================================
--- branches/movement/source/main/cLandscape.cc	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/main/cLandscape.cc	2008-08-27 13:22:23 UTC (rev 2762)
@@ -38,11 +38,12 @@
 #include "cWorld.h"
 
 
-cLandscape::cLandscape(cWorld* world, const cGenome & in_genome, const cInstSet & in_inst_set)
+cLandscape::cLandscape(cWorld* world, const cGenome& in_genome, const cInstSet& in_inst_set)
 : m_world(world), inst_set(in_inst_set), base_genome(1), peak_genome(1), trials(1), m_min_found(0),
   m_max_trials(0), site_count(NULL)
 {
   Reset(in_genome);
+  test_info.SetInstSet(const_cast<cInstSet*>(&inst_set));
 }
 
 cLandscape::~cLandscape()
@@ -777,7 +778,6 @@
     pos_frac = GetProbPos();
     
     // Print the information on the current best.
-    cCPUTestInfo test_info;
     testcpu->TestGenome(ctx, test_info, cur_genome);
     cPhenotype& colony_phenotype = test_info.GetColonyOrganism()->GetPhenotype();
     df.Write(gen, "Generation");

Modified: branches/movement/source/main/cOrganism.cc
===================================================================
--- branches/movement/source/main/cOrganism.cc	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/main/cOrganism.cc	2008-08-27 13:22:23 UTC (rev 2762)
@@ -77,10 +77,47 @@
   , m_msg(0)
   , m_opinion(0)
 {
-  // Initialization of structures...
   m_hardware = m_world->GetHardwareManager().Create(this);
-//  m_cpu_stats.Setup();
 
+  initialize(ctx);
+}
+
+cOrganism::cOrganism(cWorld* world, cAvidaContext& ctx, const cGenome& in_genome, cInstSet* inst_set)
+  : m_world(world)
+  , m_genotype(NULL)
+  , m_phenotype(world)
+  , m_initial_genome(in_genome)
+  , m_mut_info(world->GetEnvironment().GetMutationLib(), in_genome.GetSize())
+  , m_interface(NULL)
+  , m_lineage_label(-1)
+  , m_lineage(NULL)
+  , m_input_pointer(0)
+  , m_input_buf(world->GetEnvironment().GetInputSize())
+  , m_output_buf(world->GetEnvironment().GetOutputSize())
+  , m_received_messages(RECEIVED_MESSAGES_SIZE)
+  , m_sent_value(0)
+  , m_sent_active(false)
+  , m_test_receive_pos(0)
+  , m_pher_drop(false)
+  , m_max_executed(-1)
+  , m_is_running(false)
+  , m_is_sleeping(false)
+  , m_is_dead(false)
+  , killed_event(false)
+  , m_net(NULL)
+  , m_msg(0)
+  , m_opinion(0)
+{
+  m_hardware = m_world->GetHardwareManager().Create(this, inst_set);
+  
+  initialize(ctx);
+}
+
+
+void cOrganism::initialize(cAvidaContext& ctx)
+{
+  m_phenotype.SetInstSetSize(m_hardware->GetInstSet().GetSize());
+  
   if (m_world->GetConfig().DEATH_METHOD.Get() > DEATH_METHOD_OFF) {
     m_max_executed = m_world->GetConfig().AGE_LIMIT.Get();
     if (m_world->GetConfig().AGE_DEVIATION.Get() > 0.0) {
@@ -89,13 +126,13 @@
     if (m_world->GetConfig().DEATH_METHOD.Get() == DEATH_METHOD_MULTIPLE) {
       m_max_executed *= m_initial_genome.GetSize();
     }
-
+    
     // m_max_executed must be positive or an organism will not die!
     if (m_max_executed < 1) m_max_executed = 1;
   }
   
   if (m_world->GetConfig().NET_ENABLED.Get()) m_net = new cNetSupport();
-  m_id = m_world->GetStats().GetTotCreatures();
+  m_id = m_world->GetStats().GetTotCreatures();  
 }
 
 

Modified: branches/movement/source/main/cOrganism.h
===================================================================
--- branches/movement/source/main/cOrganism.h	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/main/cOrganism.h	2008-08-27 13:22:23 UTC (rev 2762)
@@ -80,6 +80,7 @@
 class cGenotype;
 class cHardwareBase;
 class cInjectGenotype;
+class cInstSet;
 class cLineage;
 class cOrgSinkMessage;
 class cSaleItem;
@@ -104,8 +105,7 @@
 	int cclade_id;				                  // @MRR Coalescence clade information (set in cPopulation)
  
 	// Other stats
-  cCPUMemory m_child_genome; // Child genome, while under construction.
-//  sCPUStats m_cpu_stats;     // Info for statistics
+  cCPUMemory m_child_genome;              // Child genome, while under construction.
 
   // Input and Output with the environment
   int m_input_pointer;
@@ -146,12 +146,16 @@
   };
   cNetSupport* m_net;
   
+  
+  void initialize(cAvidaContext& ctx);
+  
   cOrganism(); // @not_implemented
   cOrganism(const cOrganism&); // @not_implemented
   cOrganism& operator=(const cOrganism&); // @not_implemented
   
 public:
   cOrganism(cWorld* world, cAvidaContext& ctx, const cGenome& in_genome);
+  cOrganism(cWorld* world, cAvidaContext& ctx, const cGenome& in_genome, cInstSet* inst_set);
   ~cOrganism();
 
   // --------  Accessor Methods  --------
@@ -184,7 +188,6 @@
   int GetMaxExecuted() const { return m_max_executed; }
   
   cCPUMemory& ChildGenome() { return m_child_genome; }
-//  sCPUStats& CPUStats() { return m_cpu_stats; }
 
   void SetRunning(bool in_running) { m_is_running = in_running; }
   bool IsRunning() { return m_is_running; }
@@ -439,16 +442,5 @@
 };
 
 
-#ifdef ENABLE_UNIT_TESTS
-namespace nOrganism {
-  /**
-   * Run unit tests
-   *
-   * @param full Run full test suite; if false, just the fast tests.
-   **/
-  void UnitTests(bool full = false);
-}
-#endif  
-
 #endif
 

Modified: branches/movement/source/main/cPhenPlastGenotype.cc
===================================================================
--- branches/movement/source/main/cPhenPlastGenotype.cc	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/main/cPhenPlastGenotype.cc	2008-08-27 13:22:23 UTC (rev 2762)
@@ -26,14 +26,6 @@
 #include <iostream>
 #include <cmath>
 
-cPhenPlastGenotype::cPhenPlastGenotype(const cGenome& in_genome, int num_trials, cWorld* world, cAvidaContext& ctx)
-: m_genome(in_genome), m_num_trials(num_trials), m_world(world)
-{
-  cCPUTestInfo test_info;
-  test_info.UseRandomInputs(true);
-  Process(test_info, world, ctx);
-}
-
 cPhenPlastGenotype::cPhenPlastGenotype(const cGenome& in_genome, int num_trials, cCPUTestInfo& test_info,  cWorld* world, cAvidaContext& ctx)
 : m_genome(in_genome), m_num_trials(num_trials), m_world(world)
 {

Modified: branches/movement/source/main/cPhenPlastGenotype.h
===================================================================
--- branches/movement/source/main/cPhenPlastGenotype.h	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/main/cPhenPlastGenotype.h	2008-08-27 13:22:23 UTC (rev 2762)
@@ -82,7 +82,6 @@
     void Process(cCPUTestInfo& test_info, cWorld* world, cAvidaContext& ctx);
 
   public:
-      cPhenPlastGenotype(const cGenome& in_genome, int num_trials, cWorld* world, cAvidaContext& ctx);
     cPhenPlastGenotype(const cGenome& in_genome, int num_trails, cCPUTestInfo& test_info,  cWorld* world, cAvidaContext& ctx);
     ~cPhenPlastGenotype();
     

Modified: branches/movement/source/main/cPhenotype.cc
===================================================================
--- branches/movement/source/main/cPhenotype.cc	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/main/cPhenotype.cc	2008-08-27 13:22:23 UTC (rev 2762)
@@ -28,7 +28,6 @@
 #include "cEnvironment.h"
 #include "cDeme.h"
 #include "cHardwareManager.h"
-#include "cInstSet.h"
 #include "cReactionResult.h"
 #include "cTaskState.h"
 #include "cTools.h"
@@ -49,7 +48,6 @@
   , cur_task_value(m_world->GetEnvironment().GetNumTasks())  
   , cur_reaction_count(m_world->GetEnvironment().GetReactionLib().GetSize())
   , cur_reaction_add_reward(m_world->GetEnvironment().GetReactionLib().GetSize())
-  , cur_inst_count(world->GetHardwareManager().GetInstSet().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
@@ -58,7 +56,6 @@
   , last_task_value(m_world->GetEnvironment().GetNumTasks())
   , last_reaction_count(m_world->GetEnvironment().GetReactionLib().GetSize())
   , last_reaction_add_reward(m_world->GetEnvironment().GetReactionLib().GetSize())  
-  , last_inst_count(world->GetHardwareManager().GetInstSet().GetSize())
   , last_sense_count(m_world->GetStats().GetSenseSize())
   , target_best_dist(100000)  // @LMG for movement tracking
 {
@@ -256,7 +253,7 @@
   assert(age >= 0);
   assert(child_copied_size >= 0);
   // assert(to_die == false);
-  return true;
+  return (m_world);
 }
 
 
@@ -1148,222 +1145,8 @@
 }
 
 
-///// For Loading and Saving State: /////
 
 
-bool cPhenotype::SaveState(ofstream& fp)
-{
-  assert(fp.good());
-  fp << "cPhenotype" << endl;
-
-  fp << merit.GetDouble()   << " ";
-  fp << genome_length       << " ";
-  fp << copied_size         << " ";
-  fp << executed_size       << " ";
-  fp << gestation_time      << " ";
-  fp << gestation_start     << " ";
-  fp << fitness             << " ";
-  fp << div_type            << " ";
-
-  fp << cur_bonus           << " ";
-  fp << cur_num_errors      << " ";
-  fp << cur_num_donates      << " ";
-  for (int i = 0; i < cur_task_count.GetSize(); i++) {
-    fp << cur_task_count[i] << " ";
-  }
-  for (int i = 0; i < cur_reaction_count.GetSize(); i++) {
-    fp << cur_reaction_count[i] << " ";
-  }
-  for (int i = 0; i < cur_inst_count.GetSize(); i++) {
-    fp << cur_inst_count[i] << " ";
-  }
-
-  fp << last_merit_base     << " ";
-  fp << last_bonus          << " ";
-  fp << last_num_errors     << " ";
-  fp << last_num_donates    << " ";
-  for (int i = 0; i < last_task_count.GetSize(); i++) {
-    fp << last_task_count[i] << " ";
-  }
-  for (int i = 0; i < last_reaction_count.GetSize(); i++) {
-    fp << last_reaction_count[i] << " ";
-  }
-  for (int i = 0; i < last_inst_count.GetSize(); i++) {
-    fp << last_inst_count[i] << " ";
-  }
-
-  fp << num_divides         << " ";
-  fp << generation          << " ";
-  fp << cpu_cycles_used     << " ";
-  fp << time_used           << " ";
-  fp << age                 << " ";
-  fp << neutral_metric      << " ";
-  fp << life_fitness        << " ";
-
-  fp << is_injected         << " ";
-  fp << is_donor_last       << " ";
-  fp << is_donor_cur        << " ";
-  fp << is_donor_rand_last       << " ";
-  fp << is_donor_rand        << " ";
-  fp << is_donor_null_last       << " ";
-  fp << is_donor_null        << " ";
-  fp << is_donor_kin_last       << " ";
-  fp << is_donor_kin        << " ";
-  fp << is_donor_edit_last       << " ";
-  fp << is_donor_edit        << " ";
-  fp << is_donor_gbg_last       << " ";
-  fp << is_donor_gbg        << " ";
-  fp << is_donor_truegb_last       << " ";
-  fp << is_donor_truegb        << " ";
-  fp << is_donor_threshgb_last       << " ";
-  fp << is_donor_threshgb        << " ";
-  fp << is_donor_quanta_threshgb_last       << " ";
-  fp << is_donor_quanta_threshgb        << " ";
-  fp << num_thresh_gb_donations_last       << " ";
-  fp << num_thresh_gb_donations        << " ";
-  fp << num_quanta_thresh_gb_donations_last       << " ";
-  fp << num_quanta_thresh_gb_donations        << " ";
-
-  fp << is_receiver_last         << " ";
-  fp << is_receiver         << " ";
-  fp << is_receiver_rand         << " ";
-  fp << is_receiver_kin         << " ";
-  fp << is_receiver_kin_last         << " ";
-  fp << is_receiver_edit         << " ";
-  fp << is_receiver_edit_last         << " ";
-  fp << is_receiver_gbg         << " ";
-  fp << is_receiver_truegb_last         << " ";
-  fp << is_receiver_truegb         << " ";
-  fp << is_receiver_threshgb_last         << " ";
-  fp << is_receiver_threshgb         << " ";
-  fp << is_receiver_quanta_threshgb_last         << " ";
-  fp << is_receiver_quanta_threshgb         << " ";
-  fp << is_modifier         << " ";
-  fp << is_modified         << " ";
-  fp << is_fertile          << " ";
-  fp << is_mutated          << " ";
-  fp << parent_true         << " ";
-  fp << parent_sex          << " ";
-  fp << parent_cross_num    << " ";
-
-  fp << copy_true           << " ";
-  fp << divide_sex          << " ";
-  fp << mate_select_id      << " ";
-  fp << cross_num           << " ";
-  fp << child_fertile       << " ";
-  fp << last_child_fertile  << " ";
-
-  fp << endl;
-  return true;
-}
-
-
-bool cPhenotype::LoadState(ifstream & fp)
-{
-  double tmp_merit;
-  assert(fp.good());
-  if( !fp.good() ) return false;
-
-  fp >> tmp_merit;  merit = tmp_merit;
-  fp >> genome_length;
-  fp >> copied_size;
-  fp >> executed_size;
-  fp >> gestation_time;
-  fp >> gestation_start;
-  fp >> fitness;
-  fp >> div_type;
-
-  fp >> cur_bonus;
-  fp >> cur_num_errors;
-  fp >> cur_num_donates;
-
-  for (int i = 0; i < cur_task_count.GetSize(); i++) {
-    fp >> cur_task_count[i];
-  }
-  for (int i = 0; i < cur_reaction_count.GetSize(); i++) {
-    fp >> cur_reaction_count[i];
-  }
-  for (int i = 0; i < cur_inst_count.GetSize(); i++) {
-    fp >> cur_inst_count[i];
-  }
-
-  fp >> last_merit_base;
-  fp >> last_bonus;
-  fp >> last_num_errors;
-  fp >> last_num_donates;
-  for (int i = 0; i < last_task_count.GetSize(); i++) {
-    fp >> last_task_count[i];
-  }
-  for (int i = 0; i < last_reaction_count.GetSize(); i++) {
-    fp >> last_reaction_count[i];
-  }
-  for (int i = 0; i < last_inst_count.GetSize(); i++) {
-    fp >> last_inst_count[i];
-  }
-
-  fp >> num_divides;
-  fp >> generation;
-  fp >> cpu_cycles_used;
-  fp >> time_used;
-  fp >> age;
-  fp >> neutral_metric;
-  fp >> life_fitness;
-
-  fp >> is_injected;
-  fp >> is_donor_last;
-  fp >> is_donor_cur;
-  fp >> is_donor_rand_last;
-  fp >> is_donor_rand;
-  fp >> is_donor_null_last;
-  fp >> is_donor_null;
-  fp >> is_donor_kin_last;
-  fp >> is_donor_kin;
-  fp >> is_donor_edit_last;
-  fp >> is_donor_edit;
-  fp >> is_donor_gbg_last;
-  fp >> is_donor_gbg;
-  fp >> is_donor_truegb_last;
-  fp >> is_donor_truegb;
-  fp >> is_donor_threshgb_last;
-  fp >> is_donor_threshgb;
-  fp >> is_donor_quanta_threshgb_last;
-  fp >> is_donor_quanta_threshgb;
-  fp >> num_thresh_gb_donations_last;
-  fp >> num_thresh_gb_donations;
-  fp >> num_quanta_thresh_gb_donations_last;
-  fp >> num_quanta_thresh_gb_donations;
-  fp >> is_receiver_last;
-  fp >> is_receiver;
-  fp >> is_receiver_rand;
-  fp >> is_receiver_kin;
-  fp >> is_receiver_kin_last;
-  fp >> is_receiver_edit;
-  fp >> is_receiver_edit_last;
-  fp >> is_receiver_gbg;
-  fp >> is_receiver_truegb_last;
-  fp >> is_receiver_truegb;
-  fp >> is_receiver_threshgb_last;
-  fp >> is_receiver_threshgb;
-  fp >> is_receiver_quanta_threshgb_last;
-  fp >> is_receiver_quanta_threshgb;
-  fp >> is_modifier;
-  fp >> is_modified;
-  fp >> is_fertile;
-  fp >> is_mutated;
-  fp >> parent_true;
-  fp >> parent_sex;
-  fp >> parent_cross_num;
-
-  fp >> copy_true;
-  fp >> divide_sex;
-  fp >> mate_select_id;
-  fp >> cross_num;
-  fp >> child_fertile;
-  fp >> last_child_fertile;
-
-  return true;
-}
-
 void cPhenotype::PrintStatus(ostream& fp) const
 {
   fp << "  MeritBase:"

Modified: branches/movement/source/main/cPhenotype.h
===================================================================
--- branches/movement/source/main/cPhenotype.h	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/main/cPhenotype.h	2008-08-27 13:22:23 UTC (rev 2762)
@@ -86,6 +86,7 @@
 
 class cPhenotype
 {
+  friend class cOrganism;
 private:
   cWorld* m_world;
   bool initialized;
@@ -231,12 +232,20 @@
   // 7. Information that is set once (when organism was born)
   double permanent_germline_propensity;
   
+
+  inline void SetInstSetSize(int inst_set_size);
+
+  
+  cPhenotype(cWorld* world);
+
+  
 public:
-  cPhenotype() { ; } // @not_implemented
-  cPhenotype(cWorld* world);
+  cPhenotype() : m_world(NULL) { ; } // Will not construct a valid cPhenotype! Only exists to support incorrect cDeme tArray usage.
+
   cPhenotype(const cPhenotype&); 
   cPhenotype& operator=(const cPhenotype&); 
   ~cPhenotype();
+  
 
   bool OK();
 
@@ -263,8 +272,6 @@
                   tArray<int>& insts_triggered);
 
   // State saving and loading, and printing...
-  bool SaveState(std::ofstream& fp);
-  bool LoadState(std::ifstream & fp);
   void PrintStatus(std::ostream& fp) const;
 
   // Some useful methods...
@@ -520,15 +527,10 @@
 };
 
 
-#ifdef ENABLE_UNIT_TESTS
-namespace nPhenotype {
-  /**
-   * Run unit tests
-   *
-   * @param full Run full test suite; if false, just the fast tests.
-   **/
-  void UnitTests(bool full = false);
+inline void cPhenotype::SetInstSetSize(int inst_set_size)
+{
+  cur_inst_count.Resize(inst_set_size, 0);
+  last_inst_count.Resize(inst_set_size, 0);
 }
-#endif  
 
 #endif

Modified: branches/movement/source/main/cTaskLib.cc
===================================================================
--- branches/movement/source/main/cTaskLib.cc	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/main/cTaskLib.cc	2008-08-27 13:22:23 UTC (rev 2762)
@@ -49,6 +49,11 @@
 # define log2(x) (log(x)/log(2.0))
 #endif
 
+// Various workarounds for FreeBSD
+#if AVIDA_PLATFORM(FREEBSD)
+# define log2(x) (log(x)/log(2.0))
+#endif
+
 static const double dCastPrecision = 100000.0;
 
 

Modified: branches/movement/source/platform/platform.h
===================================================================
--- branches/movement/source/platform/platform.h	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/platform/platform.h	2008-08-27 13:22:23 UTC (rev 2762)
@@ -39,11 +39,15 @@
 # pragma warning( disable : 4355 )
 #endif
 
-#if defined(__APPLE__) || defined(unix) || defined(__unix) || defined(__unix__) || defined (__NetBSD__) || defined(_AIX)
+#if defined(__APPLE__) || defined(unix) || defined(__unix) || defined(__unix__) || defined (__NetBSD__) || defined(_AIX) || defined(__FreeBSD__)
 # define AVIDA_PLATFORM_UNIX 1
 # define AVIDA_PLATFORM_THREADS 1
 #endif
 
+#if defined(__FreeBSD__)
+# define AVIDA_PLATFORM_FREEBSD 1
+#endif
+
 #if defined(__APPLE__)
 # define AVIDA_PLATFORM_APPLE 1
 #endif

Modified: branches/movement/source/tools/cDataFileManager.cc
===================================================================
--- branches/movement/source/tools/cDataFileManager.cc	2008-08-27 07:28:06 UTC (rev 2761)
+++ branches/movement/source/tools/cDataFileManager.cc	2008-08-27 13:22:23 UTC (rev 2762)
@@ -96,7 +96,11 @@
     if (d == -1) break;
     
     // If directory name is not null
-    if (d - i > 0) cTools::MkDir(dir_prefix + target.Substring(0, d - i), false);
+    if (d - i > 0) {
+      cString dir = target.Substring(i, d - i);
+      // Create if  that this directory is not a relative path component
+      if (dir.GetSize() > 2 || (dir != "." && dir != "..")) cTools::MkDir(dir_prefix + target.Substring(0, d), false);
+    }
     
     // Adjust next directory name starting point
     i = d + 1;




More information about the Avida-cvs mailing list