[Avida-cvs] [Avida2-svn] r356 - in branches/brysonda: Avida2.xcodeproj source/main

brysonda@myxo.css.msu.edu brysonda at myxo.css.msu.edu
Fri Oct 21 11:13:24 PDT 2005


Author: brysonda
Date: 2005-10-21 14:13:24 -0400 (Fri, 21 Oct 2005)
New Revision: 356

Modified:
   branches/brysonda/Avida2.xcodeproj/project.pbxproj
   branches/brysonda/source/main/cAnalyze.cc
   branches/brysonda/source/main/cAnalyze.h
   branches/brysonda/source/main/cAnalyzeGenotype.cc
   branches/brysonda/source/main/cAnalyzeGenotype.h
   branches/brysonda/source/main/cAvidaDriver_Analyze.cc
   branches/brysonda/source/main/cAvidaDriver_Analyze.h
   branches/brysonda/source/main/cFitnessMatrix.cc
   branches/brysonda/source/main/cFitnessMatrix.h
   branches/brysonda/source/main/cMxCodeArray.cc
   branches/brysonda/source/main/cMxCodeArray.h
   branches/brysonda/source/main/cWorld.cc
   branches/brysonda/source/main/primitive.cc
Log:
In theory, analyze mode should now work again

Modified: branches/brysonda/Avida2.xcodeproj/project.pbxproj
===================================================================
--- branches/brysonda/Avida2.xcodeproj/project.pbxproj	2005-10-20 04:37:15 UTC (rev 355)
+++ branches/brysonda/Avida2.xcodeproj/project.pbxproj	2005-10-21 18:13:24 UTC (rev 356)
@@ -50,6 +50,10 @@
 		7040CF1E0906A52E00AA820F /* cEventManager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7040CF1A0906A52E00AA820F /* cEventManager.cc */; };
 		7040CF1F0906A52E00AA820F /* cEventManager.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7040CF1B0906A52E00AA820F /* cEventManager.h */; };
 		7040D22509071EE000AA820F /* cAnalyzeUtil.cc in Sources */ = {isa = PBXBuildFile; fileRef = 702D4F3E08DA61FE007BA469 /* cAnalyzeUtil.cc */; };
+		7040D36C09095E4E00AA820F /* cAnalyze.cc in Sources */ = {isa = PBXBuildFile; fileRef = 702D4F3C08DA61FE007BA469 /* cAnalyze.cc */; };
+		7040D36D09095E5200AA820F /* cAnalyzeGenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = 702D4F3D08DA61FE007BA469 /* cAnalyzeGenotype.cc */; };
+		7040D36E09095E5900AA820F /* cAvidaDriver_Analyze.cc in Sources */ = {isa = PBXBuildFile; fileRef = 702D4EF908DA5341007BA469 /* cAvidaDriver_Analyze.cc */; };
+		7040D3A6090964D100AA820F /* cMxCodeArray.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865808F4974300FC65FE /* cMxCodeArray.cc */; };
 		70486BA00826722F009328F0 /* analyze.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = DCC3114B0762539E008F7A48 /* analyze.cfg */; };
 		70486BA10826722F009328F0 /* environment.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = DCC311800762539F008F7A48 /* environment.cfg */; };
 		70486BA20826722F009328F0 /* events.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = DCC311810762539F008F7A48 /* events.cfg */; };
@@ -2297,6 +2301,10 @@
 				70C5BD6B0905CE5F0028A785 /* cHardwareManager.cc in Sources */,
 				7040CF1C0906A52E00AA820F /* cEventManager.cc in Sources */,
 				7040D22509071EE000AA820F /* cAnalyzeUtil.cc in Sources */,
+				7040D36C09095E4E00AA820F /* cAnalyze.cc in Sources */,
+				7040D36D09095E5200AA820F /* cAnalyzeGenotype.cc in Sources */,
+				7040D36E09095E5900AA820F /* cAvidaDriver_Analyze.cc in Sources */,
+				7040D3A6090964D100AA820F /* cMxCodeArray.cc in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: branches/brysonda/source/main/cAnalyze.cc
===================================================================
--- branches/brysonda/source/main/cAnalyze.cc	2005-10-20 04:37:15 UTC (rev 355)
+++ branches/brysonda/source/main/cAnalyze.cc	2005-10-21 18:13:24 UTC (rev 356)
@@ -20,12 +20,12 @@
 #include "cAnalyzeFlowCommandDef.h"
 #include "cAnalyzeFunction.h"
 #include "cAnalyzeGenotype.h"
-#include "cConfig.h"
 #include "cDataFile.h"
 #include "cEnvironment.h"
 #include "cFitnessMatrix.h"
 #include "cGenomeUtil.h"
 #include "cHardwareBase.h"
+#include "cHardwareManager.h"
 #include "cHardwareStatusPrinter.h"
 #include "cHelpManager.h"
 #include "cInitFile.h"
@@ -44,6 +44,7 @@
 #include "cTestUtil.h"
 #include "cResource.h"
 #include "tHashTable.h"
+#include "cWorld.h"
 #ifdef WIN32
 #  include "win32_mkdir_hack.hh"
 #endif
@@ -59,15 +60,16 @@
 //  cAnalyze
 //////////////
 
-cAnalyze::cAnalyze(cString filename, cEnvironment *environment)
+cAnalyze::cAnalyze(cWorld* world)
 : cur_batch(0)
-, d_environment(environment)
+, m_world(world)
+, inst_set(world->GetHardwareManager().GetInstSet())
 , verbose(false)
 , interactive_depth(0)
-// DDD - , inst_set(cHardwareUtil::DefaultInstSet(cConfig::GetInstFilename()))
 {
-  random.ResetSeed(cConfig::GetRandSeed());
   
+  random.ResetSeed(m_world->GetConfig().RANDOM_SEED.Get());
+  
   for (int i = 0; i < MAX_BATCHES; i++) {
     batch[i].Name().Set("Batch%d", i);
   }
@@ -77,8 +79,8 @@
   // be changed if LOAD_RESOURCES analyze command is called.  If there is
   // no resources in the environment or there is no environment, the list
   // is empty and will cause an assert to be thrown in FindResource function.
-  const cResourceLib &resource_lib = environment->GetResourceLib();
-  if(environment != NULL && resource_lib.GetSize() > 0) {
+  const cResourceLib &resource_lib = m_world->GetEnvironment().GetResourceLib();
+  if(resource_lib.GetSize() > 0) {
     vector<double> r;
     for(int i=0; i<resource_lib.GetSize(); i++) {
       cResource *resource = resource_lib.GetResource(i);
@@ -89,7 +91,7 @@
   }
   FillResources(0);
   
-  cInitFile analyze_file(filename);
+  cInitFile analyze_file(m_world->GetConfig().ANALYZE_FILE.Get());
   analyze_file.Load();
   analyze_file.Compress();
   analyze_file.Close();
@@ -123,7 +125,7 @@
   cGenome genome( cInstUtil::LoadGenome(filename, inst_set) );
   
   // Construct the new genotype..
-  cAnalyzeGenotype * genotype = new cAnalyzeGenotype(genome, inst_set);
+  cAnalyzeGenotype * genotype = new cAnalyzeGenotype(m_world, genome, inst_set);
   
   // Determine the organism's original name -- strip off directory...
   while (filename.Find('/') != -1) filename.Pop('/');
@@ -162,8 +164,7 @@
     cString cur_line = input_file.GetLine(line_id);
     
     // Setup the genotype for this line...
-    cAnalyzeGenotype * genotype =
-      new cAnalyzeGenotype(cur_line.PopWord(), inst_set);
+    cAnalyzeGenotype * genotype = new cAnalyzeGenotype(m_world, cur_line.PopWord(), inst_set);
     int num_cpus = cur_line.PopWord().AsInt();
     int id_num = cur_line.PopWord().AsInt();
     cString name = cStringUtil::Stringf("org-%d", id_num);
@@ -220,8 +221,7 @@
     int depth       = cur_line.PopWord().AsInt();
     cString name = cStringUtil::Stringf("org-%d", id_num);
     
-    cAnalyzeGenotype * genotype =
-      new cAnalyzeGenotype(cur_line.PopWord(), inst_set);
+    cAnalyzeGenotype * genotype = new cAnalyzeGenotype(m_world, cur_line.PopWord(), inst_set);
     
     genotype->SetID(id_num);
     genotype->SetParentID(parent_id);
@@ -314,8 +314,7 @@
       int depth       = cur_line.PopWord().AsInt();
       cString name = cStringUtil::Stringf("org-%d", id_num);
       
-      cAnalyzeGenotype * genotype =
-        new cAnalyzeGenotype(cur_line.PopWord(), inst_set);
+      cAnalyzeGenotype * genotype = new cAnalyzeGenotype(m_world, cur_line.PopWord(), inst_set);
       
       genotype->SetID(id_num);
       genotype->SetParentID(parent_id);
@@ -354,7 +353,7 @@
   cout << "Loading: " << sequence << endl;
   
   // Setup the genotype...
-  cAnalyzeGenotype * genotype = new cAnalyzeGenotype(sequence, inst_set);
+  cAnalyzeGenotype * genotype = new cAnalyzeGenotype(m_world, sequence, inst_set);
   
   genotype->SetNumCPUs(1);      // Initialize to a single organism.
   if (seq_name == "") {
@@ -467,17 +466,6 @@
   }
   if(which < 0) { assert(0); }
   
-  //cResourceLib &resLib = environment.GetResourceLib();
-  // The resources from the file and the original resources from
-  // environment.cfg must be the same size.
-  //assert((unsigned int)resLib.GetSize() == resources[which].second.size());
-  // Set the resource concentrations to the values for the appropriate
-  // update
-  //for(unsigned int i=0; i<resources[which].second.size(); i++) {
-  //  cResource *res = resLib.GetResource(i);
-  //  assert(res);
-  //  res->SetInitial(resources[which].second[i]);
-  //}
   
 tArray<double> temp(resources[which].second.size());
 for(unsigned int i=0; i<resources[which].second.size(); i++) {
@@ -514,7 +502,7 @@
     // Test fitness of each mutant.
     for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) {
       mod_genome[line_no].SetOp(mod_inst);
-      cAnalyzeGenotype test_genotype(mod_genome, inst_set);
+      cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
       test_genotype.Recalculate();
       // Ajust fitness ...
       if (test_genotype.GetFitness() <= base_fitness) {
@@ -590,7 +578,7 @@
     // Test fitness of each mutant.
     for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) {
       mod_genome[line_no].SetOp(mod_inst);
-      cAnalyzeGenotype test_genotype(mod_genome, inst_set);
+      cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
       test_genotype.Recalculate();
       test_fitness[mod_inst] = test_genotype.GetFitness();
     }
@@ -687,7 +675,7 @@
     // Test fitness of each mutant.
     for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) {
       genotype1_mod_genome[line_no].SetOp(mod_inst);
-      cAnalyzeGenotype test_genotype(genotype1_mod_genome, inst_set);
+      cAnalyzeGenotype test_genotype(m_world, genotype1_mod_genome, inst_set);
       test_genotype.Recalculate();
       // Ajust fitness ...
       if (test_genotype.GetFitness() <= genotype1_base_fitness) {
@@ -756,7 +744,7 @@
     // Test fitness of each mutant.
     for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) {
       genotype2_mod_genome[line_no].SetOp(mod_inst);
-      cAnalyzeGenotype test_genotype(genotype2_mod_genome, inst_set);
+      cAnalyzeGenotype test_genotype(m_world, genotype2_mod_genome, inst_set);
       test_genotype.Recalculate();
       // Ajust fitness ...
       if (test_genotype.GetFitness() <= genotype2_base_fitness) {
@@ -857,8 +845,7 @@
   for (int line_id = 0; line_id < input_file.GetNumLines(); line_id++) {
     cString cur_line = input_file.GetLine(line_id);
     
-    cAnalyzeGenotype * genotype =
-      new cAnalyzeGenotype(default_genome, inst_set);
+    cAnalyzeGenotype * genotype = new cAnalyzeGenotype(m_world, default_genome, inst_set);
     
     output_it.Reset();
     tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
@@ -2719,7 +2706,7 @@
 	int given_inst = given_genome[line].GetOp();
 	mod_genome = base_genome;
 	mod_genome[line].SetOp(given_inst);
-	cAnalyzeGenotype test_genotype(mod_genome, inst_set);
+	cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
 	test_genotype.Recalculate();
 
 	// Only when given inst make the genotype alive
@@ -2757,7 +2744,7 @@
       
       for (int mod_inst = 0; mod_inst < num_insts; ++ mod_inst) {
 	mod_genome[line].SetOp(mod_inst);
-	cAnalyzeGenotype test_genotype(mod_genome, inst_set);
+	cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
 	test_genotype.Recalculate();
 	if (test_genotype.GetFitness() >= base_fitness) {
 	  neutral_mut[line][mod_inst] = true;
@@ -3062,7 +3049,7 @@
 
       for (int mod_inst = 0; mod_inst < num_insts; ++ mod_inst) {
 	mod_genome[line].SetOp(mod_inst);
-	cAnalyzeGenotype test_genotype(mod_genome, inst_set);
+	cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
 	test_genotype.Recalculate();
 	if (test_genotype.GetFitness() >= base_fitness) {
 	  prob[line][mod_inst] = 1.0;
@@ -3539,7 +3526,7 @@
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   cAnalyzeGenotype * genotype = batch_it.Next();
   
-  cFitnessMatrix matrix( genotype->GetGenome(), &inst_set);
+  cFitnessMatrix matrix(m_world, genotype->GetGenome(), &inst_set);
   
   matrix.CalcFitnessMatrix( depth_limit, fitness_threshold_ratio, ham_thresh, error_rate_min, error_rate_max, error_rate_step, vect_fmax, vect_fstep, diag_iters, write_ham_vector, write_full_vector );
 }
@@ -3708,7 +3695,7 @@
       // The base creature...
       fp << "<tr><th colspan=3>Base Creature";
       tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
-      cAnalyzeGenotype null_genotype("a", inst_set);
+      cAnalyzeGenotype null_genotype(m_world, "a", inst_set);
       while ((data_command = output_it.Next()) != NULL) {
         data_command->SetTarget(genotype);
         genotype->SetSpecialArgs(data_command->GetArgs());
@@ -3760,7 +3747,7 @@
       char cur_symbol = base_genome[line_num].GetSymbol();
       
       mod_genome[line_num] = null_inst;
-      cAnalyzeGenotype test_genotype(mod_genome, map_inst_set);
+      cAnalyzeGenotype test_genotype(m_world, mod_genome, map_inst_set);
       test_genotype.Recalculate();
       
       if (file_type == FILE_TYPE_HTML) fp << "<tr><td align=right>";
@@ -4017,8 +4004,8 @@
           int cur_inst = base_genome[line_num].GetOp();
           
           mod_genome[line_num] = null_inst;
-          cAnalyzeGenotype test_genotype(mod_genome, map_inst_set);
-          cAnalyzeGenotype old_genotype(base_genome, map_inst_set);
+          cAnalyzeGenotype test_genotype(m_world, mod_genome, map_inst_set);
+          cAnalyzeGenotype old_genotype(m_world, base_genome, map_inst_set);
           test_genotype.Recalculate();
           
           // Print the individual columns...
@@ -4351,7 +4338,7 @@
         }
         else {
           mod_genome[line_num].SetOp(mod_inst);
-          cAnalyzeGenotype test_genotype(mod_genome, inst_set);
+          cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
           test_genotype.Recalculate();
           const double test_fitness = test_genotype.GetFitness() / base_fitness;
           row_fitness += test_fitness;
@@ -4387,7 +4374,7 @@
       
       // Column: Knockout
       mod_genome[line_num] = null_inst;
-      cAnalyzeGenotype test_genotype(mod_genome, map_inst_set);
+      cAnalyzeGenotype test_genotype(m_world, mod_genome, map_inst_set);
       test_genotype.Recalculate();
       const double test_fitness = test_genotype.GetFitness() / base_fitness;
       col_fitness[num_insts] += test_fitness;
@@ -4837,8 +4824,8 @@
           test_genome0.Replace(start0, size0, cross1);
         }
         
-        cAnalyzeGenotype * new_genotype0 = new cAnalyzeGenotype(test_genome0, inst_set); 
-        cAnalyzeGenotype * new_genotype1 = new cAnalyzeGenotype(test_genome1, inst_set); 
+        cAnalyzeGenotype * new_genotype0 = new cAnalyzeGenotype(m_world, test_genome0, inst_set); 
+        cAnalyzeGenotype * new_genotype1 = new cAnalyzeGenotype(m_world, test_genome1, inst_set); 
         new_genotype0->SetNumCPUs(1); 
         new_genotype1->SetNumCPUs(1); 
         new_genotype0->SetID(0);
@@ -5371,7 +5358,7 @@
     // Output the results...
     
     for (int i = 0; i <= total_diffs; i++) {
-      cAnalyzeGenotype max_genotype(max_sequence[i], inst_set);
+      cAnalyzeGenotype max_genotype(m_world, max_sequence[i], inst_set);
       max_genotype.Recalculate();
       fp << i                                         << " "  //  1
         << test_count[i]                             << " "  //  2
@@ -5830,7 +5817,7 @@
       // Test fitness of each mutant.
       for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) {
         mod_genome[line_num].SetOp(mod_inst);
-        cAnalyzeGenotype test_genotype(mod_genome, inst_set);
+        cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
         test_genotype.Recalculate();
         test_fitness[mod_inst] = test_genotype.GetFitness();
       }

Modified: branches/brysonda/source/main/cAnalyze.h
===================================================================
--- branches/brysonda/source/main/cAnalyze.h	2005-10-20 04:37:15 UTC (rev 355)
+++ branches/brysonda/source/main/cAnalyze.h	2005-10-21 18:13:24 UTC (rev 356)
@@ -50,6 +50,7 @@
 template <class T> class tDataEntryCommand;
 template <class T> class tListIterator;
 class cEnvironment;
+class cWorld;
 
 class cAnalyze {
 private:
@@ -61,8 +62,10 @@
   cString variables[26];
   cString local_variables[26];
   cString arg_variables[10];
-  cEnvironment *d_environment;
 
+  cWorld* m_world;
+  cInstSet& inst_set;
+
   // This is the storage for the resource information from resource.dat.  It 
   // is a pair of the update and a vector of the resource concentrations
   std::vector<std::pair<int, std::vector<double> > > resources;
@@ -73,7 +76,6 @@
   cDataFileManager data_file_manager;
   tList< tDataEntryBase<cAnalyzeGenotype> > genotype_data_list;
 
-  cInstSet & inst_set;
   cRandom random;
 
 private:
@@ -242,7 +244,7 @@
   // disabled copy constructor.
   cAnalyze(const cAnalyze &);
 public:
-  cAnalyze(cString filename, cEnvironment* = NULL);
+  cAnalyze(cWorld* world);
   ~cAnalyze();
 
   void RunInteractive();

Modified: branches/brysonda/source/main/cAnalyzeGenotype.cc
===================================================================
--- branches/brysonda/source/main/cAnalyzeGenotype.cc	2005-10-20 04:37:15 UTC (rev 355)
+++ branches/brysonda/source/main/cAnalyzeGenotype.cc	2005-10-21 18:13:24 UTC (rev 356)
@@ -7,7 +7,6 @@
 
 #include "cAnalyzeGenotype.h"
 
-#include "cConfig.h"
 #include "cCPUTestInfo.h"
 #include "cInstSet.h"
 #include "cLandscape.h"
@@ -15,15 +14,18 @@
 #include "cPhenotype.h"
 #include "cTestCPU.h"
 #include "cEnvironment.h"
+#include "cHardwareManager.h"
+#include "cWorld.h"
+
 using namespace std;
 
 //////////////////////
 //  cAnalyzeGenotype
 //////////////////////
 
-cAnalyzeGenotype::cAnalyzeGenotype(cString symbol_string,
-				   cInstSet & in_inst_set)
-  : genome(symbol_string)
+cAnalyzeGenotype::cAnalyzeGenotype(cWorld* world, cString symbol_string, cInstSet& in_inst_set)
+  : m_world(world)
+  , genome(symbol_string)
   , inst_set(in_inst_set)
   , name("")
   , aligned_sequence("")
@@ -63,9 +65,9 @@
   }
 }
 
-cAnalyzeGenotype::cAnalyzeGenotype(const cGenome & _genome,
-				   cInstSet & in_inst_set)
-  : genome(_genome)
+cAnalyzeGenotype::cAnalyzeGenotype(cWorld* world, const cGenome& _genome, cInstSet& in_inst_set)
+  : m_world(world)
+  , genome(_genome)
   , inst_set(in_inst_set)
   , name("")
   , aligned_sequence("")
@@ -98,7 +100,8 @@
 }
 
 cAnalyzeGenotype::cAnalyzeGenotype(const cAnalyzeGenotype & _gen)
-  : genome(_gen.genome)
+  : m_world(_gen.m_world)
+  , genome(_gen.genome)
   , inst_set(_gen.inst_set)
   , name(_gen.name)
   , aligned_sequence(_gen.aligned_sequence)
@@ -142,7 +145,7 @@
 
 int cAnalyzeGenotype::CalcMaxGestation() const
 {
-  return cConfig::GetTestCPUTimeMod() * genome.GetSize();
+  return m_world->GetConfig().TEST_CPU_TIME_MOD.Get() * genome.GetSize();
 }
 
 void cAnalyzeGenotype::CalcLandscape() const
@@ -165,17 +168,19 @@
   test_info.TestThreads();
   // test_info.TraceTaskOrder();
 
+  // DDD - This does some 'interesting' things with the instruction set
+  
   // Use the inst lib for this genotype... and syncrhonize environment
-  cInstSet * inst_set_backup   = cTestCPU::GetInstSet();
+  cInstSet* inst_set_backup   = cTestCPU::GetInstSet();
   cTestCPU::SetInstSet(&inst_set);
-  cInstSet env_inst_set_backup = cTestCPU::GetEnvironment()->GetInstSet();
-  cTestCPU::GetEnvironment()->GetInstSet() = inst_set;
+  cInstSet env_inst_set_backup = m_world->GetHardwareManager().GetInstSet();
+  m_world->GetHardwareManager().GetInstSet() = inst_set;
 
   cTestCPU::TestGenome(test_info, genome);
   
   // Restore test CPU and environment instruction set
   cTestCPU::SetInstSet(inst_set_backup);
-  cTestCPU::GetEnvironment()->GetInstSet() = env_inst_set_backup;
+  m_world->GetHardwareManager().GetInstSet() = env_inst_set_backup;
 
   viable = test_info.IsViable();
 

Modified: branches/brysonda/source/main/cAnalyzeGenotype.h
===================================================================
--- branches/brysonda/source/main/cAnalyzeGenotype.h	2005-10-20 04:37:15 UTC (rev 355)
+++ branches/brysonda/source/main/cAnalyzeGenotype.h	2005-10-21 18:13:24 UTC (rev 356)
@@ -37,11 +37,13 @@
 template <class T> class tArray; // aggregate
 class cStringList; // aggregate
 class cStringUtil; // access
+class cWorld;
 
 class cAnalyzeGenotype {
 private:
+  cWorld* m_world;
   cGenome genome;            // Full Genome
-  cInstSet & inst_set;       // Instruction set used in this genome
+  cInstSet& 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
@@ -109,8 +111,8 @@
   int CalcMaxGestation() const;
   void CalcLandscape() const;
 public:
-  cAnalyzeGenotype(cString symbol_string, cInstSet & in_inst_set);
-  cAnalyzeGenotype(const cGenome & _genome, cInstSet & in_inst_set);
+  cAnalyzeGenotype(cWorld* world, cString symbol_string, cInstSet & in_inst_set);
+  cAnalyzeGenotype(cWorld* world, const cGenome & _genome, cInstSet & in_inst_set);
   cAnalyzeGenotype(const cAnalyzeGenotype & _gen);
   ~cAnalyzeGenotype();
 

Modified: branches/brysonda/source/main/cAvidaDriver_Analyze.cc
===================================================================
--- branches/brysonda/source/main/cAvidaDriver_Analyze.cc	2005-10-20 04:37:15 UTC (rev 355)
+++ branches/brysonda/source/main/cAvidaDriver_Analyze.cc	2005-10-21 18:13:24 UTC (rev 356)
@@ -25,8 +25,8 @@
 //  cAvidaDriver_Analyze
 //////////////////////////
 
-cAvidaDriver_Analyze::cAvidaDriver_Analyze(bool _interactive, cEnvironment *e)
-  : interactive(_interactive), d_environment(e)
+cAvidaDriver_Analyze::cAvidaDriver_Analyze(cWorld* world, bool _interactive)
+: interactive(_interactive), m_world(world)
 {
 }
 
@@ -37,8 +37,7 @@
 void cAvidaDriver_Analyze::Run()
 {
   cout << "In analyze mode!!" << endl;
-  // DDD - get analyze config file from cAvidaConfig
-  cAnalyze analyze("analyze.cfg", d_environment);
+  cAnalyze analyze(m_world);
   if (interactive == true) {
     analyze.RunInteractive();
   }

Modified: branches/brysonda/source/main/cAvidaDriver_Analyze.h
===================================================================
--- branches/brysonda/source/main/cAvidaDriver_Analyze.h	2005-10-20 04:37:15 UTC (rev 355)
+++ branches/brysonda/source/main/cAvidaDriver_Analyze.h	2005-10-21 18:13:24 UTC (rev 356)
@@ -14,14 +14,14 @@
 #include "cAvidaDriver_Base.h"
 #endif
 
-class cEnvironment;
+class cWorld;
 
 class cAvidaDriver_Analyze : public cAvidaDriver_Base {
 protected:
   bool interactive;
-  cEnvironment *d_environment;
+  cWorld* m_world;
 public:
-  cAvidaDriver_Analyze(bool _interactive=false, cEnvironment* = NULL);
+  cAvidaDriver_Analyze(cWorld* world, bool _interactive=false);
   virtual ~cAvidaDriver_Analyze();
   virtual void Run();
 };

Modified: branches/brysonda/source/main/cFitnessMatrix.cc
===================================================================
--- branches/brysonda/source/main/cFitnessMatrix.cc	2005-10-20 04:37:15 UTC (rev 355)
+++ branches/brysonda/source/main/cFitnessMatrix.cc	2005-10-21 18:13:24 UTC (rev 356)
@@ -16,8 +16,8 @@
 using namespace std;
 
 
-cFitnessMatrix::cFitnessMatrix( const cGenome & code,  cInstSet * inst_set)
-  :  m_start_genotype(code), m_inst_set( inst_set ), m_DFS_MaxDepth(0),
+cFitnessMatrix::cFitnessMatrix(cWorld* world, const cGenome& code,  cInstSet* inst_set)
+  :  m_world(world), m_start_genotype(m_world, code), m_inst_set( inst_set ), m_DFS_MaxDepth(0),
      m_DFS_NumRecorded(0)
 {
   m_start_genotype.SetNumInstructions( m_inst_set->GetSize());

Modified: branches/brysonda/source/main/cFitnessMatrix.h
===================================================================
--- branches/brysonda/source/main/cFitnessMatrix.h	2005-10-20 04:37:15 UTC (rev 355)
+++ branches/brysonda/source/main/cFitnessMatrix.h	2005-10-21 18:13:24 UTC (rev 356)
@@ -42,8 +42,11 @@
 class cGenome;
 class cInstSet;
 class MyCodeArrayLessThan;
+class cWorld;
+
 class cFitnessMatrix {
 private:
+  cWorld* m_world;
 
   /* genome data */
   cMxCodeArray m_start_genotype;
@@ -105,7 +108,7 @@
 
 
 public:
-  cFitnessMatrix(const cGenome &, cInstSet * inst_set);
+  cFitnessMatrix(cWorld* world, const cGenome&, cInstSet* inst_set);
   ~cFitnessMatrix();
 
   /**

Modified: branches/brysonda/source/main/cMxCodeArray.cc
===================================================================
--- branches/brysonda/source/main/cMxCodeArray.cc	2005-10-20 04:37:15 UTC (rev 355)
+++ branches/brysonda/source/main/cMxCodeArray.cc	2005-10-21 18:13:24 UTC (rev 356)
@@ -5,49 +5,24 @@
 // before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
 //////////////////////////////////////////////////////////////////////////////
 
-#ifndef MX_CODE_ARRAY_HH
 #include "cMxCodeArray.h"
-#endif
 
-#ifndef CONFIG_HH
-#include "cConfig.h"
-#endif
-#ifndef CPU_TEST_INFO_HH
 #include "cCPUTestInfo.h"
-#endif
-#ifndef GENOME_HH
 #include "cGenome.h"
-#endif
-#ifndef cInstSet_h
 #include "cInstSet.h"
-#endif
-#ifndef MY_CODE_ARRAY_LESS_THAN_HH
 #include "MyCodeArrayLessThan.h"
-#endif
-#ifndef ORGANISM_HH
 #include "cOrganism.h"
-#endif
-#ifndef TEST_CPU_HH
 #include "cTestCPU.h"
-#endif
-#ifndef TOOLS_HH
 #include "cTools.h"
-#endif
 
 #include <iomanip>
 
 using namespace std;
 
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-//  cMxCodeArray
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-
 const int cMxCodeArray::m_max_gestation_time = 1000000000;
 
 
-cMxCodeArray::cMxCodeArray()
+cMxCodeArray::cMxCodeArray(cWorld* world) : m_world(world)
 {
   // Initialize the code array as empty.
   size = 0;
@@ -58,7 +33,8 @@
   m_num_instructions = 0;
 }
 
-cMxCodeArray::cMxCodeArray(int n_inst, int in_size, int in_max_size) :m_merit(0), m_gestation_time(m_max_gestation_time), m_num_instructions(n_inst)
+cMxCodeArray::cMxCodeArray(cWorld* world, int n_inst, int in_size, int in_max_size)
+: m_world(world), m_merit(0), m_gestation_time(m_max_gestation_time), m_num_instructions(n_inst)
 {  
   assert (in_max_size == 0 || in_max_size >= in_size);
 
@@ -71,14 +47,14 @@
 
   for (int i = 0; i < size; i++)
     {
-      data[i].SetOp(g_random.GetUInt(cConfig::GetNumInstructions()));
+      data[i].SetOp(g_random.GetUInt(m_world->GetNumInstructions()));
     }
 
 }
 
 cMxCodeArray::cMxCodeArray(const cMxCodeArray &in_code)
 {
-
+  m_world = in_code.m_world;
   size = in_code.size;
   max_size = in_code.max_size;
   m_merit = in_code.m_merit;
@@ -96,7 +72,8 @@
 }
 
 
-cMxCodeArray::cMxCodeArray(const cGenome &in_code, int in_max_size) :m_merit(0), m_gestation_time(m_max_gestation_time), m_num_instructions(0)
+cMxCodeArray::cMxCodeArray(cWorld* world, const cGenome &in_code, int in_max_size)
+: m_world(world), m_merit(0), m_gestation_time(m_max_gestation_time), m_num_instructions(0)
 {
   assert (in_max_size == 0 || in_max_size >= in_code.GetSize());
 
@@ -143,7 +120,7 @@
 
   // Fill in the un-filled-in bits...
   for (int i = size; i < new_size; i++) {
-    data[i].SetOp(g_random.GetUInt(cConfig::GetNumInstructions()));
+    data[i].SetOp(g_random.GetUInt(m_world->GetNumInstructions()));
   }
 
   size = new_size;
@@ -189,7 +166,7 @@
 void cMxCodeArray::Reset()
 {
   // Initialze the array
-  if( cConfig::GetAllocMethod() == ALLOC_METHOD_RANDOM ){
+  if( m_world->GetConfig().ALLOC_METHOD.Get() == ALLOC_METHOD_RANDOM ){
     // Randomize the initial contents of the new array.
     Randomize();
   }else{
@@ -220,7 +197,7 @@
   int i;
   for (i = 0; i < size; i++)
     {
-      data[i].SetOp(g_random.GetUInt(cConfig::GetNumInstructions()));
+      data[i].SetOp(g_random.GetUInt(m_world->GetNumInstructions()));
     }
 }
 

Modified: branches/brysonda/source/main/cMxCodeArray.h
===================================================================
--- branches/brysonda/source/main/cMxCodeArray.h	2005-10-20 04:37:15 UTC (rev 355)
+++ branches/brysonda/source/main/cMxCodeArray.h	2005-10-21 18:13:24 UTC (rev 356)
@@ -30,8 +30,11 @@
 
 class cGenome;
 class MyCodeArrayLessThan;
+class cWorld;
+
 class cMxCodeArray {
 private:
+  cWorld* m_world;
   int size;
   int max_size;
   cInstruction * data;
@@ -42,11 +45,13 @@
   mutable std::map<int, double, std::less<int> > m_trans_probs;
 
 
+  cMxCodeArray();
+
 public:
-  cMxCodeArray();
-  explicit cMxCodeArray(int ninst, int in_size=0, int in_max_size=0);
+  cMxCodeArray(cWorld* world);
+  explicit cMxCodeArray(cWorld* world, int ninst, int in_size=0, int in_max_size=0);
   cMxCodeArray(const cMxCodeArray &in_code);
-  cMxCodeArray(const cGenome & in_code, int in_max_size=0);
+  cMxCodeArray(cWorld* world, const cGenome & in_code, int in_max_size=0);
   virtual ~cMxCodeArray();
 
   void operator=(const cMxCodeArray &other_code);

Modified: branches/brysonda/source/main/cWorld.cc
===================================================================
--- branches/brysonda/source/main/cWorld.cc	2005-10-20 04:37:15 UTC (rev 355)
+++ branches/brysonda/source/main/cWorld.cc	2005-10-21 18:13:24 UTC (rev 356)
@@ -58,8 +58,7 @@
   }
     
   // Setup the test CPUs.
-  int rSize = m_env->GetResourceLib().GetSize();
-  cTestCPU::Setup(this, rSize);
+  cTestCPU::Setup(this, m_env->GetResourceLib().GetSize());
 
   m_pop = new cPopulation(this);
 

Modified: branches/brysonda/source/main/primitive.cc
===================================================================
--- branches/brysonda/source/main/primitive.cc	2005-10-20 04:37:15 UTC (rev 355)
+++ branches/brysonda/source/main/primitive.cc	2005-10-21 18:13:24 UTC (rev 356)
@@ -10,7 +10,7 @@
 
 #include "avida.h"
 #include "cAvidaConfig.h"
-//#include "cAvidaDriver_Analyze.h"
+#include "cAvidaDriver_Analyze.h"
 #include "cAvidaDriver_Base.h"
 #include "cAvidaDriver_Population.h"
 #include "cWorld.h"
@@ -37,9 +37,8 @@
   cWorld* world = new cWorld(cAvidaConfig::LoadWithCmdLineArgs(argc, argv));
   
   if (world->GetConfig().ANALYZE_MODE.Get() > 0) {
-    //cAvidaDriver_Base::main_driver = new cAvidaDriver_Analyze((world->GetConfig().ANALYZE_MODE.Get() == 2), world);
-  }
-  else {
+    cAvidaDriver_Base::main_driver = new cAvidaDriver_Analyze(world, (world->GetConfig().ANALYZE_MODE.Get() == 2));
+  } else {
     cAvidaDriver_Base::main_driver = new cAvidaDriver_Population(world);
   }
 




More information about the Avida-cvs mailing list