#include <ai.hpp>
Public Member Functions | |
ai (ai_interface::info &info) | |
virtual | ~ai () |
virtual void | play_turn () |
Function that is called when the AI must play its turn. | |
defensive_position const & | best_defensive_position (const location &unit, const move_map &dstsrc, const move_map &srcdst, const move_map &enemy_dstsrc) |
void | invalidate_defensive_position_cache () |
bool | leader_can_reach_keep () |
bool | attack_close (const location &loc) const |
Return true iff there has been another attack this turn 'close' to this one. | |
Protected Member Functions | |
virtual void | do_move () |
virtual bool | do_combat (std::map< gamemap::location, paths > &possible_moves, const move_map &srcdst, const move_map &dstsrc, const move_map &enemy_srcdst, const move_map &enemy_dstsrc) |
virtual bool | get_villages (std::map< gamemap::location, paths > &possible_moves, const move_map &dstsrc, const move_map &enemy_dstsrc, unit_map::iterator &leader) |
virtual bool | get_healing (std::map< gamemap::location, paths > &possible_moves, const move_map &srcdst, const move_map &enemy_dstsrc) |
virtual bool | retreat_units (std::map< gamemap::location, paths > &possible_moves, const move_map &srcdst, const move_map &dstsrc, const move_map &enemy_dstsrc, unit_map::const_iterator leader) |
virtual bool | move_to_targets (std::map< gamemap::location, paths > &possible_moves, move_map &srcdst, move_map &dstsrc, const move_map &enemy_dstsrc, unit_map::const_iterator leader) |
virtual bool | should_retreat (const gamemap::location &loc, const unit_map::const_iterator un, const move_map &srcdst, const move_map &dstsrc, const move_map &enemy_dstsrc, double caution) |
virtual void | do_recruitment () |
virtual void | move_leader_to_keep (const move_map &enemy_dstsrc) |
virtual void | move_leader_after_recruit (const move_map &srcdst, const move_map &dstsrc, const move_map &enemy_dstsrc) |
virtual void | move_leader_to_goals (const move_map &enemy_dstsrc) |
virtual bool | recruit_usage (const std::string &usage) |
virtual bool | desperate_attack (const gamemap::location &loc) |
There is no real hope for us: we should try to do some damage to the enemy. | |
void | remove_unit_from_moves (const gamemap::location &u, move_map &srcdst, move_map &dstsrc) |
void | find_threats () |
Find enemy units that threaten our valuable assets. | |
location | move_unit (location from, location to, std::map< location, paths > &possible_moves) |
Our own version of 'move_unit'. | |
void | attack_enemy (const location &attacking_unit, const location &target, int att_weapon, int def_weapon) |
Our own version of 'attack_enemy'. We record all attacks to support group attacking. | |
bool | multistep_move_possible (const location &from, const location &to, const location &via, const std::map< location, paths > &possible_moves) const |
Sees if it's possible for a unit to move 'from' -> 'via' -> 'to' all in one turn. | |
virtual void | do_attack_analysis (const location &loc, const move_map &srcdst, const move_map &dstsrc, const move_map &fullmove_srcdst, const move_map &fullmove_dstsrc, const move_map &enemy_srcdst, const move_map &enemy_dstsrc, const location *tiles, bool *used_locations, std::vector< location > &units, std::vector< attack_analysis > &result, attack_analysis &cur_analysis) |
Analyze possibility of attacking target on 'loc'. | |
virtual double | power_projection (const gamemap::location &loc, const move_map &dstsrc, bool use_terrain=true) const |
Function which finds how much 'power' a side can attack a certain location with. | |
virtual std::vector < attack_analysis > | analyze_targets (const move_map &srcdst, const move_map &dstsrc, const move_map &enemy_srcdst, const move_map &enemy_dstsrc) |
bool | is_accessible (const location &loc, const move_map &dstsrc) const |
virtual std::vector< target > | find_targets (unit_map::const_iterator leader, const move_map &enemy_dstsrc) |
virtual location | form_group (const std::vector< location > &route, const move_map &dstsrc, std::set< location > &units) |
Function to form a group of units suitable for moving along the route, 'route'. | |
virtual void | enemies_along_path (const std::vector< location > &route, const move_map &dstsrc, std::set< location > &units) |
Return the group of enemies that threaten a certain path. | |
virtual bool | move_group (const location &dst, const std::vector< location > &route, const std::set< location > &units) |
virtual double | rate_group (const std::set< location > &group, const std::vector< location > &battlefield) const |
virtual double | compare_groups (const std::set< location > &our_group, const std::set< location > &enemy_groups, const std::vector< location > &battlefield) const |
virtual std::pair< location, location > | choose_move (std::vector< target > &targets, const move_map &srcdst, const move_map &dstsrc, const move_map &enemy_dstsrc) |
virtual int | rate_terrain (const unit &u, const location &loc) |
Rates the value of moving onto certain terrain for a unit. | |
void | add_target (const target &tgt) |
virtual void | analyze_potential_recruit_movements () |
Analyze all the units that this side can recruit and rate their movement types. | |
virtual void | analyze_potential_recruit_combat () |
Analyze all the units that this side can recruit and rate their fighting suitability against enemy units. | |
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. | |
const std::set< location > & | keeps () |
Functions to deal with keeps. | |
const location & | nearest_keep (const location &loc) |
void | access_points (const move_map &srcdst, const location &u, const location &dst, std::vector< location > &out) |
Function which, given a unit position, and a position the unit wants to get to in two turns, will return all possible positions the unit can move to, that will make the destination position accessible next turn. | |
const std::set< location > & | avoided_locations () |
Function which gets the areas of the map that this AI has been instructed to avoid. | |
int | attack_depth () |
Protected Attributes | |
std::map< location, defensive_position > | defensive_position_cache_ |
bool | threats_found_ |
std::set< location > | attacks_ |
game_display & | disp_ |
const gamemap & | map_ |
unit_map & | units_ |
std::vector< team > & | teams_ |
unsigned int | team_num_ |
const gamestatus & | state_ |
bool | consider_combat_ |
std::vector< target > | additional_targets_ |
std::map< std::string, int > | unit_movement_scores_ |
std::set< std::string > | not_recommended_units_ |
std::map< std::string, int > | unit_combat_scores_ |
std::set< location > | keeps_ |
std::set< location > | avoid_ |
std::map< std::pair< location, const unit_type * >, std::pair < battle_context::unit_stats, battle_context::unit_stats > > | unit_stats_cache_ |
Weapon choice cache, to speed simulations. | |
int | attack_depth_ |
Private Member Functions | |
void | find_villages (std::map< gamemap::location, std::vector< gamemap::location > > &reachmap, std::vector< std::pair< gamemap::location, gamemap::location > > &moves, const std::multimap< gamemap::location, gamemap::location > &dstsrc, const std::map< gamemap::location, paths > &possible_moves, const std::multimap< gamemap::location, gamemap::location > &enemy_dstsrc) const |
Friends | |
struct | attack_analysis |
Classes | |
struct | attack_analysis |
struct | defensive_position |
struct | target |
Definition at line 27 of file ai.hpp.
ai::ai | ( | ai_interface::info & | info | ) |
void ai::play_turn | ( | ) | [virtual] |
Function that is called when the AI must play its turn.
Derived classes should implement their AI algorithm in this function.
Implements ai_interface.
Reimplemented in formula_ai.
Definition at line 872 of file ai.cpp.
References consider_combat_, do_move(), game_events::fire(), and lg::wml_error.
const ai::defensive_position & ai::best_defensive_position | ( | const location & | unit, | |
const move_map & | dstsrc, | |||
const move_map & | srcdst, | |||
const move_map & | enemy_dstsrc | |||
) |
Definition at line 2065 of file ai.cpp.
References ai::defensive_position::chance_to_hit, defensive_position_cache_, unit_map::end(), unit_map::find(), gamemap::get_terrain(), ai::defensive_position::loc, map_, pos, power_projection(), ai::defensive_position::support, units_, and ai::defensive_position::vulnerability.
Referenced by ai::attack_analysis::analyze(), and should_retreat().
void ai::invalidate_defensive_position_cache | ( | ) | [inline] |
Definition at line 62 of file ai.hpp.
References defensive_position_cache_.
Referenced by do_move().
bool ai::leader_can_reach_keep | ( | ) |
Definition at line 2012 of file ai.cpp.
References ai_interface::current_team(), unit_map::end(), find_leader(), map_, nearest_keep(), paths::routes, team_num_, teams_, units_, and gamemap::location::valid().
Referenced by ai::attack_analysis::rating().
bool ai::attack_close | ( | const location & | loc | ) | const |
Return true iff there has been another attack this turn 'close' to this one.
Definition at line 682 of file ai.cpp.
References attacks_, and distance_between().
Referenced by ai::attack_analysis::rating().
void ai::do_move | ( | ) | [protected, virtual] |
Definition at line 887 of file ai.cpp.
References avoided_locations(), unit_map::begin(), ai_interface::calculate_possible_moves(), consider_combat_, ai_interface::current_team(), distance_between(), do_combat(), do_recruitment(), unit_map::end(), unit_map::find(), find_leader(), find_threats(), g, get_healing(), get_villages(), invalidate_defensive_position_cache(), LOG_AI, log_scope2, map_, move_leader_after_recruit(), move_leader_to_goals(), move_leader_to_keep(), move_to_targets(), move_unit(), gamemap::on_board(), ai_interface::raise_user_interact(), remove_unit_from_moves(), retreat_units(), utils::string_bool(), team_num_, and units_.
Referenced by play_turn().
bool ai::do_combat | ( | std::map< gamemap::location, paths > & | possible_moves, | |
const move_map & | srcdst, | |||
const move_map & | dstsrc, | |||
const move_map & | enemy_srcdst, | |||
const move_map & | enemy_dstsrc | |||
) | [protected, virtual] |
Definition at line 1024 of file ai.cpp.
References add_target(), team::aggression(), analyze_targets(), attack_enemy(), ai::target::BATTLE_AID, unit_map::count(), ai_interface::current_team(), unit_map::end(), unit_map::find(), from, battle_context::get_attacker_stats(), battle_context::get_defender_stats(), LOG_AI, LOG_STREAM, map_, max_positions, move_unit(), state_, teams_, to, units_, and lg::warn.
Referenced by do_move().
bool ai::get_villages | ( | std::map< gamemap::location, paths > & | possible_moves, | |
const move_map & | dstsrc, | |||
const move_map & | enemy_dstsrc, | |||
unit_map::iterator & | leader | |||
) | [protected, virtual] |
Definition at line 148 of file ai_village.cpp.
References add_target(), lg::ai, unit_map::begin(), best_leader_loc, unit_map::count(), DBG_AI, lg::debug, debug, dispatch(), dump_reachmap(), unit_map::end(), unit_map::find(), find_leader(), find_villages(), keep_loc, leader_loc, loc, LOG_AI, move_unit(), nearest_keep(), gamemap::location::null_location, power_projection(), remove_unit(), ai::target::SUPPORT, team_num_, and units_.
Referenced by do_move().
bool ai::get_healing | ( | std::map< gamemap::location, paths > & | possible_moves, | |
const move_map & | srcdst, | |||
const move_map & | enemy_dstsrc | |||
) | [protected, virtual] |
Definition at line 1172 of file ai.cpp.
References unit_map::begin(), unit_map::end(), unit_map::find(), unit::get_ability_bool(), gamemap::gives_healing(), unit::hitpoints(), LOG_AI, map_, unit::max_hitpoints(), move_unit(), game_config::poison_amount, power_projection(), unit::side(), team_num_, and units_.
Referenced by do_move().
bool ai::retreat_units | ( | std::map< gamemap::location, paths > & | possible_moves, | |
const move_map & | srcdst, | |||
const move_map & | dstsrc, | |||
const move_map & | enemy_dstsrc, | |||
unit_map::const_iterator | leader | |||
) | [protected, virtual] |
Definition at line 1245 of file ai.cpp.
References avoided_locations(), unit_map::begin(), ai_interface::calculate_possible_moves(), ai_interface::current_team(), desperate_attack(), unit_map::end(), get_adjacent_tiles(), gamemap::get_terrain(), gamemap::is_village(), LOG_AI, map_, move_unit(), power_projection(), should_retreat(), team_num_, units_, and gamemap::location::valid().
Referenced by do_move().
bool ai::move_to_targets | ( | std::map< gamemap::location, paths > & | possible_moves, | |
move_map & | srcdst, | |||
move_map & | dstsrc, | |||
const move_map & | enemy_dstsrc, | |||
unit_map::const_iterator | leader | |||
) | [protected, virtual] |
Definition at line 1349 of file ai.cpp.
References additional_targets_, attack_enemy(), choose_move(), ai_interface::current_team(), unit_map::end(), unit_map::find(), find_targets(), find_visible_unit(), get_adjacent_tiles(), battle_context::get_attacker_stats(), battle_context::get_defender_stats(), team::is_enemy(), LOG_AI, LOG_STREAM, map_, move_unit(), gamemap::on_board(), state_, teams_, units_, and lg::warn.
Referenced by do_move().
bool ai::should_retreat | ( | const gamemap::location & | loc, | |
const unit_map::const_iterator | un, | |||
const move_map & | srcdst, | |||
const move_map & | dstsrc, | |||
const move_map & | enemy_dstsrc, | |||
double | caution | |||
) | [protected, virtual] |
Definition at line 1223 of file ai.cpp.
References best_defensive_position(), ai::defensive_position::chance_to_hit, gamemap::get_terrain(), map_, and power_projection().
Referenced by choose_move(), move_leader_after_recruit(), and retreat_units().
void ai::do_recruitment | ( | ) | [protected, virtual] |
Reimplemented in formula_ai.
Definition at line 1713 of file ai.cpp.
References analyze_potential_recruit_combat(), analyze_potential_recruit_movements(), unit_map::begin(), ai_interface::current_team(), distance_between(), unit_map::end(), find_leader(), loc, LOG_AI, map_, nearest_keep(), recruit_usage(), team::recruitment_pattern(), gamemap::starting_position(), team_num_, teams_, units_, village_owner(), gamemap::villages(), and team::villages_per_scout().
Referenced by do_move(), move_leader_to_goals(), and move_unit().
void ai::move_leader_to_keep | ( | const move_map & | enemy_dstsrc | ) | [protected, virtual] |
Definition at line 1849 of file ai.cpp.
References unit_map::count(), ai_interface::current_team(), distance_between(), unit_map::end(), find_leader(), map_, move_unit(), nearest_keep(), paths::routes, team_num_, teams_, and units_.
Referenced by do_move().
void ai::move_leader_after_recruit | ( | const move_map & | srcdst, | |
const move_map & | dstsrc, | |||
const move_map & | enemy_dstsrc | |||
) | [protected, virtual] |
Definition at line 1900 of file ai.cpp.
References unit_map::add(), avoided_locations(), ai_interface::calculate_possible_moves(), ai_interface::current_team(), desperate_attack(), distance_between(), unit_map::end(), unit_map::extract(), unit_map::find(), find_leader(), get_adjacent_tiles(), is_accessible(), gamemap::is_village(), LOG_AI, map_, move_unit(), nearest_keep(), gamemap::on_board(), team::owns_village(), paths::routes, should_retreat(), str_cast(), team_num_, teams_, units_, gamemap::location::valid(), gamemap::location::x, and gamemap::location::y.
Referenced by do_move().
void ai::move_leader_to_goals | ( | const move_map & | enemy_dstsrc | ) | [protected, virtual] |
Definition at line 1794 of file ai.cpp.
References a_star_search(), team::ai_parameters(), config::child(), ai_interface::current_team(), do_recruitment(), unit_map::end(), ERR_AI, find_leader(), ai_interface::get_info(), gamemap::h(), loc, LOG_AI, ai_interface::info::map, map, map_, move_unit(), power_projection(), paths::routes, paths::route::steps, team_num_, teams_, units_, gamemap::location::valid(), gamemap::w(), and WRN_AI.
Referenced by do_move().
bool ai::recruit_usage | ( | const std::string & | usage | ) | [protected, virtual] |
Definition at line 255 of file ai.cpp.
References boost::foreach_detail_::begin(), ai_interface::current_team(), team::gold(), unit_type::HELP_INDEX, LOG_AI, log_scope2, name, not_recommended_units_, ai_interface::raise_user_interact(), ai_interface::recruit(), team::recruits(), unit_type_data::types(), and WRN_AI.
Referenced by do_recruitment().
bool ai::desperate_attack | ( | const gamemap::location & | loc | ) | [protected, virtual] |
There is no real hope for us: we should try to do some damage to the enemy.
We can spend some cycles here, since it's rare.
Definition at line 706 of file ai_attack.cpp.
References attack_enemy(), unit::attacks(), ai_interface::current_team(), unit_map::end(), unit_map::find(), find_visible_unit(), get_adjacent_tiles(), battle_context::get_attacker_stats(), battle_context::get_defender_stats(), unit::hitpoints(), team::is_enemy(), LOG_AI, map_, state_, teams_, unit::type_id(), and units_.
Referenced by move_leader_after_recruit(), and retreat_units().
void ai::remove_unit_from_moves | ( | const gamemap::location & | u, | |
move_map & | srcdst, | |||
move_map & | dstsrc | |||
) | [protected] |
void ai::find_threats | ( | ) | [protected] |
Find enemy units that threaten our valuable assets.
Definition at line 813 of file ai.cpp.
References add_target(), team::ai_parameters(), unit_map::begin(), ai_interface::current_team(), distance_between(), unit_map::end(), find_leader(), config::get_children(), ai_interface::get_info(), team_num_, ai::target::THREAT, threats_found_, game_events::unit_matches_filter(), and units_.
Referenced by do_move().
gamemap::location ai::move_unit | ( | location | from, | |
location | to, | |||
std::map< location, paths > & | possible_moves | |||
) | [protected] |
Our own version of 'move_unit'.
It is like the version in ai_interface, however if it is the leader moving, it will first attempt recruitment.
Reimplemented from ai_interface.
Definition at line 624 of file ai.cpp.
References attack_enemy(), util::array< T, N >::begin(), ai_interface::calculate_possible_moves(), unit_map::count(), ai_interface::current_team(), util::array< T, N >::data(), do_recruitment(), util::array< T, N >::end(), unit_map::end(), unit_map::find(), get_adjacent_tiles(), battle_context::get_attacker_stats(), battle_context::get_defender_stats(), team::is_enemy(), map_, ai_interface::move_unit(), multistep_move_possible(), nearest_keep(), state_, teams_, and units_.
Referenced by do_combat(), do_move(), formula_ai::execute_variant(), get_healing(), get_villages(), move_group(), move_leader_after_recruit(), move_leader_to_goals(), move_leader_to_keep(), move_to_targets(), and retreat_units().
void ai::attack_enemy | ( | const location & | attacking_unit, | |
const location & | target, | |||
int | att_weapon, | |||
int | def_weapon | |||
) | [protected] |
Our own version of 'attack_enemy'. We record all attacks to support group attacking.
Definition at line 693 of file ai.cpp.
References ai_interface::attack_enemy(), and attacks_.
Referenced by desperate_attack(), do_combat(), formula_ai::execute_variant(), move_to_targets(), and move_unit().
bool ai::multistep_move_possible | ( | const location & | from, | |
const location & | to, | |||
const location & | via, | |||
const std::map< location, paths > & | possible_moves | |||
) | const [protected] |
Sees if it's possible for a unit to move 'from' -> 'via' -> 'to' all in one turn.
Definition at line 581 of file ai.cpp.
References unit_map::count(), ai_interface::current_team(), unit_map::end(), unit_map::find(), LOG_AI, map_, paths::routes, unit::set_movement(), teams_, and units_.
Referenced by move_unit().
void ai::do_attack_analysis | ( | const location & | loc, | |
const move_map & | srcdst, | |||
const move_map & | dstsrc, | |||
const move_map & | fullmove_srcdst, | |||
const move_map & | fullmove_dstsrc, | |||
const move_map & | enemy_srcdst, | |||
const move_map & | enemy_dstsrc, | |||
const location * | tiles, | |||
bool * | used_locations, | |||
std::vector< location > & | units, | |||
std::vector< attack_analysis > & | result, | |||
attack_analysis & | cur_analysis | |||
) | [protected, virtual] |
Analyze possibility of attacking target on 'loc'.
Definition at line 34 of file ai_attack.cpp.
References a, ai::attack_analysis::analyze(), attack_depth(), backstab_check(), unit_map::begin(), ai_interface::current_team(), unit_map::end(), unit_map::find(), get_adjacent_tiles(), ai::attack_analysis::is_surrounded, LOG_AI, map_, max_positions, maximum(), ai::attack_analysis::movements, gamemap::on_board(), power_projection(), ai_interface::raise_user_interact(), rate_terrain(), ai::attack_analysis::rating(), state_, ai::attack_analysis::support, team_num_, teams_, units_, and ai::attack_analysis::vulnerability.
Referenced by analyze_targets().
double ai::power_projection | ( | const gamemap::location & | loc, | |
const move_map & | dstsrc, | |||
bool | use_terrain = true | |||
) | const [protected, virtual] |
Function which finds how much 'power' a side can attack a certain location with.
This is basically the maximum hp of damage that can be inflicted upon a unit on loc by full-health units, multiplied by the defense these units will have. (if 'use_terrain' is false, then it will be multiplied by 0.5)
Definition at line 603 of file ai_attack.cpp.
References unit::alignment(), unit::attacks(), unit_type::CHAOTIC, unit::defense_modifier(), unit_map::end(), unit_map::find(), get_adjacent_tiles(), gamestatus::get_time_of_day(), unit::hitpoints(), gamemap::is_village(), unit_type::LAWFUL, time_of_day::lawful_bonus, map_, unit::max_hitpoints(), gamemap::on_board(), pos, state_, units_, and gamemap::location::valid().
Referenced by best_defensive_position(), choose_move(), do_attack_analysis(), find_targets(), get_healing(), get_villages(), move_leader_to_goals(), retreat_units(), and should_retreat().
std::vector< ai::attack_analysis > ai::analyze_targets | ( | const move_map & | srcdst, | |
const move_map & | dstsrc, | |||
const move_map & | enemy_srcdst, | |||
const move_map & | enemy_dstsrc | |||
) | [protected, virtual] |
Definition at line 550 of file ai_attack.cpp.
References unit_map::begin(), ai_interface::calculate_possible_moves(), ai_interface::current_team(), do_attack_analysis(), unit_map::end(), get_adjacent_tiles(), team::is_enemy(), log_scope2, ai::attack_analysis::support, ai::attack_analysis::target, team_num_, teams_, unit_stats_cache_, units_, and ai::attack_analysis::vulnerability.
Referenced by do_combat(), and formula_ai::get_value().
Definition at line 2111 of file ai.cpp.
References get_adjacent_tiles().
Referenced by move_leader_after_recruit().
std::vector< ai::target > ai::find_targets | ( | unit_map::const_iterator | leader, | |
const move_map & | enemy_dstsrc | |||
) | [protected, virtual] |
Definition at line 90 of file ai_move.cpp.
References unit_map::begin(), unit_map::count(), ai_interface::current_team(), unit_map::end(), ai::target::EXPLICIT, get_adjacent_tiles(), get_village(), team::is_enemy(), ai::target::LEADER, LOG_AI, log_scope2, map_, gamemap::on_board(), power_projection(), team::targets(), teams_, ai::target::THREAT, units_, value, ai::target::VILLAGE, and gamemap::villages().
Referenced by analyze_potential_recruit_movements(), and move_to_targets().
gamemap::location ai::form_group | ( | const std::vector< location > & | route, | |
const move_map & | dstsrc, | |||
std::set< location > & | units | |||
) | [protected, virtual] |
Function to form a group of units suitable for moving along the route, 'route'.
Returns the location which the group may reach this turn. Stores the locations of the units in the group in 'units'
Definition at line 198 of file ai_move.cpp.
References unit_map::count(), unit_map::end(), unit_map::find(), and units_.
Referenced by choose_move().
void ai::enemies_along_path | ( | const std::vector< location > & | route, | |
const move_map & | dstsrc, | |||
std::set< location > & | units | |||
) | [protected, virtual] |
Return the group of enemies that threaten a certain path.
Definition at line 239 of file ai_move.cpp.
References get_adjacent_tiles().
Referenced by choose_move().
bool ai::move_group | ( | const location & | dst, | |
const std::vector< location > & | route, | |||
const std::set< location > & | units | |||
) | [protected, virtual] |
Definition at line 253 of file ai_move.cpp.
References ai_interface::calculate_possible_moves(), unit_map::count(), unit_map::end(), unit_map::find(), get_adjacent_tiles(), gamemap::get_terrain(), LOG_AI, map_, move_unit(), boost::foreach_detail_::next(), gamemap::on_board(), units_, gamemap::location::valid(), gamemap::location::x, and gamemap::location::y.
Referenced by choose_move().
double ai::rate_group | ( | const std::set< location > & | group, | |
const std::vector< location > & | battlefield | |||
) | const [protected, virtual] |
Definition at line 350 of file ai_move.cpp.
References a, unit::attacks(), unit_map::begin(), unit::defense_modifier(), unit_map::end(), unit_map::find(), gamemap::get_terrain(), unit::hitpoints(), map_, unit::max_hitpoints(), and units_.
Referenced by compare_groups().
double ai::compare_groups | ( | const std::set< location > & | our_group, | |
const std::set< location > & | enemy_groups, | |||
const std::vector< location > & | battlefield | |||
) | const [protected, virtual] |
Definition at line 382 of file ai_move.cpp.
References a, b, and rate_group().
Referenced by choose_move().
std::pair< gamemap::location, gamemap::location > ai::choose_move | ( | std::vector< target > & | targets, | |
const move_map & | srcdst, | |||
const move_map & | dstsrc, | |||
const move_map & | enemy_dstsrc | |||
) | [protected, virtual] |
Definition at line 389 of file ai_move.cpp.
References a_star_search(), access_points(), team::ai_parameters(), avoided_locations(), ai::target::BATTLE_AID, unit_map::begin(), ai_interface::calculate_possible_moves(), compare_groups(), ai_interface::current_team(), game_config::debug, unit::defense_modifier(), distance_between(), unit_map::end(), enemies_along_path(), unit_map::find(), form_group(), gamemap::get_terrain(), group, gamemap::h(), unit::hitpoints(), team::is_enemy(), loc, LOG_AI, log_scope2, map_, ai::target::MASS, minimum(), move_group(), paths::route::move_left, gamemap::on_board(), power_projection(), ai_interface::raise_user_interact(), should_retreat(), paths::route::steps, utils::string_bool(), ai::target::SUPPORT, team_num_, units_, gamemap::location::valid(), value, ai::target::VILLAGE, and gamemap::w().
Referenced by move_to_targets().
Rates the value of moving onto certain terrain for a unit.
Definition at line 2035 of file ai.cpp.
References unit::defense_modifier(), unit::get_ability_bool(), gamemap::get_terrain(), gamemap::gives_healing(), gamemap::is_village(), map_, team_num_, teams_, and village_owner().
Referenced by do_attack_analysis().
void ai::add_target | ( | const target & | tgt | ) | [inline, protected] |
Definition at line 259 of file ai.hpp.
References additional_targets_.
Referenced by do_combat(), find_threats(), and get_villages().
void ai::analyze_potential_recruit_movements | ( | ) | [protected, 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 1603 of file ai.cpp.
References a_star_search(), ai_interface::current_team(), boost::foreach_detail_::end(), unit_map::end(), find_leader(), find_targets(), ai_interface::get_info(), gamemap::h(), LOG_AI, log_scope2, ai_interface::info::map, map, map_, paths::route::move_left, nearest_keep(), not_recommended_units_, gamemap::on_board(), team::recruits(), paths::route::steps, utils::string_bool(), team_num_, teams, teams_, unit_type_data::types(), unit_movement_scores_, units_, unit::usage(), and gamemap::w().
Referenced by do_recruitment().
void ai::analyze_potential_recruit_combat | ( | ) | [protected, 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 1522 of file ai.cpp.
References _, unit_map::begin(), compare_unit_types(), unit::cost(), ai_interface::current_team(), unit_map::end(), boost::foreach_detail_::end(), unit::hitpoints(), team::is_enemy(), LOG_AI, log_scope2, unit::max_hitpoints(), not_recommended_units_, team::recruits(), utils::string_bool(), unit::type_id(), unit_type_data::types(), unit_combat_scores_, units_, and VALIDATE.
Referenced by do_recruitment().
Rates two unit types for their suitability against each other.
Definition at line 1511 of file ai.cpp.
References average_resistance_against(), unit_type::id(), and LOG_AI.
Referenced by analyze_potential_recruit_combat().
int ai::average_resistance_against | ( | const unit_type & | a, | |
const unit_type & | b | |||
) | const [protected, virtual] |
calculates the average resistance unit type a has against the attacks of unit type b.
Definition at line 1433 of file ai.cpp.
References unit_type::attacks(), unit_movement_type::defense_modifier(), ERR_AI, 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, and unit_movement_type::resistance_against().
Referenced by compare_unit_types().
const std::set< gamemap::location > & ai::keeps | ( | ) | [protected] |
Functions to deal with keeps.
Definition at line 2125 of file ai.cpp.
References get_adjacent_tiles(), gamemap::h(), gamemap::is_castle(), gamemap::is_keep(), keeps_, loc, map_, and gamemap::w().
Referenced by nearest_keep().
const gamemap::location & ai::nearest_keep | ( | const location & | loc | ) | [protected] |
Definition at line 2150 of file ai.cpp.
References distance_between(), and keeps().
Referenced by analyze_potential_recruit_movements(), do_recruitment(), get_villages(), leader_can_reach_keep(), move_leader_after_recruit(), move_leader_to_keep(), and move_unit().
void ai::access_points | ( | const move_map & | srcdst, | |
const location & | u, | |||
const location & | dst, | |||
std::vector< location > & | out | |||
) | [protected] |
Function which, given a unit position, and a position the unit wants to get to in two turns, will return all possible positions the unit can move to, that will make the destination position accessible next turn.
Definition at line 774 of file ai_move.cpp.
References a_star_search(), ai_interface::current_team(), distance_between(), unit_map::end(), unit_map::find(), gamemap::h(), loc, map_, paths::route::steps, teams_, units_, and gamemap::w().
Referenced by choose_move().
const std::set< gamemap::location > & ai::avoided_locations | ( | ) | [protected] |
Function which gets the areas of the map that this AI has been instructed to avoid.
Definition at line 2171 of file ai.cpp.
References a, team::ai_parameters(), avoid_, unit_map::begin(), ai_interface::current_team(), unit_map::end(), config::get_children(), and parse_location_range().
Referenced by choose_move(), do_move(), move_leader_after_recruit(), and retreat_units().
int ai::attack_depth | ( | ) | [protected] |
Definition at line 2191 of file ai.cpp.
References team::ai_parameters(), attack_depth_, and ai_interface::current_team().
Referenced by do_attack_analysis().
void ai::find_villages | ( | std::map< gamemap::location, std::vector< gamemap::location > > & | reachmap, | |
std::vector< std::pair< gamemap::location, gamemap::location > > & | moves, | |||
const std::multimap< gamemap::location, gamemap::location > & | dstsrc, | |||
const std::map< gamemap::location, paths > & | possible_moves, | |||
const std::multimap< gamemap::location, gamemap::location > & | enemy_dstsrc | |||
) | const [private] |
Referenced by get_villages().
friend struct attack_analysis [friend] |
std::map<location,defensive_position> ai::defensive_position_cache_ [protected] |
Definition at line 71 of file ai.hpp.
Referenced by best_defensive_position(), and invalidate_defensive_position_cache().
bool ai::threats_found_ [protected] |
std::set<location> ai::attacks_ [protected] |
game_display& ai::disp_ [protected] |
Definition at line 251 of file ai.hpp.
Referenced by access_points(), analyze_potential_recruit_movements(), average_resistance_against(), best_defensive_position(), choose_move(), desperate_attack(), do_attack_analysis(), do_combat(), do_move(), do_recruitment(), find_targets(), get_healing(), keeps(), leader_can_reach_keep(), move_group(), move_leader_after_recruit(), move_leader_to_goals(), move_leader_to_keep(), move_to_targets(), move_unit(), multistep_move_possible(), power_projection(), rate_group(), rate_terrain(), retreat_units(), and should_retreat().
unit_map& ai::units_ [protected] |
Definition at line 252 of file ai.hpp.
Referenced by access_points(), analyze_potential_recruit_combat(), analyze_potential_recruit_movements(), analyze_targets(), best_defensive_position(), choose_move(), desperate_attack(), do_attack_analysis(), do_combat(), do_move(), do_recruitment(), formula_ai::execute_variant(), find_targets(), find_threats(), form_group(), get_healing(), get_villages(), leader_can_reach_keep(), move_group(), move_leader_after_recruit(), move_leader_to_goals(), move_leader_to_keep(), move_to_targets(), move_unit(), multistep_move_possible(), formula_ai::play_turn(), power_projection(), rate_group(), and retreat_units().
std::vector<team>& ai::teams_ [protected] |
Definition at line 253 of file ai.hpp.
Referenced by access_points(), analyze_potential_recruit_movements(), analyze_targets(), desperate_attack(), do_attack_analysis(), do_combat(), do_recruitment(), find_targets(), leader_can_reach_keep(), move_leader_after_recruit(), move_leader_to_goals(), move_leader_to_keep(), move_to_targets(), move_unit(), multistep_move_possible(), and rate_terrain().
unsigned int ai::team_num_ [protected] |
Definition at line 254 of file ai.hpp.
Referenced by analyze_potential_recruit_movements(), analyze_targets(), choose_move(), do_attack_analysis(), do_move(), do_recruitment(), find_threats(), get_healing(), get_villages(), leader_can_reach_keep(), move_leader_after_recruit(), move_leader_to_goals(), move_leader_to_keep(), rate_terrain(), and retreat_units().
const gamestatus& ai::state_ [protected] |
Definition at line 255 of file ai.hpp.
Referenced by desperate_attack(), do_attack_analysis(), do_combat(), move_to_targets(), move_unit(), and power_projection().
bool ai::consider_combat_ [protected] |
std::vector<target> ai::additional_targets_ [protected] |
std::map<std::string,int> ai::unit_movement_scores_ [protected] |
std::set<std::string> ai::not_recommended_units_ [protected] |
Definition at line 269 of file ai.hpp.
Referenced by analyze_potential_recruit_combat(), analyze_potential_recruit_movements(), and recruit_usage().
std::map<std::string,int> ai::unit_combat_scores_ [protected] |
std::set<location> ai::keeps_ [protected] |
std::set<location> ai::avoid_ [protected] |
std::map<std::pair<location,const unit_type *>, std::pair<battle_context::unit_stats,battle_context::unit_stats> > ai::unit_stats_cache_ [protected] |
Weapon choice cache, to speed simulations.
Definition at line 312 of file ai.hpp.
Referenced by ai::attack_analysis::analyze(), and analyze_targets().
int ai::attack_depth_ [protected] |
Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |