[Avida-SVN] r1141 - in development: Avida.xcodeproj source source/cpu source/main source/targets/avida-viewer

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Tue Dec 12 20:46:37 PST 2006


Author: brysonda
Date: 2006-12-12 23:46:37 -0500 (Tue, 12 Dec 2006)
New Revision: 1141

Added:
   development/source/main/cEnvReqs.h
Modified:
   development/Avida.xcodeproj/project.pbxproj
   development/source/cpu/cHardwareCPU.cc
   development/source/cpu/nHardware.h
   development/source/defs.h
   development/source/main/cEnvironment.cc
   development/source/main/cEnvironment.h
   development/source/main/cOrganism.cc
   development/source/main/cPopulationCell.cc
   development/source/main/cPopulationCell.h
   development/source/main/cTaskEntry.h
   development/source/main/cTaskLib.cc
   development/source/main/cTaskLib.h
   development/source/targets/avida-viewer/cZoomScreen.cc
Log:
Added support for extensible input from the environment.  The task lib now takes a cEnvReqs object that allows for tasks to specify environment requirements.  The only entry in the object right now is the minimum number of inputs required for the task.   This functionality will allow me to implement a sort task.

Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj	2006-12-13 01:46:56 UTC (rev 1140)
+++ development/Avida.xcodeproj/project.pbxproj	2006-12-13 04:46:37 UTC (rev 1141)
@@ -109,6 +109,13 @@
 		708BF2FE0AB65DC700A923BF /* cEventList.cc in Sources */ = {isa = PBXBuildFile; fileRef = 708BF2FD0AB65DC700A923BF /* cEventList.cc */; };
 		708BF2FF0AB65DC700A923BF /* cEventList.cc in Sources */ = {isa = PBXBuildFile; fileRef = 708BF2FD0AB65DC700A923BF /* cEventList.cc */; };
 		708BF3000AB65DC700A923BF /* cEventList.cc in Sources */ = {isa = PBXBuildFile; fileRef = 708BF2FD0AB65DC700A923BF /* cEventList.cc */; };
+		7099EEC00B2F9D2A001269F6 /* cEnvReqs.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7099EEBF0B2F9D2A001269F6 /* cEnvReqs.h */; };
+		7099EEC10B2F9D2A001269F6 /* cEnvReqs.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7099EEBF0B2F9D2A001269F6 /* cEnvReqs.h */; };
+		7099EEC20B2F9D2A001269F6 /* cEnvReqs.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7099EEBF0B2F9D2A001269F6 /* cEnvReqs.h */; };
+		7099EF510B2FBC85001269F6 /* cAnalyzeScreen.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7099EF470B2FBC85001269F6 /* cAnalyzeScreen.cc */; };
+		7099EF530B2FBC85001269F6 /* cAnalyzeView.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7099EF490B2FBC85001269F6 /* cAnalyzeView.cc */; };
+		7099EF560B2FBC86001269F6 /* cTextViewerAnalyzeDriver.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7099EF4C0B2FBC85001269F6 /* cTextViewerAnalyzeDriver.cc */; };
+		7099EF580B2FBC86001269F6 /* cTextViewerDriver_Base.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7099EF4E0B2FBC85001269F6 /* cTextViewerDriver_Base.cc */; };
 		709D924C0A5D950D00D6A163 /* cMutationalNeighborhood.cc in Sources */ = {isa = PBXBuildFile; fileRef = 709D924B0A5D950D00D6A163 /* cMutationalNeighborhood.cc */; };
 		709D924D0A5D950E00D6A163 /* cMutationalNeighborhood.cc in Sources */ = {isa = PBXBuildFile; fileRef = 709D924B0A5D950D00D6A163 /* cMutationalNeighborhood.cc */; };
 		709D924E0A5D950E00D6A163 /* cMutationalNeighborhood.cc in Sources */ = {isa = PBXBuildFile; fileRef = 709D924B0A5D950D00D6A163 /* cMutationalNeighborhood.cc */; };
@@ -402,6 +409,7 @@
 			files = (
 				700E2B87085DE54400CF158A /* avida-viewer in CopyFiles */,
 				109746440AE9606E00929ED6 /* cDeme.h in CopyFiles */,
+				7099EEC10B2F9D2A001269F6 /* cEnvReqs.h in CopyFiles */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -425,6 +433,7 @@
 				7049F3720A66AD7E00640512 /* default-smt.org in CopyFiles */,
 				7049F3730A66AD7E00640512 /* default-transsmt.org in CopyFiles */,
 				109746400AE9606E00929ED6 /* cDeme.h in CopyFiles */,
+				7099EEC20B2F9D2A001269F6 /* cEnvReqs.h in CopyFiles */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -436,6 +445,7 @@
 			files = (
 				702F532F0993060A00B2B507 /* avida-s in CopyFiles */,
 				109746420AE9606E00929ED6 /* cDeme.h in CopyFiles */,
+				7099EEC00B2F9D2A001269F6 /* cEnvReqs.h in CopyFiles */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -626,6 +636,17 @@
 		70920C690A9CCE2C00757CDB /* structure.html */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.html.documentation; path = structure.html; sourceTree = "<group>"; };
 		70920C6A0A9CCE2C00757CDB /* svn.html */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.html.documentation; path = svn.html; sourceTree = "<group>"; };
 		7093DB4009D6F50300DE7FEB /* tSmartArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tSmartArray.h; sourceTree = "<group>"; };
+		7099EEBF0B2F9D2A001269F6 /* cEnvReqs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cEnvReqs.h; sourceTree = "<group>"; };
+		7099EF470B2FBC85001269F6 /* cAnalyzeScreen.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cAnalyzeScreen.cc; sourceTree = "<group>"; };
+		7099EF480B2FBC85001269F6 /* cAnalyzeScreen.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeScreen.h; sourceTree = "<group>"; };
+		7099EF490B2FBC85001269F6 /* cAnalyzeView.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cAnalyzeView.cc; sourceTree = "<group>"; };
+		7099EF4A0B2FBC85001269F6 /* cAnalyzeView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeView.h; sourceTree = "<group>"; };
+		7099EF4B0B2FBC85001269F6 /* cTabBox.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cTabBox.h; sourceTree = "<group>"; };
+		7099EF4C0B2FBC85001269F6 /* cTextViewerAnalyzeDriver.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cTextViewerAnalyzeDriver.cc; sourceTree = "<group>"; };
+		7099EF4D0B2FBC85001269F6 /* cTextViewerAnalyzeDriver.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cTextViewerAnalyzeDriver.h; sourceTree = "<group>"; };
+		7099EF4E0B2FBC85001269F6 /* cTextViewerDriver_Base.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cTextViewerDriver_Base.cc; sourceTree = "<group>"; };
+		7099EF4F0B2FBC85001269F6 /* cTextViewerDriver_Base.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cTextViewerDriver_Base.h; sourceTree = "<group>"; };
+		7099EF500B2FBC85001269F6 /* cView_Base.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cView_Base.h; sourceTree = "<group>"; };
 		709D92490A5D94FD00D6A163 /* cMutationalNeighborhood.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cMutationalNeighborhood.h; sourceTree = "<group>"; };
 		709D924A0A5D94FD00D6A163 /* cMutationalNeighborhoodResults.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cMutationalNeighborhoodResults.h; sourceTree = "<group>"; };
 		709D924B0A5D950D00D6A163 /* cMutationalNeighborhood.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cMutationalNeighborhood.cc; sourceTree = "<group>"; };
@@ -1194,6 +1215,16 @@
 		70DCAC58097AF730002F8733 /* avida-viewer */ = {
 			isa = PBXGroup;
 			children = (
+				7099EF470B2FBC85001269F6 /* cAnalyzeScreen.cc */,
+				7099EF480B2FBC85001269F6 /* cAnalyzeScreen.h */,
+				7099EF490B2FBC85001269F6 /* cAnalyzeView.cc */,
+				7099EF4A0B2FBC85001269F6 /* cAnalyzeView.h */,
+				7099EF4B0B2FBC85001269F6 /* cTabBox.h */,
+				7099EF4C0B2FBC85001269F6 /* cTextViewerAnalyzeDriver.cc */,
+				7099EF4D0B2FBC85001269F6 /* cTextViewerAnalyzeDriver.h */,
+				7099EF4E0B2FBC85001269F6 /* cTextViewerDriver_Base.cc */,
+				7099EF4F0B2FBC85001269F6 /* cTextViewerDriver_Base.h */,
+				7099EF500B2FBC85001269F6 /* cView_Base.h */,
 				703CA3730A50737700AB4DB4 /* SConscript */,
 				70DCAC59097AF730002F8733 /* cBarScreen.cc */,
 				70DCAC5A097AF730002F8733 /* cBarScreen.h */,
@@ -1481,6 +1512,7 @@
 				7027621A09D73E7700741717 /* cOrgSinkMessage.h */,
 				70DA5E9D09DA1A8D00FFF42B /* cOrgSeqMessage.h */,
 				700AE91B09DB65F200A073FD /* cTaskContext.h */,
+				7099EEBF0B2F9D2A001269F6 /* cEnvReqs.h */,
 			);
 			path = main;
 			sourceTree = "<group>";
@@ -1997,6 +2029,10 @@
 				70BCB2350AB7B26B003FF331 /* cArgContainer.cc in Sources */,
 				703D4D700ABA374A0032C8A0 /* cArgSchema.cc in Sources */,
 				109746430AE9606E00929ED6 /* cDeme.cc in Sources */,
+				7099EF510B2FBC85001269F6 /* cAnalyzeScreen.cc in Sources */,
+				7099EF530B2FBC85001269F6 /* cAnalyzeView.cc in Sources */,
+				7099EF560B2FBC86001269F6 /* cTextViewerAnalyzeDriver.cc in Sources */,
+				7099EF580B2FBC86001269F6 /* cTextViewerDriver_Base.cc in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc	2006-12-13 01:46:56 UTC (rev 1140)
+++ development/source/cpu/cHardwareCPU.cc	2006-12-13 04:46:37 UTC (rev 1141)
@@ -2710,7 +2710,8 @@
 
 bool cHardwareCPU::Inst_TaskStackLoad(cAvidaContext& ctx)
 {
-  for (int i = 0; i < nHardware::IO_SIZE; i++) 
+  // @DMB - TODO: this should look at the input_size...
+  for (int i = 0; i < 3; i++) 
     StackPush( organism->GetNextInput() );
   return true;
 }

Modified: development/source/cpu/nHardware.h
===================================================================
--- development/source/cpu/nHardware.h	2006-12-13 01:46:56 UTC (rev 1140)
+++ development/source/cpu/nHardware.h	2006-12-13 04:46:37 UTC (rev 1141)
@@ -23,7 +23,6 @@
   enum tHeads { HEAD_IP = 0, HEAD_READ, HEAD_WRITE, HEAD_FLOW, NUM_HEADS };
   
   static const int STACK_SIZE = 10;
-  static const int IO_SIZE = 3;
 }
 
 enum tFaultTypes {

Modified: development/source/defs.h
===================================================================
--- development/source/defs.h	2006-12-13 01:46:56 UTC (rev 1140)
+++ development/source/defs.h	2006-12-13 04:46:37 UTC (rev 1141)
@@ -93,7 +93,7 @@
 const int MIN_INJECT_SIZE = 8;
 
 // Number of distinct input and outputs stored in the IOBufs (to test tasks)
-const int INPUT_BUF_SIZE = 3;
+const int INPUT_SIZE_DEFAULT = 3;
 const int OUTPUT_BUF_SIZE = 10;
 #define RECEIVED_MESSAGES_SIZE 10
 const int MARKET_SIZE = 10000;

Added: development/source/main/cEnvReqs.h
===================================================================
--- development/source/main/cEnvReqs.h	2006-12-13 01:46:56 UTC (rev 1140)
+++ development/source/main/cEnvReqs.h	2006-12-13 04:46:37 UTC (rev 1141)
@@ -0,0 +1,26 @@
+/*
+ *  cEnvReqs.h
+ *  Avida
+ *
+ *  Created by David Bryson on 12/12/06.
+ *  Copyright 2006 Michigan State University. All rights reserved.
+ *
+ */
+
+#ifndef cEnvReqs_h
+#define cEnvReqs_h
+
+class cEnvReqs
+{
+private:
+  int m_min_inputs;
+
+
+public:
+  cEnvReqs() : m_min_inputs(0) { ; }
+  
+  int GetMinInputs() { return m_min_inputs; }
+  void SetMinInputs(int v) { m_min_inputs = v; }
+};
+
+#endif

Modified: development/source/main/cEnvironment.cc
===================================================================
--- development/source/main/cEnvironment.cc	2006-12-13 01:46:56 UTC (rev 1140)
+++ development/source/main/cEnvironment.cc	2006-12-13 04:46:37 UTC (rev 1141)
@@ -11,6 +11,7 @@
 #include "cEnvironment.h"
 
 #include "cAvidaContext.h"
+#include "cEnvReqs.h"
 #include "cHardwareManager.h"
 #include "cInitFile.h"
 #include "nMutation.h"
@@ -502,7 +503,8 @@
 	cString trigger = trigger_info.Pop('=');
   
   // Load the task trigger
-  cTaskEntry* cur_task = m_tasklib.AddTask(trigger, trigger_info);
+  cEnvReqs envreqs;
+  cTaskEntry* cur_task = m_tasklib.AddTask(trigger, trigger_info, envreqs);
   if (cur_task == NULL) {
     cerr << "...failed to find task in cTaskLib..." << endl;
     return false;
@@ -535,6 +537,9 @@
     }
   }
   
+  // Process the environment requirements of this task
+  if (envreqs.GetMinInputs() > m_input_size) m_input_size = envreqs.GetMinInputs();
+  
   return true;
 }
 
@@ -725,7 +730,7 @@
 
 void cEnvironment::SetupInputs(cAvidaContext& ctx, tArray<int>& input_array) const
 {
-  input_array.Resize(3);
+  input_array.Resize(m_input_size);
   
   // Set the top 8 bits of the input buffer...
   input_array[0] = 15 << 24;  // 00001111
@@ -733,7 +738,7 @@
   input_array[2] = 85 << 24;  // 01010101
   
   // And randomize the rest...
-  for (int i = 0; i < 3; i++) {
+  for (int i = 0; i < m_input_size; i++) {
     input_array[i] += ctx.GetRandom().GetUInt(1 << 24);
   }
 }

Modified: development/source/main/cEnvironment.h
===================================================================
--- development/source/main/cEnvironment.h	2006-12-13 01:46:56 UTC (rev 1140)
+++ development/source/main/cEnvironment.h	2006-12-13 04:46:37 UTC (rev 1141)
@@ -32,6 +32,9 @@
 #ifndef cTaskLib_h
 #include "cTaskLib.h"
 #endif
+#ifndef defs_h
+#include "defs.h"
+#endif
 #ifndef tList_h
 #include "tList.h"
 #endif
@@ -68,6 +71,9 @@
   cInstSet inst_set;
   cMutationRates mut_rates;
 
+  int m_input_size;
+  
+  
   static bool ParseSetting(cString entry, cString& var_name, cString& var_value, const cString& var_type);
   static bool AssertInputInt(const cString& input, const cString& name, const cString& type);
   static bool AssertInputDouble(const cString& input, const cString& name, const cString& type);
@@ -92,7 +98,7 @@
   cEnvironment& operator=(const cEnvironment&); // @not_implemented
 
 public:
-  cEnvironment(cWorld* world) : m_world(world), m_tasklib(world), inst_set(world) { mut_rates.Setup(world); }
+  cEnvironment(cWorld* world) : m_world(world), m_tasklib(world), inst_set(world), m_input_size(INPUT_SIZE_DEFAULT) { mut_rates.Setup(world); }
   ~cEnvironment() { ; }
 
   bool Load(const cString& filename);  // Reads the environment from disk.
@@ -118,6 +124,8 @@
   cResourceLib& GetResourceLib() { return resource_lib; }
   cReactionLib& GetReactionLib() { return reaction_lib; }
   cMutationRates& GetMutRates() { return mut_rates; }
+  
+  int GetInputSize() { return m_input_size; }
 
   double GetReactionValue(int& reaction_id);
   bool SetReactionValue(cAvidaContext& ctx, const cString& name, double value);

Modified: development/source/main/cOrganism.cc
===================================================================
--- development/source/main/cOrganism.cc	2006-12-13 01:46:56 UTC (rev 1140)
+++ development/source/main/cOrganism.cc	2006-12-13 04:46:37 UTC (rev 1141)
@@ -44,7 +44,7 @@
   , m_lineage_label(-1)
   , m_lineage(NULL)
   , m_input_pointer(0)
-  , m_input_buf(INPUT_BUF_SIZE)
+  , m_input_buf(world->GetEnvironment().GetInputSize())
   , m_output_buf(OUTPUT_BUF_SIZE)
   , m_received_messages(RECEIVED_MESSAGES_SIZE)
   , m_sent_value(0)

Modified: development/source/main/cPopulationCell.cc
===================================================================
--- development/source/main/cPopulationCell.cc	2006-12-13 01:46:56 UTC (rev 1140)
+++ development/source/main/cPopulationCell.cc	2006-12-13 04:46:37 UTC (rev 1141)
@@ -28,15 +28,15 @@
 cPopulationCell::cPopulationCell(const cPopulationCell& in_cell)
   : m_world(in_cell.m_world)
   , organism(in_cell.organism)
+  , input_array(in_cell.input_array)
   , cell_id(in_cell.cell_id)
   , deme_id(in_cell.deme_id)
   , organism_count(in_cell.organism_count)
 {
-  for (int i = 0; i < nHardware::IO_SIZE; i++) input_array[i] = in_cell.input_array[i];
   mutation_rates = new cMutationRates(*in_cell.mutation_rates);
   tConstListIterator<cPopulationCell> conn_it(in_cell.connection_list);
-  cPopulationCell * test_cell;
-  while ( (test_cell = (cPopulationCell *) conn_it.Next()) != NULL) {
+  cPopulationCell* test_cell;
+  while ( (test_cell = (cPopulationCell*) conn_it.Next()) != NULL) {
     connection_list.PushRear(test_cell);
   }
 }
@@ -45,7 +45,7 @@
 {
   m_world = in_cell.m_world;
   organism = in_cell.organism;
-  for (int i = 0; i < nHardware::IO_SIZE; i++) input_array[i] = in_cell.input_array[i];
+  input_array = in_cell.input_array;
   cell_id = in_cell.cell_id;
   deme_id = in_cell.deme_id;
   organism_count = in_cell.organism_count;
@@ -90,13 +90,13 @@
 
 int cPopulationCell::GetInputAt(int & input_pointer)
 {
-  if (input_pointer >= nHardware::IO_SIZE) input_pointer = 0;
+  input_pointer %= input_array.GetSize();
   return input_array[input_pointer++];
 }
 
 int cPopulationCell::GetInput(int id)
 {
-  assert(id >= 0 && id < nHardware::IO_SIZE);
+  assert(id >= 0 && id < input_array.GetSize());
   return input_array[id];
 }
 

Modified: development/source/main/cPopulationCell.h
===================================================================
--- development/source/main/cPopulationCell.h	2006-12-13 01:46:56 UTC (rev 1140)
+++ development/source/main/cPopulationCell.h	2006-12-13 04:46:37 UTC (rev 1141)
@@ -64,6 +64,7 @@
   cMutationRates & MutationRates() { return *mutation_rates; }
   int GetInput(int);
   int GetInputAt(int & input_pointer);
+  int GetInputSize() { return input_array.GetSize(); }
 
   int GetID() const { return cell_id; }
   int GetDemeID() const { return deme_id; }

Modified: development/source/main/cTaskEntry.h
===================================================================
--- development/source/main/cTaskEntry.h	2006-12-13 01:46:56 UTC (rev 1140)
+++ development/source/main/cTaskEntry.h	2006-12-13 04:46:37 UTC (rev 1141)
@@ -49,6 +49,8 @@
   
   bool HasArguments() const { return (m_args != NULL); }
   const cArgContainer& GetArguments() const { return *m_args; }
+  
+  
 };
 
 

Modified: development/source/main/cTaskLib.cc
===================================================================
--- development/source/main/cTaskLib.cc	2006-12-13 01:46:56 UTC (rev 1140)
+++ development/source/main/cTaskLib.cc	2006-12-13 04:46:37 UTC (rev 1141)
@@ -11,6 +11,7 @@
 #include "cTaskLib.h"
 
 #include "cArgSchema.h"
+#include "cEnvReqs.h"
 
 #include <stdlib.h>
 extern "C" {
@@ -35,7 +36,7 @@
   return static_cast<double>(32 - bit_diff) / 32.0; 
 }
 
-cTaskEntry* cTaskLib::AddTask(const cString& name, const cString& info)
+cTaskEntry* cTaskLib::AddTask(const cString& name, const cString& info, cEnvReqs& envreqs)
 {
   // Determine if this task is already in the active library.
   for (int i = 0; i < task_array.GetSize(); i++) {
@@ -311,23 +312,10 @@
     NewTask(name, "Math 3AM ((X+Y)^2+(Y+Z)^2)", &cTaskLib::Task_Math3in_AM);  
   
   // Matching Tasks
-  if (name == "matchstr") {
-    cArgSchema schema(',',':');
-    schema.AddEntry("string", 0, cArgSchema::SCHEMA_STRING);
-    cArgContainer* args = cArgContainer::Load(info, schema);
-    if (args) NewTask(name, "MatchStr", &cTaskLib::Task_MatchStr, 0, args);
-  } else if (name == "match_number") {
-    cArgSchema schema(',',':');
-    
-    // Integer Arguments
-    schema.AddEntry("target", 0, cArgSchema::SCHEMA_INT);
-    schema.AddEntry("threshold", 1, -1);
-    // Double Arguments
-    schema.AddEntry("halflife", 0, cArgSchema::SCHEMA_DOUBLE);
-    
-    cArgContainer* args = cArgContainer::Load(info, schema);
-    if (args) NewTask(name, "Match Number", &cTaskLib::Task_MatchNumber, 0, args);
-  }
+  if (name == "matchstr") 
+    Load_MatchStr(name, info, envreqs);
+  else if (name == "match_number")
+    Load_MatchNumber(name, info, envreqs);
 
 	// Communication Tasks
   if (name == "comm_echo")
@@ -1792,6 +1780,15 @@
   return 0.0;
 }
 
+
+void cTaskLib::Load_MatchStr(const cString& name, const cString& argstr, cEnvReqs& envreqs)
+{
+  cArgSchema schema(',',':');
+  schema.AddEntry("string", 0, cArgSchema::SCHEMA_STRING);
+  cArgContainer* args = cArgContainer::Load(argstr, schema);
+  if (args) NewTask(name, "MatchStr", &cTaskLib::Task_MatchStr, 0, args);
+}
+
 double cTaskLib::Task_MatchStr(cTaskContext& ctx) const
 {
 	tBuffer<int> temp_buf(ctx.GetOutputBuffer());
@@ -1853,6 +1850,20 @@
 }
 
 
+void cTaskLib::Load_MatchNumber(const cString& name, const cString& argstr, cEnvReqs& envreqs)
+{
+  cArgSchema schema(',',':');
+  
+  // Integer Arguments
+  schema.AddEntry("target", 0, cArgSchema::SCHEMA_INT);
+  schema.AddEntry("threshold", 1, -1);
+  // Double Arguments
+  schema.AddEntry("halflife", 0, cArgSchema::SCHEMA_DOUBLE);
+  
+  cArgContainer* args = cArgContainer::Load(argstr, schema);
+  if (args) NewTask(name, "Match Number", &cTaskLib::Task_MatchNumber, 0, args);
+}
+
 double cTaskLib::Task_MatchNumber(cTaskContext& ctx) const
 {
   double quality = 0.0;

Modified: development/source/main/cTaskLib.h
===================================================================
--- development/source/main/cTaskLib.h	2006-12-13 01:46:56 UTC (rev 1140)
+++ development/source/main/cTaskLib.h	2006-12-13 04:46:37 UTC (rev 1141)
@@ -28,6 +28,7 @@
 #endif
 
 
+class cEnvReqs;
 class cString;
 class cWorld;
 
@@ -61,7 +62,7 @@
 
   int GetSize() const { return task_array.GetSize(); }
 
-  cTaskEntry* AddTask(const cString& name, const cString& info);
+  cTaskEntry* AddTask(const cString& name, const cString& info, cEnvReqs& envreqs);
   const cTaskEntry& GetTask(int id) const { return *(task_array[id]); }
   
   void SetupTests(cTaskContext& ctx) const;
@@ -70,6 +71,7 @@
   bool UseNeighborInput() const { return use_neighbor_input; }
   bool UseNeighborOutput() const { return use_neighbor_output; }
   
+  
 private:  // Direct task related methods
   void NewTask(const cString& name, const cString& desc, tTaskTest task_fun, int reqs = 0,
                cArgContainer* args = NULL);
@@ -219,7 +221,9 @@
   double Task_Math3in_AM(cTaskContext& ctx) const;
   
   // Matching Tasks
+  void Load_MatchStr(const cString& name, const cString& argstr, cEnvReqs& envreqs);
   double Task_MatchStr(cTaskContext& ctx) const;
+  void Load_MatchNumber(const cString& name, const cString& argstr, cEnvReqs& envreqs);
   double Task_MatchNumber(cTaskContext& ctx) const;
 
   // Communication Tasks

Modified: development/source/targets/avida-viewer/cZoomScreen.cc
===================================================================
--- development/source/targets/avida-viewer/cZoomScreen.cc	2006-12-13 01:46:56 UTC (rev 1140)
+++ development/source/targets/avida-viewer/cZoomScreen.cc	2006-12-13 04:46:37 UTC (rev 1141)
@@ -624,7 +624,7 @@
   Print(INPUT_Y+3, INPUT_X+2, "%12d", info.GetActiveCell()->GetInput(0));
   
   SetColor(COLOR_CYAN);
-  for (int i = 1; i < nHardware::IO_SIZE; i++) {
+  for (int i = 1; i < info.GetActiveCell()->GetInputSize(); i++) {
     Print(INPUT_Y+3+i, INPUT_X+2, "%12d", info.GetActiveCell()->GetInput(i));
   }
   
@@ -686,7 +686,7 @@
   Print(INPUT_Y+3, INPUT_X+2, "%12d", info.GetActiveCell()->GetInput(0));
   
   SetColor(COLOR_CYAN);
-  for (int i = 1; i < nHardware::IO_SIZE; i++) {
+  for (int i = 1; i < info.GetActiveCell()->GetInputSize(); i++) {
     Print(INPUT_Y+3+i, INPUT_X+2, "%12d", info.GetActiveCell()->GetInput(i));
   }
   




More information about the Avida-cvs mailing list