[Avida-SVN] r2917 - in branches/hjg-dev/source: cpu main
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Tue Nov 4 11:53:34 PST 2008
Author: hjg
Date: 2008-11-04 14:53:34 -0500 (Tue, 04 Nov 2008)
New Revision: 2917
Modified:
branches/hjg-dev/source/cpu/cHardwareCPU.cc
branches/hjg-dev/source/main/cAvidaConfig.h
Log:
Added execution errors to the model. Donations will fail with a probability set in the configuration file.
Modified: branches/hjg-dev/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/hjg-dev/source/cpu/cHardwareCPU.cc 2008-11-04 04:54:18 UTC (rev 2916)
+++ branches/hjg-dev/source/cpu/cHardwareCPU.cc 2008-11-04 19:53:34 UTC (rev 2917)
@@ -6759,6 +6759,18 @@
// Subtract raw materials from the organism (currently subtracts 1 resource...)
// fails if the organism does not have any more resources
if (organism->SubtractSelfRawMaterials(1)) {
+
+ // sometimes the donation will fail.
+ // get the probability of failure
+ int prob_fail = m_world->GetConfig().DONATION_FAILURE_PERCENT.Get();
+ unsigned int rand_num = m_world->GetRandom().GetUInt(0, 100);
+ // neighbor donates to organism.
+ if (rand_num < prob_fail) {
+ // EXIT
+ return true;
+ }
+
+
neighbor->AddOtherRawMaterials(1, organism->GetID());
// rotate recipient to face donor
Modified: branches/hjg-dev/source/main/cAvidaConfig.h
===================================================================
--- branches/hjg-dev/source/main/cAvidaConfig.h 2008-11-04 04:54:18 UTC (rev 2916)
+++ branches/hjg-dev/source/main/cAvidaConfig.h 2008-11-04 19:53:34 UTC (rev 2917)
@@ -563,6 +563,7 @@
CONFIG_ADD_VAR(MY_RAW_MAT_MULT, double, 1.00, "Number multiplied by the number of your raw materials");
CONFIG_ADD_VAR(ROTATE_ON_DONATE, int, 0, "Rotate an organism to face its donor 0/1 (off/on)");
CONFIG_ADD_VAR(REPUTATION_REWARD, int, 0, "Reward an organism for having a good reputation");
+ CONFIG_ADD_VAR(DONATION_FAILURE_PERCENT, int, 0, "Percentage of times that a donation fails");
#endif
More information about the Avida-cvs
mailing list