[Avida-cvs] [avida-svn] r911 - in development: documentation source/main

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Wed Aug 30 19:01:54 PDT 2006


Author: brysonda
Date: 2006-08-30 22:01:54 -0400 (Wed, 30 Aug 2006)
New Revision: 911

Modified:
   development/documentation/code_environment.html
   development/documentation/code_genome.html
   development/source/main/cTaskEntry.h
   development/source/main/cTaskLib.h
Log:
Finish updating the Building Blocks documentation.   
Update the Environment Source Code documentation.

Modified: development/documentation/code_environment.html
===================================================================
--- development/documentation/code_environment.html	2006-08-30 21:03:41 UTC (rev 910)
+++ development/documentation/code_environment.html	2006-08-31 02:01:54 UTC (rev 911)
@@ -1,41 +1,57 @@
 <html>
-<title>The Environment Code</title>
-<body
- bgcolor="#FFFFFF"
- text="#000000"
- link="#0000AA"
- alink="#0000FF"
- vlink="#000044">
+<head>
+  <title>Avida : The Environment Source Code</title>
+</head>
+<body>
 
-<h2 align=center>The Environment Code</h2>
+<div style="float: right">
+Revised 2006-08-30 DMB
+</div>
 
+<p><a href="index.html">Return to the Index</a></p>
+<hr />
+
+<div align="center">
+<h1>The Environment Source Code</h1>
+</div>
+
+<p>
 The environment source code consists of several main components: resources,
 reactions, and task triggers, plus the libraries that maintain each of these.
+</p>
 
-<h3>Task Entries</h3>
 
+<p>&nbsp;</p>
+<h2>Task Entries</h2>
+
+<p>
 A task library is composed of a collection of entries, each of which fully
 describes a single task that can be used to trigger reactions.
-
+</p>
 <pre>
-  typedef <font color="#880000">double</font> (<font color="#880000">cTaskLib</font>::*<font color="#000088">tTaskTest</font>)() const;
+typedef <span style="color: #880000">double</span> (<span style="color: #880000">cTaskLib</span>::*<span style="color: #000088">tTaskTest</span>)(<span style="color: #880000">cTaskContext</span>*) const;
 
-  class <font color="#880000">cTaskEntry</font> {
-  private:
-    <font color="#880000">cString</font> <font color="#000088">name</font>;  <font color="#886600">// Short keyword for task</font>
-    <font color="#880000">cString</font> <font color="#000088">desc</font>;  <font color="#886600">// For more human-understandable output...</font>
-    <font color="#880000">int</font> <font color="#000088">id</font>;
-    <font color="#880000">tTaskTest</font> <font color="#000088">test_fun</font>;
-  public:
-    <font color="#008800">cTaskEntry</font>(const <font color="#880000">cString</font> & <font color="#000088">_name</font>, const <font color="#880000">cString</font> & <font color="#000088">_desc</font>, <font color="#880000">int</font> <font color="#000088">_id</font>,
-               <font color="#880000">tTaskTest</font> <font color="#000088">_test_fun</font>);
-    ~<font color="#008800">cTaskEntry</font>();
+class <span style="color: #880000">cTaskEntry</span> {
+private:
+  <span style="color: #880000">cString</span> <span style="color: #000088">m_name</span>;  <span style="color: #886600">// Short keyword for task</span>
+  <span style="color: #880000">cString</span> <span style="color: #000088">m_desc</span>;  <span style="color: #886600">// For more human-understandable output...</span>
+  <span style="color: #880000">int</span> <span style="color: #000088">m_id</span>;
+  <span style="color: #880000">tTaskTest</span> <span style="color: #000088">m_test_fun</span>;
+  <span style="color: #880000">cString</span> <span style="color: #000088">m_info</span>;  <span style="color: #886600">// extra info (like the string or whatever to match)</span>
   
-    const <font color="#880000">cString</font> & <font color="#008800">GetName</font>()    const { return <font color="#000088">name</font>; }
-    const <font color="#880000">cString</font> & <font color="#008800">GetDesc</font>()    const { return <font color="#000088">desc</font>; }
-    const <font color="#880000">int</font>       <font color="#008800">GetID</font>()      const { return <font color="#000088">id</font>; }
-    const <font color="#880000">tTaskTest</font> <font color="#008800">GetTestFun</font>() const { return <font color="#000088">test_fun</font>; }
-  };
+public:
+  <span style="color: #008800">cTaskEntry</span>(const <span style="color: #880000">cString</span>&amp; <span style="color: #000088">name</span>, const <span style="color: #880000">cString</span>&amp; <span style="color: #000088">desc</span>, int <span style="color: #000088">in_id</span>, <span style="color: #880000">tTaskTest</span> <span style="color: #000088">test_fun</span>, const <span style="color: #880000">cString</span>&amp; <span style="color: #000088">info</span>);
+    : m_name(name), m_desc(desc), m_id(in_id), m_test_fun(test_fun), m_info(info)
+  {
+  }
+  ~<span style="color: #008800">cTaskEntry</span>() { ; }
+
+  const <span style="color: #880000">cString</span>&amp; <span style="color: #008800">GetName</span>() const { return <span style="color: #000088">m_name</span>; }
+  const <span style="color: #880000">cString</span>&amp; <span style="color: #008800">GetDesc</span>() const { return <span style="color: #000088">m_desc</span>; }
+  const int <span style="color: #008800">GetID</span>() const { return <span style="color: #000088">m_id</span>; }
+  const <span style="color: #880000">tTaskTest</span> <span style="color: #008800">GetTestFun</span>() const { return <span style="color: #000088">m_test_fun</span>; }
+  const <span style="color: #880000">cString</span>&amp; <span style="color: #008800">GetInfo</span>() const { return <span style="color: #000088">m_info</span>; }
+};
 </pre>
 
 <p>
@@ -46,192 +62,161 @@
 representing how well the task was performed.  Currently, all task tests will
 return an exact zero or one, but fractions are possible if there
 is a quality component associated with the task.
+</p>
 
-<h3>Task Libraries</h3>
 
+<p>&nbsp;</p>
+<h2>Task Libraries</h2>
+
 <p>
-Here is the task library that manages all of the individual entries:
+Here is an abridged version of the  task library class that manages all of the
+individual entries:
+</p>
 
 <pre>
-  class <font color="#880000">cTaskLib</font> {
-  private:
-    <font color="#880000">tArray</font><<font color="#880000">cTaskEntry</font> *> <font color="#000088">task_array</font>;
-  
-    <font color="#886600">// Active task information...</font>
-    <font color="#880000">tBuffer</font><<font color="#880000">int</font>> <font color="#000088">input_buffer</font>;
-    <font color="#880000">tBuffer</font><<font color="#880000">int</font>> <font color="#000088">output_buffer</font>;
-    <font color="#880000">int</font> <font color="#000088">logic_id</font>;
+class <span style="color: #880000">cTaskLib</span> {
+private:
+  <span style="color: #880000">tArray</span>&lt;<span style="color: #880000">cTaskEntry</span>*&gt; <span style="color: #000088">task_array</span>;
 
-    void <font color="#008800">SetupLogicTests</font>(const <font color="#880000">tBuffer</font><<font color="#880000">int</font>> & <font color="#000088">inputs</font>,
-                         const <font color="#880000">tBuffer</font><<font color="#880000">int</font>> & <font color="#000088">outputs</font>) const;
+public:
+  int <span style="color: #008800">GetSize</span>() const { return <span style="color: #000088">task_array</span>.<span style="color: #008800">GetSize</span>(); }
 
-    <font color="#880000">double</font> <font color="#008800">Task_Echo</font>() const;
-    <font color="#880000">double</font> <font color="#008800">Task_Add</font>()  const;
-    <font color="#880000">double</font> <font color="#008800">Task_Sub</font>()  const;
-  
-    <font color="#880000">double</font> <font color="#008800">Task_Not</font>()    const;
-    <font color="#880000">double</font> <font color="#008800">Task_Nand</font>()   const;
-    <font color="#880000">double</font> <font color="#008800">Task_And</font>()    const;
-    <font color="#886600">// ... And a whole bunch more ...</font>
+  <span style="color: #880000">cTaskEntry</span>* <span style="color: #008800">AddTask</span>(const <span style="color: #880000">cString</span>&amp; <span style="color: #000088">name</span>, const <span style="color: #880000">cString</span>&amp; <span style="color: #000088">info</span>);
+  const <span style="color: #880000">cTaskEntry</span>&amp; <span style="color: #008800">GetTask</span>(<span style="color: #880000">int</span> <span style="color: #000088">id</span>) const;
 
-  public:
-    <font color="#008800">cTaskLib</font>();
-    ~<font color="#008800">cTaskLib</font>();
+  void <span style="color: #008800">SetupTests</span>(<span style="color: #880000">cTaskContext</span>&amp; <span style="color: #000088">ctx</span>) const;
+  inline double <span style="color: #008800">TestOutput</span>(const <span style="color: #880000">cTaskEntry</span>&amp; <span style="color: #000088">task</span>, <span style="color: #880000">cTaskContext</span>* ctx) const;
 
-    <font color="#880000">int</font> <font color="#008800">GetSize</font>() const { return <font color="#000088">task_array</font>.<font color="#008800">GetSize</font>(); }
+private:
+  double <span style="color: #008800">Task_Echo</span>(<span style="color: #880000">cTaskContext</span>* <span style="color: #000088">ctx</span>) const;
+  double <span style="color: #008800">Task_Add</span>(<span style="color: #880000">cTaskContext</span>* <span style="color: #000088">ctx</span>) const;
+  double <span style="color: #008800">Task_Sub</span>(<span style="color: #880000">cTaskContext</span>* <span style="color: #000088">ctx</span>) const;
 
-    <font color="#880000">cTaskEntry</font> * <font color="#008800">AddTask</font>(const <font color="#880000">cString</font> & <font color="#000088">name</font>);
-    const <font color="#880000">cTaskEntry</font> & <font color="#008800">GetTask</font>(<font color="#880000">int</font> <font color="#000088">id</font>) const;
-  
-    void <font color="#008800">SetupTests</font>(const <font color="#880000">tBuffer</font><<font color="#880000">int</font>> & <font color="#000088">inputs</font>,
-  		  const <font color="#880000">tBuffer</font><<font color="#880000">int</font>> & <font color="#000088">outputs</font>) const;
-    <font color="#880000">double</font> <font color="#008800">TestOutput</font>(const <font color="#880000">cTaskEntry</font> & <font color="#000088">task</font>) const;
-  };
+  double <span style="color: #008800">Task_Not</span>(<span style="color: #880000">cTaskContext</span>* <span style="color: #000088">ctx</span>) const;
+  double <span style="color: #008800">Task_Nand</span>(<span style="color: #880000">cTaskContext</span>* <span style="color: #000088">ctx</span>) const;
+  double <span style="color: #008800">Task_And</span>(<span style="color: #880000">cTaskContext</span>* <span style="color: #000088">ctx</span>) const;
+  <span style="color: #886600">// ... And a whole bunch more ...</span>
+
+};
 </pre>
 
 <p>
 The task library contains an array of task entries that define all of the
-rewarded (or otherwise acted upon) tasks in an environment.  This array is the
-only "long term" variable that is stored here.  Whenever an organism outputs
-a new number that needs to be tested, the
-<font color="#008800">SetupTasks</font>() method is called with the
-appropriate inputs and output for that organism, which are temporarily saved
-in the data variables <font color="#000088">input_buffer</font> and
-<font color="#000088">output_buffer</font>.  Additionally, if there are
-any logic-based tasks rewarded, SetupTasks() will, in turn, call the private
-method <font color="#008800">SetupLogicTasks</font>() to calculate a
-logic_id.  This is a number generated by looking at all bitwise inputs and
-their associated bit output.  It can be later used so that work doesn't need
-to be repeated for each and every logic task tested.
-
+rewarded (or otherwise acted upon) tasks in an environment.
+</p>
 <p>
-The <font color="#008800">TestOutput</font>() method can only be run after
-the setup has finished.  It will test the specific task passed in and return
-the 0.0 - 1.0 quality measure of how well that task was done with the most
-recent output.
+The <span style="color: #008800">TestOutput</span>() method can only be run with
+as <span style="color: #880000">cTaskContext</span> object that has been initialized
+with the <span style="color: #008800">SetupTests</span> method. It will test the
+specific task passed in and return the 0.0 - 1.0 quality measure of how well
+that task was done with the most recent output.
+</p>
 
 <p>
 Below is a sample task-tester implementation:
 
 <pre>
-  <font color="#880000">double</font> <font color="#880000">cTaskLib</font>::<font color="#008800">Task_Add</font>() const
-  {
-    const <font color="#880000">int</font> <font color="#000088">test_output</font> = <font color="#000088">output_buffer</font>[0];
-    for (<font color="#880000">int</font> <font color="#000088">i</font> = 0; <font color="#000088">i</font> < <font color="#000088">input_buffer</font>.<font color="#008800">GetNumStored</font>(); <font color="#000088">i</font>++) {
-      for (<font color="#880000">int</font> <font color="#000088">j</font> = 0; <font color="#000088">j</font> < <font color="#000088">i</font>; <font color="#000088">j</font>++) {
-        if (<font color="#000088">test_output</font> == <font color="#000088">input_buffer</font>[<font color="#000088">i</font>] + <font color="#000088">input_buffer</font>[<font color="#000088">j</font>]) return 1.0;
-      }
+double <span style="color: #880000">cTaskLib</span>::<span style="color: #008800">Task_Add</span>(<span style="color: #880000">cTaskContext</span>* <span style="color: #000088">ctx</span>) const
+{
+  const int <span style="color: #000088">test_output</span> = <span style="color: #000088">ctx</span>-&gt;<span style="color: #000088">output_buffer</span>[0];
+  for (<span style="color: #880000">int</span> <span style="color: #000088">i</span> = 0; <span style="color: #000088">i</span> &lt; <span style="color: #000088">ctx</span>-&gt;<span style="color: #000088">input_buffer</span>.<span style="color: #008800">GetNumStored</span>(); <span style="color: #000088">i</span>++) {
+    for (<span style="color: #880000">int</span> <span style="color: #000088">j</span> = 0; <span style="color: #000088">j</span> < <span style="color: #000088">i</span>; <span style="color: #000088">j</span>++) {
+      if (<span style="color: #000088">test_output</span> == <span style="color: #000088">ctx</span>-&gt;<span style="color: #000088">input_buffer</span>[<span style="color: #000088">i</span>] + <span style="color: #000088">ctx</span>-&gt;<span style="color: #000088">input_buffer</span>[<span style="color: #000088">j</span>]) return 1.0;
     }
-    return 0.0;
   }
+  return 0.0;
+}
 </pre>
 
 <p>
 This case tests to see if the organism has performed an addition operation.
 It compares all pairs of inputs summed together against the most recent
 output of the organism.  If there is a match a full reward (1.0) is given.
-If no match is found, no reward is given (0.0).  The logic_id has 256
-possible values, each of which can only be associated with a single logic
-task.  These tests look more like:
+If no match is found, no reward is given (0.0).
+</p>
 
+<p>
+The <span style="color: #008800">SetupTests</span> method performs some
+precomptution for all of the logic tasks, creating the value
+<span style="color: #000088">logic_id</span> within the task context.  The
+<span style="color: #000088">logic_id</span> has 256 possible values, each of which
+can only be associated with a single logic task.  These tests look more like:
+</p>
+
 <pre>
-  <font color="#880000">double</font> <font color="#880000">cTaskLib</font>::<font color="#008800">Task_AndNot</font>() const
-  {
-    if (<font color="#000088">logic_id</font> == 10 || <font color="#000088">logic_id</font> == 12 || <font color="#000088">logic_id</font> == 34 ||
-        <font color="#000088">logic_id</font> == 48 || <font color="#000088">logic_id</font> == 68 || <font color="#000088">logic_id</font> == 80) return 1.0;
-  
-    return 0.0;
-  }
+double <span style="color: #880000">cTaskLib</span>::<span style="color: #008800">Task_AndNot</span>(<span style="color: #880000">cTaskContext</span>* <span style="color: #000088">ctx</span>) const
+{
+  const int <span style="color: #000088">logic_id</span> = <span style="color: #000088">ctx</span>-&gt;<span style="color: #000088">logic_id</span>;
+  if (<span style="color: #000088">logic_id</span> == 10 || <span style="color: #000088">logic_id</span> == 12 || <span style="color: #000088">logic_id</span> == 34 ||
+      <span style="color: #000088">logic_id</span> == 48 || <span style="color: #000088">logic_id</span> == 68 || <span style="color: #000088">logic_id</span> == 80) return 1.0;
+  return 0.0;
+}
 </pre>
 
 <p>
 If the logic ID is on the list, the task has been done, otherwise it hasn't.
 In each case, the outside world needs to request a test of which tasks have
 been performed, and the library just replied with a numerical answer.
+</p>
 
-<h3>Building a Reaction</h3>
 
+<p>&nbsp;</p>
+<h2>Building a Reaction</h2>
+
 <p>
 The reaction class keeps track of all of the information associated with
-a single possible environmental reaction.  The class appears as follows:
+a single possible environmental reaction.  Each reaction must have a unique
+name and a unique numerical ID associated with them.  In addition to those
+data, a reaction object also has a task that acts as its trigger, a list of
+other requisites that must be met for the trigger to work, and a list of
+processes that will occur if the reaction goes off.  The cReaction object
+acts a a single place to store all of this information.
+</p>
 
-<pre>
-  class <font color="#880000">cReaction</font> {
-  private:
-    <font color="#880000">cString</font> <font color="#000088">name</font>;
-    <font color="#880000">int</font> <font color="#000088">id</font>;
-    <font color="#880000">cTaskEntry</font> * <font color="#000088">task</font>;
-    <font color="#880000">tList</font><<font color="#880000">cReactionRequisite</font>> <font color="#000088">requisite_list</font>;
-    <font color="#880000">tList</font><<font color="#880000">cReactionProcess</font>> <font color="#000088">process_list</font>;
-  public:
-    <font color="#008800">cReaction</font>(const <font color="#880000">cString</font> & <font color="#000088">_name</font>, <font color="#880000">int</font> <font color="#000088">_id</font>);
-    ~<font color="#008800">cReaction</font>();
 
-    const <font color="#880000">cString</font> & <font color="#008800">GetName</font>() const { return <font color="#000088">name</font>; }
-    <font color="#880000">int</font> <font color="#008800">GetID</font>() const { return <font color="#000088">id</font>; }
-    <font color="#880000">cTaskEntry</font> * <font color="#008800">GetTask</font>() { return <font color="#000088">task</font>; }
-    const <font color="#880000">tList</font><<font color="#880000">cReactionRequisite</font>> & <font color="#008800">GetRequisites</font>()
-      { return <font color="#000088">requisite_list</font>; }
-    const <font color="#880000">tList</font><<font color="#880000">cReactionProcess</font>> & <font color="#008800">GetProcesses</font>() { return <font color="#000088">process_list</font>; }
+<p>&nbsp;</p>
+<h2>Resources</h2>
 
-    void <font color="#008800">SetTask</font>(<font color="#880000">cTaskEntry</font> * <font color="#000088">_task</font>) { <font color="#000088">task</font> = <font color="#000088">_task</font>; }
-    <font color="#880000">cReactionProcess</font> * <font color="#008800">AddProcess</font>();
-    <font color="#880000">cReactionRequisite</font> * <font color="#008800">AddRequisite</font>();
-  };
-</pre>
-
 <p>
-Each reaction must have a unique name and a unique numerical ID associated
-with them.  In addition to those data, a reaction object also has a task that
-acts as its trigger, a list of other requisites that must be met for the
-trigger to work, and a list of processes that will occur if the reaction goes
-off.  The cReaction object acts a a single place to store all of this
-information.
-
-<h3>Resources</h3>
-
-<p>
 Resources are a little more complicated than task entries to manage
-and understand.  An object
-of type <font color="#880000">cResource</font> contains 18 pieces of
-data, and the associated accessors.  Like all of the other individual 
-units we have discussed, resources have a unique 
-<font color="#000088">name</font> and numerical
-<font color="#000088">id</font>.  For all resource we store the quantities
-associated with their <font color="#000088">inflow</font>,
-<font color="#000088">outflow</font>, and
-<font color="#000088">initial</font> count (each stored as a
-<font color="#880000">double</font>) as well as the 
-<font color="#000088">geometry</font> of that resource.
+and understand.  An object of type <span style="color: #880000">cResource</span>
+contains 18 pieces of data, and the associated accessors.  Like all of the
+other individual units we have discussed, resources have a unique 
+<span style="color: #000088">name</span> and numerical
+<span style="color: #000088">id</span>.  For all resource we store the quantities
+associated with their <span style="color: #000088">inflow</span>,
+<span style="color: #000088">outflow</span>, and
+<span style="color: #000088">initial</span> count (each stored as a
+double) as well as the <span style="color: #000088">geometry</span> of that resource.
 
 <p>
 For spatial resources we need to be able to describe how a resource
 exists in space so we store data for:
 <ul>
   <li>
-    <font color="#000088">inflowX1</font>, <font
-    color="#000088">inflowX2</font>, <font
-    color="#000088">inflowY1</font>, and  <font
-    color="#000088">inflowY2</font> to describe a rectangle where
-    resources flow in
+    <span style="color: #000088">inflowX1</span>, 
+    <span style="color: #000088">inflowX2</span>,
+    <span style="color: #000088">inflowY1</span>, and 
+    <span style="color: #000088">inflowY2</span> to describe a rectangle where
+    resources flow in.
   </li>
   <li>
-    <font color="#000088">outflowX1</font>, <font
-    color="#000088">outflowX2</font>, <font
-    color="#000088">outflowY1</font>, and  <font
-    color="#000088">outfowY2</font> for a rectangle where resources flow
-    out of
+    <span style="color: #000088">outflowX1</span>,
+    <span style="color: #000088">outflowX2</span>,
+    <span style="color: #000088">outflowY1</span>, and 
+    <span style="color: #000088">outfowY2</span> for a rectangle where resources
+    flow out.
   </li>
   <li>
-    <font color="#000088">xdiffuse</font> and <font
-    color="#000088">ydiffuse</font> describe how fast resources will
+    <span style="color: #000088">xdiffuse</span> and
+    <span style="color: #000088">ydiffuse</span> describe how fast resources will
     flow from cells of higher amounts of that resource to cells with
-    lower amounts of that resource
+    lower amounts of that resource.
   </li>
   <li>
-    <font color="#000088">xgravity</font> and <font
-    color="#000088">ygravity</font> describe the preferential flow of
-    resource in a given direction
+    <span style="color: #000088">xgravity</span> and
+    <span style="color: #000088">ygravity</span> describe the preferential flow of
+    resource in a given direction.
   </li>
 </ul>                                   
 <p>
@@ -240,64 +225,64 @@
 would have its own count).  However, every time a
 resource is needed, any changes in its quantity from the last time it was
 used can be calculated using these numbers.
+</p>
 
 
-<h3>Tying it all together: The Environment</h3>
+<p>&nbsp;</p>
+<h2>Tying it all together: The Environment</h2>
 
 <p>
 The cEnvironment class is used to maintain the details of how the environments
 work using the classes described above and a few others.  Below is an
 abbreviated version of this class:
+</p>
 
 <pre>
-class <font color="#880000">cEnvironment</font> {
+class <span style="color: #880000">cEnvironment</span> {
 private:
-  <font color="#886600">// Keep libraries of resources, reactions, and tasks.</font>
-  <font color="#880000">cResourceLib</font> <font color="#000088">resource_lib</font>;
-  <font color="#880000">cReactionLib</font> <font color="#000088">reaction_lib</font>;
-  <font color="#880000">cTaskLib</font> <font color="#000088">task_lib</font>;
-  <font color="#880000">cInstLib</font> <font color="#000088">inst_lib</font>;
-  <font color="#880000">cMutationRates</font> <font color="#000088">mut_rates</font>;
+  <span style="color: #886600">// Keep libraries of resources, reactions, and tasks.</span>
+  <span style="color: #880000">cResourceLib</span> <span style="color: #000088">resource_lib</span>;
+  <span style="color: #880000">cReactionLib</span> <span style="color: #000088">reaction_lib</span>;
+  <span style="color: #880000">cTaskLib</span> <span style="color: #000088">task_lib</span>;
+  <span style="color: #880000">cInstLib</span> <span style="color: #000088">inst_lib</span>;
+  <span style="color: #880000">cMutationRates</span> <span style="color: #000088">mut_rates</span>;
 
 public:
-  <font color="#008800">cEnvironment</font>();
-  <font color="#008800">cEnvironment</font>(const <font color="#880000">cString</font> & <font color="#000088">filename</font>);
-  ~<font color="#008800">cEnvironment</font>() { ; }
+  <span style="color: #880000">bool</span> <span style="color: #008800">Load</span>(const <span style="color: #880000">cString</span>&amp; <span style="color: #000088">filename</span>);
 
-  <font color="#880000">bool</font> <font color="#008800">Load</font>(const <font color="#880000">cString</font> & <font color="#000088">filename</font>);
-
-  <font color="#886600">// Interaction with the organisms</font>
-  <font color="#880000">bool</font> <font color="#008800">TestOutput</font>(  <font color="#880000">cReactionResult</font> & <font color="#000088">result</font>,
-                    const <font color="#880000">tBuffer</font><<font color="#880000">int</font>> & <font color="#000088">inputs</font>,
-                    const <font color="#880000">tBuffer</font><<font color="#880000">int</font>> & <font color="#000088">outputs</font>,
-                    const <font color="#880000">tArray</font><<font color="#880000">int</font>> & <font color="#000088">task_count</font>,
-                    const <font color="#880000">tArray</font><<font color="#880000">int</font>> & <font color="#000088">reaction_count</font>,
-                    const <font color="#880000">tArray</font><<font color="#880000">double</font>> & <font color="#000088">resource_count</font> ) const;
+  <span style="color: #886600">// Interaction with the organisms</span>
+  <span style="color: #880000">bool</span> <span style="color: #008800">TestOutput</span>(<span style="color: #880000">cAvidaContext</span>&amp; <span style="color: #000088">ctx</span>, <span style="color: #880000">cReactionResult</span>&amp; <span style="color: #000088">result</span>, <span style="color: #880000">cTaskContext</span>&amp; <span style="color: #000088">taskctx</span>,
+                 const <span style="color: #880000">tBuffer</span>&lt;int&gt;&amp; <span style="color: #000088">send_buf</span>, const <span style="color: #880000">tBuffer</span>&lt;int&gt;&amp; <span style="color: #000088">receive_buf</span>,
+                 const <span style="color: #880000">tArray</span>&lt;int&gt;&amp; <span style="color: #000088">task_count</span>, const <span style="color: #880000">tArray</span>&lt;int&gt;&amp; <span style="color: #000088">reaction_count</span>,
+                 const <span style="color: #880000">tArray</span>&lt;double&gt;&amp; <span style="color: #000088">resource_count</span>) const;
 };
 </pre>
 
 <p>
 The private data members include all of the libraries needed to specify
 the environment, plus its mutation rates.  The
-<font color="#008800">Load</font>() method takes a filename (environment.cfg
-by default) and will fill out all of the libraries in this environment.  The
-most important feature of this class is the
-<font color="#008800">TestOutput</font>() method, which takes in all sorts
+<span style="color: #008800">Load</span>() method takes a filename
+(<kbd>environment.cfg</kbd> by default) and will fill out all of the libraries
+in this environment.  The most important feature of this class is the
+<span style="color: #008800">TestOutput</span>() method, which takes in all sorts
 of information about the current state of the organism that has just done
 an output and fills out an object of type
-<font color="#880000">cReactionResult</font> with information about what
+<span style="color: #880000">cReactionResult</span> with information about what
 happened.  It also directly returns a bool that will indicate if there have
-been any changes at all.  The specific information it uses to determine
-the results are the <font color="#000088">inputs</font> the organism has
-taken in and the <font color="#000088">outputs</font> it has produced --
-both needed to determine what tasks have been done, and therefore what
-reactions may have been triggered.  That organism's previous
-<font color="#000088">task_count</font> and
-<font color="#000088">resource_count</font> are also needed to determine
+been any changes at all. The specific information it uses to determine
+the results are the inputs the organism has taken in and the outputs it has
+produced -- both needed to determine what tasks have been done, and therefore
+what reactions may have been triggered.  This information is encapsulated in
+the task context <span style="color: #000088">taskctx</span>.  The organism's
+previous <span style="color: #000088">task_count</span> and
+<span style="color: #000088">resource_count</span> are also needed to determine
 if the reactions requisites have been met.  And finally the
-<font color="#000088">resource_count</font> available to the organisms is
+<span style="color: #000088">resource_count</span> available to the organisms is
 needed to determine how much of each resource can be used in the reactions.
+</p>
 
-<br><hr>
-Project hosted by:<br>
-<a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=46761&type=2" width="125" height="37" border="0" alt="SourceForge.net"/></a>
+<hr />
+<p><a href="index.html">Return to the Index</a></p>
+
+</body>
+</html>

Modified: development/documentation/code_genome.html
===================================================================
--- development/documentation/code_genome.html	2006-08-30 21:03:41 UTC (rev 910)
+++ development/documentation/code_genome.html	2006-08-31 02:01:54 UTC (rev 911)
@@ -16,8 +16,7 @@
 </div>
 
 <p>
-This document discusses the implementation of the cInstruction, cGenome,
-and cInstLib (instruction library) classes.
+This document discusses the implementation of the cInstruction and cGenome classes.
 </p>
 
 
@@ -32,35 +31,35 @@
 </p>
 
 <pre>
-class <font color="#880000">cInstruction</font> {
+class <span style="color: #880000">cInstruction</span> {
 private:
-  unsigned char <font color="#000088">m_operand</font>;
+  unsigned char <span style="color: #000088">m_operand</span>;
 
 public:
-  <font color="#886600">// Constructors and Destructor...</font>
-  <font color="#008800">cInstruction()</font> : <font color="#000088">m_operand</font>(0) { ; }
-  <font color="#008800">cInstruction</font>(const <font color="#880000">cInstruction</font>&amp; <font color="#000088">inst</font>) { *<font color="#000088">this</font> = <font color="#000088">inst</font>; }
-  explicit <font color="#008800">cInstruction</font>(<font color="#880000">int</font> <font color="#000088">in_op</font>) { <font color="#008800">SetOp</font>(<font color="#000088">in_op</font>); }
-  <font color="#008800">~cInstruction</font>() { ; }
+  <span style="color: #886600">// Constructors and Destructor...</span>
+  <span style="color: #008800">cInstruction()</span> : <span style="color: #000088">m_operand</span>(0) { ; }
+  <span style="color: #008800">cInstruction</span>(const <span style="color: #880000">cInstruction</span>&amp; <span style="color: #000088">inst</span>) { *<span style="color: #000088">this</span> = <span style="color: #000088">inst</span>; }
+  explicit <span style="color: #008800">cInstruction</span>(<span style="color: #880000">int</span> <span style="color: #000088">in_op</span>) { <span style="color: #008800">SetOp</span>(<span style="color: #000088">in_op</span>); }
+  <span style="color: #008800">~cInstruction</span>() { ; }
 
-  <font color="#886600">// Accessors...</font>
-  <font color="#880000">int</font> <font color="#008800">GetOp()</font> const { return static_cast&lt;int&gt;(<font color="#000088">m_operand</font>); }
-  void <font color="#008800">SetOp</font>(<font color="#880000">int</font> <font color="#000088">in_op</font>) { <font color="#008800">assert</font>(<font color="#000088">in_op</font> &lt; 256); <font color="#000088">m_operand</font> = <font color="#000088">in_op</font>; }
+  <span style="color: #886600">// Accessors...</span>
+  <span style="color: #880000">int</span> <span style="color: #008800">GetOp()</span> const { return static_cast&lt;int&gt;(<span style="color: #000088">m_operand</span>); }
+  void <span style="color: #008800">SetOp</span>(<span style="color: #880000">int</span> <span style="color: #000088">in_op</span>) { <span style="color: #008800">assert</span>(<span style="color: #000088">in_op</span> &lt; 256); <span style="color: #000088">m_operand</span> = <span style="color: #000088">in_op</span>; }
 
-  <font color="#886600">// Operators...</font>
-  void <font color="#008800">operator=</font>(const <font color="#880000">cInstruction</font>&amp; <font color="#000088">inst</font>) { <font color="#000088">m_operand</font> = <font color="#000088">inst</font>.<font color="#000088">m_operand</font>; }
-  <font color="#880000">bool</font> <font color="#008800">operator==</font>(const <font color="#880000">cInstruction</font>&amp; <font color="#000088">inst</font>) const { return (<font color="#000088">m_operand</font> == <font color="#000088">inst</font>.<font color="#000088">m_operand</font>); }
-  <font color="#880000">bool</font> <font color="#008800">operator!=</font>(const <font color="#880000">cInstruction</font>&amp; <font color="#000088">inst</font>) const { return !(<font color="#008800">operator==</font>(<font color="#000088">inst</font>)); }
+  <span style="color: #886600">// Operators...</span>
+  void <span style="color: #008800">operator=</span>(const <span style="color: #880000">cInstruction</span>&amp; <span style="color: #000088">inst</span>) { <span style="color: #000088">m_operand</span> = <span style="color: #000088">inst</span>.<span style="color: #000088">m_operand</span>; }
+  <span style="color: #880000">bool</span> <span style="color: #008800">operator==</span>(const <span style="color: #880000">cInstruction</span>&amp; <span style="color: #000088">inst</span>) const { return (<span style="color: #000088">m_operand</span> == <span style="color: #000088">inst</span>.<span style="color: #000088">m_operand</span>); }
+  <span style="color: #880000">bool</span> <span style="color: #008800">operator!=</span>(const <span style="color: #880000">cInstruction</span>&amp; <span style="color: #000088">inst</span>) const { return !(<span style="color: #008800">operator==</span>(<span style="color: #000088">inst</span>)); }
 
-  <font color="#886600">// Some extra methods to convert too and from alpha-numeric symbols...</font>
-  <font color="#880000">char</font> <font color="#008800">GetSymbol</font>() const;
-  void <font color="#008800">SetSymbol</font>(<font color="#880000">char</font> <font color="#000088">symbol</font>);
+  <span style="color: #886600">// Some extra methods to convert too and from alpha-numeric symbols...</span>
+  <span style="color: #880000">char</span> <span style="color: #008800">GetSymbol</span>() const;
+  void <span style="color: #008800">SetSymbol</span>(<span style="color: #880000">char</span> <span style="color: #000088">symbol</span>);
 };
 </pre>
 
 <p>
 As stated above, the only private datum is a numerical value that identifies
-this instruction.  The name <font color="#000088">m_operand</font> is the term
+this instruction.  The name <span style="color: #000088">m_operand</span> is the term
 that is used for a command name in an assembly language.  Most normal assembly
 languages have both an operand and arguments associated with each full command.
 In Avida, the commands have no arguments, and hence they just consist of a
@@ -75,12 +74,12 @@
 make up over half of all the memory resources used by Avida.
 </p>
 <p>
-The public methods begin with the <font color="#008800">GetOp</font>() and
-<font color="#008800">SetOp</font>() methods, which are standard accessors.
+The public methods begin with the <span style="color: #008800">GetOp</span>() and
+<span style="color: #008800">SetOp</span>() methods, which are standard accessors.
 Next, we have a collection of methods that begin with the word 'operator'.
 These are used to define how the corresponding symbols should be treated
 when applied to objects of this class.  For example, the method 
-<font color="#008800">operator==</font>() is called when we try to compare
+<span style="color: #008800">operator==</span>() is called when we try to compare
 an object of type cInstruction to another.  We have full control over the
 definition of this method, just like any other.
 </p>
@@ -105,280 +104,80 @@
 </p>
 
 <pre>
-class <font color="#880000">cGenome</font>
+class <span style="color: #880000">cGenome</span>
 {
 protected:
-  <font color="#880000">tArray</font>&lt;<font color="#880000">cInstruction</font>&gt; <font color="#000088">genome</font>;
-  int <font color="#000088">active_size</font>;
+  <span style="color: #880000">tArray</span>&lt;<span style="color: #880000">cInstruction</span>&gt; <span style="color: #000088">genome</span>;
+  int <span style="color: #000088">active_size</span>;
  
 public:
-  <font color="#008800">cGenome</font>() { ; }
-  explicit <font color="#008800">cGenome</font>(int <font color="#000088">_size</font>);
-  <font color="#008800">cGenome</font>(const <font color="#880000">cGenome</font>&amp; <font color="#000088">in_genome</font>);
-  <font color="#008800">cGenome</font>(const <font color="#880000">cString</font>&amp; <font color="#000088">in_string</font>);
-  virtual <font color="#008800">~cGenome</font>();
+  <span style="color: #008800">cGenome</span>() { ; }
+  explicit <span style="color: #008800">cGenome</span>(int <span style="color: #000088">_size</span>);
+  <span style="color: #008800">cGenome</span>(const <span style="color: #880000">cGenome</span>&amp; <span style="color: #000088">in_genome</span>);
+  <span style="color: #008800">cGenome</span>(const <span style="color: #880000">cString</span>&amp; <span style="color: #000088">in_string</span>);
+  virtual <span style="color: #008800">~cGenome</span>();
  
-  virtual void <font color="#008800">operator=</font>(const <font color="#880000">cGenome</font>&amp; <font color="#000088">other_genome</font>);
-  virtual bool <font color="#008800">operator==</font>(const <font color="#880000">cGenome</font>&amp; <font color="#000088">other_genome</font>) const;
-  virtual bool <font color="#008800">operator!=</font>(const <font color="#880000">cGenome</font>&amp; <font color="#000088">other_genome</font>) const { return !(<font color="#000088">this</font>-&gt;<font color="#008800">operator==</font>(<font color="#000088">other_genome</font>)); }
-  virtual bool <font color="#008800">operator&lt;</font>(const <font color="#880000">cGenome</font>&amp; <font color="#000088">other_genome</font>) const { return <font color="#008800">AsString</font>() &lt; <font color="#000088">other_genome</font>.<font color="#008800">AsString</font>(); }
+  virtual void <span style="color: #008800">operator=</span>(const <span style="color: #880000">cGenome</span>&amp; <span style="color: #000088">other_genome</span>);
+  virtual bool <span style="color: #008800">operator==</span>(const <span style="color: #880000">cGenome</span>&amp; <span style="color: #000088">other_genome</span>) const;
+  virtual bool <span style="color: #008800">operator!=</span>(const <span style="color: #880000">cGenome</span>&amp; <span style="color: #000088">other_genome</span>) const { return !(<span style="color: #000088">this</span>-&gt;<span style="color: #008800">operator==</span>(<span style="color: #000088">other_genome</span>)); }
+  virtual bool <span style="color: #008800">operator&lt;</span>(const <span style="color: #880000">cGenome</span>&amp; <span style="color: #000088">other_genome</span>) const { return <span style="color: #008800">AsString</span>() &lt; <span style="color: #000088">other_genome</span>.<span style="color: #008800">AsString</span>(); }
  
-  <font color="#880000">cInstruction</font> & <font color="#008800">operator[]</font>(<font color="#880000">int</font> <font color="#000088">index</font>)
-    { <font color="#008800">assert</font>(<font color="#000088">index</font> &gt;= 0 && <font color="#000088">index</font> &lt; <font color="#000088">active_size</font>);  return <font color="#000088">genome</font>[<font color="#000088">index</font>]; }
-  const <font color="#880000">cInstruction</font> & <font color="#008800">operator[]</font>(<font color="#880000">int</font> <font color="#000088">index</font>) const
-    { <font color="#008800">assert</font>(<font color="#000088">index</font> &gt;= 0 && <font color="#000088">index</font> &lt; <font color="#000088">active_size</font>);  return <font color="#000088">genome</font>[<font color="#000088">index</font>]; }
+  <span style="color: #880000">cInstruction</span>&amp; <span style="color: #008800">operator[]</span>(int <span style="color: #000088">index</span>) { <span style="color: #008800">assert</span>(<span style="color: #000088">index</span> &gt;= 0 &amp;&amp; <span style="color: #000088">index</span> &lt; <span style="color: #000088">active_size</span>);  return <span style="color: #000088">genome</span>[<span style="color: #000088">index</span>]; }
+  const <span style="color: #880000">cInstruction</span>&amp; <span style="color: #008800">operator[]</span>(<span style="color: #880000">int</span> <span style="color: #000088">index</span>) const { <span style="color: #008800">assert</span>(<span style="color: #000088">index</span> &gt;= 0 &amp;&amp; <span style="color: #000088">index</span> &lt; <span style="color: #000088">active_size</span>);  return <span style="color: #000088">genome</span>[<span style="color: #000088">index</span>]; }
  
-  virtual void <font color="#008800">Copy</font>(<font color="#880000">int</font> <font color="#000088">to</font>, <font color="#880000">int</font> <font color="#000088">from</font>);
+  virtual void <span style="color: #008800">Copy</span>(int <span style="color: #000088">to</span>, int <span style="color: #000088">from</span>);
  
-  <font color="#880000">int</font> <font color="#008800">GetSize()</font> const { return <font color="#000088">active_size</font>; }
-  <font color="#880000">cString</font> <font color="#008800">AsString()</font> const;
+  int <span style="color: #008800">GetSize</span>() const { return <span style="color: #000088">active_size</span>; }
+  <span style="color: #880000">cString</span> <span style="color: #008800">AsString</span>() const;
 };
 </pre>
 
 <p>
-The protected variable <font color="#000088">genome</font> is an array 
+The protected variable <span style="color: #000088">genome</span> is an array 
 containing an object of type cInstruction at each position.  The second
-variable, <font color="#000088">active_size</font> denotes the number of
+variable <span style="color: #000088">active_size</span> denotes the number of
 instructions in this array that are currently being used.  The fact that
 these variables are "protected" instead of "private" means that any
-class derived from cGenome will also have access to the variables.  In
-particular, we will discuss the class <font color="#880000">cCPUMemory</font>
-in a future lecture, which extends cGenome, adding methods to alter the
-array length and new variables to keep track of information about each
-instruction.
-
+class derived from <span style="color: #880000">cGenome</span> will also have direct
+access to the variables.  In particular, the class
+<span style="color: #880000">cCPUMemory</span> extends cGenome, adding methods to
+alter the array length and new variables to keep track of information about
+each instruction.
+</p>
 <p>
 Three constructors allow for a new cGenome object to be specified by either a
 genome length, a previously created genome, or else a string -- a sequence
 of symbols representing each instruction in order.
-
+</p>
 <p>
 The operators created for manipulating genomes include both assignment 
 (setting one genome equal to another) and comparison (testing to see if
 two genomes are identical.)  Additionally, there are two
-<font color="#008800">operator[]</font> methods.  These means that if you
+<span style="color: #008800">operator[]</span> methods.  This means that if you
 have an object of type cGenome, you can index into it to retrieve a single
-instruction.  Thus, if the object was called "initial_genome", the 
-statement "initial_genome[15]" would return the instruction at position
-fifteen in the genome.  This occurs by calling one of these methods with
-the appropriate integer.  The difference between these two operator methods
-is that one of them is for mutable genomes (i.e. those that can be modified)
--- a reference
-to the instruction in question is returned allowing it to be altered.
-The other index operator (operator[] method) is for const genomes, which
-can never be changed so only the value of the instruction is returned.
-
+instruction.  Thus, if the object was called <code>initial_genome</code>, the 
+statement <code>initial_genome[15]</code> would return the instruction at
+position fifteen in the genome. This occurs by calling one of these methods
+with the appropriate integer. The difference between these two operator
+methods is that one of them is for mutable genomes (i.e. those that can be
+modified) -- a reference to the instruction in question is returned allowing
+it to be altered. The other index operator (operator[] method) is for const
+genomes, which can never be changed so only the value of the instruction is
+returned.
+</p>
 <p>
-The <font color="#008800">Copy()</font> method is a shortcut to copy memory
+The <span style="color: #008800">Copy(</span>) method is a shortcut to copy memory
 from one position in the genome to another.  This method will later be
-<b>overloaded</b> (that is, replaced with a newer version) by cCPUMemory such
-that the proper flags will be copied, with
-the instruction and others will be set to indicate the copied instruction
-for future tests.  <font color="#008800">GetSize</font> returns the length
-of the genome, and <font color="#008800">AsString</font> returns a string
-who has symbols in each position that correspond to the the instruction in
-the same position in the genome.
+<strong>overloaded</strong> (that is, replaced with a newer version) by
+cCPUMemory such that the proper flags will be copied, with the instruction
+and others will be set to indicate the copied instruction for future tests.
+<span style="color: #008800">GetSize</span>() returns the length of the genome, and
+<span style="color: #008800">AsString</span>() returns a string who has symbols in
+each position that correspond to the the instruction in the same position in
+the genome.
+</p>
 
-<h3>The cInstLib class</h3>
 
-<p>
-This class keeps track of all of the possible, legal instructions, and 
-relates each of them to the hardware method that should be triggered when
-that instruction is executed.
-
-<p>
-The beginning of the <tt>inst_lib.hh</tt> file has a couple of commands
-required for the class definition.  They are:
-
-<pre>
-  class <font color="#880000">cHardwareBase</font>;
-  typedef void (<font color="#880000">cHardwareBase</font>::*<font color="#880000">tHardwareMethod</font>)();
-</pre>
-
-<p>
-The first command basically states that there will be a class called
-<font color="#880000">cHardwareBase</font> that will be fully defined at
-some point in the future.  We need to refer to the class here, but not
-directly interact with any of its methods or variables, so it is sufficient
-to just tell the compiler that it is a class.  This form of statement is
-called a <b>predeclaration</b>.
-
-<p>
-The second line is a <tt>typedef</tt> statement, which defines a new data \
-type.  A typedef looks just like a variable declaration, but the
-keyword <tt>typedef</tt> indicates that the "variable" that
-would have been defined is instead a new "type".  For example, the command
-"<tt>typedef unsigned char UCHAR</tt>" creates a new type called "UCHAR" that
-is just an unsigned char.  In the case above, we are creating a new type
-called <font color="#880000">tHardwareMethod</font>, which is a pointer to
-a method in the class cHardwareBase.  Basically it will point to a location
-in memory that contains a method in the yet-to-be-defined class.  This is
-a tricky concept -- but it is the easiest way to point to a variable method
-that we don't know about until run time (when we load the instruction set
-file in).
-
-<p>
-The cInstLib class is long, so I'm going to split the code presentation into
-two halves, with explanation in between.  Here is the first part:
-
-<pre>
-  class <font color="#880000">cInstLib</font> {
-  private:
-
-    // This class gives full info about a single instruction in the library.
-    class <font color="#880000">cInstEntry</font> {
-    public:
-      <font color="#880000">cString</font> <font color="#000088">name</font>;             <font color="#886600">// Name of this instruction.</font>
-      <font color="#880000">tHardwareMethod</font> <font color="#000088">function</font>; <font color="#886600">// Pointer to hardware method.</font>
-  
-      <font color="#886600">// Some additional details to be used in the future...</font>
-      <font color="#880000">int</font> <font color="#000088">redundancy</font>;           <font color="#886600">// Weight in instruction set</font>
-      <font color="#880000">int</font> <font color="#000088">cost</font>;                 <font color="#886600">// additional time spent to execute inst.</font>
-      <font color="#880000">int</font> <font color="#000088">ft_cost</font>;              <font color="#886600">// additional time spent first time exec</font>
-      <font color="#880000">double</font> <font color="#000088">prob_fail</font>;         <font color="#886600">// probability of failing to execute inst</font>
-    };
-   
-    <font color="#880000">tArray&lt;cInstEntry&gt;</font> <font color="#000088">inst_array</font>;  <font color="#886600">// The instructions</font>
-    <font color="#880000">tArray&lt;int&gt;</font> <font color="#000088">nop_mods</font>;           <font color="#886600">// Modification table for nops</font>
-  
-    <font color="#886600">// Static components...</font>
-    static const <font color="#880000">cInstruction</font> <font color="#000088">inst_error</font>;
-    static const <font color="#880000">cInstruction</font> <font color="#000088">inst_none</font>;
-    static const <font color="#880000">cInstruction</font> <font color="#000088">inst_default</font>;
-</pre>
-
-<p>
-The first thing that I do in the private section of the cInstLib definition is
-define another class called <font color="#880000">cInstEntry</font>, which
-contains all of the information about a single entry in an instruction
-library.  Since it is defined internally and privately, cInstEntry can only
-be used <i>inside</i> of cInstLib; we refer to it as a <b>helper</b> class.
-
-<p>
-cInstEntry contains only pubiic data about a single instruction.  At the
-moment, the only portion of that data that we are using is the instruction
-name and the hardware method that it is supposed to call.  We also have
-room to record how redundant this instruction is supposed to be in the 
-full instruction set, how many CPU cycles should be spent as the cost to
-executing it, an additional first-time cost incurred only the first time
-the instruction is used by an organism, and a probability of failure, that
-the instruction will not be executed at all.  Any other useful information
-about an instruction can be put here, but then it should also be made use
-of elsewhere in the code.
-
-<p>
-After the definition of cInstEntry, we have the declaration of an array of
-entries called <font color="#000088">inst_array</font>.  The position of
-an instruction in this array is the ID number that uniquely identifies that
-instruction.  Thus, whichever instruction entry is placed in the array first,
-that instruction has ID of 0.  The next one has an ID of 1, then 2, and so on.
-
-<p>
-The inst_array has the instructions ordered in the same order they are
-presented in the inst_lib file from which they are loaded with one
-caveat: all no-operation instructions must be listed first.  This is 
-because the next variable, <font color="#000088">nop_mods</font> is an
-array that indicates which CPU component each nop is associated with.
-The size of this array determines how many nops there are, and they 
-directly correspond to the same array positions in inst_array.
-
-<p>
-In the default instruction set, the inst_array has 26 entries contained
-in it, since this is the size of the instruction set, the first three of
-which are <tt>nop-A</tt>, <tt>nop-B</tt>, and <tt>nop-C</tt> respectively.
-The nop_mods array has three integers in it, one for each of the three
-nops.
-
-<p>
-The remainder of the private section of the cInstSet definition contains
-three static and constant variables that represent special instructions.
-They are <font color="#000088">inst_error</font>, for an illegal instruction
-(it will be given the ID number 254), <font color="#000088">inst_none</font>
-to represent an empty position (ID number 255), and
-<font color="#000088">inst_default</font> for the default instruction to
-initialize genomes with, unless otherwise specified (usually ID number 0
--- <tt>nop-A</tt> in the default set -- but this can be changed).
-
-<p>
-Here is the public portion of the cInstLib definition:
-
-<pre>
-  public:
-    <font color="#008800">cInstLib()</font> { ; }
-    <font color="#008800">cInstLib</font>(const <font color="#880000">cInstLib</font> & <font color="#000088">in_inst_lib</font>);
-    <font color="#008800">~cInstLib()</font> { ; }
-   
-    <font color="#880000">cInstLib</font> & <font color="#008800">operator=</font>(const <font color="#880000">cInstLib</font> & <font color="#000088">_in</font>);
-   
-    <font color="#886600">// Accessors</font>
-    const <font color="#880000">cString</font> & <font color="#008800">GetName</font>(const <font color="#880000">cInstruction</font> & <font color="#000088">inst</font>) const;
-    <font color="#880000">tHardwareMethod</font> <font color="#008800">GetFunction</font>(const <font color="#880000">cInstruction</font> & <font color="#000088">inst</font>) const;
-    <font color="#880000">int</font> <font color="#008800">GetNopMod</font>(const <font color="#880000">cInstruction</font> & <font color="#000088">inst</font>) const
-      { return <font color="#000088">nop_mods</font>[<font color="#000088">inst</font>.<font color="#008800">GetOp()</font>]; }
-
-    <font color="#880000">cInstruction</font> <font color="#008800">GetInst</font>(const <font color="#880000">cString</font> & <font color="#000088">in_name</font>) const;
-   
-    <font color="#880000">int</font> <font color="#008800">GetSize()</font> const { return <font color="#000088">inst_array</font>.<font color="#008800">GetSize()</font>; }
-    <font color="#880000">int</font> <font color="#008800">GetNumNops()</font> const { return <font color="#000088">nop_mods</font>.<font color="#008800">GetSize()</font>; }
-   
-    <font color="#886600">// Instruction Analysis.</font>
-    <font color="#880000">int</font> <font color="#008800">IsNop</font>(const <font color="#880000">cInstruction</font> & <font color="#000088">inst</font>) const
-      { return (<font color="#000088">inst</font>.<font color="#008800">GetOp()</font> &lt; <font color="#000088">nop_mods</font>.<font color="#008800">GetSize()</font>); }
-    <font color="#880000">cString</font> <font color="#008800">FindBestMatch</font>(const <font color="#880000">cString</font> & <font color="#000088">in_name</font>) const;
-  
-    <font color="#886600">// Insertion of new instructions...</font>
-    <font color="#880000">int</font> <font color="#008800">Add</font>(const <font color="#880000">cString</font> & <font color="#000088">_name</font>, <font color="#880000">tHardwareMethod</font> <font color="#000088">_fun</font>,
-            <font color="#880000">int</font> <font color="#000088">redundancy</font>=1, <font color="#880000">int</font> <font color="#000088">ft_cost</font>=0, <font color="#880000">int</font> <font color="#000088">cost</font>=0, <font color="#880000">double</font> <font color="#000088">prob_fail</font>=0.0);
-    <font color="#880000">int</font> <font color="#008800">AddNop</font>(const <font color="#880000">cString</font> & <font color="#000088">_name</font>, <font color="#880000">tHardwareMethod</font> <font color="#000088">_fun</font>, <font color="#880000">int</font> <font color="#000088">reg</font>,
-            <font color="#880000">int</font> <font color="#000088">redundancy</font>=1, <font color="#880000">int</font> <font color="#000088">ft_cost</font>=0, <font color="#880000">int</font> <font color="#000088">cost</font>=0, <font color="#880000">double</font> <font color="#000088">prob_fail</font>=0.0);
-   
-    <font color="#886600">// Static methods...</font>
-    static const <font color="#880000">cInstruction</font> & <font color="#008800">GetInstDefault()</font> { return <font color="#000088">inst_default</font>; }
-    static const <font color="#880000">cInstruction</font> & <font color="#008800">GetInstError()</font>   { return <font color="#000088">inst_error</font>; }
-    static const <font color="#880000">cInstruction</font> & <font color="#008800">GetInstNone()</font>    { return <font color="#000088">inst_none</font>; }
-  };
-</pre>
-
-<p>
-The constructors, destructor, and assignment operator are all rather standard
-for this class -- an instruction library can either be created from scratch
-or else copied over from a pre-existing one.
-
-<p>
-The accessors in this class allow specific information to be obtained about
-instructions passed in.  The <font color="#008800">GetName()</font> method
-returns the human-readable name for a specific instruction,
-<font color="#008800">GetFunction()</font> returns a pointer to the method
-associated with an instruction, and <font color="#008800">GetNopMod()</font>
-returns the id of the component modified by a nop-instruction passed in.
-Conversely, <font color="#008800">GetInst()</font> will return an instruction
-object when an instruction name (as a string) is passed in.
-Additionally, there are the accessors <font color="#008800">GetSize()</font>
-to obtain the total number of instructions in the set, and
-<font color="#008800">GetNumNops()</font> will return the number of nop
-instructions in the set.
-
-<p>
-Two instruction analysis methods also exist; one to determine if an
-instruction is a nop called <font color="#008800">IsNop()</font>, and
-another method called <font color="#008800">FindBestMatch()</font> takes
-in an unknown instruction name, and returns the closest name match that it
-can find in the set.  This allows Avida to make suggestions to the user
-in the case of a mis-spelled instruction name.
-
-<p>
-An instruction set is initially loaded by successive calls to the
-<font color="#008800">Add()</font> and <font color="#008800">AddNop()</font>,
-filling in the appropriate arguments.  These methods are called from a
-utility class (<font color="#880000">cHardwareUtil</font>) that manages the
-loading of the inst_set file.  Next class we will be integrating the classes
-discussed here with the classes that directly implment the hardware.
-
-<p>
-Finally, three static methods are included to provide access to the
-three pre-defined instructions.
-
-
 <hr />
 <p><a href="index.html">Return to the Index</a></p>
 

Modified: development/source/main/cTaskEntry.h
===================================================================
--- development/source/main/cTaskEntry.h	2006-08-30 21:03:41 UTC (rev 910)
+++ development/source/main/cTaskEntry.h	2006-08-31 02:01:54 UTC (rev 911)
@@ -43,7 +43,7 @@
   const cString& GetDesc() const { return m_desc; }
   const int GetID() const { return m_id; }
   const tTaskTest GetTestFun() const { return m_test_fun; }
-  const cString & GetInfo() const { return m_info; }
+  const cString& GetInfo() const { return m_info; }
 };
 
 

Modified: development/source/main/cTaskLib.h
===================================================================
--- development/source/main/cTaskLib.h	2006-08-30 21:03:41 UTC (rev 910)
+++ development/source/main/cTaskLib.h	2006-08-31 02:01:54 UTC (rev 911)
@@ -49,7 +49,7 @@
   };
   
 
-  cTaskLib(const cTaskLib &); // @not_implemented
+  cTaskLib(const cTaskLib&); // @not_implemented
   cTaskLib& operator=(const cTaskLib&); // @not_implemented
 
 public:
@@ -58,7 +58,7 @@
 
   int GetSize() const { return task_array.GetSize(); }
 
-  cTaskEntry * AddTask(const cString & name, const cString & info);
+  cTaskEntry* AddTask(const cString& name, const cString& info);
   const cTaskEntry& GetTask(int id) const;
   
   void SetupTests(cTaskContext& ctx) const;




More information about the Avida-cvs mailing list