[Avida-cvs] [avida-svn] r627 - development/source/main

brysonda@myxo.css.msu.edu brysonda at myxo.css.msu.edu
Sun Apr 23 10:25:38 PDT 2006


Author: brysonda
Date: 2006-04-23 13:25:38 -0400 (Sun, 23 Apr 2006)
New Revision: 627

Modified:
   development/source/main/cAvidaConfig.h
   development/source/main/cOrganism.cc
Log:
Add new message corruption style, always flip last bit.

Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h	2006-04-22 03:13:45 UTC (rev 626)
+++ development/source/main/cAvidaConfig.h	2006-04-23 17:25:38 UTC (rev 627)
@@ -263,6 +263,7 @@
   CONFIG_ADD_VAR(NET_ENABLED, bool, 0, "Enable Network Communication Support");
   CONFIG_ADD_VAR(NET_DROP_PROB, double, 0.0, "Message drop rate");
   CONFIG_ADD_VAR(NET_MUT_PROB, double, 0.0, "Message corruption probability");
+  CONFIG_ADD_VAR(NET_MUT_TYPE, int, 0, "Type of message corruption.  0 = Random Single Bit, 1 = Always Flip Last");
   CONFIG_ADD_VAR(NET_STYLE, int, 0, "Communication Style.  0 = Random Next, 1 = Receiver Facing");
 #endif
   

Modified: development/source/main/cOrganism.cc
===================================================================
--- development/source/main/cOrganism.cc	2006-04-22 03:13:45 UTC (rev 626)
+++ development/source/main/cOrganism.cc	2006-04-23 17:25:38 UTC (rev 627)
@@ -227,8 +227,20 @@
   int actual_value = value;
   const double mut_prob = m_world->GetConfig().NET_MUT_PROB.Get();
   if (mut_prob > 0.0 && ctx.GetRandom().P(mut_prob)) {
-    actual_value ^= 1 << ctx.GetRandom().GetUInt(31); // Flip a single random bit
-    m_net->sent[index].SetCorrupted();
+    switch (m_world->GetConfig().NET_MUT_TYPE.Get())
+    {
+      case 0: // Flip a single random bit
+        actual_value ^= 1 << ctx.GetRandom().GetUInt(31);
+        m_net->sent[index].SetCorrupted();
+        break;
+      case 1: // Flip the last bit
+        actual_value ^= 1;
+        m_net->sent[index].SetCorrupted();
+        break;
+      default:
+        // invalid selection, no action
+        break;
+    }
   }
   
   assert(m_interface);




More information about the Avida-cvs mailing list