1 /* 2 * cReactionResult.h 3 * Avida 4 * 5 * Called "reaction_result.hh" prior to 12/5/05. 6 * Copyright 1999-2011 Michigan State University. All rights reserved. 7 * Copyright 1993-2004 California Institute of Technology. 8 * 9 * 10 * This file is part of Avida. 11 * 12 * Avida is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License 13 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 14 * 15 * Avida is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public License along with Avida. 19 * If not, see <http://www.gnu.org/licenses/>. 20 * 21 */ 22 23 #ifndef cReactionResult_h 24 #define cReactionResult_h 25 26 #include "tArray.h" 27 #include "cString.h" 28 29 class cReactionResult { 30 private: 31 tArray<double> resources_consumed; 32 tArray<double> resources_produced; 33 tArray<double> resources_detected; //Initialize to -1.0 34 tArray<double> internal_resources_consumed; 35 tArray<double> internal_resources_produced; 36 tArray<bool> tasks_done; 37 tArray<double> tasks_quality; 38 tArray<double> tasks_value; 39 tArray<bool> reactions_triggered; 40 tArray<double> reaction_add_bonus; 41 tArray<double> task_plasticity; 42 double energy_add; 43 double bonus_add; 44 double bonus_mult; 45 double germline_add; 46 double germline_mult; 47 tArray<cString> insts_triggered; 48 bool lethal; 49 bool sterilize; 50 bool active_reaction; 51 bool used_env_resource; 52 53 double deme_add_bonus; //!< Additive bonus applied to the deme as a result of this reaction. 54 double deme_mult_bonus; //!< Multiplicative bonus applied to the deme as a result of this reaction. 55 bool active_deme_reaction; //!< Whether this reaction result includes a deme merit component. 56 57 inline void ActivateReaction(); 58 59 cReactionResult(); // @not_implemented 60 cReactionResult(const cReactionResult&); // @not_implemented 61 cReactionResult& operator=(const cReactionResult&); // @not_implemented 62 63 public: 64 cReactionResult(const int num_resources, const int num_tasks, const int num_reactions); ~cReactionResult()65 ~cReactionResult() { ; } 66 GetActive()67 bool GetActive() const { return active_reaction; } GetActiveDeme()68 bool GetActiveDeme() const { return active_deme_reaction; } Invalidate()69 void Invalidate() { active_reaction = false; } 70 71 72 void Consume(int id, double num, bool is_env_resource); 73 void Produce(int id, double num, bool is_env_resource); 74 void Detect(int id, double num); 75 void Lethal(bool flag); 76 void Sterilize(bool flag); 77 void MarkTask(int id, const double quality=1, const double value=0); 78 79 void MarkReaction(int id); 80 void AddEnergy(double value); 81 void AddBonus(double value, int id); 82 void MultBonus(double value); 83 void AddDemeBonus(double value); 84 void MultDemeBonus(double value); 85 void AddGermline(double value); 86 void MultGermline(double value); 87 88 void AddInst(const cString& inst); 89 90 double GetConsumed(int id); 91 double GetProduced(int id); 92 double GetDetected(int id); 93 double GetInternalConsumed(int id); 94 double GetInternalProduced(int id); 95 bool GetLethal(); 96 bool GetSterilize(); 97 bool ReactionTriggered(int id); 98 bool TaskDone(int id); 99 double TaskQuality(int id); 100 double TaskValue(int id); GetAddEnergy()101 double GetAddEnergy() { return energy_add; } GetAddBonus()102 double GetAddBonus() { return bonus_add; } GetReactionAddBonus(const int i)103 double GetReactionAddBonus(const int i) { return reaction_add_bonus[i]; } GetMultBonus()104 double GetMultBonus() { return bonus_mult; } GetInstArray()105 tArray<cString>& GetInstArray() { return insts_triggered; } UsedEnvResource()106 bool UsedEnvResource() { return used_env_resource; } IsEnvResource()107 bool IsEnvResource() { return used_env_resource; } GetAddDemeBonus()108 double GetAddDemeBonus() { return deme_add_bonus; } GetMultDemeBonus()109 double GetMultDemeBonus() { return deme_mult_bonus; } GetAddGermline()110 double GetAddGermline() { return germline_add; } GetMultGermline()111 double GetMultGermline() { return germline_mult; } 112 }; 113 114 #endif 115