Public Member Functions | Private Member Functions | Private Attributes

ai::testing_ai_default::recruitment_phase Class Reference

#include <ca.hpp>

Inheritance diagram for ai::testing_ai_default::recruitment_phase:
Inheritance graph
[legend]
Collaboration diagram for ai::testing_ai_default::recruitment_phase:
Collaboration graph
[legend]

List of all members.

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_

Detailed Description

Definition at line 72 of file ca.hpp.


Constructor & Destructor Documentation

ai::testing_ai_default::recruitment_phase::recruitment_phase ( rca_context context,
const config cfg 
)

Definition at line 166 of file ca.cpp.

ai::testing_ai_default::recruitment_phase::~recruitment_phase (  )  [virtual]

Definition at line 175 of file ca.cpp.


Member Function Documentation

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

double ai::testing_ai_default::recruitment_phase::evaluate (  )  [virtual]

Evaluate the candidate action, resetting the internal state of the action.

Returns:
the score
Return values:
>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.

Here is the call graph for this function:

void ai::testing_ai_default::recruitment_phase::execute (  )  [virtual]
bool ai::testing_ai_default::recruitment_phase::recruit_usage ( const std::string &  usage  )  [private]

Member Data Documentation

Definition at line 88 of file ca.hpp.

Referenced by analyze_potential_recruit_combat(), execute(), and recruit_usage().

Definition at line 100 of file ca.hpp.

Referenced by analyze_potential_recruit_combat(), and execute().

Definition at line 87 of file ca.hpp.

Referenced by execute().


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:19:06 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs