[avida-cvs] avida CVS commits: /current/source/main environment.cc environment.hh reaction.cc reaction.hh
bckirkup
avida-cvs at alife.org
Thu Jun 19 01:41:59 PDT 2003
bckirkup Wed Jun 18 17:41:59 2003 EDT
Modified files:
/avida/current/source/main environment.cc environment.hh
reaction.cc reaction.hh
Log:
Adding the input handling and utility code for detection of resources and lethal reactions
Index: avida/current/source/main/environment.cc
diff -u avida/current/source/main/environment.cc:1.11 avida/current/source/main/environment.cc:1.12
--- avida/current/source/main/environment.cc:1.11 Sun May 18 19:07:58 2003
+++ avida/current/source/main/environment.cc Wed Jun 18 17:41:59 2003
@@ -82,6 +82,24 @@
return true;
}
+bool cEnvironment::AssertInputBool(const cString & input,
+ const cString & name,
+ const cString & type)
+{
+ if (input.IsNumber() == false) {
+ cerr << "Error: In " << type << "," << name << " set to non-number."
+ << endl;
+ return false;
+ }
+ int value = input.AsInt();
+ if ((value != 1) && (value != 0)) {
+ cerr << "Error: In " << type << "," << name << " set to non-bool."
+ << endl;
+ return false;
+ }
+ return true;
+}
+
bool cEnvironment::AssertInputValid(void * input,
const cString & name,
const cString & type,
@@ -161,6 +179,25 @@
else if (var_name == "conversion") {
if (!AssertInputDouble(var_value, "conversion", var_type)) return false;
new_process->SetConversion(var_value.AsDouble());
+ }
+ else if (var_name == "lethal") {
+ if (!AssertInputBool(var_value, "lethal", var_type)) return false;
+ new_process->SetLethal(var_value.AsInt());
+ }
+ else if (var_name == "detect") {
+ cResource * test_resource = resource_lib.GetResource(var_value);
+ if (!AssertInputValid(test_resource, "product", var_type, var_value)) {
+ return false;
+ }
+ new_process->SetDetect(test_resource);
+ }
+ else if (var_name == "threshold") {
+ if (!AssertInputDouble(var_value, "threshold", var_type)) return false;
+ new_process->SetDetectionThreshold(var_value.AsDouble());
+ }
+ else if (var_name == "detectionerror") {
+ if (!AssertInputDouble(var_value, "detectionerror", var_type)) return false;
+ new_process->SetDetectionError(var_value.AsDouble());
}
else {
cerr << "Error: Unknown process variable '" << var_name
Index: avida/current/source/main/environment.hh
diff -u avida/current/source/main/environment.hh:1.9 avida/current/source/main/environment.hh:1.10
--- avida/current/source/main/environment.hh:1.9 Sat May 17 14:54:54 2003
+++ avida/current/source/main/environment.hh Wed Jun 18 17:41:59 2003
@@ -35,6 +35,8 @@
const cString & type);
static bool AssertInputDouble(const cString & input, const cString & name,
const cString & type);
+ static bool AssertInputBool(const cString & input, const cString & name,
+ const cString & type);
static bool AssertInputValid(void * input, const cString & name,
const cString & type, const cString & value);
Index: avida/current/source/main/reaction.cc
diff -u avida/current/source/main/reaction.cc:1.5 avida/current/source/main/reaction.cc:1.6
--- avida/current/source/main/reaction.cc:1.5 Sat May 17 02:48:10 2003
+++ avida/current/source/main/reaction.cc Wed Jun 18 17:41:59 2003
@@ -27,6 +27,10 @@
, max_fraction(1.0)
, product(NULL)
, conversion(1.0)
+ , lethal(0)
+ , detect(NULL)
+ , detection_threshold(0.0)
+ , detection_error(0.0)
{
}
Index: avida/current/source/main/reaction.hh
diff -u avida/current/source/main/reaction.hh:1.3 avida/current/source/main/reaction.hh:1.4
--- avida/current/source/main/reaction.hh:1.3 Fri Oct 12 05:22:55 2001
+++ avida/current/source/main/reaction.hh Wed Jun 18 17:41:59 2003
@@ -32,6 +32,10 @@
double max_fraction; // Max fraction of avaiable resources useable.
cResource * product; // Output resource.
double conversion; // Conversion factor.
+ bool lethal; // Lethality of reaction
+ cResource * detect; // Resource Measured
+ double detection_threshold; //Minimum quantity of resource to register as present
+ double detection_error; //Standard Deviation of Detection Event (as % present)
public:
cReactionProcess();
~cReactionProcess();
@@ -44,6 +48,10 @@
double GetMaxFraction() const { return max_fraction; }
cResource * GetProduct() const { return product; }
double GetConversion() const { return conversion; }
+ bool GetLethal() const { return lethal; }
+ cResource * GetDetect() const { return detect; }
+ double GetDetectionThreshold() const { return detection_threshold; }
+ double GetDetectionError() const { return detection_error; }
void SetResource(cResource * _in) { resource = _in; }
void SetValue(double _in) { value = _in; }
@@ -53,6 +61,10 @@
void SetMaxFraction(double _in) { max_fraction = _in; }
void SetProduct(cResource * _in) { product = _in; }
void SetConversion(double _in) { conversion = _in; }
+ void SetLethal(int _in) { lethal = _in; }
+ void SetDetect(cResource * _in) { detect = _in; }
+ void SetDetectionThreshold(double _in) { detection_threshold = _in; }
+ void SetDetectionError(double _in) { detection_error = _in; }
};
class cReactionRequisite {
More information about the Avida-cvs
mailing list