Classes | Public Member Functions | Private Member Functions | Private Attributes

ai::ai_default_recruitment_stage Class Reference

#include <ai.hpp>

Inheritance diagram for ai::ai_default_recruitment_stage:
Inheritance graph
[legend]
Collaboration diagram for ai::ai_default_recruitment_stage:
Collaboration graph
[legend]

List of all members.

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_

Detailed Description

Definition at line 57 of file ai.hpp.


Constructor & Destructor Documentation

ai::ai_default_recruitment_stage::ai_default_recruitment_stage ( ai_context context,
const config cfg 
)

Definition at line 512 of file ai.cpp.

ai::ai_default_recruitment_stage::~ai_default_recruitment_stage (  )  [virtual]

Definition at line 527 of file ai.cpp.


Member Function Documentation

void ai::ai_default_recruitment_stage::analyze_all (  )  [private]
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().

Here is the call graph for this function:

Here is the caller graph for this function:

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'.

Todo:
1.9: we give max movement, but recruited will get 0? Seems inaccurate

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

int ai::ai_default_recruitment_stage::average_resistance_against ( const unit_type a,
const unit_type b 
) const [private, virtual]
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().

Here is the call graph for this function:

Here is the caller graph for this function:

bool ai::ai_default_recruitment_stage::do_play_stage (  )  [virtual]
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().

Here is the caller graph for this function:

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()().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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_.

Here is the call graph for this function:

bool ai::ai_default_recruitment_stage::recruit_usage ( const std::string &  usage  )  [private, virtual]
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().

Here is the call graph for this function:


Member Data Documentation

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().

Reimplemented from ai::stage.

Definition at line 105 of file ai.hpp.

Referenced by on_create().

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::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().

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().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:18:55 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs