21 #ifndef AI_DEFAULT_RECRUITMENT_HPP_INCLUDED
22 #define AI_DEFAULT_RECRUITMENT_HPP_INCLUDED
29 #include <boost/optional.hpp>
35 #pragma warning(disable:4250)
46 namespace default_recruitment {
70 : leader(leader), ratio_score(1.0), recruit_count(0), in_danger(false) { }
73 for (
const score_map::value_type& entry : scores) {
84 for (
const score_map::value_type& entry : scores) {
85 normalized[entry.first] = entry.second / sum;
91 s <<
"---------------Content of leader data---------------\n";
92 s <<
"For leader: " << leader->name() <<
"\n";
93 s <<
"ratio_score: " << ratio_score <<
"\n";
94 s <<
"recruit_count: " << recruit_count <<
"\n\n";
95 for (
const score_map::value_type& entry : scores) {
96 s << std::setw(20) << entry.first <<
97 " score: " << std::setw(7) << entry.second <<
"\n";
99 s <<
"----------------------------------------------------\n";
109 a_defense(a_def), b_defense(b_def), value(v) {
112 return value < o.
value;
122 : types(t), leader(L), id(id)
123 , number(n), importance(i)
124 , total(s), pattern(p), blocker(b)
128 if(number > 0 && number < 99999) {
132 cfg[
"total"] =
total;
135 if(!leader.empty()) {
136 cfg[
"leader_id"] =
leader;
156 : types(t), id(id), limit(lim)
175 std::vector<boost::shared_ptr<recruit_job> >
jobs_;
176 std::vector<boost::shared_ptr<recruit_limit> >
limits_;
184 typedef std::map<std::string, std::set<cached_combat_value> >
table_row;
199 const data& leader_data)
const;
220 double a_defense,
double b_defense);
223 double attacker_defense,
double defender_defense,
224 double* damage_to_attacker,
double* damage_to_defender)
const;
236 const std::vector<std::string>&
types)
const;
std::string get_id() const
std::string to_string() const
std::vector< std::string > types
const double * get_cached_combat_value(const std::string &a, const std::string &b, double a_defense, double b_defense)
For Combat Analysis.
recruit_limit(std::vector< std::string > t, std::string id, int lim)
GLint GLenum GLboolean normalized
count_map own_units_count_
std::map< size_t, int > cheapest_unit_costs_
void reset_gamestate_changed()
bool recruit_list_changed_
std::vector< boost::shared_ptr< recruit_job > > jobs_
cached_combat_value(double a_def, double b_def, double v)
bool recruit_matches_job(const std::string &recruit, const config *job) const
For Configuration / Aspect "recruitment-instructions" Checks if a given recruit-type is specified in ...
void update_average_local_cost()
For Map Analysis.
bool remove_job_if_no_blocker(config *job)
For Configuration / Aspect "recruitment-instructions".
terrain_count_map important_terrain_
virtual void execute()
Execute the candidate action.
const std::string get_random_pattern_type_if_exists(const data &leader_data, const config *job) const
For Configuration / Aspect "recruitment-instructions" If the flag pattern is set, this method returns...
GLuint GLuint GLsizei GLenum type
bool limit_ok(const std::string &recruit) const
For Configuration / Aspect "recruitment-instructions" Checks if a recruit-type can be recruited accor...
void handle_recruitment_more(std::vector< data > *leader_data) const
For Aspect "recruitment_more".
std::map< map_location, double > average_local_cost_
void update_important_hexes()
For Map Analysis.
std::vector< boost::shared_ptr< recruit_limit > > limits_
data * get_best_leader_from_ratio_scores(std::vector< data > &leader_data, const config *job) const
A helper function for execute().
void do_randomness(std::vector< data > *leader_data) const
Will add a random value between 0 and "recruitment_randomness" to all recruits.
void update_scouts_wanted()
This function will use the aspect villages_per_scout to decide how many scouts we want to recruit...
void update_own_units_count()
double get_score_sum() const
int get_cheapest_unit_cost_for_leader(const unit_map::const_iterator &leader)
Called at the beginning and whenever the recruitment list changes.
std::map< std::string, int > count_map
const std::string get_best_recruit_from_scores(const data &leader_data, const config *job)
A helper function for execute().
double get_estimated_unit_gain() const
For Aspect "recruitment_save_gold".
recruit_situation_change_observer recruit_situation_change_observer_
std::map< t_translation::t_terrain, int > terrain_count_map
GLsizei GLenum GLenum * types
std::set< map_location > important_hexes_
double compare_unit_types(const std::string &a, const std::string &b)
For Combat Analysis.
int average_lawful_bonus_
std::string get_engine() const
GLdouble GLdouble GLdouble b
double get_estimated_village_gain() const
For Aspect "recruitment_save_gold".
void handle_generic_event(const std::string &event)
std::string get_engine() const
bool recruit_matches_type(const std::string &recruit, const std::string &type) const
For Configuration / Aspect "recruitment-instructions" Checks if a given recruit-type matches one atom...
double get_unit_ratio() const
For Aspect "recruitment_save_gold".
A small explanation about what's going on here: Each action has access to two game_info objects First...
double get_average_defense(const std::string &unit_type) const
For Map Analysis.
void update_average_lawful_bonus()
Calculates a average lawful bonus, so Combat Analysis will work better in caves and custom time of da...
cache_table combat_cache_
void integrate_recruitment_pattern_in_recruitment_instructions()
For Configuration / Aspect "recruitment_pattern" Converts the (old) recruitment_pattern into a recrui...
config * get_most_important_job()
For Configuration / Aspect "recruitment-instructions" We call a [recruit] tag a "job".
GLboolean GLboolean GLboolean GLboolean a
bool operator<(const cached_combat_value &o) const
bool is_enemy_in_radius(const map_location &loc, int radius) const
Helper function.
void create_limit(std::vector< boost::shared_ptr< recruit_limit > > &limits, const config &lim)
std::vector< std::string > types
std::string get_name() const
void do_combat_analysis(std::vector< data > *leader_data)
Combat Analysis.
bool recruit_matches_types(const std::string &recruit, const std::vector< std::string > &types) const
For Configuration / Aspect "recruitment-instructions" Checks if a given recruit-type matches one of t...
config to_config() const
serialize
action_result_ptr execute_recall(const std::string &id, data &leader_data)
A helper function for execute().
std::string join(T const &v, const std::string &s=",")
Generates a new string joining container items in a list.
Encapsulates the map of the game.
~recruit_situation_change_observer()
data(const unit_map::const_iterator leader)
void compare_cost_maps_and_update_important_hexes(const pathfind::full_cost_map &my_cost_map, const pathfind::full_cost_map &enemy_cost_map)
For Map Analysis Computes from our cost map and the combined cost map of all enemies the important he...
Structure which uses find_routes() to build a cost map This maps each hex to a the movements a unit w...
action_result_ptr execute_recruit(const std::string &type, data &leader_data)
A helper function for execute().
std::map< std::string, std::set< cached_combat_value > > table_row
bool recruit_list_changed()
void set_recruit_list_changed(bool changed)
double get_estimated_income(int turns) const
For Aspect "recruitment_save_gold".
void create_job(std::vector< boost::shared_ptr< recruit_job > > &jobs, const config &job)
recruit_job(std::vector< std::string > t, std::string L, std::string id, int n, int i, bool s, bool p, bool b)
config recruitment_instructions_
recruitment(rca_context &context, const config &cfg)
const std::string * get_appropriate_recall(const std::string &type, const data &leader_data) const
A helper function for execute().
void simulate_attack(const unit_type *const attacker, const unit_type *const defender, double attacker_defense, double defender_defense, double *damage_to_attacker, double *damage_to_defender) const
For Combat Analysis.
recruitment_aspect(readonly_context &context, const config &cfg, const std::string &id)
score_map get_normalized_scores() const
unit_map::const_iterator leader
std::map< std::string, table_row > cache_table
recruit_situation_change_observer()
Observer Code.
A config object defines a single node in a WML file, with access to child nodes.
virtual double evaluate()
Evaluate the candidate action, resetting the internal state of the action.
void update_state()
For Aspect "recruitment_save_gold".
std::string get_id() const
const pathfind::full_cost_map get_cost_map_of_side(int side) const
For Map Analysis.
int recruitment_instructions_turn_
void show_important_hexes() const
For Map Analysis.
std::map< std::string, double > score_map
GLsizei const GLcharARB ** string
void do_similarity_penalty(std::vector< data > *leader_data) const
Will give a penalty to similar units.
std::set< std::string > recruits
int own_units_in_combat_counter_
candidate action framework
bool leader_matches_job(const data &leader_data, const config *job) const
For Configuration / Aspect "recruitment-instructions" Checks if a given leader is specified in the "l...
std::string get_name() const