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 =
72 cfg.
add_child(
"candidate_action",ca->to_config());
82 return a->get_max_score() > b->get_max_score();
97 bool executed =
false;
98 bool gamestate_changed =
false;
106 if (!
ca_ptr->is_enabled()){
111 if (
ca_ptr->get_max_score()<=best_score) {
112 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()<< std::endl;
117 double score =
ca_ptr->evaluate();
120 if (score>best_score) {
135 DBG_AI_TESTING_RCA_DEFAULT <<
"Disabling candidate action because it failed to change the game state: "<< *best_ptr << std::endl;
139 gamestate_changed =
true;
147 return gamestate_changed;
152 std::vector<size_t> tbr;
162 for (
size_t i = 0;
i != tbr.size(); ++
i)
165 size_t index = tbr.size() -
i - 1;
170 cfg[
"action"] =
"delete";
child_itors child_range(const std::string &key)
static lg::log_domain log_ai_testing_rca_default("ai/stage/rca")
bool is_gamestate_changed()
Check if the gamestate has changed since last reset reset is done once on construction, and can be done by hand via reset() method.
property_handler_map & property_handlers()
game_logic::candidate_action_ptr ca_ptr
virtual std::string get_id() const
candidate_action_evaluation_loop(ai_context &context, const config &cfg)
std::vector< candidate_action_ptr > candidate_actions_
AI Support engine - creating specific ai components from config.
static void register_vector_property(std::map< std::string, property_handler_ptr > &property_handlers, const std::string &property, std::vector< boost::shared_ptr< X > > &values, std::function< void(std::vector< boost::shared_ptr< X > > &, const config &)> construction_factory)
A helper class to observe the game state.
rca_context & get_rca_context()
Unwrap.
#define LOG_AI_TESTING_RCA_DEFAULT
GLdouble GLdouble GLdouble b
A small explanation about what's going on here: Each action has access to two game_info objects First...
GLsizei const char ** path
virtual config to_config() const
serialize
Composite AI with turn sequence which is a vector of stages.
GLboolean GLboolean GLboolean GLboolean a
config & add_child(const std::string &key)
Managing the AIs lifecycle - headers.
static void modify_active_ai_for_side(ai::side_number side, const config &cfg)
Modifies AI parameters for active AI of the given side.
static void parse_candidate_action_from_config(rca_context &context, const config &cfg, std::back_insert_iterator< std::vector< candidate_action_ptr > > b)
candidate action evaluator
void remove_completed_cas()
bool operator()(const candidate_action_ptr &a, const candidate_action_ptr &b)
void create_candidate_action(std::vector< candidate_action_ptr > &candidate_actions, const config &cfg)
static int sort(lua_State *L)
config to_config() const
serialize
~candidate_action_evaluation_loop()
void on_create()
Initialization.
bool do_play_stage()
Play the turn - implementation.
Standard logging facilities (interface).
virtual side_number get_side() const =0
Get the side number.
static const double BAD_SCORE
#define DBG_AI_TESTING_RCA_DEFAULT
A config object defines a single node in a WML file, with access to child nodes.
GLsizei const GLcharARB ** string
candidate action framework