38 namespace default_recruitment {
65 for (
const score_map::value_type& entry :
scores) {
76 for (
const score_map::value_type& entry :
scores) {
77 normalized[entry.first] = entry.second / sum;
101 recruit_job(std::vector<std::string>
t, std::string L, std::string
id,
int n,
int i,
bool s,
bool p,
bool b)
112 cfg[
"total"] =
total;
116 cfg[
"leader_id"] =
leader;
127 std::string
get_name()
const {
return "recruit_job";}
150 std::string
get_name()
const {
return "recruit_limit";}
155 std::vector<std::shared_ptr<recruit_job>>
jobs_;
156 std::vector<std::shared_ptr<recruit_limit>>
limits_;
160 void create_job(std::vector<std::shared_ptr<recruit_job>> &jobs,
const config &job);
161 void create_limit(std::vector<std::shared_ptr<recruit_limit>> &limits,
const config &lim);
164 typedef std::map<std::string, std::set<cached_combat_value>>
table_row;
180 const data& leader_data)
const;
201 double a_defense,
double b_defense);
204 double attacker_defense,
double defender_defense,
205 double* damage_to_attacker,
double* damage_to_defender)
const;
213 bool limit_ok(
const std::string& recruit)
const;
217 const std::vector<std::string>& types)
const;
bool recruit_list_changed_
~recruit_situation_change_observer()
void handle_generic_event(const std::string &event)
void reset_gamestate_changed()
bool recruit_list_changed()
void set_recruit_list_changed(bool changed)
recruit_situation_change_observer()
Observer Code.
void create_job(std::vector< std::shared_ptr< recruit_job >> &jobs, const config &job)
std::vector< std::shared_ptr< recruit_limit > > limits_
recruitment_aspect(readonly_context &context, const config &cfg, const std::string &id)
void create_limit(std::vector< std::shared_ptr< recruit_limit >> &limits, const config &lim)
std::vector< std::shared_ptr< recruit_job > > jobs_
double get_estimated_unit_gain() const
For Aspect "recruitment_save_gold".
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...
void update_own_units_count()
void update_average_local_cost()
For Map Analysis.
std::map< std::size_t, int > cheapest_unit_costs_
config to_config() const
serialize
virtual void execute()
Execute the candidate action.
config * get_most_important_job()
For Configuration / Aspect "recruitment-instructions" We call a [recruit] tag a "job".
std::set< map_location > important_hexes_
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...
void do_combat_analysis(std::vector< data > *leader_data)
Combat Analysis.
int average_lawful_bonus_
const std::string * get_appropriate_recall(const std::string &type, const data &leader_data) const
void show_important_hexes() const
For Map Analysis.
int recruitment_instructions_turn_
void integrate_recruitment_pattern_in_recruitment_instructions()
For Configuration / Aspect "recruitment_pattern" Converts the (old) recruitment_pattern into a recrui...
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 ...
action_result_ptr execute_recall(const std::string &id, data &leader_data)
A helper function for execute().
double get_estimated_village_gain() const
For Aspect "recruitment_save_gold".
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...
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_
count_map own_units_count_
std::map< map_location, double > average_local_cost_
double compare_unit_types(const std::string &a, const std::string &b)
For Combat Analysis.
void handle_recruitment_more(std::vector< data > *leader_data) const
For Aspect "recruitment_more".
void update_important_hexes()
For Map Analysis.
action_result_ptr execute_recruit(const std::string &type, data &leader_data)
A helper function for execute().
bool is_enemy_in_radius(const map_location &loc, int radius) const
Helper function.
bool remove_job_if_no_blocker(config *job)
For Configuration / Aspect "recruitment-instructions".
terrain_count_map important_terrain_
recruitment(rca_context &context, const config &cfg)
const pathfind::full_cost_map get_cost_map_of_side(int side) const
For Map Analysis.
double get_estimated_income(int turns) const
For Aspect "recruitment_save_gold".
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...
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.
virtual double evaluate()
Evaluate the candidate action, resetting the internal state of the action.
int get_cheapest_unit_cost_for_leader(const unit_map::const_iterator &leader)
Called at the beginning and whenever the recruitment list changes.
double recall_unit_value(const unit_const_ptr &recall_unit) const
A helper function for execute().
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.
recruit_situation_change_observer recruit_situation_change_observer_
bool limit_ok(const std::string &recruit) const
For Configuration / Aspect "recruitment-instructions" Checks if a recruit-type can be recruited accor...
double get_unit_ratio() const
For Aspect "recruitment_save_gold".
void update_state()
For Aspect "recruitment_save_gold".
config recruitment_instructions_
int own_units_in_combat_counter_
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...
const double * get_cached_combat_value(const std::string &a, const std::string &b, double a_defense, double b_defense)
For Combat Analysis.
double get_average_defense(const std::string &unit_type) const
For Map Analysis.
void do_similarity_penalty(std::vector< data > *leader_data) const
Will give a penalty to similar units.
const std::string get_best_recruit_from_scores(const data &leader_data, const config *job)
A helper function for execute().
A config object defines a single node in a WML file, with access to child nodes.
A single unit type that the player may recruit.
bool recall_unit(const std::string &id, team ¤t_team, const map_location &loc, const map_location &from, map_location::direction facing)
Recalls the unit with the indicated ID for the provided team.
std::map< t_translation::terrain_code, int > terrain_count_map
std::map< std::string, std::set< cached_combat_value > > table_row
std::map< std::string, table_row > cache_table
std::map< std::string, double > score_map
std::map< std::string, int > count_map
A small explanation about what's going on here: Each action has access to two game_info objects First...
std::shared_ptr< action_result > action_result_ptr
std::string join(const T &v, const std::string &s=",")
Generates a new string joining container items in a list.
std::shared_ptr< const unit > unit_const_ptr
candidate action framework
bool operator<(const cached_combat_value &o) const
cached_combat_value(double a_def, double b_def, double v)
unit_map::const_iterator leader
std::string to_string() const
std::set< std::string > recruits
score_map get_normalized_scores() const
double get_score_sum() const
data(const unit_map::const_iterator leader)
std::vector< std::string > types
std::string get_name() const
std::string get_id() const
std::string get_engine() const
recruit_job(std::vector< std::string > t, std::string L, std::string id, int n, int i, bool s, bool p, bool b)
recruit_limit(std::vector< std::string > t, std::string id, int lim)
std::string get_name() const
std::string get_id() const
std::vector< std::string > types
std::string get_engine() const
Encapsulates the map of the game.
Structure which uses find_routes() to build a cost map This maps each hex to a the movements a unit w...
static map_location::direction n
static map_location::direction s