#include <contexts.hpp>
Public Member Functions | |
readonly_context_impl (side_context &context, const config &cfg) | |
Constructor. More... | |
virtual | ~readonly_context_impl () |
Destructor. More... | |
virtual readonly_context & | get_readonly_context () override |
virtual void | on_readonly_context_create () override |
virtual void | handle_generic_event (const std::string &event_name) override |
Handle generic event. More... | |
const team & | current_team () const override |
Return a reference to the 'team' object for the AI. More... | |
void | diagnostic (const std::string &msg) override |
Show a diagnostic message on the screen. More... | |
void | log_message (const std::string &msg) override |
Display a debug message as a chat message. More... | |
attack_result_ptr | check_attack_action (const map_location &attacker_loc, const map_location &defender_loc, int attacker_weapon) override |
Check if it is possible to attack enemy defender using our unit attacker from attackers current location,. More... | |
move_result_ptr | check_move_action (const map_location &from, const map_location &to, bool remove_movement=true, bool unreach_is_ok=false) override |
Check if it is possible to move our unit from location 'from' to location 'to'. More... | |
recall_result_ptr | check_recall_action (const std::string &id, const map_location &where=map_location::null_location(), const map_location &from=map_location::null_location()) override |
Check if it is possible to recall a unit for us on specified location. More... | |
recruit_result_ptr | check_recruit_action (const std::string &unit_name, const map_location &where=map_location::null_location(), const map_location &from=map_location::null_location()) override |
Check if it is possible to recruit a unit for us on specified location. More... | |
stopunit_result_ptr | check_stopunit_action (const map_location &unit_location, bool remove_movement=true, bool remove_attacks=false) override |
Check if it is possible to remove unit movements and/or attack. More... | |
synced_command_result_ptr | check_synced_command_action (const std::string &lua_code, const map_location &location=map_location::null_location()) override |
Check if it is possible to run Lua code. More... | |
void | calculate_possible_moves (std::map< map_location, pathfind::paths > &possible_moves, move_map &srcdst, move_map &dstsrc, bool enemy, bool assume_full_movement=false, const terrain_filter *remove_destinations=nullptr) const override |
Calculate the moves units may possibly make. More... | |
void | calculate_moves (const unit_map &units, std::map< map_location, pathfind::paths > &possible_moves, move_map &srcdst, move_map &dstsrc, bool enemy, bool assume_full_movement=false, const terrain_filter *remove_destinations=nullptr, bool see_all=false) const override |
A more fundamental version of calculate_possible_moves which allows the use of a speculative unit map. More... | |
virtual const game_info & | get_info () const override |
void | raise_user_interact () const override |
Function which should be called frequently to allow the user to interact with the interface. More... | |
virtual int | get_recursion_count () const override |
Get the value of the recursion counter. More... | |
const defensive_position & | best_defensive_position (const map_location &unit, const move_map &dstsrc, const move_map &srcdst, const move_map &enemy_dstsrc) const override |
virtual std::map< map_location, defensive_position > & | defensive_position_cache () const override |
virtual const unit_advancements_aspect & | get_advancements () const override |
virtual double | get_aggression () const override |
virtual bool | get_allow_ally_villages () const override |
virtual const aspect_map & | get_aspects () const override |
virtual aspect_map & | get_aspects () override |
virtual const attacks_vector & | get_attacks () const override |
virtual const wfl::variant & | get_attacks_as_variant () const override |
virtual const terrain_filter & | get_avoid () const override |
virtual double | get_caution () const override |
virtual const move_map & | get_dstsrc () const override |
virtual const move_map & | get_enemy_dstsrc () const override |
virtual const moves_map & | get_enemy_possible_moves () const override |
virtual const move_map & | get_enemy_srcdst () const override |
virtual engine_ptr | get_engine_by_cfg (const config &cfg) override |
get engine by cfg, creating it if it is not created yet but known More... | |
virtual const std::vector< engine_ptr > & | get_engines () const override |
virtual std::vector< engine_ptr > & | get_engines () override |
virtual std::string | get_grouping () const override |
virtual const std::vector< goal_ptr > & | get_goals () const override |
virtual std::vector< goal_ptr > & | get_goals () override |
virtual double | get_leader_aggression () const override |
virtual config | get_leader_goal () const override |
virtual utils::variant< bool, std::vector< std::string > > | get_leader_ignores_keep () const override |
virtual double | get_leader_value () const override |
virtual utils::variant< bool, std::vector< std::string > > | get_passive_leader () const override |
virtual utils::variant< bool, std::vector< std::string > > | get_passive_leader_shares_keep () const override |
virtual const moves_map & | get_possible_moves () const override |
virtual double | get_recruitment_diversity () const override |
virtual const config | get_recruitment_instructions () const override |
virtual const std::vector< std::string > | get_recruitment_more () const override |
virtual const std::vector< std::string > | get_recruitment_pattern () const override |
virtual int | get_recruitment_randomness () const override |
virtual const config | get_recruitment_save_gold () const override |
virtual double | get_retreat_enemy_weight () const override |
virtual double | get_retreat_factor () const override |
virtual double | get_scout_village_targeting () const override |
virtual bool | get_simple_targeting () const override |
virtual const move_map & | get_srcdst () const override |
virtual bool | get_support_villages () const override |
virtual double | get_village_value () const override |
virtual int | get_villages_per_scout () const override |
virtual bool | is_active (const std::string &time_of_day, const std::string &turns) const override |
virtual bool | is_keep_ignoring_leader (const std::string &id) const override |
virtual bool | is_passive_leader (const std::string &id) const override |
virtual bool | is_passive_keep_sharing_leader (const std::string &id) const override |
virtual bool | is_dst_src_valid_lua () const override |
virtual bool | is_dst_src_enemy_valid_lua () const override |
virtual bool | is_src_dst_valid_lua () const override |
virtual bool | is_src_dst_enemy_valid_lua () const override |
virtual void | invalidate_defensive_position_cache () const override |
virtual void | invalidate_move_maps () const override |
virtual void | invalidate_keeps_cache () const override |
virtual const std::set< map_location > & | keeps () const override |
virtual bool | leader_can_reach_keep () const override |
virtual const map_location & | nearest_keep (const map_location &loc) const override |
virtual double | power_projection (const map_location &loc, const move_map &dstsrc) const override |
Function which finds how much 'power' a side can attack a certain location with. More... | |
virtual void | recalculate_move_maps () const override |
virtual void | recalculate_move_maps_enemy () const override |
virtual void | add_aspects (std::vector< aspect_ptr > &aspects) override |
virtual void | add_facet (const std::string &id, const config &cfg) const override |
void | on_create () |
virtual void | set_dst_src_valid_lua () override |
virtual void | set_dst_src_enemy_valid_lua () override |
virtual void | set_src_dst_valid_lua () override |
virtual void | set_src_dst_enemy_valid_lua () override |
virtual const map_location & | suitable_keep (const map_location &leader_location, const pathfind::paths &leader_paths) const override |
get most suitable keep for leader - nearest free that can be reached in 1 turn, if none - return nearest occupied that can be reached in 1 turn, if none - return nearest keep, if none - return null_location More... | |
virtual config | to_readonly_context_config () const override |
serialize to config More... | |
virtual unit_stats_cache_t & | unit_stats_cache () const override |
Weapon choice cache, to speed simulations. More... | |
Public Member Functions inherited from ai::side_context_proxy | |
side_context_proxy () | |
virtual | ~side_context_proxy () |
void | init_side_context_proxy (side_context &target) |
virtual side_number | get_side () const override |
Get the side number. More... | |
virtual void | set_side (side_number side) override |
Set the side number. More... | |
virtual side_context & | get_side_context () override |
unwrap More... | |
virtual config | to_side_context_config () const override |
serialize this context to config More... | |
Public Member Functions inherited from ai::side_context | |
virtual | ~side_context () |
empty destructor More... | |
side_context () | |
empty constructor More... | |
Public Member Functions inherited from ai::readonly_context | |
readonly_context () | |
virtual | ~readonly_context () |
Public Member Functions inherited from events::observer | |
virtual | ~observer () |
Private Member Functions | |
template<typename T > | |
void | add_known_aspect (const std::string &name, typesafe_aspect_ptr< T > &where) |
bool | applies_to_leader (const utils::variant< bool, std::vector< std::string >> &aspect_value, const std::string &id) const |
Additional Inherited Members | |
Public Types inherited from ai::readonly_context | |
typedef std::map< std::pair< map_location, const unit_type * >, std::pair< battle_context_unit_stats, battle_context_unit_stats > > | unit_stats_cache_t |
Definition at line 986 of file contexts.hpp.
ai::readonly_context_impl::readonly_context_impl | ( | side_context & | context, |
const config & | cfg | ||
) |
Constructor.
Definition at line 161 of file contexts.cpp.
References ai::manager::add_gamestate_observer(), add_known_aspect(), advancements_, aggression_, allow_ally_villages_, attacks_, avoid_, caution_, resources::gameboard, ai::manager::get_singleton(), grouping_, ai::keeps_cache::init(), ai::side_context_proxy::init_side_context_proxy(), keeps_, leader_aggression_, leader_goal_, leader_ignores_keep_, leader_value_, passive_leader_, passive_leader_shares_keep_, recruitment_diversity_, recruitment_instructions_, recruitment_more_, recruitment_pattern_, recruitment_randomness_, recruitment_save_gold_, retreat_enemy_weight_, retreat_factor_, scout_village_targeting_, simple_targeting_, support_villages_, village_value_, and villages_per_scout_.
|
virtual |
Destructor.
Definition at line 285 of file contexts.cpp.
References ai::manager::get_singleton(), and ai::manager::remove_gamestate_observer().
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 424 of file contexts.cpp.
References ERR_AI, i, and known_aspects_.
Referenced by on_readonly_context_create().
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 437 of file contexts.cpp.
References ERR_AI, i, and known_aspects_.
|
private |
Definition at line 156 of file contexts.cpp.
References aspects_, and known_aspects_.
Referenced by readonly_context_impl().
|
private |
Definition at line 1230 of file contexts.cpp.
References utils::contains(), and utils::decayed_is_same.
Referenced by is_keep_ignoring_leader(), is_passive_keep_sharing_leader(), and is_passive_leader().
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 447 of file contexts.cpp.
References ai::defensive_position::chance_to_hit, defensive_position_cache_, unit_map::find(), resources::gameboard, i, ai::defensive_position::loc, power_projection(), ai::defensive_position::support, game_board::units(), and ai::defensive_position::vulnerability.
|
overridevirtual |
A more fundamental version of calculate_possible_moves which allows the use of a speculative unit map.
NOTE: Support for a speculative map is broken (not used when pathfinding) and has not been used since (probably) r38610 (September 2009). (See the TODO in the implementation.)
TODO: This is where support for a speculative unit map is incomplete. There are several places (deep) within the paths constructor where resources::gameboard->units() is assumed to be the unit map. Rather than introduce a new parameter to numerous functions, a better solution may be for the creator of the speculative map (if one is used in the future) to cause resources::gameboard->units() to point to that map (and restore the "real" pointer when the speculating is completed). If that approach is adopted, calculate_moves() and calculate_possible_moves() become redundant, and one of them should probably be eliminated.
Implements ai::readonly_context.
Definition at line 330 of file contexts.cpp.
References unit_map::begin(), pathfind::paths::step::curr, current_team(), dst, unit_map::end(), enemy, resources::gameboard, ai::side_context_proxy::get_side(), src, and t.
Referenced by calculate_possible_moves().
|
overridevirtual |
Calculate the moves units may possibly make.
possible_moves | A map which will be filled with the paths each unit can take to get to every possible destination. You probably don't want to use this object at all, except to pass to 'move_unit'. |
srcdst | A map of units to all their possible destinations. |
dstsrc | A map of destinations to all the units that can move to that destination. |
enemy | if true, a map of possible moves for enemies will be calculated. If false, a map of possible moves for units on the AI's side will be calculated. The AI's own leader will not be included in this map. |
assume_full_movement | If true, the function will operate on the assumption that all units can move their full movement allotment. |
remove_destinations | a pointer to a terrain filter for possible destinations to omit. |
Implements ai::readonly_context.
Definition at line 323 of file contexts.cpp.
References calculate_moves(), enemy, and resources::gameboard.
Referenced by recalculate_move_maps(), and recalculate_move_maps_enemy().
|
overridevirtual |
Check if it is possible to attack enemy defender using our unit attacker from attackers current location,.
attacker_loc | location of attacker |
defender_loc | location of defender |
attacker_weapon | weapon of attacker |
possible | results: ok, something wrong, attacker and/or defender are invalid, attacker and/or defender are invalid, or attacker doesn't have the specified weapon |
Implements ai::readonly_context.
Definition at line 109 of file contexts.cpp.
References ai::actions::execute_attack_action(), unit_map::find(), resources::gameboard, get_aggression(), get_leader_aggression(), ai::side_context_proxy::get_side(), i, and game_board::units().
|
overridevirtual |
Check if it is possible to move our unit from location 'from' to location 'to'.
from | location of our unit |
to | where to move |
remove_movement | set unit movement to 0 in case of successful move |
unreach_is_ok | whether it's okay for a destination to be unreachable |
possible | results: ok, something wrong, move is interrupted, or move is impossible |
Implements ai::readonly_context.
Definition at line 119 of file contexts.cpp.
References ai::actions::execute_move_action(), and ai::side_context_proxy::get_side().
|
overridevirtual |
Check if it is possible to recall a unit for us on specified location.
id | the id of the unit to be recruited. |
where | location where the unit is to be recruited. |
from | location of the recaller. |
possible | results: ok, something wrong, leader not on keep, no free space on keep, or not enough gold |
Implements ai::readonly_context.
Definition at line 131 of file contexts.cpp.
References ai::actions::execute_recall_action(), and ai::side_context_proxy::get_side().
|
overridevirtual |
Check if it is possible to recruit a unit for us on specified location.
unit_name | the name of the unit to be recruited. |
where | location where the unit is to be recruited. |
from | location of the recruiter. |
possible | results: ok, something wrong, leader not on keep, no free space on keep, or not enough gold |
Implements ai::readonly_context.
Definition at line 135 of file contexts.cpp.
References ai::actions::execute_recruit_action(), ai::side_context_proxy::get_side(), and unit_name().
|
overridevirtual |
Check if it is possible to remove unit movements and/or attack.
unit_location | the location of our unit |
remove_movement | set remaining movements to 0 |
remove_attacks | set remaining attacks to 0 |
possible | results: ok, something wrong, or nothing to do |
Implements ai::readonly_context.
Definition at line 143 of file contexts.cpp.
References ai::actions::execute_stopunit_action(), and ai::side_context_proxy::get_side().
|
overridevirtual |
Check if it is possible to run Lua code.
lua_code | the code to be run |
location | location to be passed to the code as x1/y1 |
possible | results: ok, something wrong, or nothing to do |
Implements ai::readonly_context.
Definition at line 151 of file contexts.cpp.
References ai::actions::execute_synced_command_action(), and ai::side_context_proxy::get_side().
|
overridevirtual |
Return a reference to the 'team' object for the AI.
Implements ai::readonly_context.
Definition at line 310 of file contexts.cpp.
References resources::gameboard, ai::side_context_proxy::get_side(), and game_board::get_team().
Referenced by calculate_moves(), and leader_can_reach_keep().
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 493 of file contexts.cpp.
References defensive_position_cache_.
|
overridevirtual |
Show a diagnostic message on the screen.
Implements ai::readonly_context.
Definition at line 303 of file contexts.cpp.
References game_config::debug, display::get_singleton(), wfl::msg(), and display::set_diagnostic().
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 498 of file contexts.cpp.
References advancements_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 508 of file contexts.cpp.
References aggression_.
Referenced by check_attack_action().
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 516 of file contexts.cpp.
References allow_ally_villages_.
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 552 of file contexts.cpp.
References config::add_child(), avoid_, and resources::filter_con.
Referenced by nearest_keep(), and recalculate_move_maps().
|
overridevirtual |
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 571 of file contexts.cpp.
References dstsrc_, move_maps_valid_, and recalculate_move_maps().
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 579 of file contexts.cpp.
References enemy_dstsrc_, move_maps_enemy_valid_, and recalculate_move_maps_enemy().
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 587 of file contexts.cpp.
References enemy_possible_moves_, move_maps_enemy_valid_, and recalculate_move_maps_enemy().
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 595 of file contexts.cpp.
References enemy_srcdst_, move_maps_enemy_valid_, and recalculate_move_maps_enemy().
|
overridevirtual |
get engine by cfg, creating it if it is not created yet but known
Implements ai::readonly_context.
Definition at line 603 of file contexts.cpp.
References DBG_AI, engines_, ERR_AI, ai::engine_factory::get_list(), and ai::side_context_proxy::get_side().
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 656 of file contexts.cpp.
References goals_.
Referenced by on_readonly_context_create().
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 295 of file contexts.cpp.
References ai::manager::get_active_ai_info_for_side(), ai::side_context_proxy::get_side(), and ai::manager::get_singleton().
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 666 of file contexts.cpp.
References leader_aggression_.
Referenced by check_attack_action().
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 674 of file contexts.cpp.
References leader_goal_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 682 of file contexts.cpp.
References leader_ignores_keep_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 690 of file contexts.cpp.
References leader_value_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 698 of file contexts.cpp.
References passive_leader_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 706 of file contexts.cpp.
References passive_leader_shares_keep_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 714 of file contexts.cpp.
References move_maps_valid_, possible_moves_, and recalculate_move_maps().
|
inlineoverridevirtual |
Unwrap - this class is not a proxy, so return *this
:w
Implements ai::readonly_context.
Definition at line 1003 of file contexts.hpp.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 722 of file contexts.cpp.
References recruitment_diversity_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 730 of file contexts.cpp.
References recruitment_instructions_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 738 of file contexts.cpp.
References recruitment_more_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 746 of file contexts.cpp.
References recruitment_pattern_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 754 of file contexts.cpp.
References recruitment_randomness_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 762 of file contexts.cpp.
References recruitment_save_gold_.
|
overridevirtual |
Get the value of the recursion counter.
Reimplemented from ai::side_context_proxy.
Definition at line 78 of file contexts.cpp.
References ai::recursion_counter::get_count(), and recursion_counter_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 770 of file contexts.cpp.
References retreat_enemy_weight_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 778 of file contexts.cpp.
References retreat_factor_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 786 of file contexts.cpp.
References scout_village_targeting_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 794 of file contexts.cpp.
References simple_targeting_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 802 of file contexts.cpp.
References move_maps_valid_, recalculate_move_maps(), and srcdst_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 810 of file contexts.cpp.
References support_villages_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 818 of file contexts.cpp.
References village_value_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 826 of file contexts.cpp.
References villages_per_scout_.
|
overridevirtual |
Handle generic event.
Implements events::observer.
Definition at line 290 of file contexts.cpp.
References invalidate_move_maps().
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 854 of file contexts.cpp.
References defensive_position_cache_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 859 of file contexts.cpp.
References ai::keeps_cache::clear(), and keeps_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 869 of file contexts.cpp.
References dst_src_enemy_valid_lua_, dst_src_valid_lua_, move_maps_enemy_valid_, move_maps_valid_, src_dst_enemy_valid_lua_, and src_dst_valid_lua_.
Referenced by handle_generic_event().
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 1207 of file contexts.cpp.
References tod_manager::get_time_of_day(), time_of_day::id, utils::parse_range(), utils::split(), resources::tod_manager, and tod_manager::turn().
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 839 of file contexts.cpp.
References dst_src_enemy_valid_lua_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 834 of file contexts.cpp.
References dst_src_valid_lua_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 1244 of file contexts.cpp.
References applies_to_leader(), and leader_ignores_keep_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 1254 of file contexts.cpp.
References applies_to_leader(), and passive_leader_shares_keep_.
Referenced by recalculate_move_maps().
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 1249 of file contexts.cpp.
References applies_to_leader(), and passive_leader_.
Referenced by recalculate_move_maps().
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 849 of file contexts.cpp.
References src_dst_enemy_valid_lua_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 844 of file contexts.cpp.
References src_dst_valid_lua_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 881 of file contexts.cpp.
References ai::keeps_cache::get(), and keeps_.
Referenced by nearest_keep(), and suitable_keep().
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 933 of file contexts.cpp.
References pathfind::paths::dest_vect::contains(), current_team(), pathfind::paths::destinations, unit_map::find_leader(), resources::gameboard, ai::side_context_proxy::get_side(), nearest_keep(), game_board::units(), and map_location::valid().
|
overridevirtual |
Display a debug message as a chat message.
Implements ai::readonly_context.
Definition at line 315 of file contexts.cpp.
References display_chat_manager::add_chat_message(), game_config::debug, game_display::get_chat_manager(), ai::side_context_proxy::get_side(), game_display::get_singleton(), events::chat_handler::MESSAGE_PUBLIC, and wfl::msg().
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 955 of file contexts.cpp.
References distance_between(), dummy, get_avoid(), i, keeps(), and map_location::null_location().
Referenced by leader_can_reach_keep(), and suitable_keep().
void ai::readonly_context_impl::on_create | ( | ) |
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 241 of file contexts.cpp.
References add_aspects(), cfg_, config::child_range(), engines_, get_goals(), ai::engine::parse_aspect_from_config(), ai::engine::parse_engine_from_config(), and ai::engine::parse_goal_from_config().
|
overridevirtual |
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)
Example: 'loc' can be reached by two units, one of whom has a 10-3 attack and has 48/48 hp, and can defend at 40% on the adjacent grassland. The other has a 8-2 attack, and has 30/40 hp, and can defend at 60% on the adjacent mountain. The rating will be 10*3*1.0*0.4 + 8*2*0.75*0.6 = 19.2
Implements ai::readonly_context.
Definition at line 984 of file contexts.cpp.
References unit::alignment(), unit::attacks(), unit::defense_modifier(), unit_map::end(), unit_map::find(), resources::gameboard, get_adjacent_tiles(), ai::side_context_proxy::get_side(), tod_manager::get_time_of_day(), unit::hitpoints(), i, utf8::index(), gamemap::is_village(), time_of_day::lawful_bonus, game_board::map(), unit::max_hitpoints(), gamemap_base::on_board(), unit::side(), resources::tod_manager, tod_manager::turn(), game_board::units(), map_location::valid(), and WRN_AI.
Referenced by best_defensive_position().
|
overridevirtual |
Function which should be called frequently to allow the user to interact with the interface.
This function will make sure that interaction doesn't occur too often, so there is no problem with calling it very regularly.
Implements ai::readonly_context.
Definition at line 88 of file contexts.cpp.
References ai::manager::get_singleton(), and ai::manager::raise_user_interact().
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 1099 of file contexts.cpp.
References calculate_possible_moves(), dst_src_valid_lua_, dstsrc_, unit_map::find_leader(), resources::gameboard, get_avoid(), ai::side_context_proxy::get_side(), i, is_passive_keep_sharing_leader(), is_passive_leader(), move_maps_valid_, possible_moves_, src_dst_valid_lua_, srcdst_, and game_board::units().
Referenced by get_dstsrc(), get_possible_moves(), and get_srcdst().
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 1126 of file contexts.cpp.
References calculate_possible_moves(), dst_src_enemy_valid_lua_, enemy_dstsrc_, enemy_possible_moves_, enemy_srcdst_, move_maps_enemy_valid_, and src_dst_enemy_valid_lua_.
Referenced by get_enemy_dstsrc(), get_enemy_possible_moves(), and get_enemy_srcdst().
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 1144 of file contexts.cpp.
References dst_src_enemy_valid_lua_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 1139 of file contexts.cpp.
References dst_src_valid_lua_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 1154 of file contexts.cpp.
References src_dst_enemy_valid_lua_.
|
overridevirtual |
Implements ai::readonly_context.
Definition at line 1149 of file contexts.cpp.
References src_dst_valid_lua_.
|
overridevirtual |
get most suitable keep for leader - nearest free that can be reached in 1 turn, if none - return nearest occupied that can be reached in 1 turn, if none - return nearest keep, if none - return null_location
Implements ai::readonly_context.
Definition at line 1159 of file contexts.cpp.
References pathfind::paths::step::curr, pathfind::paths::destinations, resources::gameboard, keeps(), pathfind::paths::step::move_left, nearest_keep(), and map_location::null_location().
|
overridevirtual |
serialize to config
Implements ai::readonly_context.
Definition at line 270 of file contexts.cpp.
References config::add_child(), aspects_, e, engines_, g, and goals_.
|
overridevirtual |
Weapon choice cache, to speed simulations.
Implements ai::readonly_context.
Definition at line 1202 of file contexts.cpp.
References unit_stats_cache_.
|
private |
Definition at line 1285 of file contexts.hpp.
Referenced by get_advancements(), and readonly_context_impl().
|
private |
Definition at line 1286 of file contexts.hpp.
Referenced by get_aggression(), and readonly_context_impl().
|
private |
Definition at line 1287 of file contexts.hpp.
Referenced by get_allow_ally_villages(), and readonly_context_impl().
|
private |
Definition at line 1288 of file contexts.hpp.
Referenced by add_known_aspect(), get_aspects(), and to_readonly_context_config().
|
private |
Definition at line 1289 of file contexts.hpp.
Referenced by get_attacks(), get_attacks_as_variant(), and readonly_context_impl().
|
mutableprivate |
Definition at line 1290 of file contexts.hpp.
Referenced by get_avoid(), and readonly_context_impl().
|
private |
Definition at line 1291 of file contexts.hpp.
Referenced by get_caution(), and readonly_context_impl().
|
private |
Definition at line 1276 of file contexts.hpp.
Referenced by on_readonly_context_create().
|
mutableprivate |
Definition at line 1292 of file contexts.hpp.
Referenced by best_defensive_position(), defensive_position_cache(), and invalidate_defensive_position_cache().
|
mutableprivate |
Definition at line 1307 of file contexts.hpp.
Referenced by invalidate_move_maps(), is_dst_src_enemy_valid_lua(), recalculate_move_maps_enemy(), and set_dst_src_enemy_valid_lua().
|
mutableprivate |
Definition at line 1306 of file contexts.hpp.
Referenced by invalidate_move_maps(), is_dst_src_valid_lua(), recalculate_move_maps(), and set_dst_src_valid_lua().
|
mutableprivate |
Definition at line 1293 of file contexts.hpp.
Referenced by get_dstsrc(), and recalculate_move_maps().
|
mutableprivate |
Definition at line 1294 of file contexts.hpp.
Referenced by get_enemy_dstsrc(), and recalculate_move_maps_enemy().
|
mutableprivate |
Definition at line 1295 of file contexts.hpp.
Referenced by get_enemy_possible_moves(), and recalculate_move_maps_enemy().
|
mutableprivate |
Definition at line 1296 of file contexts.hpp.
Referenced by get_enemy_srcdst(), and recalculate_move_maps_enemy().
|
private |
AI Support Engines.
Definition at line 1281 of file contexts.hpp.
Referenced by get_engine_by_cfg(), get_engines(), on_readonly_context_create(), and to_readonly_context_config().
|
private |
Definition at line 1298 of file contexts.hpp.
Referenced by get_goals(), and to_readonly_context_config().
|
private |
Definition at line 1297 of file contexts.hpp.
Referenced by get_grouping(), and readonly_context_impl().
|
mutableprivate |
Definition at line 1299 of file contexts.hpp.
Referenced by invalidate_keeps_cache(), keeps(), and readonly_context_impl().
|
private |
Definition at line 1283 of file contexts.hpp.
Referenced by add_aspects(), add_facet(), and add_known_aspect().
|
private |
Definition at line 1300 of file contexts.hpp.
Referenced by get_leader_aggression(), and readonly_context_impl().
|
private |
Definition at line 1301 of file contexts.hpp.
Referenced by get_leader_goal(), and readonly_context_impl().
|
private |
Definition at line 1302 of file contexts.hpp.
Referenced by get_leader_ignores_keep(), is_keep_ignoring_leader(), and readonly_context_impl().
|
private |
Definition at line 1303 of file contexts.hpp.
Referenced by get_leader_value(), and readonly_context_impl().
|
mutableprivate |
Definition at line 1304 of file contexts.hpp.
Referenced by get_enemy_dstsrc(), get_enemy_possible_moves(), get_enemy_srcdst(), invalidate_move_maps(), and recalculate_move_maps_enemy().
|
mutableprivate |
Definition at line 1305 of file contexts.hpp.
Referenced by get_dstsrc(), get_possible_moves(), get_srcdst(), invalidate_move_maps(), and recalculate_move_maps().
|
private |
Definition at line 1310 of file contexts.hpp.
Referenced by get_passive_leader(), is_passive_leader(), and readonly_context_impl().
|
private |
Definition at line 1311 of file contexts.hpp.
Referenced by get_passive_leader_shares_keep(), is_passive_keep_sharing_leader(), and readonly_context_impl().
|
mutableprivate |
Definition at line 1312 of file contexts.hpp.
Referenced by get_possible_moves(), and recalculate_move_maps().
|
private |
Definition at line 1313 of file contexts.hpp.
Referenced by get_recruitment_diversity(), and readonly_context_impl().
|
private |
Definition at line 1314 of file contexts.hpp.
Referenced by get_recruitment_instructions(), and readonly_context_impl().
|
private |
Definition at line 1315 of file contexts.hpp.
Referenced by get_recruitment_more(), and readonly_context_impl().
|
private |
Definition at line 1316 of file contexts.hpp.
Referenced by get_recruitment_pattern(), and readonly_context_impl().
|
private |
Definition at line 1317 of file contexts.hpp.
Referenced by get_recruitment_randomness(), and readonly_context_impl().
|
private |
Definition at line 1318 of file contexts.hpp.
Referenced by get_recruitment_save_gold(), and readonly_context_impl().
|
private |
Definition at line 1319 of file contexts.hpp.
Referenced by get_recursion_count().
|
private |
Definition at line 1320 of file contexts.hpp.
Referenced by get_retreat_enemy_weight(), and readonly_context_impl().
|
private |
Definition at line 1321 of file contexts.hpp.
Referenced by get_retreat_factor(), and readonly_context_impl().
|
private |
Definition at line 1322 of file contexts.hpp.
Referenced by get_scout_village_targeting(), and readonly_context_impl().
|
private |
Definition at line 1323 of file contexts.hpp.
Referenced by get_simple_targeting(), and readonly_context_impl().
|
mutableprivate |
Definition at line 1309 of file contexts.hpp.
Referenced by invalidate_move_maps(), is_src_dst_enemy_valid_lua(), recalculate_move_maps_enemy(), and set_src_dst_enemy_valid_lua().
|
mutableprivate |
Definition at line 1308 of file contexts.hpp.
Referenced by invalidate_move_maps(), is_src_dst_valid_lua(), recalculate_move_maps(), and set_src_dst_valid_lua().
|
mutableprivate |
Definition at line 1324 of file contexts.hpp.
Referenced by get_srcdst(), and recalculate_move_maps().
|
private |
Definition at line 1325 of file contexts.hpp.
Referenced by get_support_villages(), and readonly_context_impl().
|
mutableprivate |
Definition at line 1326 of file contexts.hpp.
Referenced by unit_stats_cache().
|
private |
Definition at line 1327 of file contexts.hpp.
Referenced by get_village_value(), and readonly_context_impl().
|
private |
Definition at line 1328 of file contexts.hpp.
Referenced by get_villages_per_scout(), and readonly_context_impl().