[Avida-cvs] [Avida2-svn] r197 - in trunk: . notes source source/cpu source/main

ofria@myxo.css.msu.edu ofria at myxo.css.msu.edu
Thu Jun 9 21:10:35 PDT 2005


Author: ofria
Date: 2005-06-10 00:10:35 -0400 (Fri, 10 Jun 2005)
New Revision: 197

Added:
   trunk/notes/
   trunk/notes/3.0-notes
   trunk/notes/inst_set.stack_based
   trunk/notes/mutations.cfg
Modified:
   trunk/source/cpu/test_cpu.cc
   trunk/source/defs.hh
   trunk/source/main/analyze_util.cc
   trunk/source/main/environment.cc
   trunk/source/main/environment.hh
   trunk/source/main/organism.cc
   trunk/source/main/organism.hh
   trunk/source/main/phenotype.cc
   trunk/source/main/phenotype.hh
   trunk/source/main/reaction_process.hh
   trunk/source/main/reaction_result.cc
   trunk/source/main/reaction_result.hh
Log:
Added a notes directory to keep track of useful information about development.
Checking in Sherri's changes for communication
Minor fix on outputting task grids (there were problems with some compilers)
Fixed triggering instructions when tasks are performed.



Added: trunk/notes/3.0-notes
===================================================================
--- trunk/notes/3.0-notes	2005-06-09 19:52:48 UTC (rev 196)
+++ trunk/notes/3.0-notes	2005-06-10 04:10:35 UTC (rev 197)
@@ -0,0 +1,23 @@
+Get rid of merit.  Organisms have energy (which they absorb by performing
+reactions) and metabolic rate, which determines how quickly they use that
+energy to execute instructions.
+
+Each thread in an organism is placed into the scheduler.  When a thread is
+created, the scheduler assigns it a process ID, and that ID is then freed
+up with the thread is removed.  A thread must keep track of its own ID.
+When a thread is removed, its ID is placed in a container of free IDs.  Only
+when that container is empty are new IDs created.  This will happen rarely
+enough that its okay if its a slow process.
+
+New analyze mode!  This should be interesting...  Require lex & yacc?
+
+Implement new method of performing mutations.  The old stuff should be
+entirely removed.
+
+This version will be optimized for stack-based CPUs, but the old register
+based CPUs should still function fine.
+
+Make sure all output files have headers.  There should be a central object
+that all files are output through that will make sure this is the case.
+
+Make events just call analyze scripts.  Re-design entire even structure.

Added: trunk/notes/inst_set.stack_based
===================================================================
--- trunk/notes/inst_set.stack_based	2005-06-09 19:52:48 UTC (rev 196)
+++ trunk/notes/inst_set.stack_based	2005-06-10 04:10:35 UTC (rev 197)
@@ -0,0 +1,179 @@
+# This new CPU has 8 heads, 2 of each main type, and otherwise has four
+# stacks (A, B, C, and D) and no registers.
+
+# Base Instruction Set
+# Nops (1-4)
+Nop-A      1   # Associated with the Instruction Pointers
+Nop-B      1   # Associated with the Read Heads
+Nop-C      1   # Associated with the Write Heads
+Nop-D      1   # Associated with the Flow Heads
+
+# Other control functions (5)
+Toggle     1  # Causes all instructions to swap to a complementary behavior
+              # affects only the instruction that immediately follows it.
+              # A nop indicates that the associate head should be toggled
+              # to its alternate.  Two toggles will reset all toggled states
+
+# Single input Math -- *modifies* top of ?Stack-B? (6-7)
+Val-Shift  1  # shirt-r before toggle, shift-l after.
+Val-Inc    1  # inc before toggle, dec after
+
+# Double input math -- uses top of Stack-A and Stack-B; pushes result onto
+# the top of Stack-B (8-9)
+Val-Nand   1  # unaffected by toggle
+Val-Add    1  # add before toggle, sub after
+
+# Biological  (10-13)
+SetMemory  1  # Set the write head at the beginning of a memory space.  Up
+              #   to four memory spaces can be used at once.  Nop-A is the
+              #   main genome, and the other nops are possible offspring.
+              #   A nop argument will indicate a space; no nops will find
+              #   an "unclaimed" memory space (if possible)
+              #   Perhaps Toggle can be used for recombination somehow??
+Divide     1  # Divide off offspring memory.  After toggle becomes Inject.
+              #   If threads are active a successful inject will also cause
+              #   a fork.  In either case, it uses the memory that contains
+              #   the active write head.
+Inst-Read  1  # Push the instruction at ?read-head? into Stack-A (advance 
+              #   head) Toggle to move head back by one rather than advance.
+Inst-Write 1  # Pop Stack-A into position at ?write-head? (advance head)
+              #   Toggle to move head back by one rather than advance.
+
+# Flow Control (14-15)
+If-Equal   1  # Compares top of ?Stack-A? with successor (Default: Stack-B)
+              #   Becomes If-NEqual after toggle
+If-Less    1  # Compares top of ?Stack-A? with successor (Default: Stack-B)
+              #   Becomes If-Greater after toggle
+
+# Head Control (16-19)
+Head-Push  1  # Push position of ?IP? head onto Stack-B.
+              #   Toggle to use Stack-D
+Head-Pop   1  # Move ?flow-head? to address in Stack-B (pop Stack-B)
+              #   Toggle to use Stack-D
+
+Head-Move  1  # Move ?IP? head to flow-head
+              #   - if flow-head is given as nop, advance flow-head
+              #   Toggle to decrement flow-head when given as nop.
+Search     1  # Search for matching template, set flow head to last line,
+              #   template size to Stack-A and template distance to Stack-B
+	         #   If no template, move flow-head to next line, set A&B=0.
+              #   Toggle to NOT leave size&distance
+
+# Stack Control (20-24)
+Push-Next  1   # Pop off ?Stack-A? and push on successor   (Default: Stack-B)
+Push-Prev  1   # Pop off ?Stack-B? and push on predecessor (Default: Stack-A)
+Push-Comp  1   # Pop off ?Stack-B? and push on complement  (Default: Stack-D)
+Val-Delete 1   # Pop off (and lose) top value of ?Stack-B?
+Val-Copy   1   # Duplicate the contents at the top of ?Stack-B?
+
+# CPU:
+#  Stack-A (Used in copying & math)
+#  Stack-B (Used for positioning and math)
+#  Stack-C (Input)      -- Filled on birth
+#  Stack-D (Output)     -- Scanned (and emptied) on divide
+#
+# Four nops.  Each nop has a predecessor, successor and complement (opposite)
+#
+#  nop-A -> IP
+#  nop-B -> Read Head
+#  nop-C -> Write Head
+#  nop-D -> Flow Head
+#
+# Note lack of allocate instruction!
+# The organism has additional memory space that the write heads starts out
+# at the beginning of.  It is treated as an extension of the main memory,
+# BUT is local to each thread if there is more than one.
+
+# SAMPLE ORGANISM:
+#
+# Search       #  1:  Find organism end.
+# Nop-C        #  2:  - Match A:A
+# Nop-C        #  3:
+# Head-Push    #  4:  Save end position to Stack-B
+# Nop-D        #  5:  - Flow head is at end...
+# Push-Prev    #  6:  Move end position to Stack-A
+# SetMemory    #  7:  Place write-head in memory space for offspring
+# Search       #  8:  Drop flow head at start of copy loop
+# Inst-Read    #  9:
+# Inst-Write   # 10: 
+# Head-Push    # 11:  Get current position of...
+# Nop-C        # 12:  - Read-Head
+# If-Equal     # 13:  Test if we are done copying...
+# Divide       # 14:  ...If so, divide.
+# Head-Move    # 15:  ...If not, continue with loop.
+# Nop-A        # 16:
+# Nop-A        # 17:
+
+# Other possible, special instructions...
+# ScanWorld  1   # Environment-specific scanning instruction...
+# Val-Swap   1   # Swap top contents of ?Stack-A? with successor (Default: B)
+                 #  Toggle will swap with complement.
+# Inst-Copy  1   # Combine read and write
+# Inst-Move  1   # Like Inst-Copy, but actually deletes original and can
+                 #   move multiple lines at once (as indicated by ?Stack-B?)
+# SearchOut  1   # Like search, but in faced creature.  Needs exact match!
+# Rotate     1   # Rotate to neighbor with template (toggle reverses dir)
+                 #   in mass action, find randomly in population.
+# If-Bit-1   1   # Is last bit of ?Stack-B? a one? (toggle to If-Bit-0)
+# If-Zero    1   # Toggle to If-N-Zero
+# If-InstEqu 1   # Does contents of ?read-head? match successor (write-head)
+                 #   (toggle to If-InstNEqu)
+# Order      1   # Put top two numbers in ?Stack-B? into numerical order
+# Push-Zero  1   # Push a zero onto the top of ?Stack-B?
+# Replicate  1   # Make a full offspring
+
+ 
+# ------- THREADING --------
+# There can only be up to four threads in an organism, specified as
+# Thead-A through Thread-D
+
+# Hardware:
+#  For threads, Stacks A and B are local, while C and D are global.
+#  All heads are local to each thread.
+#   - Read and Flow heads will initialize to fork.
+#   - Write head will initialize on new offspring memory.
+#  Each thread has its own offspring memory.
+#  Each thread keeps its own list of toggled instructions.
+
+# Instructions:
+#  ThreadFork 1   # Create a new thread.  By default this will be the next
+                  #   available thread ID, but if a nop follows it will
+                  #   indicate the thread instead.  If a thread is specified
+                  #   that already exists, its priority will increase to a
+                  #   maximum.  On the original thread executes the next
+                  #   instruction.  Toggle to ThreadKill ?cur-Thread?, which
+                  #   will decrement a thread one step, to a min of 0.
+#  If-Thread  1   # Only execute next instruction if this is ?Thread-A?
+                  #   Toggle to IfNThread
+#  ThreadCopy 1   # Make this thread an exact copy of ?Thread A? including
+                  #   working on the same memory space.  Toggle to ThreadClr
+                  #   which will reset the specifed thread (default current)
+
+# SAMPLE PARASITE
+#
+# Nop-A        #  1: Some nop to extend the template above
+# Toggle       #  2: Toggle the Divide command...
+#  Divide      #  3:   ... to become "Inject"
+# Toggle       #  4: Toggle the If-Equal command...
+#  If-Equal    #  5:   ... to become "If-NEqual"
+# Search       #  6: Locate the end, so we know when to stop.
+# Nop-C        #  7:
+# Nop-D        #  8:
+# Head-Push    #  9: Save the location of the flow head to mark the end.
+# Nop-D        # 10:
+# Push-Prev    # 11:  Move end position to Stack-A
+# SetMemory    # 12:  Claim and empty memory space
+# Search       # 13:  Drop flow head at start of copy loop
+# Inst-Read    # 14:
+# Inst-Write   # 15: 
+# Head-Push    # 16:  Get current position of...
+# Nop-C        # 17:  - Read-Head
+# If-Equal     # 18:  Test if we are done copying... (If-NEqual)
+# Head-Move    # 19:  ...If not, continue with loop.
+# Divide       # 20:  ...If so, Inject!
+# Nop-C        # 21:     ... Into the very end of the host.
+# Nop-C        # 22
+# Head-Move    # 23: Go to the beginning of the copy loop and start over!
+# Nop-A        # 24: End Template
+# Nop-B        # 25:
+

Added: trunk/notes/mutations.cfg
===================================================================
--- trunk/notes/mutations.cfg	2005-06-09 19:52:48 UTC (rev 196)
+++ trunk/notes/mutations.cfg	2005-06-10 04:10:35 UTC (rev 197)
@@ -0,0 +1,64 @@
+# @CAO : THIS IS A PROTOTYPE FILE FOR HOW I'D LIKE TO SEE MUTATIONS WORK
+
+# This file is used to configure the mutations that occur during an avida
+# run.  The format is simple:
+#
+#   MUTATION <name> <trigger> <scope> <type> <rate>
+#
+# The "trigger" determines when the mutation should be tested for. 
+# Possibilities are -
+#
+#   update  : Test for these mutations each update
+#   divide  : Test during the successful birth of an offspring
+#   parent  : Test on a parent during a divide operation
+#   write   : Test each time an instruction is written to memory
+#   read    : Test whenever an instruction is read from memory.
+#   exec    : Test while an instruction is being processed by the hardware
+#
+# A copy command will perform both a read and a write.  A read mutation will
+# affect the site being read, and are therefore particulaly dangerous.
+#
+# The scope of a mutation type determines how much will be mutated.  There
+# are currently a few options -
+#
+#   genome  : A single mutation occurs in the whole genome.
+#   local   : Mutations occur at a local position.  If no local position can
+#             be specified in the trigger (i.e. 'parent') nothing happens.
+#   prop    : Proportional: same as local, but the rate used is normalized to
+#             1/genome_length
+#   global  : Same as local, but *all* positions in the genome are tested.
+#   spread  : Same as prop, but all positions are tested.
+#
+# The type of mutation determines what happens when a mutation does occur
+# at a site -
+#
+#   point    : Change the affected locus to a random instruction.
+#   insert   : Insert a random instruction at this poistion.
+#   delete   : Remove the instruction currently at this position.
+#   head_inc : Advance heads at this position.
+#   head_dec : Retreat heads at this position.
+#   temp     : Don't change the genome, but temporarily act as if a change has
+#              occured.  This is only relevent for types "read" and "exec".
+#   kill     : Sterilize the organism affected so that it is effectively dead.
+#
+# Finally, the rate indicates the frequency at which mutations occur.
+#
+# EXAMPLES:
+#
+# Old stype copy mutation rate of 0.0075:
+#
+#   MUTATION copy_mutation write local point 0.0075
+#
+# Old style divide insertion of 0.05:
+#
+#   MUTATION divide_ins divide genome insert 0.05
+#
+# Keeping an average genome mutation rate at 2.0 with copy mutations...
+#
+#   MUTATION copy_spread write prop point 2.0
+#
+# Most types of mutations that people want should be possible.
+#
+# CONFLICTS:
+#  Only local & spread scopes can interact with head/temp types.
+#  Divide trigger cannot work with local & spread scopes.
\ No newline at end of file

Modified: trunk/source/cpu/test_cpu.cc
===================================================================
--- trunk/source/cpu/test_cpu.cc	2005-06-09 19:52:48 UTC (rev 196)
+++ trunk/source/cpu/test_cpu.cc	2005-06-10 04:10:35 UTC (rev 197)
@@ -221,7 +221,7 @@
     input_array[1] = 0x3308e53e;  // 00110011 00001000 11100101 00111110
     input_array[2] = 0x556241eb;  // 01010101 01100010 01000001 11101011
 
-	receive_array.Resize(3);
+    receive_array.Resize(3);
     receive_array[0] = 0x0f139f14;  // 00001111 00010011 10011111 00010100
     receive_array[1] = 0x33083ee5;  // 00110011 00001000 00111110 11100101
     receive_array[2] = 0x5562eb41;  // 01010101 01100010 11101011 01000001

Modified: trunk/source/defs.hh
===================================================================
--- trunk/source/defs.hh	2005-06-09 19:52:48 UTC (rev 196)
+++ trunk/source/defs.hh	2005-06-10 04:10:35 UTC (rev 197)
@@ -168,6 +168,8 @@
 // Number of distinct input and outputs stored in the IOBufs (to test tasks)
 #define INPUT_BUF_SIZE  3
 #define OUTPUT_BUF_SIZE 1
+#define SEND_BUF_SIZE 3
+#define RECEIVE_BUF_SIZE 3
 
 // Task Merit Method //
 #define TASK_MERIT_NONE   0

Modified: trunk/source/main/analyze_util.cc
===================================================================
--- trunk/source/main/analyze_util.cc	2005-06-09 19:52:48 UTC (rev 196)
+++ trunk/source/main/analyze_util.cc	2005-06-10 04:10:35 UTC (rev 197)
@@ -790,10 +790,10 @@
         int num_tasks = test_phenotype.GetEnvironment().GetTaskLib().GetSize();   
         for (int k = 0; k < num_tasks; k++) {
           if (test_phenotype.GetLastTaskCount()[k]>0) {
-            task_sum = task_sum + (int)pow(2,k);
-          }
-        }  
-      }  
+	    task_sum = task_sum + (int) pow(2.0,k); 
+          } 
+        }
+      }
       fp << task_sum << " ";
     }
     fp << endl;

Modified: trunk/source/main/environment.cc
===================================================================
--- trunk/source/main/environment.cc	2005-06-09 19:52:48 UTC (rev 196)
+++ trunk/source/main/environment.cc	2005-06-10 04:10:35 UTC (rev 197)
@@ -704,8 +704,10 @@
 
 
 bool cEnvironment::TestOutput( cReactionResult & result,
-			       const tBuffer<int> & inputs,
-			       const tBuffer<int> & outputs,
+			       const tBuffer<int> & input_buf,
+			       const tBuffer<int> & output_buf,
+			       const tBuffer<int> & send_buf,
+			       const tBuffer<int> & receive_buf,
 			       const tArray<int> & task_count,
 			       const tArray<int> & reaction_count,
 			       const tArray<double> & resource_count,
@@ -713,7 +715,7 @@
 			       const tList< tBuffer<int> > & output_buffers) const
 {
   // Do setup for reaction tests...
-  task_lib.SetupTests(inputs, outputs, input_buffers, output_buffers);
+  task_lib.SetupTests(input_buf, output_buf, input_buffers, output_buffers);
 
   // Loop through all reactions to see if any have been triggered...
   const int num_reactions = reaction_lib.GetSize();
@@ -750,6 +752,34 @@
     result.MarkReaction(cur_reaction->GetID());
   }
 
+  // Loop again to check receive tasks...
+  // if (receive_buf.GetSize() != 0)
+  {
+    // Do setup for reaction tests...
+    task_lib.
+      SetupTests(receive_buf, output_buf, input_buffers, output_buffers);
+
+    for (int i = 0; i < num_reactions; i++) {
+      cReaction * cur_reaction = reaction_lib.GetReaction(i);
+      assert(cur_reaction != NULL);
+      
+      // Only use active reactions...
+      if (cur_reaction->GetActive() == false) continue;
+      
+      // Examine the task trigger associated with this reaction
+      cTaskEntry * cur_task = cur_reaction->GetTask();
+      assert(cur_task != NULL);
+      const double task_quality = task_lib.TestOutput(*cur_task);
+      const int task_id = cur_task->GetID();
+      
+      // If this task wasn't performed, move on to the next one.
+      if (task_quality == 0.0) continue;
+      
+      // Mark this task as performed...
+      result.MarkReceiveTask(task_id);
+    }
+  }
+
   return result.GetActive();
 }
 

Modified: trunk/source/main/environment.hh
===================================================================
--- trunk/source/main/environment.hh	2005-06-09 19:52:48 UTC (rev 196)
+++ trunk/source/main/environment.hh	2005-06-10 04:10:35 UTC (rev 197)
@@ -108,8 +108,10 @@
 		   const tArray<double> & resource_count ) const;
 
   bool TestOutput(  cReactionResult & result,
-		    const tBuffer<int> & inputs,
-		    const tBuffer<int> & outputs,
+		    const tBuffer<int> & input_buf,
+		    const tBuffer<int> & output_buf,
+		    const tBuffer<int> & send_buf,
+		    const tBuffer<int> & receive_buf,
 		    const tArray<int> & task_count,
 		    const tArray<int> & reaction_count,
 		    const tArray<double> & resource_count,

Modified: trunk/source/main/organism.cc
===================================================================
--- trunk/source/main/organism.cc	2005-06-09 19:52:48 UTC (rev 196)
+++ trunk/source/main/organism.cc	2005-06-10 04:10:35 UTC (rev 197)
@@ -45,6 +45,8 @@
   , input_pointer(0)
   , input_buf(INPUT_BUF_SIZE)
   , output_buf(OUTPUT_BUF_SIZE)
+  , send_buf(SEND_BUF_SIZE)
+  , receive_buf(RECEIVE_BUF_SIZE)
   , sent_value(0)
   , sent_active(false)
   , test_receive_pos(0)
@@ -92,7 +94,9 @@
   
 int cOrganism::ReceiveValue()
 {
-  return pop_interface.ReceiveValue();
+  const int out_value = pop_interface.ReceiveValue();
+  receive_buf.Add(out_value);
+  return out_value;
 }
 
 
@@ -137,8 +141,9 @@
   output_buf.Add(value);
   tArray<double> res_change(resource_count.GetSize());
   tArray<int> insts_triggered;
-  phenotype.TestOutput(input_buf, output_buf, resource_count, res_change,
-		       insts_triggered, other_input_list, other_output_list);
+  phenotype.TestOutput(input_buf, output_buf, send_buf, receive_buf,
+		       resource_count, res_change, insts_triggered,
+		       other_input_list, other_output_list);
   pop_interface.UpdateResources(res_change);
 
   for (int i = 0; i < insts_triggered.GetSize(); i++) {

Modified: trunk/source/main/organism.hh
===================================================================
--- trunk/source/main/organism.hh	2005-06-09 19:52:48 UTC (rev 196)
+++ trunk/source/main/organism.hh	2005-06-10 04:10:35 UTC (rev 197)
@@ -74,6 +74,8 @@
   int input_pointer;
   tBuffer<int> input_buf;
   tBuffer<int> output_buf;
+  tBuffer<int> send_buf;
+  tBuffer<int> receive_buf;
 
   // Communication
   int sent_value;         // What number is this org sending?

Modified: trunk/source/main/phenotype.cc
===================================================================
--- trunk/source/main/phenotype.cc	2005-06-09 19:52:48 UTC (rev 196)
+++ trunk/source/main/phenotype.cc	2005-06-10 04:10:35 UTC (rev 197)
@@ -493,7 +493,8 @@
   return false; // Nothing happened...
 }
 
-bool cPhenotype::TestOutput(tBuffer<int> & inputs, tBuffer<int> & outputs,
+bool cPhenotype::TestOutput(tBuffer<int> & input_buf, tBuffer<int> &output_buf,
+			    tBuffer<int> & send_buf, tBuffer<int> &receive_buf,
 			    const tArray<double> & res_in,
 			    tArray<double> & res_change,
 			    tArray<int> & insts_triggered,
@@ -509,8 +510,9 @@
   cReactionResult result(num_resources, num_tasks, num_reactions);
 			
   // Run everything through the environment.
-  bool found = environment.TestOutput(result, inputs, outputs, cur_task_count,
-		      cur_reaction_count, res_in, other_inputs, other_outputs);
+  bool found = environment.TestOutput(result, input_buf, output_buf, send_buf,
+			      receive_buf, cur_task_count, cur_reaction_count,
+			      res_in, other_inputs, other_outputs);
 
   // If nothing was found, stop here.
   if (found == false) {

Modified: trunk/source/main/phenotype.hh
===================================================================
--- trunk/source/main/phenotype.hh	2005-06-09 19:52:48 UTC (rev 196)
+++ trunk/source/main/phenotype.hh	2005-06-10 04:10:35 UTC (rev 197)
@@ -147,7 +147,8 @@
 
   // Input and Output Reaction Tests
   bool TestInput(tBuffer<int> & inputs, tBuffer<int> & outputs);
-  bool TestOutput(tBuffer<int> & inputs, tBuffer<int> & outputs,
+  bool TestOutput(tBuffer<int> & input_buf, tBuffer<int> & output_buf,
+		  tBuffer<int> & send_buf, tBuffer<int> & receive_buf,
 		  const tArray<double> & res_in, tArray<double> & res_change,
 		  tArray<int> & insts_triggered,
 		  tList<tBuffer<int> > & other_inputs,

Modified: trunk/source/main/reaction_process.hh
===================================================================
--- trunk/source/main/reaction_process.hh	2005-06-09 19:52:48 UTC (rev 196)
+++ trunk/source/main/reaction_process.hh	2005-06-10 04:10:35 UTC (rev 197)
@@ -8,6 +8,10 @@
 #ifndef REACTION_PROCESS_HH
 #define REACTION_PROCESS_HH
 
+#include <iostream>
+
+using namespace std;
+
 class cResource;
 class cReactionProcess {
 private:
@@ -38,7 +42,7 @@
   double GetMaxFraction() const { return max_fraction; }
   cResource * GetProduct() const { return product; }
   double GetConversion() const { return conversion; }
-  bool GetInstID() const { return inst_id; }
+  int GetInstID() const { return inst_id; }
   bool GetLethal() const { return lethal; }
   cResource * GetDetect() const { return detect; }
   double GetDetectionThreshold() const { return detection_threshold; }

Modified: trunk/source/main/reaction_result.cc
===================================================================
--- trunk/source/main/reaction_result.cc	2005-06-09 19:52:48 UTC (rev 196)
+++ trunk/source/main/reaction_result.cc	2005-06-10 04:10:35 UTC (rev 197)
@@ -15,6 +15,8 @@
   , resources_produced(num_resources)
   , resources_detected(num_resources)
   , tasks_done(num_tasks)
+  , receive_tasks_done(num_tasks)
+  , send_tasks_done(num_tasks)
   , reactions_triggered(num_reactions)
   , bonus_add(0.0)
   , bonus_mult(1.0)
@@ -24,17 +26,6 @@
 {
 }
 
-//  cReactionResult::cReactionResult(const cReactionResult & _in)
-//    : resources_consumed(_in.resources_consumed)
-//    , resources_produced(_in.resources_produced)
-//    , tasks_done(_in.tasks_done)
-//    , reactions_triggered(_in.reactions_triggered)
-//    , bonus_add(_in.bonus_add)
-//    , bonus_mult(_in.bonus_mult)
-//    , active_reaction(_in.active_reaction)
-//  {
-//  }
-
 cReactionResult::~cReactionResult()
 {
 }
@@ -50,6 +41,8 @@
   resources_produced.SetAll(0.0);
   resources_detected.SetAll(-1.0);
   tasks_done.SetAll(false);
+  receive_tasks_done.SetAll(false);
+  send_tasks_done.SetAll(false);
   reactions_triggered.SetAll(false);
 
   // And finally note that this is indeed already active.
@@ -90,6 +83,20 @@
 }
 
 
+void cReactionResult::MarkReceiveTask(int id)
+{
+  ActivateReaction();
+  receive_tasks_done[id] = true;
+}
+
+
+void cReactionResult::MarkSendTask(int id)
+{
+  ActivateReaction();
+  send_tasks_done[id] = true;
+}
+
+
 void cReactionResult::MarkReaction(int id)
 {
   ActivateReaction();

Modified: trunk/source/main/reaction_result.hh
===================================================================
--- trunk/source/main/reaction_result.hh	2005-06-09 19:52:48 UTC (rev 196)
+++ trunk/source/main/reaction_result.hh	2005-06-10 04:10:35 UTC (rev 197)
@@ -20,6 +20,8 @@
   tArray<double> resources_produced;
   tArray<double> resources_detected;  //Initialize to -1.0
   tArray<bool> tasks_done;
+  tArray<bool> receive_tasks_done;
+  tArray<bool> send_tasks_done;
   tArray<bool> reactions_triggered;
   double bonus_add;
   double bonus_mult;
@@ -40,6 +42,8 @@
   void Detect(int id, double num);
   void Lethal(bool flag);
   void MarkTask(int id);
+  void MarkReceiveTask(int id);
+  void MarkSendTask(int id);
   void MarkReaction(int id);
   void AddBonus(double value);
   void MultBonus(double value);




More information about the Avida-cvs mailing list