[Avida-cvs] [avida-svn] r801 - in branches/developers/avida-edward/source: bindings/Boost.Python cpu

kaben@myxo.css.msu.edu kaben at myxo.css.msu.edu
Wed Jul 5 08:23:38 PDT 2006


Author: kaben
Date: 2006-07-05 11:23:38 -0400 (Wed, 05 Jul 2006)
New Revision: 801

Modified:
   branches/developers/avida-edward/source/bindings/Boost.Python/CMakeLists.txt
   branches/developers/avida-edward/source/bindings/Boost.Python/test_cpu.pyste
   branches/developers/avida-edward/source/cpu/cTestCPU.cc
   branches/developers/avida-edward/source/cpu/cTestCPU.h
Log:

Changes to support mutations in test cpu.



Modified: branches/developers/avida-edward/source/bindings/Boost.Python/CMakeLists.txt
===================================================================
--- branches/developers/avida-edward/source/bindings/Boost.Python/CMakeLists.txt	2006-07-05 15:10:46 UTC (rev 800)
+++ branches/developers/avida-edward/source/bindings/Boost.Python/CMakeLists.txt	2006-07-05 15:23:38 UTC (rev 801)
@@ -205,11 +205,11 @@
   test_cpu-fixups.cc
 )
 
-IF(AVD_PY_MONOLITHIC)
+IF(MINGW)
   ADD_LIBRARY(PyAvidaRepairHacks STATIC ${PyAvida_Extra_Cpp_Files})
-ELSE(AVD_PY_MONOLITHIC)
+ELSE(MINGW)
   ADD_LIBRARY(PyAvidaRepairHacks SHARED ${PyAvida_Extra_Cpp_Files})
-ENDIF(AVD_PY_MONOLITHIC)
+ENDIF(MINGW)
 TARGET_LINK_LIBRARIES(PyAvidaRepairHacks main cpu event main tools yaktest)
 
 STRING(REGEX REPLACE ";" ";-I;" PyAvida_Includes "${ALL_INC_DIRS}")

Modified: branches/developers/avida-edward/source/bindings/Boost.Python/test_cpu.pyste
===================================================================
--- branches/developers/avida-edward/source/bindings/Boost.Python/test_cpu.pyste	2006-07-05 15:10:46 UTC (rev 800)
+++ branches/developers/avida-edward/source/bindings/Boost.Python/test_cpu.pyste	2006-07-05 15:23:38 UTC (rev 801)
@@ -3,6 +3,7 @@
 Include("cEnvironment.h")
 Include("cGenome.h")
 Include("cInstSet.h")
+Include("cOrganism.h")
 Include("cPopulationInterface.h")
 Include("cResourceCount.h")
 
@@ -11,6 +12,7 @@
 set_policy(cTestCPU.GetEnvironment, return_value_policy(reference_existing_object))
 set_policy(cTestCPU.GetResources, return_value_policy(reference_existing_object))
 set_policy(cTestCPU.GetResourceCount, return_value_policy(reference_existing_object))
+set_policy(cTestCPU.SetupTestOrganism, return_value_policy(reference_existing_object))
 exclude(cTestCPU.UseResources)
 
 exclude(cTestCPU.UseResources)

Modified: branches/developers/avida-edward/source/cpu/cTestCPU.cc
===================================================================
--- branches/developers/avida-edward/source/cpu/cTestCPU.cc	2006-07-05 15:10:46 UTC (rev 800)
+++ branches/developers/avida-edward/source/cpu/cTestCPU.cc	2006-07-05 15:23:38 UTC (rev 801)
@@ -224,9 +224,22 @@
   return test_info.is_viable;
 }
 
-bool cTestCPU::TestGenome_Body(cCPUTestInfo & test_info,
-			       const cGenome & genome, int cur_depth)
+cOrganism & cTestCPU::SetupTestOrganism(cCPUTestInfo & test_info, const cGenome & genome, int cur_depth)
 {
+  if (cur_depth > test_info.max_depth) test_info.max_depth = cur_depth;
+
+  // Setup the organism we're working with now.
+  if (test_info.org_array[cur_depth] != NULL) {
+    delete test_info.org_array[cur_depth];
+  }
+  test_info.org_array[cur_depth] =
+    new cOrganism(genome, test_interface, *environment);
+  cOrganism & organism = *( test_info.org_array[cur_depth] );
+  return organism;
+}
+
+bool cTestCPU::TestGenome_Body(cCPUTestInfo & test_info, cOrganism & organism, const cGenome & genome, int cur_depth)
+{
   assert(initialized == true);
   assert(cur_depth < test_info.generation_tests);
 
@@ -253,13 +266,6 @@
 
   if (cur_depth > test_info.max_depth) test_info.max_depth = cur_depth;
 
-  // Setup the organism we're working with now.
-  if (test_info.org_array[cur_depth] != NULL) {
-    delete test_info.org_array[cur_depth];
-  }
-  test_info.org_array[cur_depth] =
-    new cOrganism(genome, test_interface, *environment);
-  cOrganism & organism = *( test_info.org_array[cur_depth] );
   organism.GetPhenotype().SetupInject(genome.GetSize());
 
   // Run the current organism.
@@ -312,6 +318,13 @@
 }
 
 
+bool cTestCPU::TestGenome_Body(cCPUTestInfo & test_info, const cGenome & genome, int cur_depth)
+{
+  cOrganism & organism = SetupTestOrganism(test_info, genome, cur_depth);
+  return TestGenome_Body(test_info, organism, genome, cur_depth);
+}
+
+
 void cTestCPU::TestThreads(const cGenome & genome)
 {
   assert(initialized == true);

Modified: branches/developers/avida-edward/source/cpu/cTestCPU.h
===================================================================
--- branches/developers/avida-edward/source/cpu/cTestCPU.h	2006-07-05 15:10:46 UTC (rev 800)
+++ branches/developers/avida-edward/source/cpu/cTestCPU.h	2006-07-05 15:23:38 UTC (rev 801)
@@ -28,6 +28,7 @@
 class cResourceCount;
 class cCPUTestInfo;
 class cGenome;
+class cOrganism;
 class cString; // aggregate
 
 class cTestCPU {
@@ -48,8 +49,10 @@
 
   static bool ProcessGestation(cCPUTestInfo & test_info, int cur_depth);
 
-  static bool TestGenome_Body(cCPUTestInfo & test_info, const cGenome & genome,
-			      int cur_depth);
+public:
+  static cOrganism & SetupTestOrganism(cCPUTestInfo & test_info, const cGenome & genome, int cur_depth);
+  static bool TestGenome_Body(cCPUTestInfo & test_info, cOrganism & organism, const cGenome & genome, int cur_depth);
+  static bool TestGenome_Body(cCPUTestInfo & test_info, const cGenome & genome, int cur_depth);
 
 public:
   static void Setup(cInstSet * in_inst_set,




More information about the Avida-cvs mailing list