#include <ca.hpp>


Public Member Functions | |
| recruitment_phase (rca_context &context, const config &cfg) | |
| virtual | ~recruitment_phase () |
| virtual double | evaluate () |
| Evaluate the candidate action, resetting the internal state of the action. | |
| virtual void | execute () |
| Execute the candidate action. | |
Private Member Functions | |
| bool | recruit_usage (const std::string &usage) |
| void | analyze_potential_recruit_combat () |
| Analyze all the units that this side can recruit and rate their fighting suitability against enemy units. | |
| int | compare_unit_types (const unit_type &a, const unit_type &b) const |
| Rates two unit types for their suitability against each other. | |
| 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 > | unit_movement_scores_ |
| std::set< std::string > | not_recommended_units_ |
| std::map< std::string, int > | unit_combat_scores_ |
Definition at line 72 of file ca.hpp.
| ai::testing_ai_default::recruitment_phase::recruitment_phase | ( | rca_context & | context, | |
| const config & | cfg | |||
| ) |
| ai::testing_ai_default::recruitment_phase::~recruitment_phase | ( | ) | [virtual] |
| void ai::testing_ai_default::recruitment_phase::analyze_potential_recruit_combat | ( | ) | [private] |
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 456 of file ca.cpp.
References unit_map::begin(), compare_unit_types(), unit::cost(), ai::readonly_context_proxy::current_team(), unit_map::end(), unit_type_data::find(), ai::readonly_context_proxy::get_recruitment_ignore_bad_combat(), unit::hitpoints(), lg::info, team::is_enemy(), LOG_AI_TESTING_AI_DEFAULT, log_ai_testing_ai_default, log_scope2, unit::max_hitpoints(), not_recommended_units_, team::recruits(), unit::type_id(), unit_combat_scores_, unit_types, resources::units, unit_type::usage(), and VALIDATE.
Referenced by execute().


| int ai::testing_ai_default::recruitment_phase::average_resistance_against | ( | const unit_type & | a, | |
| const unit_type & | b | |||
| ) | const [private] |
calculates the average resistance unit type a has against the attacks of unit type b.
Definition at line 365 of file ca.cpp.
References unit_type::attacks(), unit_movement_type::defense_modifier(), ERR_AI_TESTING_AI_DEFAULT, resources::game_map, gamemap::get_weighted_terrain_frequencies(), unit_type::has_ability_by_id(), unit_type::hitpoints(), unit_type::id(), LOG_AI_TESTING_AI_DEFAULT, 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::testing_ai_default::recruitment_phase::compare_unit_types | ( | const unit_type & | a, | |
| const unit_type & | b | |||
| ) | const [private] |
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 445 of file ca.cpp.
References average_resistance_against(), unit_type::id(), and LOG_AI_TESTING_AI_DEFAULT.
Referenced by analyze_potential_recruit_combat().


| double ai::testing_ai_default::recruitment_phase::evaluate | ( | ) | [virtual] |
Evaluate the candidate action, resetting the internal state of the action.
| >0 | if the action is good | |
| <=0 | if the action is not good |
Implements ai::candidate_action.
Definition at line 179 of file ca.cpp.
References ai::candidate_action::BAD_SCORE, ai::default_ai_context_proxy::count_free_hexes_in_castle(), unit_map::find_leader(), resources::game_map, ai::candidate_action::get_score(), ai::side_context_proxy::get_side(), and resources::units.

| void ai::testing_ai_default::recruitment_phase::execute | ( | ) | [virtual] |
Execute the candidate action.
Implements ai::candidate_action.
Definition at line 201 of file ca.cpp.
References analyze_potential_recruit_combat(), unit_map::begin(), preferences::editor::TransitionUpdateMode::count, gui2::distance(), distance_between(), unit_map::end(), unit_map::find_leader(), resources::game_map, ai::readonly_context_proxy::get_recruitment_pattern(), ai::side_context_proxy::get_side(), ai::readonly_context_proxy::get_villages_per_scout(), LOG_AI_TESTING_AI_DEFAULT, map_, not_recommended_units_, ai::readonly_context_proxy::raise_user_interact(), recruit_usage(), gamemap::starting_position(), resources::teams, unit_combat_scores_, unit_movement_scores_, unit_types, resources::units, village_owner(), and gamemap::villages().

| bool ai::testing_ai_default::recruitment_phase::recruit_usage | ( | const std::string & | usage | ) | [private] |
Definition at line 293 of file ca.cpp.
References unit_type_data::build_all(), game_state::classification(), unit_type::cost(), ai::readonly_context_proxy::current_team(), game_classification::difficulty, ai::readwrite_context_proxy::execute_recruit_action(), unit_type_data::find(), ai::side_context_proxy::get_side(), team::gold(), unit_type::HELP_INDEX, lexical_cast(), LOG_AI_TESTING_AI_DEFAULT, log_ai_testing_ai_default, log_scope2, team::name(), not_recommended_units_, ai::readonly_context_proxy::raise_user_interact(), resources::state_of_game, unit_types, unit_type::usage(), and WRN_AI_TESTING_AI_DEFAULT.
Referenced by execute().


std::set<std::string> ai::testing_ai_default::recruitment_phase::not_recommended_units_ [private] |
Definition at line 88 of file ca.hpp.
Referenced by analyze_potential_recruit_combat(), execute(), and recruit_usage().
std::map<std::string,int> ai::testing_ai_default::recruitment_phase::unit_combat_scores_ [private] |
Definition at line 100 of file ca.hpp.
Referenced by analyze_potential_recruit_combat(), and execute().
std::map<std::string,int> ai::testing_ai_default::recruitment_phase::unit_movement_scores_ [private] |
| Generated by doxygen 1.7.1 on Thu May 24 2012 01:19:06 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |