#include <ai.hpp>


Classes | |
| class | recruit_situation_change_observer |
Public Member Functions | |
| ai_default_recruitment_stage (ai_context &context, const config &cfg) | |
| virtual | ~ai_default_recruitment_stage () |
| void | on_create () |
| Initialization. | |
| bool | do_play_stage () |
| Play the turn - implementation. | |
| config | to_config () const |
| serialize | |
| int | get_combat_score (const unit_type &ut) const |
Private Member Functions | |
| void | get_combat_score_vs (const unit_type &ut, const std::string &enemy_type_id, int &score, int &weighting, int hitpoints, int max_hitpoints) const |
| virtual bool | recruit_usage (const std::string &usage) |
| void | analyze_all () |
| initialize recruitment recommendations | |
| virtual void | analyze_potential_recruit_movements () |
| Analyze all the units that this side can recruit and rate their movement types. | |
| std::string | find_suitable_recall_id () |
| virtual void | analyze_potential_recruit_combat () |
| Analyze all the units that this side can recruit and rate their fighting suitability against enemy units. | |
| bool | analyze_recall_list () |
| virtual int | compare_unit_types (const unit_type &a, const unit_type &b) const |
| Rates two unit types for their suitability against each other. | |
| virtual int | average_resistance_against (const unit_type &a, const unit_type &b) const |
| calculates the average resistance unit type a has against the attacks of unit type b. | |
Private Attributes | |
| std::map< std::string, int > | best_usage_ |
| config | cfg_ |
| std::map< std::string, int > | maximum_counts_ |
| std::set< std::string > | not_recommended_units_ |
| std::vector< std::pair < std::string, double > > | recall_list_scores_ |
| recruit_situation_change_observer | recruit_situation_change_observer_ |
| std::map< std::string, int > | unit_combat_scores_ |
| std::map< std::string, int > | unit_movement_scores_ |
Definition at line 57 of file ai.hpp.
| ai::ai_default_recruitment_stage::ai_default_recruitment_stage | ( | ai_context & | context, | |
| const config & | cfg | |||
| ) |
| ai::ai_default_recruitment_stage::~ai_default_recruitment_stage | ( | ) | [virtual] |
| void ai::ai_default_recruitment_stage::analyze_all | ( | ) | [private] |
initialize recruitment recommendations
Definition at line 163 of file ai.cpp.
References analyze_potential_recruit_combat(), analyze_potential_recruit_movements(), ai::ai_default_recruitment_stage::recruit_situation_change_observer::get_valid(), not_recommended_units_, recruit_situation_change_observer_, ai::ai_default_recruitment_stage::recruit_situation_change_observer::set_valid(), unit_combat_scores_, and unit_movement_scores_.
Referenced by do_play_stage(), and recruit_usage().


| void ai::ai_default_recruitment_stage::analyze_potential_recruit_combat | ( | ) | [private, virtual] |
Analyze all the units that this side can recruit and rate their fighting suitability against enemy units.
Ratings will be placed in 'unit_combat_scores_', with a '0' rating indicating that the unit is 'average' against enemy units, negative ratings meaning they are poorly suited, and positive ratings meaning they are well suited.
Definition at line 449 of file ai.cpp.
References best_usage_, ai::readonly_context_proxy::current_team(), unit_type_data::find(), get_combat_score(), ai::readonly_context_proxy::get_recruitment_ignore_bad_combat(), lg::info, LOG_AI, log_ai, log_scope2, not_recommended_units_, team::recruits(), unit_combat_scores_, unit_types, and unit_type::usage().
Referenced by analyze_all().


| void ai::ai_default_recruitment_stage::analyze_potential_recruit_movements | ( | ) | [private, virtual] |
Analyze all the units that this side can recruit and rate their movement types.
Ratings will be placed in 'unit_movement_scores_', with lower scores being better, and the lowest possible rating being '10'.
Definition at line 531 of file ai.cpp.
References pathfind::a_star_search(), ai::readonly_context_proxy::current_team(), unit_map::end(), unit_type_data::find(), unit_map::find_leader(), ai::default_ai_context_proxy::find_targets(), resources::game_map, ai::readonly_context_proxy::get_recruitment_ignore_bad_movement(), ai::side_context_proxy::get_side(), gamemap::h(), lg::info, LOG_AI, log_ai, log_scope2, map_, pathfind::plain_route::move_cost, unit_type::movement(), unit_type::movement_type(), ai::readonly_context_proxy::nearest_keep(), not_recommended_units_, gamemap::on_board(), team::recruits(), sort(), editor::start(), pathfind::plain_route::steps, unit_movement_scores_, unit_types, resources::units, unit_type::usage(), and gamemap::w().
Referenced by analyze_all().


| bool ai::ai_default_recruitment_stage::analyze_recall_list | ( | ) | [private] |
Definition at line 758 of file ai.cpp.
References ai::readonly_context_proxy::current_team(), ai::debug_print_recall_list_scores(), game_config::recall_cost, team::recall_list(), recall_list_scores_, sort(), and unit_combat_scores_.
Referenced by do_play_stage().


| int ai::ai_default_recruitment_stage::average_resistance_against | ( | const unit_type & | a, | |
| const unit_type & | b | |||
| ) | const [private, virtual] |
calculates the average resistance unit type a has against the attacks of unit type b.
Definition at line 318 of file ai.cpp.
References unit_type::attacks(), unit_movement_type::defense_modifier(), ERR_AI, resources::game_map, gamemap::get_weighted_terrain_frequencies(), unit_type::has_ability_by_id(), unit_type::hitpoints(), unit_type::id(), LOG_AI, map_, unit_movement_type::movement_cost(), unit_type::movement_type(), unit_type::not_living(), game_config::poison_amount, unit_movement_type::resistance_against(), gui2::terrain, and unit_movement_type::UNREACHABLE.
Referenced by compare_unit_types().


| int ai::ai_default_recruitment_stage::compare_unit_types | ( | const unit_type & | a, | |
| const unit_type & | b | |||
| ) | const [private, virtual] |
Rates two unit types for their suitability against each other.
Returns 0 if the units are equally matched, a positive number if a is suited against b, and a negative number if b is suited against a.
Definition at line 397 of file ai.cpp.
References average_resistance_against(), unit_type::id(), and LOG_AI.
Referenced by get_combat_score_vs().


| bool ai::ai_default_recruitment_stage::do_play_stage | ( | ) | [virtual] |
Play the turn - implementation.
Implements ai::stage.
Definition at line 790 of file ai.cpp.
References analyze_all(), analyze_recall_list(), unit_map::begin(), ai::readonly_context_proxy::check_recall_action(), preferences::editor::TransitionUpdateMode::count, gui2::distance(), distance_between(), unit_map::end(), ERR_AI, unit_map::find_leader(), find_suitable_recall_id(), resources::game_map, ai::readonly_context_proxy::get_recruitment_pattern(), ai::side_context_proxy::get_side(), ai::readonly_context_proxy::get_villages_per_scout(), gui2::id, LOG_AI, ai::readonly_context_proxy::nearest_keep(), recruit_usage(), gamemap::starting_position(), resources::teams, unit_types, resources::units, village_owner(), and gamemap::villages().

| std::string ai::ai_default_recruitment_stage::find_suitable_recall_id | ( | ) | [private] |
Definition at line 641 of file ai.cpp.
References recall_list_scores_.
Referenced by do_play_stage().

| int ai::ai_default_recruitment_stage::get_combat_score | ( | const unit_type & | ut | ) | const |
Definition at line 421 of file ai.cpp.
References unit_map::begin(), ai::readonly_context_proxy::current_team(), unit_map::end(), get_combat_score_vs(), unit_type::hitpoints(), team::is_enemy(), team::recruits(), and resources::units.
Referenced by analyze_potential_recruit_combat(), and ai::unit_combat_score_getter::operator()().


| void ai::ai_default_recruitment_stage::get_combat_score_vs | ( | const unit_type & | ut, | |
| const std::string & | enemy_type_id, | |||
| int & | score, | |||
| int & | weighting, | |||
| int | hitpoints, | |||
| int | max_hitpoints | |||
| ) | const [private] |
Definition at line 408 of file ai.cpp.
References compare_unit_types(), unit_type::cost(), unit_type_data::find(), unit_types, and VALIDATE.
Referenced by get_combat_score().


| void ai::ai_default_recruitment_stage::on_create | ( | ) | [virtual] |
Initialization.
Reimplemented from ai::stage.
Definition at line 141 of file ai.cpp.
References cfg_, config::child_range(), config::has_attribute(), and maximum_counts_.

| bool ai::ai_default_recruitment_stage::recruit_usage | ( | const std::string & | usage | ) | [private, virtual] |
Definition at line 175 of file ai.cpp.
References analyze_all(), unit_type_data::build_all(), ai::readonly_context_proxy::check_recruit_action(), game_state::classification(), unit_type::cost(), ai::readonly_context_proxy::current_team(), game_classification::difficulty, unit_map::end(), ERR_AI, unit_type_data::find(), ai::side_context_proxy::get_side(), team::gold(), unit_type::HELP_INDEX, lexical_cast(), LOG_AI, log_ai, log_scope2, maximum_counts_, team::name(), not_recommended_units_, ai::readonly_context_proxy::raise_user_interact(), resources::state_of_game, unit_types, resources::units, unit_type::usage(), and WRN_AI.
Referenced by do_play_stage().


| config ai::ai_default_recruitment_stage::to_config | ( | ) | const [virtual] |
serialize
Reimplemented from ai::stage.
Definition at line 150 of file ai.cpp.
References config::add_child(), maximum_counts_, and str_cast().

std::map<std::string,int> ai::ai_default_recruitment_stage::best_usage_ [private] |
Definition at line 103 of file ai.hpp.
Referenced by analyze_potential_recruit_combat().
config ai::ai_default_recruitment_stage::cfg_ [private] |
std::map<std::string,int> ai::ai_default_recruitment_stage::maximum_counts_ [private] |
Definition at line 107 of file ai.hpp.
Referenced by on_create(), recruit_usage(), and to_config().
std::set<std::string> ai::ai_default_recruitment_stage::not_recommended_units_ [private] |
Definition at line 109 of file ai.hpp.
Referenced by analyze_all(), analyze_potential_recruit_combat(), analyze_potential_recruit_movements(), and recruit_usage().
std::vector<std::pair<std::string,double> > ai::ai_default_recruitment_stage::recall_list_scores_ [private] |
Definition at line 111 of file ai.hpp.
Referenced by analyze_recall_list(), and find_suitable_recall_id().
recruit_situation_change_observer ai::ai_default_recruitment_stage::recruit_situation_change_observer_ [private] |
Definition at line 113 of file ai.hpp.
Referenced by analyze_all().
std::map<std::string,int> ai::ai_default_recruitment_stage::unit_combat_scores_ [private] |
Definition at line 115 of file ai.hpp.
Referenced by analyze_all(), analyze_potential_recruit_combat(), and analyze_recall_list().
std::map<std::string,int> ai::ai_default_recruitment_stage::unit_movement_scores_ [private] |
Definition at line 117 of file ai.hpp.
Referenced by analyze_all(), and analyze_potential_recruit_movements().
| Generated by doxygen 1.7.1 on Thu May 24 2012 01:18:55 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |