34 namespace ai_default_rca {
37 #define DBG_AI_TESTING_RCA_DEFAULT LOG_STREAM(debug, log_ai_testing_rca_default)
38 #define LOG_AI_TESTING_RCA_DEFAULT LOG_STREAM(info, log_ai_testing_rca_default)
39 #define ERR_AI_TESTING_RCA_DEFAULT LOG_STREAM(err, log_ai_testing_rca_default)
43 , candidate_actions_()
55 std::function<void(std::vector<candidate_action_ptr>&,
const config&)> factory_candidate_actions = [
this](std::vector<candidate_action_ptr> &candidate_actions,
const config &cfg)
67 cfg.
add_child(
"candidate_action",ca->to_config());
77 return a->get_max_score() >
b->get_max_score();
92 bool executed =
false;
93 bool gamestate_changed =
false;
101 if (!
ca_ptr->is_enabled()){
106 if (
ca_ptr->get_max_score()<=best_score) {
107 DBG_AI_TESTING_RCA_DEFAULT <<
"Ending candidate action evaluation loop because current score "<<best_score<<
" is greater than the upper bound of score for remaining candidate actions "<<
ca_ptr->get_max_score();
112 double score =
ca_ptr->evaluate();
115 if (score>best_score) {
134 gamestate_changed =
true;
142 return gamestate_changed;
147 std::vector<std::size_t> tbr;
157 for (std::size_t
i = 0;
i != tbr.size(); ++
i)
160 std::size_t
index = tbr.size() -
i - 1;
165 cfg[
"action"] =
"delete";
Managing the AIs lifecycle - headers TODO: Refactor history handling and internal commands.
std::vector< candidate_action_ptr > candidate_actions_
config to_config() const
serialize
candidate_action_evaluation_loop(ai_context &context, const config &cfg)
~candidate_action_evaluation_loop()
bool do_play_stage()
Play the turn - implementation.
void on_create()
Initialization.
void remove_completed_cas()
rca_context & get_rca_context()
Unwrap.
bool operator()(const candidate_action_ptr &a, const candidate_action_ptr &b) const
static const double BAD_SCORE
property_handler_map & property_handlers()
static void parse_candidate_action_from_config(rca_context &context, const config &cfg, std::back_insert_iterator< std::vector< candidate_action_ptr >> b)
bool is_gamestate_changed()
Check if the gamestate has changed since last reset reset is done once on construction,...
static manager & get_singleton()
void modify_active_ai_for_side(ai::side_number side, const config &cfg)
Modifies AI parameters for active AI of the given side.
virtual side_number get_side() const =0
Get the side number.
virtual std::string get_id() const
virtual config to_config() const
serialize
A config object defines a single node in a WML file, with access to child nodes.
child_itors child_range(config_key_type key)
config & add_child(config_key_type key)
AI Support engine - creating specific ai components from config.
A helper class to observe the game state.
Standard logging facilities (interface).
static lg::log_domain log_ai_testing_rca_default("ai/stage/rca")
A small explanation about what's going on here: Each action has access to two game_info objects First...
wfl::candidate_action_ptr ca_ptr
std::shared_ptr< candidate_action > candidate_action_ptr
static void register_vector_property(property_handler_map &property_handlers, const std::string &property, std::vector< std::shared_ptr< X >> &values, std::function< void(std::vector< std::shared_ptr< X >> &, const config &)> construction_factory)
std::size_t index(const std::string &str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
candidate action framework
#define LOG_AI_TESTING_RCA_DEFAULT
#define DBG_AI_TESTING_RCA_DEFAULT
candidate action evaluator