36 #define DBG_AI_COMPOSITE LOG_STREAM(debug, log_ai_composite)
37 #define LOG_AI_COMPOSITE LOG_STREAM(info, log_ai_composite)
38 #define ERR_AI_COMPOSITE LOG_STREAM(err, log_ai_composite)
45 return "[composite_ai]";
49 : cfg_(cfg),stages_(),recursion_counter_(context.get_recursion_count())
65 cfg[
"engine"] =
"fai";
68 e_ptr->set_ai_context(
this);
71 std::function<void(std::vector<engine_ptr>&,
const config&)> factory_engines =
74 std::function<void(std::vector<goal_ptr>&,
const config&)> factory_goals =
77 std::function<void(std::vector<stage_ptr>&,
const config&)> factory_stages =
80 std::function<void(std::map<std::string,aspect_ptr>&,
const config&, std::string)> factory_aspects =
107 std::vector<aspect_ptr> temp_aspects;
109 aspects[
id] = temp_aspects.back();
118 std::vector< stage_ptr > stages;
130 std::vector< goal_ptr > goals;
159 return cfg_[
"engine"];
165 cfg[
"engine"] =
"fai";
169 return "engine not found for evaluate command";
171 return e_ptr->evaluate(str);
212 config temp_cfg, parsed_cfg;
Various functions that implement attacks and attack calculations.
void replace_aspect(std::map< std::string, aspect_ptr > &aspects, const config &cfg, std::string id)
virtual void new_turn()
On new turn.
void create_goal(std::vector< goal_ptr > &goals, const config &cfg)
virtual bool add_goal(const config &cfg)
int get_recursion_count() const
Get the value of the recursion counter.
void create_stage(std::vector< stage_ptr > &stages, const config &cfg)
void switch_side(side_number side)
virtual std::string get_id() const
std::vector< stage_ptr > stages_
Stages of the composite AI.
static config preparse_cfg(ai_context &ctx, const config &cfg)
virtual std::string get_name() const
virtual ai_context & get_ai_context()
unwrap
recursion_counter recursion_counter_
Recursion counter.
virtual std::string evaluate(const std::string &str)
Evaluate command (using fai)
const config & cfg_
Config of the AI.
virtual ~ai_composite()
Destructor.
void create_engine(std::vector< engine_ptr > &engines, const config &cfg)
virtual bool add_stage(const config &cfg)
ai_composite(default_ai_context &context, const config &cfg)
Constructor.
virtual config to_config() const
serialize
void play_turn()
Play the turn.
std::string describe_self() const
virtual std::string get_engine() const
property_handler_map & property_handlers()
static bool parse_side_config(side_number side, const config &original_cfg, config &cfg)
virtual void clear_additional_targets() const
void init_default_ai_context_proxy(default_ai_context &target)
static void parse_goal_from_config(readonly_context &context, const config &cfg, std::back_insert_iterator< std::vector< goal_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 void parse_stage_from_config(ai_context &context, const config &cfg, std::back_insert_iterator< std::vector< stage_ptr >> b)
static void parse_engine_from_config(readonly_context &context, const config &cfg, std::back_insert_iterator< std::vector< engine_ptr >> b)
virtual void invalidate_keeps_cache() const override
virtual const aspect_map & get_aspects() const override
virtual void recalculate_move_maps() const override
virtual engine_ptr get_engine_by_cfg(const config &cfg) override
get engine by cfg, creating it if it is not created yet but known
virtual const std::vector< goal_ptr > & get_goals() const override
virtual void invalidate_defensive_position_cache() const override
virtual const std::vector< engine_ptr > & get_engines() const override
virtual unit_stats_cache_t & unit_stats_cache() const override
int get_count() const
Get the current value of the recursion counter.
virtual void set_side(side_number side) override
Set the side number.
virtual side_number get_side() const override
Get the side number.
virtual side_number get_side() const =0
Get the side number.
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)
Composite AI with turn sequence which is a vector of stages.
Managing the AIs configuration - headers.
AI Support engine - creating specific ai components from config.
std::string id
Text to match against addon_info.tags()
Standard logging facilities (interface).
A small explanation about what's going on here: Each action has access to two game_info objects First...
std::shared_ptr< engine > engine_ptr
static void register_aspect_property(property_handler_map &property_handlers, const std::string &property, std::map< std::string, std::shared_ptr< X >> &aspects, std::function< void(std::map< std::string, std::shared_ptr< X >> &, const config &, std::string)> construction_factory)
static lg::log_domain log_ai_composite("ai/composite")
std::shared_ptr< goal > goal_ptr
std::shared_ptr< stage > stage_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)
static map_location::direction s