The Battle for Wesnoth  1.15.0-dev
Public Types | Public Member Functions | List of all members
ai::readonly_context Class Referenceabstract

#include <contexts.hpp>

Inheritance diagram for ai::readonly_context:
Inheritance graph

Public Types

using unit_stats_cache_t = std::map< std::pair< map_location, const unit_type * >, std::pair< battle_context_unit_stats, battle_context_unit_stats > >
 

Public Member Functions

 readonly_context ()
 
virtual ~readonly_context ()
 
virtual readonly_contextget_readonly_context ()=0
 
virtual void on_readonly_context_create ()=0
 
virtual const teamcurrent_team () const =0
 
virtual void diagnostic (const std::string &msg)=0
 
virtual void log_message (const std::string &msg)=0
 
virtual attack_result_ptr check_attack_action (const map_location &attacker_loc, const map_location &defender_loc, int attacker_weapon)=0
 
virtual move_result_ptr check_move_action (const map_location &from, const map_location &to, bool remove_movement=true, bool unreach_is_ok=false)=0
 
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())=0
 
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())=0
 
virtual stopunit_result_ptr check_stopunit_action (const map_location &unit_location, bool remove_movement=true, bool remove_attacks=false)=0
 
virtual synced_command_result_ptr check_synced_command_action (const std::string &lua_code, const map_location &location=map_location::null_location())=0
 
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 =0
 
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 =0
 
virtual const game_infoget_info () const =0
 
virtual const defensive_positionbest_defensive_position (const map_location &unit, const move_map &dstsrc, const move_map &srcdst, const move_map &enemy_dstsrc) const =0
 
virtual std::map< map_location, defensive_position > & defensive_position_cache () const =0
 
virtual const unit_advancements_aspectget_advancements () const =0
 
virtual double get_aggression () const =0
 
virtual int get_attack_depth () const =0
 
virtual const aspect_mapget_aspects () const =0
 
virtual aspect_mapget_aspects ()=0
 
virtual void add_facet (const std::string &id, const config &cfg) const =0
 
virtual void add_aspects (std::vector< aspect_ptr > &aspects)=0
 
virtual const attacks_vectorget_attacks () const =0
 
virtual const wfl::variantget_attacks_as_variant () const =0
 
virtual const terrain_filterget_avoid () const =0
 
virtual double get_caution () const =0
 
virtual const move_mapget_dstsrc () const =0
 
virtual const move_mapget_enemy_dstsrc () const =0
 
virtual const moves_mapget_enemy_possible_moves () const =0
 
virtual const move_mapget_enemy_srcdst () const =0
 
virtual engine_ptr get_engine_by_cfg (const config &cfg)=0
 get engine by cfg, creating it if it is not created yet but known More...
 
virtual const std::vector< engine_ptr > & get_engines () const =0
 
virtual std::vector< engine_ptr > & get_engines ()=0
 
virtual std::string get_grouping () const =0
 
virtual const std::vector< goal_ptr > & get_goals () const =0
 
virtual std::vector< goal_ptr > & get_goals ()=0
 
virtual double get_leader_aggression () const =0
 
virtual config get_leader_goal () const =0
 
virtual bool get_leader_ignores_keep () const =0
 
virtual double get_leader_value () const =0
 
virtual bool get_passive_leader () const =0
 
virtual bool get_passive_leader_shares_keep () const =0
 
virtual const moves_mapget_possible_moves () const =0
 
virtual const std::vector< unit_ptr > & get_recall_list () const =0
 
virtual double get_recruitment_diversity () const =0
 
virtual const config get_recruitment_instructions () const =0
 
virtual const std::vector< std::string > get_recruitment_more () const =0
 
virtual const std::vector< std::string > get_recruitment_pattern () const =0
 
virtual int get_recruitment_randomness () const =0
 
virtual const config get_recruitment_save_gold () const =0
 
virtual double get_scout_village_targeting () const =0
 
virtual bool get_simple_targeting () const =0
 
virtual const move_mapget_srcdst () const =0
 
virtual bool get_support_villages () const =0
 
virtual double get_village_value () const =0
 
virtual int get_villages_per_scout () const =0
 
virtual bool is_active (const std::string &time_of_day, const std::string &turns) const =0
 
virtual bool is_dst_src_valid_lua () const =0
 
virtual bool is_dst_src_enemy_valid_lua () const =0
 
virtual bool is_src_dst_valid_lua () const =0
 
virtual bool is_src_dst_enemy_valid_lua () const =0
 
virtual void invalidate_defensive_position_cache () const =0
 
virtual void invalidate_move_maps () const =0
 
virtual void invalidate_keeps_cache () const =0
 
virtual const std::set< map_location > & keeps () const =0
 
virtual bool leader_can_reach_keep () const =0
 
virtual const map_locationnearest_keep (const map_location &loc) const =0
 
virtual double power_projection (const map_location &loc, const move_map &dstsrc) const =0
 Function which finds how much 'power' a side can attack a certain location with. More...
 
virtual void raise_user_interact () const =0
 
virtual void recalculate_move_maps () const =0
 
virtual void recalculate_move_maps_enemy () const =0
 
virtual void set_src_dst_valid_lua ()=0
 
virtual void set_src_dst_enemy_valid_lua ()=0
 
virtual void set_dst_src_valid_lua ()=0
 
virtual void set_dst_src_enemy_valid_lua ()=0
 
virtual const map_locationsuitable_keep (const map_location &leader_location, const pathfind::paths &leader_paths) const =0
 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 =0
 serialize to config More...
 
virtual unit_stats_cache_tunit_stats_cache () const =0
 
- Public Member Functions inherited from ai::side_context
virtual side_number get_side () const =0
 Get the side number. More...
 
virtual void set_side (side_number side)=0
 Set the side number. More...
 
virtual ~side_context ()
 empty destructor More...
 
 side_context ()
 empty constructor More...
 
virtual side_contextget_side_context ()=0
 unwrap More...
 
virtual config to_side_context_config () const =0
 serialize this context to config More...
 
virtual int get_recursion_count () const =0
 Get the value of the recursion counter. More...
 

Detailed Description

Definition at line 173 of file contexts.hpp.

Member Typedef Documentation

◆ unit_stats_cache_t

Definition at line 388 of file contexts.hpp.

Constructor & Destructor Documentation

◆ readonly_context()

ai::readonly_context::readonly_context ( )
inline

Definition at line 176 of file contexts.hpp.

◆ ~readonly_context()

virtual ai::readonly_context::~readonly_context ( )
inlinevirtual

Member Function Documentation

◆ add_aspects()

virtual void ai::readonly_context::add_aspects ( std::vector< aspect_ptr > &  aspects)
pure virtual

◆ add_facet()

virtual void ai::readonly_context::add_facet ( const std::string &  id,
const config cfg 
) const
pure virtual

◆ best_defensive_position()

virtual const defensive_position& ai::readonly_context::best_defensive_position ( const map_location unit,
const move_map dstsrc,
const move_map srcdst,
const move_map enemy_dstsrc 
) const
pure virtual

◆ calculate_moves()

virtual void ai::readonly_context::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
pure virtual

◆ calculate_possible_moves()

virtual void ai::readonly_context::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
pure virtual

◆ check_attack_action()

virtual attack_result_ptr ai::readonly_context::check_attack_action ( const map_location attacker_loc,
const map_location defender_loc,
int  attacker_weapon 
)
pure virtual

◆ check_move_action()

virtual move_result_ptr ai::readonly_context::check_move_action ( const map_location from,
const map_location to,
bool  remove_movement = true,
bool  unreach_is_ok = false 
)
pure virtual

◆ check_recall_action()

virtual recall_result_ptr ai::readonly_context::check_recall_action ( const std::string &  id,
const map_location where = map_location::null_location(),
const map_location from = map_location::null_location() 
)
pure virtual

◆ check_recruit_action()

virtual recruit_result_ptr ai::readonly_context::check_recruit_action ( const std::string &  unit_name,
const map_location where = map_location::null_location(),
const map_location from = map_location::null_location() 
)
pure virtual

◆ check_stopunit_action()

virtual stopunit_result_ptr ai::readonly_context::check_stopunit_action ( const map_location unit_location,
bool  remove_movement = true,
bool  remove_attacks = false 
)
pure virtual

◆ check_synced_command_action()

virtual synced_command_result_ptr ai::readonly_context::check_synced_command_action ( const std::string &  lua_code,
const map_location location = map_location::null_location() 
)
pure virtual

◆ current_team()

virtual const team& ai::readonly_context::current_team ( ) const
pure virtual

◆ defensive_position_cache()

virtual std::map<map_location, defensive_position>& ai::readonly_context::defensive_position_cache ( ) const
pure virtual

◆ diagnostic()

virtual void ai::readonly_context::diagnostic ( const std::string &  msg)
pure virtual

◆ get_advancements()

virtual const unit_advancements_aspect& ai::readonly_context::get_advancements ( ) const
pure virtual

◆ get_aggression()

virtual double ai::readonly_context::get_aggression ( ) const
pure virtual

◆ get_aspects() [1/2]

virtual const aspect_map& ai::readonly_context::get_aspects ( ) const
pure virtual

◆ get_aspects() [2/2]

virtual aspect_map& ai::readonly_context::get_aspects ( )
pure virtual

◆ get_attack_depth()

virtual int ai::readonly_context::get_attack_depth ( ) const
pure virtual

◆ get_attacks()

virtual const attacks_vector& ai::readonly_context::get_attacks ( ) const
pure virtual

◆ get_attacks_as_variant()

virtual const wfl::variant& ai::readonly_context::get_attacks_as_variant ( ) const
pure virtual

◆ get_avoid()

virtual const terrain_filter& ai::readonly_context::get_avoid ( ) const
pure virtual

◆ get_caution()

virtual double ai::readonly_context::get_caution ( ) const
pure virtual

◆ get_dstsrc()

virtual const move_map& ai::readonly_context::get_dstsrc ( ) const
pure virtual

◆ get_enemy_dstsrc()

virtual const move_map& ai::readonly_context::get_enemy_dstsrc ( ) const
pure virtual

◆ get_enemy_possible_moves()

virtual const moves_map& ai::readonly_context::get_enemy_possible_moves ( ) const
pure virtual

◆ get_enemy_srcdst()

virtual const move_map& ai::readonly_context::get_enemy_srcdst ( ) const
pure virtual

◆ get_engine_by_cfg()

virtual engine_ptr ai::readonly_context::get_engine_by_cfg ( const config cfg)
pure virtual

◆ get_engines() [1/2]

virtual const std::vector<engine_ptr>& ai::readonly_context::get_engines ( ) const
pure virtual

◆ get_engines() [2/2]

virtual std::vector<engine_ptr>& ai::readonly_context::get_engines ( )
pure virtual

◆ get_goals() [1/2]

virtual const std::vector<goal_ptr>& ai::readonly_context::get_goals ( ) const
pure virtual

◆ get_goals() [2/2]

virtual std::vector<goal_ptr>& ai::readonly_context::get_goals ( )
pure virtual

◆ get_grouping()

virtual std::string ai::readonly_context::get_grouping ( ) const
pure virtual

◆ get_info()

virtual const game_info& ai::readonly_context::get_info ( ) const
pure virtual

◆ get_leader_aggression()

virtual double ai::readonly_context::get_leader_aggression ( ) const
pure virtual

◆ get_leader_goal()

virtual config ai::readonly_context::get_leader_goal ( ) const
pure virtual

◆ get_leader_ignores_keep()

virtual bool ai::readonly_context::get_leader_ignores_keep ( ) const
pure virtual

◆ get_leader_value()

virtual double ai::readonly_context::get_leader_value ( ) const
pure virtual

◆ get_passive_leader()

virtual bool ai::readonly_context::get_passive_leader ( ) const
pure virtual

◆ get_passive_leader_shares_keep()

virtual bool ai::readonly_context::get_passive_leader_shares_keep ( ) const
pure virtual

◆ get_possible_moves()

virtual const moves_map& ai::readonly_context::get_possible_moves ( ) const
pure virtual

◆ get_readonly_context()

virtual readonly_context& ai::readonly_context::get_readonly_context ( )
pure virtual

◆ get_recall_list()

virtual const std::vector<unit_ptr>& ai::readonly_context::get_recall_list ( ) const
pure virtual

◆ get_recruitment_diversity()

virtual double ai::readonly_context::get_recruitment_diversity ( ) const
pure virtual

◆ get_recruitment_instructions()

virtual const config ai::readonly_context::get_recruitment_instructions ( ) const
pure virtual

◆ get_recruitment_more()

virtual const std::vector<std::string> ai::readonly_context::get_recruitment_more ( ) const
pure virtual

◆ get_recruitment_pattern()

virtual const std::vector<std::string> ai::readonly_context::get_recruitment_pattern ( ) const
pure virtual

◆ get_recruitment_randomness()

virtual int ai::readonly_context::get_recruitment_randomness ( ) const
pure virtual

◆ get_recruitment_save_gold()

virtual const config ai::readonly_context::get_recruitment_save_gold ( ) const
pure virtual

◆ get_scout_village_targeting()

virtual double ai::readonly_context::get_scout_village_targeting ( ) const
pure virtual

◆ get_simple_targeting()

virtual bool ai::readonly_context::get_simple_targeting ( ) const
pure virtual

◆ get_srcdst()

virtual const move_map& ai::readonly_context::get_srcdst ( ) const
pure virtual

◆ get_support_villages()

virtual bool ai::readonly_context::get_support_villages ( ) const
pure virtual

◆ get_village_value()

virtual double ai::readonly_context::get_village_value ( ) const
pure virtual

◆ get_villages_per_scout()

virtual int ai::readonly_context::get_villages_per_scout ( ) const
pure virtual

◆ invalidate_defensive_position_cache()

virtual void ai::readonly_context::invalidate_defensive_position_cache ( ) const
pure virtual

◆ invalidate_keeps_cache()

virtual void ai::readonly_context::invalidate_keeps_cache ( ) const
pure virtual

◆ invalidate_move_maps()

virtual void ai::readonly_context::invalidate_move_maps ( ) const
pure virtual

◆ is_active()

virtual bool ai::readonly_context::is_active ( const std::string &  time_of_day,
const std::string &  turns 
) const
pure virtual

◆ is_dst_src_enemy_valid_lua()

virtual bool ai::readonly_context::is_dst_src_enemy_valid_lua ( ) const
pure virtual

◆ is_dst_src_valid_lua()

virtual bool ai::readonly_context::is_dst_src_valid_lua ( ) const
pure virtual

◆ is_src_dst_enemy_valid_lua()

virtual bool ai::readonly_context::is_src_dst_enemy_valid_lua ( ) const
pure virtual

◆ is_src_dst_valid_lua()

virtual bool ai::readonly_context::is_src_dst_valid_lua ( ) const
pure virtual

◆ keeps()

virtual const std::set<map_location>& ai::readonly_context::keeps ( ) const
pure virtual

◆ leader_can_reach_keep()

virtual bool ai::readonly_context::leader_can_reach_keep ( ) const
pure virtual

◆ log_message()

virtual void ai::readonly_context::log_message ( const std::string &  msg)
pure virtual

◆ nearest_keep()

virtual const map_location& ai::readonly_context::nearest_keep ( const map_location loc) const
pure virtual

◆ on_readonly_context_create()

virtual void ai::readonly_context::on_readonly_context_create ( )
pure virtual

◆ power_projection()

virtual double ai::readonly_context::power_projection ( const map_location loc,
const move_map dstsrc 
) const
pure 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)

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

Implemented in ai::readonly_context_impl, and ai::readonly_context_proxy.

Referenced by ai::default_ai_context_impl::find_targets().

◆ raise_user_interact()

virtual void ai::readonly_context::raise_user_interact ( ) const
pure virtual

◆ recalculate_move_maps()

virtual void ai::readonly_context::recalculate_move_maps ( ) const
pure virtual

◆ recalculate_move_maps_enemy()

virtual void ai::readonly_context::recalculate_move_maps_enemy ( ) const
pure virtual

◆ set_dst_src_enemy_valid_lua()

virtual void ai::readonly_context::set_dst_src_enemy_valid_lua ( )
pure virtual

◆ set_dst_src_valid_lua()

virtual void ai::readonly_context::set_dst_src_valid_lua ( )
pure virtual

◆ set_src_dst_enemy_valid_lua()

virtual void ai::readonly_context::set_src_dst_enemy_valid_lua ( )
pure virtual

◆ set_src_dst_valid_lua()

virtual void ai::readonly_context::set_src_dst_valid_lua ( )
pure virtual

◆ suitable_keep()

virtual const map_location& ai::readonly_context::suitable_keep ( const map_location leader_location,
const pathfind::paths leader_paths 
) const
pure virtual

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

Implemented in ai::readonly_context_impl, and ai::readonly_context_proxy.

Referenced by ai::cfun_ai_get_suitable_keep().

◆ to_readonly_context_config()

virtual config ai::readonly_context::to_readonly_context_config ( ) const
pure virtual

serialize to config

Implemented in ai::readonly_context_impl, and ai::readonly_context_proxy.

◆ unit_stats_cache()

virtual unit_stats_cache_t& ai::readonly_context::unit_stats_cache ( ) const
pure virtual

The documentation for this class was generated from the following file: