[Avida-SVN] r2318 - in development: Avida.xcodeproj source/main
dknoester at myxo.css.msu.edu
dknoester at myxo.css.msu.edu
Sat Feb 9 09:33:40 PST 2008
Author: dknoester
Date: 2008-02-09 12:33:40 -0500 (Sat, 09 Feb 2008)
New Revision: 2318
Modified:
development/Avida.xcodeproj/project.pbxproj
development/source/main/cEnvironment.cc
development/source/main/cPhenotype.cc
development/source/main/cReactionProcess.h
development/source/main/cReactionResult.cc
development/source/main/cReactionResult.h
Log:
Added a 'sterilize' flag to reaction process descriptions. If sterilize is true (1), performing that reaction will prevent the caller from dividing.
Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj 2008-02-08 21:09:31 UTC (rev 2317)
+++ development/Avida.xcodeproj/project.pbxproj 2008-02-09 17:33:40 UTC (rev 2318)
@@ -844,7 +844,7 @@
DCC315CE076253A5008F7A48 /* environment.rotate */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = environment.rotate; sourceTree = "<group>"; };
DCC315D0076253A5008F7A48 /* task_event_gen.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = task_event_gen.cc; sourceTree = "<group>"; };
DCC315D1076253A5008F7A48 /* task_event_gen.old.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = task_event_gen.old.cc; sourceTree = "<group>"; };
- DCC3164D07626CF3008F7A48 /* avida */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = avida; sourceTree = BUILT_PRODUCTS_DIR; };
+ DCC3164D07626CF3008F7A48 /* avida */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = avida; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
Modified: development/source/main/cEnvironment.cc
===================================================================
--- development/source/main/cEnvironment.cc 2008-02-08 21:09:31 UTC (rev 2317)
+++ development/source/main/cEnvironment.cc 2008-02-09 17:33:40 UTC (rev 2318)
@@ -200,6 +200,11 @@
return false;
new_process->SetLethal(var_value.AsInt());
}
+ else if (var_name == "sterilize") {
+ if (!AssertInputBool(var_value, "sterilize", var_type))
+ return false;
+ new_process->SetSterile(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)) {
@@ -1062,7 +1067,8 @@
result.AddInst(inst_id);
}
- result.Lethal(cur_process->GetLethal());
+ result.Lethal(cur_process->GetLethal());
+ result.Sterilize(cur_process->GetSterilize());
}
}
Modified: development/source/main/cPhenotype.cc
===================================================================
--- development/source/main/cPhenotype.cc 2008-02-08 21:09:31 UTC (rev 2317)
+++ development/source/main/cPhenotype.cc 2008-02-09 17:33:40 UTC (rev 2318)
@@ -1023,7 +1023,11 @@
//Kill any cells that did lethal reactions
to_die = result.GetLethal();
-
+
+ // Sterilize organisms that have performed a sterilizing task.
+ if(result.GetSterilize()) {
+ is_fertile = false;
+ }
return true;
}
Modified: development/source/main/cReactionProcess.h
===================================================================
--- development/source/main/cReactionProcess.h 2008-02-08 21:09:31 UTC (rev 2317)
+++ development/source/main/cReactionProcess.h 2008-02-09 17:33:40 UTC (rev 2318)
@@ -53,6 +53,7 @@
cResource* product; // Output resource.
double conversion; // Conversion factor.
bool lethal; // Lethality of reaction
+ bool sterilize; //! Whether performance of this reaction sterilizes the organism.
cString match_string; // Bit string to match if this is a match string reaction
int inst_id; // Instruction to be triggered if reaction successful.
bool depletable; // Does completing consume resource?
@@ -79,6 +80,7 @@
, product(NULL)
, conversion(1.0)
, lethal(0)
+ , sterilize(false)
, inst_id(-1)
, depletable(true)
, detect(NULL)
@@ -99,6 +101,7 @@
int GetInstID() const { return inst_id; }
bool GetDepletable() const { return depletable; }
bool GetLethal() const { return lethal; }
+ bool GetSterilize() const { return sterilize; }
cResource* GetDetect() const { return detect; }
double GetDetectionThreshold() const { return detection_threshold; }
double GetDetectionError() const { return detection_error; }
@@ -115,6 +118,7 @@
void SetInstID(int _in) { inst_id = _in; }
void SetDepletable(bool _in) { depletable = _in; }
void SetLethal(int _in) { lethal = _in; }
+ void SetSterile(int _in) { sterilize = _in; }
void SetDetect(cResource* _in) { detect = _in; }
void SetDetectionThreshold(double _in) { detection_threshold = _in; }
void SetDetectionError(double _in) { detection_error = _in; }
Modified: development/source/main/cReactionResult.cc
===================================================================
--- development/source/main/cReactionResult.cc 2008-02-08 21:09:31 UTC (rev 2317)
+++ development/source/main/cReactionResult.cc 2008-02-09 17:33:40 UTC (rev 2318)
@@ -92,6 +92,13 @@
lethal = flag;
}
+void cReactionResult::Sterilize(bool flag)
+{
+ ActivateReaction();
+ sterilize = flag;
+}
+
+
void cReactionResult::MarkTask(int id, const double quality, const double value)
{
ActivateReaction();
@@ -157,6 +164,12 @@
return lethal;
}
+bool cReactionResult::GetSterilize()
+{
+ if (GetActive() == false) return false;
+ return sterilize;
+}
+
bool cReactionResult::ReactionTriggered(int id)
{
if (GetActive() == false) return false;
Modified: development/source/main/cReactionResult.h
===================================================================
--- development/source/main/cReactionResult.h 2008-02-08 21:09:31 UTC (rev 2317)
+++ development/source/main/cReactionResult.h 2008-02-09 17:33:40 UTC (rev 2318)
@@ -45,6 +45,7 @@
double bonus_mult;
tArray<int> insts_triggered;
bool lethal;
+ bool sterilize;
bool active_reaction;
inline void ActivateReaction();
@@ -63,6 +64,7 @@
void Produce(int id, double num);
void Detect(int id, double num);
void Lethal(bool flag);
+ void Sterilize(bool flag);
void MarkTask(int id, const double quality=1, const double value=0);
void MarkReaction(int id);
@@ -76,6 +78,7 @@
double GetProduced(int id);
double GetDetected(int id);
bool GetLethal();
+ bool GetSterilize();
bool ReactionTriggered(int id);
bool TaskDone(int id);
double TaskQuality(int id);
More information about the Avida-cvs
mailing list