The Battle for Wesnoth  1.19.7+dev
Public Member Functions | Private Attributes | List of all members
ai::readwrite_context_impl Class Reference

#include <contexts.hpp>

Inheritance diagram for ai::readwrite_context_impl:

Public Member Functions

virtual readwrite_contextget_readwrite_context () override
 Unwrap - this class is not a proxy, so return *this. More...
 
virtual attack_result_ptr execute_attack_action (const map_location &attacker_loc, const map_location &defender_loc, int attacker_weapon) override
 Ask the game to attack an enemy defender using our unit attacker from attackers current location,. More...
 
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
 Ask the game to move our unit from location 'from' to location 'to', optionally - doing a partial move. More...
 
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
 Ask the game to recall a unit for us on specified location. More...
 
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
 Ask the game to recruit a unit for us on specified location. More...
 
virtual stopunit_result_ptr execute_stopunit_action (const map_location &unit_location, bool remove_movement=true, bool remove_attacks=false) override
 Ask the game to remove unit movements and/or attack. More...
 
virtual synced_command_result_ptr execute_synced_command_action (const std::string &lua_code, const map_location &location=map_location::null_location()) override
 Ask the game to run Lua code. More...
 
virtual teamcurrent_team_w () override
 Return a reference to the 'team' object for the AI. More...
 
void raise_gamestate_changed () const override
 Notifies all interested observers of the event respectively. More...
 
 readwrite_context_impl (readonly_context &context, const config &)
 Constructor. More...
 
virtual ~readwrite_context_impl ()
 
virtual game_infoget_info_w () override
 Functions to retrieve the 'info' object. More...
 
virtual int get_recursion_count () const override
 Get the value of the recursion counter. More...
 
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_contextget_readonly_context () override
 
virtual void on_readonly_context_create () override
 
virtual const teamcurrent_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_infoget_info () const override
 
virtual void raise_user_interact () const override
 
const defensive_positionbest_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_aspectget_advancements () const override
 
virtual double get_aggression () const override
 
virtual bool get_allow_ally_villages () const override
 
virtual const aspect_mapget_aspects () const override
 
virtual aspect_mapget_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_vectorget_attacks () const override
 
virtual const wfl::variantget_attacks_as_variant () const override
 
virtual const terrain_filterget_avoid () const override
 
virtual double get_caution () const override
 
virtual const move_mapget_dstsrc () const override
 
virtual const move_mapget_enemy_dstsrc () const override
 
virtual const moves_mapget_enemy_possible_moves () const override
 
virtual const move_mapget_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_mapget_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_mapget_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_locationnearest_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_locationsuitable_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_tunit_stats_cache () const override
 
- 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::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_contextget_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::readwrite_context
 readwrite_context ()
 
virtual ~readwrite_context ()
 

Private Attributes

recursion_counter recursion_counter_
 

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
 

Detailed Description

Definition at line 1331 of file contexts.hpp.

Constructor & Destructor Documentation

◆ readwrite_context_impl()

ai::readwrite_context_impl::readwrite_context_impl ( readonly_context context,
const config  
)
inline

Constructor.

Definition at line 1404 of file contexts.hpp.

References ai::readonly_context_proxy::init_readonly_context_proxy().

◆ ~readwrite_context_impl()

virtual ai::readwrite_context_impl::~readwrite_context_impl ( )
inlinevirtual

Definition at line 1410 of file contexts.hpp.

Member Function Documentation

◆ current_team_w()

team & ai::readwrite_context_impl::current_team_w ( )
overridevirtual

Return a reference to the 'team' object for the AI.

Implements ai::readwrite_context.

Definition at line 98 of file contexts.cpp.

References resources::gameboard, ai::side_context_proxy::get_side(), and game_board::get_team().

◆ execute_attack_action()

attack_result_ptr ai::readwrite_context_impl::execute_attack_action ( const map_location attacker_loc,
const map_location defender_loc,
int  attacker_weapon 
)
overridevirtual

Ask the game to attack an enemy defender using our unit attacker from attackers current location,.

Parameters
attacker_loclocation of attacker
defender_loclocation of defender
attacker_weaponweapon of attacker
Return values
possibleresults: 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::readwrite_context.

Definition at line 103 of file contexts.cpp.

References ai::actions::execute_attack_action(), unit_map::find(), resources::gameboard, ai::readonly_context_proxy::get_aggression(), ai::readonly_context_proxy::get_leader_aggression(), ai::side_context_proxy::get_side(), i, and game_board::units().

◆ execute_move_action()

move_result_ptr ai::readwrite_context_impl::execute_move_action ( const map_location from,
const map_location to,
bool  remove_movement = true,
bool  unreach_is_ok = false 
)
overridevirtual

Ask the game to move our unit from location 'from' to location 'to', optionally - doing a partial move.

Parameters
fromlocation of our unit
towhere to move
remove_movementset unit movement to 0 in case of successful move
unreach_is_okwhether it's okay for a destination to be unreachable
Return values
possibleresults: ok, something wrong, move is interrupted, or move is impossible

Implements ai::readwrite_context.

Definition at line 115 of file contexts.cpp.

References ai::actions::execute_move_action(), and ai::side_context_proxy::get_side().

◆ execute_recall_action()

recall_result_ptr ai::readwrite_context_impl::execute_recall_action ( const std::string &  id,
const map_location where = map_location::null_location(),
const map_location from = map_location::null_location() 
)
overridevirtual

Ask the game to recall a unit for us on specified location.

Parameters
idthe id of the unit to be recalled.
wherelocation where the unit is to be recalled.
fromlocation of the recaller.
Return values
possibleresults: ok, something wrong, leader not on keep, no free space on keep, or not enough gold

Implements ai::readwrite_context.

Definition at line 123 of file contexts.cpp.

References ai::actions::execute_recall_action(), and ai::side_context_proxy::get_side().

◆ execute_recruit_action()

recruit_result_ptr ai::readwrite_context_impl::execute_recruit_action ( const std::string &  unit_name,
const map_location where = map_location::null_location(),
const map_location from = map_location::null_location() 
)
overridevirtual

Ask the game to recruit a unit for us on specified location.

Parameters
unit_namethe name of the unit to be recruited.
wherelocation where the unit is to be recruited.
fromlocation of the recruiter.
Return values
possibleresults: ok, something wrong, leader not on keep, no free space on keep, or not enough gold

Implements ai::readwrite_context.

Definition at line 127 of file contexts.cpp.

References ai::actions::execute_recruit_action(), ai::side_context_proxy::get_side(), and unit_name().

◆ execute_stopunit_action()

stopunit_result_ptr ai::readwrite_context_impl::execute_stopunit_action ( const map_location unit_location,
bool  remove_movement = true,
bool  remove_attacks = false 
)
overridevirtual

Ask the game to remove unit movements and/or attack.

Parameters
unit_locationthe location of our unit
remove_movementset remaining movements to 0
remove_attacksset remaining attacks to 0
Return values
possibleresults: ok, something wrong, nothing to do

Implements ai::readwrite_context.

Definition at line 139 of file contexts.cpp.

References ai::actions::execute_stopunit_action(), and ai::side_context_proxy::get_side().

◆ execute_synced_command_action()

synced_command_result_ptr ai::readwrite_context_impl::execute_synced_command_action ( const std::string &  lua_code,
const map_location location = map_location::null_location() 
)
overridevirtual

Ask the game to run Lua code.

Parameters
lua_codethe code to be run
locationlocation to be passed to the code as x1/y1
Return values
possibleresults: ok, something wrong, nothing to do

Implements ai::readwrite_context.

Definition at line 147 of file contexts.cpp.

References ai::actions::execute_synced_command_action(), and ai::side_context_proxy::get_side().

◆ get_info_w()

game_info & ai::readwrite_context_impl::get_info_w ( )
overridevirtual

Functions to retrieve the 'info' object.

Used by derived classes to discover all necessary game information.

Implements ai::readwrite_context.

Definition at line 299 of file contexts.cpp.

References ai::manager::get_active_ai_info_for_side(), ai::side_context_proxy::get_side(), and ai::manager::get_singleton().

◆ get_readwrite_context()

virtual readwrite_context& ai::readwrite_context_impl::get_readwrite_context ( )
inlineoverridevirtual

Unwrap - this class is not a proxy, so return *this.

Implements ai::readwrite_context.

Definition at line 1336 of file contexts.hpp.

◆ get_recursion_count()

int ai::readwrite_context_impl::get_recursion_count ( ) const
overridevirtual

Get the value of the recursion counter.

Reimplemented from ai::readonly_context_proxy.

Definition at line 83 of file contexts.cpp.

References ai::recursion_counter::get_count(), and recursion_counter_.

◆ raise_gamestate_changed()

void ai::readwrite_context_impl::raise_gamestate_changed ( ) const
overridevirtual

Notifies all interested observers of the event respectively.

Implements ai::readwrite_context.

Definition at line 93 of file contexts.cpp.

References ai::manager::get_singleton(), and ai::manager::raise_gamestate_changed().

◆ to_readwrite_context_config()

config ai::readwrite_context_impl::to_readwrite_context_config ( ) const
overridevirtual

serialize this context to config

Implements ai::readwrite_context.

Definition at line 265 of file contexts.cpp.

Member Data Documentation

◆ recursion_counter_

recursion_counter ai::readwrite_context_impl::recursion_counter_
private

Definition at line 1425 of file contexts.hpp.

Referenced by get_recursion_count().


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