[Avida-SVN] r1143 - in development/source: . main

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Wed Dec 13 15:54:42 PST 2006


Author: brysonda
Date: 2006-12-13 18:54:42 -0500 (Wed, 13 Dec 2006)
New Revision: 1143

Modified:
   development/source/defs.h
   development/source/main/avida.cc
   development/source/main/cEnvReqs.h
   development/source/main/cEnvironment.cc
   development/source/main/cEnvironment.h
   development/source/main/cOrganism.cc
Log:
Adjust output buffer sizing behavior to be configurable via an envreq.  Set the default to 1, as nothing currently uses more then that.  Sorting will, however.

Modified: development/source/defs.h
===================================================================
--- development/source/defs.h	2006-12-13 21:12:32 UTC (rev 1142)
+++ development/source/defs.h	2006-12-13 23:54:42 UTC (rev 1143)
@@ -34,9 +34,6 @@
 #ifndef SMT_FULLY_ASSOCIATIVE
 #define SMT_FULLY_ASSOCIATIVE 1
 #endif
-#ifndef WRITE_PROTECTION
-#define WRITE_PROTECTION 1
-#endif
 #ifndef FATAL_ERRORS
 #define FATAL_ERRORS 0
 #endif
@@ -94,7 +91,7 @@
 
 // Number of distinct input and outputs stored in the IOBufs (to test tasks)
 const int INPUT_SIZE_DEFAULT = 3;
-const int OUTPUT_BUF_SIZE = 10;
+const int OUTPUT_SIZE_DEFAULT = 1;
 #define RECEIVED_MESSAGES_SIZE 10
 const int MARKET_SIZE = 10000;
 

Modified: development/source/main/avida.cc
===================================================================
--- development/source/main/avida.cc	2006-12-13 21:12:32 UTC (rev 1142)
+++ development/source/main/avida.cc	2006-12-13 23:54:42 UTC (rev 1143)
@@ -55,9 +55,6 @@
 #if CLASSIC_FULLY_ASSOCIATIVE
   version += " c_fa";
 #endif
-#if WRITE_PROTECTION
-  version += " wp";
-#endif
 #ifdef ENABLE_UNIT_TESTS
   version += " ut";
 #endif

Modified: development/source/main/cEnvReqs.h
===================================================================
--- development/source/main/cEnvReqs.h	2006-12-13 21:12:32 UTC (rev 1142)
+++ development/source/main/cEnvReqs.h	2006-12-13 23:54:42 UTC (rev 1143)
@@ -14,13 +14,16 @@
 {
 private:
   int m_min_inputs;
+  int m_min_outputs;
 
 
 public:
-  cEnvReqs() : m_min_inputs(0) { ; }
+  cEnvReqs() : m_min_inputs(0), m_min_outputs(0) { ; }
   
   int GetMinInputs() { return m_min_inputs; }
   void SetMinInputs(int v) { m_min_inputs = v; }
+  int GetMinOutputs() { return m_min_outputs; }
+  void SetMinOutputs(int v) { m_min_outputs = v; }
 };
 
 #endif

Modified: development/source/main/cEnvironment.cc
===================================================================
--- development/source/main/cEnvironment.cc	2006-12-13 21:12:32 UTC (rev 1142)
+++ development/source/main/cEnvironment.cc	2006-12-13 23:54:42 UTC (rev 1143)
@@ -539,6 +539,7 @@
   
   // Process the environment requirements of this task
   if (envreqs.GetMinInputs() > m_input_size) m_input_size = envreqs.GetMinInputs();
+  if (envreqs.GetMinOutputs() > m_output_size) m_output_size = envreqs.GetMinOutputs();
   
   return true;
 }
@@ -745,7 +746,7 @@
 
 
 bool cEnvironment::TestInput(cReactionResult& result, const tBuffer<int>& inputs,
-                             const tBuffer<int>& outputs, const tArray<double>& resource_count ) const
+                             const tBuffer<int>& outputs, const tArray<double>& resource_count) const
 {
   // @CAO nothing for the moment...
   return false;
@@ -753,9 +754,8 @@
 
 
 bool cEnvironment::TestOutput(cAvidaContext& ctx, cReactionResult& result,
-	      cTaskContext& taskctx,
-              const tArray<int>& task_count, const tArray<int>& reaction_count,
-	      const tArray<double>& resource_count) const
+                              cTaskContext& taskctx, const tArray<int>& task_count,
+                              const tArray<int>& reaction_count, const tArray<double>& resource_count) const
 {
   // Do setup for reaction tests...
   m_tasklib.SetupTests(taskctx);
@@ -811,11 +811,9 @@
   // (unless this is a check upon dividing, in which case we want the default to be to not check the task
   // and only if the requisite has been added to check it
   if (num_reqs == 0) {
-	  if (on_divide)
-		  return false;
-	  else
-		return true;
+	  return !on_divide;
   }
+  
   tLWConstListIterator<cReactionRequisite> req_it(req_list);
   for (int i = 0; i < num_reqs; i++) {
     // See if this requisite batch can be satisfied.
@@ -852,9 +850,9 @@
     // if 2 we check always
     if (task_count >= cur_req->GetMaxTaskCount()) continue;
 
-	int div_type = cur_req->GetDivideOnly();
-	if (div_type == 1 && on_divide == false) continue;
-	if (div_type == 0 && on_divide) continue;
+    int div_type = cur_req->GetDivideOnly();
+    if (div_type == 1 && !on_divide) continue;
+    if (div_type == 0 && on_divide) continue;
     
     return true;
   }

Modified: development/source/main/cEnvironment.h
===================================================================
--- development/source/main/cEnvironment.h	2006-12-13 21:12:32 UTC (rev 1142)
+++ development/source/main/cEnvironment.h	2006-12-13 23:54:42 UTC (rev 1143)
@@ -72,6 +72,7 @@
   cMutationRates mut_rates;
 
   int m_input_size;
+  int m_output_size;
   
   
   static bool ParseSetting(cString entry, cString& var_name, cString& var_value, const cString& var_type);
@@ -98,8 +99,8 @@
   cEnvironment& operator=(const cEnvironment&); // @not_implemented
 
 public:
-  cEnvironment(cWorld* world) : m_world(world), m_tasklib(world), inst_set(world), m_input_size(INPUT_SIZE_DEFAULT) { mut_rates.Setup(world); }
-  ~cEnvironment() { ; }
+  inline cEnvironment(cWorld* world);
+  inline ~cEnvironment() { ; }
 
   bool Load(const cString& filename);  // Reads the environment from disk.
   bool LoadLine(cString line);  // Reads in a single environment configuration line
@@ -126,6 +127,7 @@
   cMutationRates& GetMutRates() { return mut_rates; }
   
   int GetInputSize() { return m_input_size; }
+  int GetOutputSize() { return m_input_size; }
 
   double GetReactionValue(int& reaction_id);
   bool SetReactionValue(cAvidaContext& ctx, const cString& name, double value);
@@ -133,7 +135,18 @@
   bool SetReactionInst(const cString& name, cString inst_name);
 };
 
+inline cEnvironment::cEnvironment(cWorld* world)
+  : m_world(world)
+  , m_tasklib(world)
+  , inst_set(world)
+  , m_input_size(INPUT_SIZE_DEFAULT)
+  , m_output_size(OUTPUT_SIZE_DEFAULT)
+{
+  mut_rates.Setup(world);
+}
 
+
+
 #ifdef ENABLE_UNIT_TESTS
 namespace nEnvironment {
   /**

Modified: development/source/main/cOrganism.cc
===================================================================
--- development/source/main/cOrganism.cc	2006-12-13 21:12:32 UTC (rev 1142)
+++ development/source/main/cOrganism.cc	2006-12-13 23:54:42 UTC (rev 1143)
@@ -45,7 +45,7 @@
   , m_lineage(NULL)
   , m_input_pointer(0)
   , m_input_buf(world->GetEnvironment().GetInputSize())
-  , m_output_buf(OUTPUT_BUF_SIZE)
+  , m_output_buf(world->GetEnvironment().GetOutputSize())
   , m_received_messages(RECEIVED_MESSAGES_SIZE)
   , m_sent_value(0)
   , m_sent_active(false)
@@ -196,7 +196,7 @@
 
   for (int i = 0; i < insts_triggered.GetSize(); i++) {
     const int cur_inst = insts_triggered[i];
-    m_hardware->ProcessBonusInst(ctx, cInstruction(cur_inst) );
+    m_hardware->ProcessBonusInst(ctx, cInstruction(cur_inst));
   }
 }
 




More information about the Avida-cvs mailing list