Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "ai.hpp"
00022 #include "engine.hpp"
00023 #include "rca.hpp"
00024 #include "../../log.hpp"
00025
00026 namespace ai {
00027
00028 static lg::log_domain log_ai_stage_rca("ai/stage/rca");
00029 #define DBG_AI_STAGE_RCA LOG_STREAM(debug, log_ai_stage_rca)
00030 #define LOG_AI_STAGE_RCA LOG_STREAM(info, log_ai_stage_rca)
00031 #define ERR_AI_STAGE_RCA LOG_STREAM(err, log_ai_stage_rca)
00032
00033 const double candidate_action::BAD_SCORE = 0;
00034 const double candidate_action::HIGH_SCORE = 10000000;
00035
00036 candidate_action::candidate_action(rca_context &context, const config &cfg):
00037 recursion_counter_(context.get_recursion_count()),
00038 enabled_(cfg["enabled"].to_bool(true)), engine_(cfg["engine"]),
00039 score_(cfg["score"].to_double(BAD_SCORE)),
00040 max_score_(cfg["max_score"].to_double(HIGH_SCORE)),
00041 id_(cfg["id"]), name_(cfg["name"]), type_(cfg["type"]), to_be_removed_(false)
00042 {
00043 init_rca_context_proxy(context);
00044 }
00045
00046 candidate_action::~candidate_action()
00047 {
00048 }
00049
00050
00051 bool candidate_action::is_enabled() const
00052 {
00053 return enabled_;
00054 }
00055
00056
00057 void candidate_action::enable()
00058 {
00059 enabled_ = true;
00060 }
00061
00062 int candidate_action::get_recursion_count() const
00063 {
00064 return recursion_counter_.get_count();
00065 }
00066
00067 void candidate_action::disable()
00068 {
00069 enabled_ = false;
00070 }
00071
00072
00073 double candidate_action::get_score() const
00074 {
00075 return score_;
00076 }
00077
00078
00079 double candidate_action::get_max_score() const
00080 {
00081 return max_score_;
00082 }
00083
00084 const std::string& candidate_action::get_type() const
00085 {
00086 return type_;
00087 }
00088
00089 config candidate_action::to_config() const
00090 {
00091 config cfg;
00092 cfg["enabled"] = enabled_;
00093 cfg["engine"] = engine_;
00094 cfg["name"] = name_;
00095 cfg["score"] = score_;
00096 cfg["max_score"] = max_score_;
00097 cfg["type"] = type_;
00098 return cfg;
00099 }
00100
00101 void candidate_action::set_to_be_removed()
00102 {
00103 to_be_removed_ = true;
00104 }
00105
00106 bool candidate_action::to_be_removed()
00107 {
00108 return to_be_removed_;
00109 }
00110
00111
00112
00113 }
00114
00115
00116 std::ostream &operator<<(std::ostream &s, ai::candidate_action const &ca) {
00117 s << "candidate action with name ["<< ca.get_name() <<"]";
00118 return s;
00119 }
00120