37 #define DBG_AI_COMPOSITE LOG_STREAM(debug, log_ai_composite)
38 #define LOG_AI_COMPOSITE LOG_STREAM(info, log_ai_composite)
39 #define ERR_AI_COMPOSITE LOG_STREAM(err, log_ai_composite)
46 return "[composite_ai]";
50 : cfg_(cfg),stages_(),recursion_counter_(context.get_recursion_count())
58 cfg_[
"id"]<<
"]"<<std::endl;
66 cfg[
"engine"] =
"fai";
69 e_ptr->set_ai_context(
this);
72 std::function<void(std::vector<engine_ptr>&,
const config&)> factory_engines =
75 std::function<void(std::vector<goal_ptr>&,
const config&)> factory_goals =
78 std::function<void(std::vector<stage_ptr>&,
const config&)> factory_stages =
81 std::function<void(std::map<std::string,aspect_ptr>&,
const config&,
std::string)> factory_aspects =
112 std::vector<aspect_ptr> temp_aspects;
114 aspects[
id] = temp_aspects.back();
124 std::vector< stage_ptr >
stages;
137 std::vector< goal_ptr > goals;
170 return cfg_[
"engine"];
177 cfg[
"engine"] =
"fai";
181 return "engine not found for evaluate command";
183 return e_ptr->evaluate(str);
228 config temp_cfg, parsed_cfg;
virtual side_number get_side() const
Get the side number.
virtual std::string evaluate(const std::string &str)
Evaluate command (using fai)
virtual void invalidate_defensive_position_cache() const
child_itors child_range(const std::string &key)
virtual std::string get_id() const
void create_engine(std::vector< engine_ptr > &engines, const config &cfg)
Various functions that implement attacks and attack calculations.
std::vector< stage_ptr > stages_
Stages of the composite AI.
void create_stage(std::vector< stage_ptr > &stages, const config &cfg)
property_handler_map & property_handlers()
static void parse_engine_from_config(readonly_context &context, const config &cfg, std::back_insert_iterator< std::vector< engine_ptr > > b)
std::string describe_self() const
virtual bool add_stage(const config &cfg)
AI Support engine - creating specific ai components from config.
const config & cfg_
Config of the AI.
virtual unit_stats_cache_t & unit_stats_cache() const
static bool parse_side_config(side_number side, const config &cfg, config &parsed_cfg)
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)
virtual const std::vector< goal_ptr > & get_goals() const
virtual bool add_goal(const config &cfg)
static lg::log_domain log_ai_composite("ai/composite")
GLdouble GLdouble GLdouble b
int get_recursion_count() const
Get the value of the recursion counter.
virtual config to_config() const
serialize
void replace_aspect(std::map< std::string, aspect_ptr > &aspects, const config &cfg, std::string id)
A small explanation about what's going on here: Each action has access to two game_info objects First...
recursion_counter recursion_counter_
Recursion counter.
virtual void new_turn()
On new turn.
static void register_aspect_property(std::map< std::string, property_handler_ptr > &property_handlers, const std::string &property, std::map< std::string, boost::shared_ptr< X > > &aspects, std::function< void(std::map< std::string, boost::shared_ptr< X > > &, const config &, std::string)> construction_factory)
ai_composite(default_ai_context &context, const config &cfg)
Constructor.
Composite AI with turn sequence which is a vector of stages.
virtual ai_context & get_ai_context()
unwrap
void switch_side(side_number side)
virtual void set_side(side_number side)
Set the side number.
config & add_child(const std::string &key)
Managing the AIs lifecycle - headers.
void create_goal(std::vector< goal_ptr > &goals, const config &cfg)
void init_default_ai_context_proxy(default_ai_context &target)
int get_count() const
Get the current value of the recursion counter.
static void parse_stage_from_config(ai_context &context, const config &cfg, std::back_insert_iterator< std::vector< stage_ptr > > b)
static void parse_aspect_from_config(readonly_context &context, const config &cfg, const std::string &id, std::back_insert_iterator< std::vector< aspect_ptr > > b)
static config preparse_cfg(ai_context &ctx, const config &cfg)
virtual ~ai_composite()
Destructor.
void play_turn()
Play the turn.
virtual const aspect_map & get_aspects() const
Managing the AIs configuration - headers.
Standard logging facilities (interface).
virtual side_number get_side() const =0
Get the side number.
virtual void recalculate_move_maps() const
virtual void clear_additional_targets() const
virtual void invalidate_keeps_cache() const
virtual const std::vector< engine_ptr > & get_engines() const
A config object defines a single node in a WML file, with access to child nodes.
virtual std::string get_engine() const
static void parse_goal_from_config(readonly_context &context, const config &cfg, std::back_insert_iterator< std::vector< goal_ptr > > b)
GLsizei const GLcharARB ** string
virtual engine_ptr get_engine_by_cfg(const config &cfg)
get engine by cfg, creating it if it is not created yet but known
virtual std::string get_name() const