[Avida-cvs] [Avida2-svn] r404 - in development/source: . main

brysonda@myxo.css.msu.edu brysonda at myxo.css.msu.edu
Sat Nov 19 12:43:22 PST 2005


Author: brysonda
Date: 2005-11-19 15:43:22 -0500 (Sat, 19 Nov 2005)
New Revision: 404

Modified:
   development/source/Doxyfile
   development/source/main/cTaskLib.cc
   development/source/main/cTaskLib.h
Log:
Add in FractionReward algorithm to the cTaskLib.  Not used yet.

Modified: development/source/Doxyfile
===================================================================
--- development/source/Doxyfile	2005-11-17 21:32:54 UTC (rev 403)
+++ development/source/Doxyfile	2005-11-19 20:43:22 UTC (rev 404)
@@ -587,7 +587,8 @@
 
 LATEX_OUTPUT           = latex
 
-# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be invoked. If left blank `latex' will be used as the default command name.
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be invoked.
+# If left blank `latex' will be used as the default command name.
 
 LATEX_CMD_NAME         = latex
 

Modified: development/source/main/cTaskLib.cc
===================================================================
--- development/source/main/cTaskLib.cc	2005-11-17 21:32:54 UTC (rev 403)
+++ development/source/main/cTaskLib.cc	2005-11-19 20:43:22 UTC (rev 404)
@@ -39,6 +39,15 @@
   }
 }
 
+inline double cTaskLib::FractionalReward(unsigned int supplied, unsigned int correct)
+{
+  const unsigned int variance = supplied ^ correct;
+  const unsigned int w = variance - ((variance >> 1) & 0x55555555);
+  const unsigned int x = (w & 0x33333333) + ((w >> 2) & 0x33333333);
+  const unsigned int bit_diff = ((x + (x >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
+  return static_cast<double>(32 - bit_diff) / 32.0; 
+}
+
 cTaskEntry * cTaskLib::AddTask(const cString & name)
 {
   // Determine if this task is already in the active library.

Modified: development/source/main/cTaskLib.h
===================================================================
--- development/source/main/cTaskLib.h	2005-11-17 21:32:54 UTC (rev 403)
+++ development/source/main/cTaskLib.h	2005-11-19 20:43:22 UTC (rev 404)
@@ -70,6 +70,8 @@
   void SetupLogicTests(const tBuffer<int> & inputs,
 		       const tBuffer<int> & outputs) const;
 
+  inline double FractionalReward(unsigned int supplied, unsigned int correct);  
+
   double Task_Echo() const;
   double Task_Add()  const;
   double Task_Sub()  const;




More information about the Avida-cvs mailing list