#include <ca_move_to_targets.hpp>
Public Member Functions | |
move_to_targets_phase (rca_context &context, const config &cfg) | |
virtual | ~move_to_targets_phase () |
virtual double | evaluate () |
Evaluate the candidate action, resetting the internal state of the action. More... | |
virtual void | execute () |
Execute the candidate action. More... | |
Public Member Functions inherited from ai::candidate_action | |
candidate_action (rca_context &context, const config &cfg) | |
virtual | ~candidate_action () |
Destructor. More... | |
bool | is_enabled () const |
Is this candidate action enabled ? More... | |
void | enable () |
Enable the candidate action. More... | |
void | disable () |
Disable the candidate action. More... | |
double | get_score () const |
Get the usual score of the candidate action without re-evaluation. More... | |
double | get_max_score () const |
Get the upper bound of the score of the candidate action without re-evaluation. More... | |
std::shared_ptr< unit_filter > | get_filter_own () const |
Get the unit filter for allowed units for this candidate action. More... | |
bool | is_allowed_unit (const unit &u) const |
Flag indicating whether unit may be used by this candidate action. More... | |
virtual std::string | get_name () const |
Get the name of the candidate action (useful for debug purposes) More... | |
const std::string & | get_type () const |
Get the type of the candidate action (useful for debug purposes) More... | |
virtual std::string | get_id () const |
virtual std::string | get_engine () const |
int | get_recursion_count () const |
Get the value of the recursion counter. More... | |
virtual config | to_config () const |
serialize More... | |
virtual void | set_to_be_removed () |
virtual bool | to_be_removed () |
Public Member Functions inherited from ai::rca_context_proxy | |
rca_context_proxy () | |
virtual | ~rca_context_proxy () |
void | init_rca_context_proxy (rca_context &target) |
rca_context & | get_rca_context () |
Unwrap. More... | |
Public Member Functions inherited from ai::rca_context | |
rca_context () | |
Constructor. More... | |
virtual | ~rca_context () |
Destructor. More... | |
bool | is_offense () |
void | set_offense () |
bool | is_defense () |
void | set_defense () |
void | clear_strategy () |
bool | has_strategy () |
Public Member Functions inherited from ai::default_ai_context | |
default_ai_context () | |
Constructor. More... | |
virtual | ~default_ai_context () |
Destructor. More... | |
Public Member Functions inherited from ai::readwrite_context | |
readwrite_context () | |
virtual | ~readwrite_context () |
Public Member Functions inherited from ai::readonly_context | |
readonly_context () | |
virtual | ~readonly_context () |
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::ai_context_proxy | |
ai_context_proxy () | |
void | init_ai_context_proxy (ai_context &target) |
virtual | ~ai_context_proxy () |
ai_context & | get_ai_context () |
Unwrap. More... | |
Public Member Functions inherited from ai::default_ai_context_proxy | |
int | count_free_hexes_in_castle (const map_location &loc, std::set< map_location > &checked_hexes) |
default_ai_context_proxy () | |
virtual | ~default_ai_context_proxy () |
virtual const std::vector< target > & | additional_targets () const |
virtual void | add_target (const target &t) const |
virtual void | clear_additional_targets () const |
virtual default_ai_context & | get_default_ai_context () |
virtual std::vector< target > | find_targets (const move_map &enemy_dstsrc) |
void | init_default_ai_context_proxy (default_ai_context &target) |
virtual int | rate_terrain (const unit &u, const map_location &loc) const |
virtual config | to_default_ai_context_config () const |
Public Member Functions inherited from ai::readwrite_context_proxy | |
readwrite_context_proxy () | |
void | init_readwrite_context_proxy (readwrite_context &target) |
virtual readwrite_context & | get_readwrite_context () override |
virtual attack_result_ptr | execute_attack_action (const map_location &attacker_loc, const map_location &defender_loc, int attacker_weapon) override |
virtual move_result_ptr | execute_move_action (const map_location &from, const map_location &to, bool remove_movement=true, bool unreach_is_ok=false) override |
virtual recall_result_ptr | execute_recall_action (const std::string &id, const map_location &where=map_location::null_location(), const map_location &from=map_location::null_location()) override |
virtual recruit_result_ptr | execute_recruit_action (const std::string &unit_name, const map_location &where=map_location::null_location(), const map_location &from=map_location::null_location()) override |
virtual stopunit_result_ptr | execute_stopunit_action (const map_location &unit_location, bool remove_movement=true, bool remove_attacks=false) override |
virtual synced_command_result_ptr | execute_synced_command_action (const std::string &lua_code, const map_location &location=map_location::null_location()) override |
virtual team & | current_team_w () override |
virtual void | raise_gamestate_changed () const override |
virtual game_info & | get_info_w () override |
virtual config | to_readwrite_context_config () const override |
serialize this context to config More... | |
Public Member Functions inherited from ai::readonly_context_proxy | |
readonly_context_proxy () | |
virtual | ~readonly_context_proxy () |
void | init_readonly_context_proxy (readonly_context &target) |
virtual readonly_context & | get_readonly_context () override |
virtual void | on_readonly_context_create () override |
virtual const team & | current_team () const override |
virtual void | diagnostic (const std::string &msg) override |
virtual void | log_message (const std::string &msg) override |
virtual attack_result_ptr | check_attack_action (const map_location &attacker_loc, const map_location &defender_loc, int attacker_weapon) override |
virtual move_result_ptr | check_move_action (const map_location &from, const map_location &to, bool remove_movement=true, bool unreach_is_ok=false) override |
virtual 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 |
virtual 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 |
virtual stopunit_result_ptr | check_stopunit_action (const map_location &unit_location, bool remove_movement=true, bool remove_attacks=false) override |
virtual synced_command_result_ptr | check_synced_command_action (const std::string &lua_code, const map_location &location=map_location::null_location()) override |
virtual 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 |
virtual 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 |
virtual const game_info & | get_info () const override |
virtual void | raise_user_interact () const override |
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 void | add_aspects (std::vector< aspect_ptr > &aspects) override |
virtual void | add_facet (const std::string &id, const config &cfg) const 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 | 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 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 const move_map & | get_srcdst () 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 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 void | recalculate_move_maps () const override |
virtual void | recalculate_move_maps_enemy () const override |
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 |
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::component | |
component () | |
virtual | ~component () |
virtual component * | get_child (const path_element &child) |
virtual std::vector< component * > | get_children (const std::string &type) |
virtual std::vector< std::string > | get_children_types () |
virtual bool | change_child (const path_element &child, const config &cfg) |
virtual bool | add_child (const path_element &child, const config &cfg) |
virtual bool | delete_child (const path_element &child) |
property_handler_map & | property_handlers () |
Protected Member Functions | |
void | access_points (const move_map &srcdst, const map_location &u, const map_location &dst, std::vector< map_location > &out) |
std::pair< map_location, map_location > | choose_move (std::vector< target > &targets) |
double | compare_groups (const std::set< map_location > &our_group, const std::set< map_location > &their_group, const std::vector< map_location > &battlefield) const |
void | enemies_along_path (const std::vector< map_location > &route, const move_map &dstsrc, std::set< map_location > &res) |
map_location | form_group (const std::vector< map_location > &route, const move_map &dstsrc, std::set< map_location > &res) |
bool | move_group (const map_location &dst, const std::vector< map_location > &route, const std::set< map_location > &units) |
double | rate_group (const std::set< map_location > &group, const std::vector< map_location > &battlefield) const |
double | rate_target (const target &tg, const unit_map::iterator &u, const move_map &dstsrc, const move_map &enemy_dstsrc, const pathfind::plain_route &rt) |
rate a target, but can also return the maximal possible rating by passing a dummy route More... | |
bool | should_retreat (const map_location &loc, const unit_map::const_iterator &un, const move_map &srcdst, const move_map &dstsrc, const move_map &enemy_dstsrc, double caution) |
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 |
Static Public Attributes inherited from ai::candidate_action | |
static const double | BAD_SCORE = 0 |
static const double | HIGH_SCORE = 10000000 |
Definition at line 37 of file ca_move_to_targets.hpp.
ai::ai_default_rca::move_to_targets_phase::move_to_targets_phase | ( | rca_context & | context, |
const config & | cfg | ||
) |
Definition at line 117 of file ca_move_to_targets.cpp.
|
virtual |
Definition at line 122 of file ca_move_to_targets.cpp.
|
protected |
Definition at line 614 of file ca_move_to_targets.cpp.
References pathfind::a_star_search(), ai::readonly_context_proxy::current_team(), distance_between(), dst, unit_map::end(), unit_map::find(), resources::gameboard, pathfind::get_teleport_locations(), gamemap_base::h(), i, game_board::map(), pathfind::plain_route::steps, game_board::units(), and gamemap_base::w().
Referenced by choose_move().
|
protected |
Definition at line 258 of file ca_move_to_targets.cpp.
References pathfind::a_star_search(), access_points(), unit_map::begin(), ai::readonly_context_proxy::calculate_possible_moves(), compare_groups(), ai::readonly_context_proxy::current_team(), unit::defense_modifier(), distance_between(), dst, unit_map::end(), enemies_along_path(), unit_map::find(), form_group(), resources::gameboard, ai::readonly_context_proxy::get_caution(), ai::readonly_context_proxy::get_dstsrc(), ai::readonly_context_proxy::get_enemy_dstsrc(), ai::readonly_context_proxy::get_grouping(), ai::side_context_proxy::get_side(), ai::readonly_context_proxy::get_simple_targeting(), ai::readonly_context_proxy::get_srcdst(), pathfind::get_teleport_locations(), gamemap_base::get_terrain(), gamemap_base::h(), unit::hitpoints(), i, ai::candidate_action::is_allowed_unit(), ai::readonly_context_proxy::is_keep_ignoring_leader(), ai::target::loc, LOG_AI, ai::ai_default_rca::log_ai_testing_ca_move_to_targets, log_scope2, game_board::map(), pathfind::plain_route::move_cost, move_group(), gamemap_base::on_board(), ai::readonly_context_proxy::power_projection(), ai::readonly_context_proxy::raise_user_interact(), rate_target(), should_retreat(), pathfind::plain_route::steps, game_board::units(), map_location::valid(), ai::target::value, and gamemap_base::w().
Referenced by execute().
|
protected |
Definition at line 639 of file ca_move_to_targets.cpp.
References b, and rate_group().
Referenced by choose_move().
|
protected |
Definition at line 646 of file ca_move_to_targets.cpp.
References get_adjacent_tiles(), and i.
Referenced by choose_move(), and rate_target().
|
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 126 of file ca_move_to_targets.cpp.
References ai::candidate_action::get_score().
|
virtual |
Execute the candidate action.
Implements ai::candidate_action.
Definition at line 131 of file ca_move_to_targets.cpp.
References ai::default_ai_context_proxy::additional_targets(), choose_move(), utils::erase_if(), ai::readwrite_context_proxy::execute_move_action(), unit_map::find_leader(), ai::default_ai_context_proxy::find_targets(), resources::gameboard, ai::readonly_context_proxy::get_enemy_dstsrc(), ai::side_context_proxy::get_side(), LOG_AI, game_board::map(), gamemap_base::on_board(), game_board::units(), and WRN_AI.
|
protected |
Definition at line 658 of file ca_move_to_targets.cpp.
References unit_map::count(), unit_map::end(), unit_map::find(), resources::gameboard, i, ai::readonly_context_proxy::is_keep_ignoring_leader(), n, and game_board::units().
Referenced by choose_move().
|
protected |
Definition at line 700 of file ca_move_to_targets.cpp.
References ai::readonly_context_proxy::calculate_possible_moves(), unit_map::count(), dst, unit_map::end(), ai::readwrite_context_proxy::execute_move_action(), unit_map::find(), resources::gameboard, get_adjacent_tiles(), gamemap_base::get_terrain(), i, LOG_AI, game_board::map(), n, gamemap_base::on_board(), game_board::units(), and map_location::valid().
Referenced by choose_move().
|
protected |
Definition at line 797 of file ca_move_to_targets.cpp.
References unit::attacks(), unit::defense_modifier(), unit_map::end(), unit_map::find(), resources::gameboard, gamemap_base::get_terrain(), unit::hitpoints(), i, game_board::map(), unit::max_hitpoints(), and game_board::units().
Referenced by compare_groups().
|
protected |
rate a target, but can also return the maximal possible rating by passing a dummy route
Definition at line 194 of file ca_move_to_targets.cpp.
References enemies_along_path(), ai::readonly_context_proxy::get_scout_village_targeting(), ai::target::loc, pathfind::plain_route::move_cost, pathfind::plain_route::steps, ai::target::type, and ai::target::value.
Referenced by choose_move().
|
protected |
Definition at line 831 of file ca_move_to_targets.cpp.
References ai::readonly_context_proxy::best_defensive_position(), ai::defensive_position::chance_to_hit, resources::gameboard, and ai::readonly_context_proxy::power_projection().
Referenced by choose_move().