The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ai::readonly_context_impl Class Reference

#include <contexts.hpp>

Inheritance diagram for ai::readonly_context_impl:
Inheritance graph

Public Member Functions

 readonly_context_impl (side_context &context, const config &cfg)
 Constructor. More...
 
virtual ~readonly_context_impl ()
 Destructor. More...
 
virtual readonly_contextget_readonly_context () override
 
   Unwrap - this class is not a proxy, so return *this

:w More...

 
virtual void on_readonly_context_create () override
 
virtual void handle_generic_event (const std::string &event_name) override
 Handle generic event. More...
 
const teamcurrent_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_infoget_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...
 
defensive_position const & 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 int get_attack_depth () const override
 
virtual const aspect_mapget_aspects () const override
 
virtual aspect_mapget_aspects () 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 bool get_leader_ignores_keep () const override
 
virtual double get_leader_value () const override
 
virtual bool get_passive_leader () const override
 
virtual bool get_passive_leader_shares_keep () const override
 
virtual const moves_mapget_possible_moves () const override
 
virtual const std::vector
< unit_ptr > & 
get_recall_list () 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_scout_village_targeting () const override
 
virtual bool get_simple_targeting () const override
 
virtual const move_mapget_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_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 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_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
 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_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::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, std::shared_ptr< typesafe_aspect< T > > &where)
 

Private Attributes

const config cfg_
 
std::vector< engine_ptrengines_
 AI Support Engines. More...
 
known_aspect_map known_aspects_
 
aspect_type
< unit_advancements_aspect >
::typesafe_ptr 
advancements_
 
aspect_type< double >::typesafe_ptr aggression_
 
aspect_type< int >::typesafe_ptr attack_depth_
 
aspect_map aspects_
 
aspect_type< attacks_vector >
::typesafe_ptr 
attacks_
 
aspect_type< terrain_filter >
::typesafe_ptr 
avoid_
 
aspect_type< double >::typesafe_ptr caution_
 
std::map< map_location,
defensive_position
defensive_position_cache_
 
move_map dstsrc_
 
move_map enemy_dstsrc_
 
moves_map enemy_possible_moves_
 
move_map enemy_srcdst_
 
aspect_type< std::string >
::typesafe_ptr 
grouping_
 
std::vector< goal_ptrgoals_
 
keeps_cache keeps_
 
aspect_type< double >::typesafe_ptr leader_aggression_
 
aspect_type< config >::typesafe_ptr leader_goal_
 
aspect_type< bool >::typesafe_ptr leader_ignores_keep_
 
aspect_type< double >::typesafe_ptr leader_value_
 
bool move_maps_enemy_valid_
 
bool move_maps_valid_
 
bool dst_src_valid_lua_
 
bool dst_src_enemy_valid_lua_
 
bool src_dst_valid_lua_
 
bool src_dst_enemy_valid_lua_
 
aspect_type< bool >::typesafe_ptr passive_leader_
 
aspect_type< bool >::typesafe_ptr passive_leader_shares_keep_
 
moves_map possible_moves_
 
aspect_type< double >::typesafe_ptr recruitment_diversity_
 
aspect_type< config >::typesafe_ptr recruitment_instructions_
 
aspect_type< std::vector
< std::string >
>::typesafe_ptr 
recruitment_more_
 
aspect_type< std::vector
< std::string >
>::typesafe_ptr 
recruitment_pattern_
 
aspect_type< int >::typesafe_ptr recruitment_randomness_
 
aspect_type< config >::typesafe_ptr recruitment_save_gold_
 
recursion_counter recursion_counter_
 
aspect_type< double >::typesafe_ptr scout_village_targeting_
 
aspect_type< bool >::typesafe_ptr simple_targeting_
 
move_map srcdst_
 
aspect_type< bool >::typesafe_ptr support_villages_
 
unit_stats_cache_t unit_stats_cache_
 
aspect_type< double >::typesafe_ptr village_value_
 
aspect_type< int >::typesafe_ptr villages_per_scout_
 

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 1132 of file contexts.hpp.

Constructor & Destructor Documentation

ai::readonly_context_impl::readonly_context_impl ( side_context context,
const config cfg 
)
ai::readonly_context_impl::~readonly_context_impl ( )
virtual

Destructor.

Definition at line 306 of file contexts.cpp.

References ai::manager::remove_gamestate_observer().

Member Function Documentation

void ai::readonly_context_impl::add_aspects ( std::vector< aspect_ptr > &  aspects)
overridevirtual

Implements ai::readonly_context.

Definition at line 451 of file contexts.cpp.

References a, ERR_AI, i, and known_aspects_.

Referenced by on_readonly_context_create().

void ai::readonly_context_impl::add_facet ( const std::string &  id,
const config cfg 
) const
overridevirtual

Implements ai::readonly_context.

Definition at line 464 of file contexts.cpp.

References ERR_AI, i, and known_aspects_.

template<typename T >
void ai::readonly_context_impl::add_known_aspect ( const std::string &  name,
std::shared_ptr< typesafe_aspect< T > > &  where 
)
private

Definition at line 177 of file contexts.cpp.

References aspects_, and known_aspects_.

Referenced by readonly_context_impl().

const defensive_position & ai::readonly_context_impl::best_defensive_position ( const map_location unit,
const move_map dstsrc,
const move_map srcdst,
const move_map enemy_dstsrc 
) const
overridevirtual
void ai::readonly_context_impl::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
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 356 of file contexts.cpp.

References unit_map::begin(), pathfind::paths::step::curr, current_team(), unit_map::end(), resources::gameboard, ai::side_context_proxy::get_side(), team::is_enemy(), terrain_filter::match(), n, game_board::teams(), terrain_filter::to_config(), and resources::units.

Referenced by calculate_possible_moves().

void ai::readonly_context_impl::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
overridevirtual

Calculate the moves units may possibly make.

Parameters
possible_movesA 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'.
srcdstA map of units to all their possible destinations.
dstsrcA map of destinations to all the units that can move to that destination.
enemyif 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_movementIf true, the function will operate on the assumption that all units can move their full movement allotment.
remove_destinationsa pointer to a terrain filter for possible destinations to omit.

Implements ai::readonly_context.

Definition at line 349 of file contexts.cpp.

References calculate_moves(), resources::gameboard, and resources::units.

Referenced by recalculate_move_maps(), and recalculate_move_maps_enemy().

attack_result_ptr ai::readonly_context_impl::check_attack_action ( const map_location attacker_loc,
const map_location defender_loc,
int  attacker_weapon 
)
overridevirtual

Check if it is possible to attack 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
possibleresult: ok
possibleresult: something wrong
possibleresult: attacker and/or defender are invalid
possibleresult: attacker and/or defender are invalid
possibleresult: attacker doesn't have the specified weapon

Implements ai::readonly_context.

Definition at line 118 of file contexts.cpp.

References ai::actions::execute_attack_action(), unit_map::find(), resources::gameboard, get_advancements(), get_aggression(), get_leader_aggression(), ai::side_context_proxy::get_side(), i, game_board::units(), and unit_map::iterator_base< iter_types >::valid().

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

Check if it is possible to move our unit from location 'from' to location 'to'.

Parameters
fromlocation of our unit
towhere to move
remove_movementset unit movement to 0 in case of successful move
Return values
possibleresult: ok
possibleresult: something wrong
possibleresult: move is interrupted
possibleresult: move is impossible

Implements ai::readonly_context.

Definition at line 131 of file contexts.cpp.

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

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

Check if it is possible to recall a unit for us on specified location.

Parameters
idthe id of the unit to be recruited.
wherelocation where the unit is to be recruited.
Return values
possibleresult: ok
possible_resultsomething wrong
possible_resultleader not on keep
possible_resultno free space on keep
possible_resultnot enough gold

Implements ai::readonly_context.

Definition at line 146 of file contexts.cpp.

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

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

Check if it is possible 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.
Return values
possibleresult: ok
possible_resultsomething wrong
possible_resultleader not on keep
possible_resultno free space on keep
possible_resultnot enough gold

Implements ai::readonly_context.

Definition at line 151 of file contexts.cpp.

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

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

Check if it is possible 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
possibleresult: ok
possible_resultsomething wrong
possible_resultnothing to do

Implements ai::readonly_context.

Definition at line 161 of file contexts.cpp.

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

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

Check if it is possible to run Lua code.

Parameters
lua_codethe code to be run
locationlocation to be passed to the code as x1/y1
Return values
possibleresult: ok
possible_resultsomething wrong
possible_resultnothing to do

Implements ai::readonly_context.

Definition at line 171 of file contexts.cpp.

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

const team & ai::readonly_context_impl::current_team ( ) const
overridevirtual

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

Implements ai::readonly_context.

Definition at line 334 of file contexts.cpp.

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

Referenced by calculate_moves(), get_recall_list(), and leader_can_reach_keep().

std::map< map_location, defensive_position > & ai::readonly_context_impl::defensive_position_cache ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 521 of file contexts.cpp.

References defensive_position_cache_.

void ai::readonly_context_impl::diagnostic ( const std::string &  msg)
overridevirtual

Show a diagnostic message on the screen.

Implements ai::readonly_context.

Definition at line 326 of file contexts.cpp.

References game_config::debug, resources::screen, and display::set_diagnostic().

const unit_advancements_aspect & ai::readonly_context_impl::get_advancements ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 527 of file contexts.cpp.

References advancements_.

Referenced by check_attack_action().

double ai::readonly_context_impl::get_aggression ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 538 of file contexts.cpp.

References aggression_.

Referenced by check_attack_action().

const aspect_map & ai::readonly_context_impl::get_aspects ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 556 of file contexts.cpp.

References aspects_.

aspect_map & ai::readonly_context_impl::get_aspects ( )
overridevirtual

Implements ai::readonly_context.

Definition at line 562 of file contexts.cpp.

References aspects_.

int ai::readonly_context_impl::get_attack_depth ( ) const
overridevirtual
Todo:
1.9: add validators, such as minmax filters to aspects

Implements ai::readonly_context.

Definition at line 547 of file contexts.cpp.

References attack_depth_.

const attacks_vector & ai::readonly_context_impl::get_attacks ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 568 of file contexts.cpp.

References attacks_.

const wfl::variant & ai::readonly_context_impl::get_attacks_as_variant ( ) const
overridevirtual
Todo:
1.9: replace with variant::null_variant;

Implements ai::readonly_context.

Definition at line 578 of file contexts.cpp.

References attacks_.

const terrain_filter & ai::readonly_context_impl::get_avoid ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 587 of file contexts.cpp.

References config::add_child(), avoid_, and resources::filter_con.

Referenced by nearest_keep(), and recalculate_move_maps().

double ai::readonly_context_impl::get_caution ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 599 of file contexts.cpp.

References caution_.

const move_map & ai::readonly_context_impl::get_dstsrc ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 607 of file contexts.cpp.

References dstsrc_, move_maps_valid_, and recalculate_move_maps().

const move_map & ai::readonly_context_impl::get_enemy_dstsrc ( ) const
overridevirtual
const moves_map & ai::readonly_context_impl::get_enemy_possible_moves ( ) const
overridevirtual
const move_map & ai::readonly_context_impl::get_enemy_srcdst ( ) const
overridevirtual
engine_ptr ai::readonly_context_impl::get_engine_by_cfg ( const config cfg)
overridevirtual

get engine by cfg, creating it if it is not created yet but known

Implements ai::readonly_context.

Definition at line 643 of file contexts.cpp.

References DBG_AI, engines_, ERR_AI, ai::engine_factory::get_list(), and ai::side_context_proxy::get_side().

const std::vector< engine_ptr > & ai::readonly_context_impl::get_engines ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 680 of file contexts.cpp.

References engines_.

std::vector< engine_ptr > & ai::readonly_context_impl::get_engines ( )
overridevirtual

Implements ai::readonly_context.

Definition at line 686 of file contexts.cpp.

References engines_.

const std::vector< goal_ptr > & ai::readonly_context_impl::get_goals ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 701 of file contexts.cpp.

References goals_.

Referenced by on_readonly_context_create().

std::vector< goal_ptr > & ai::readonly_context_impl::get_goals ( )
overridevirtual

Implements ai::readonly_context.

Definition at line 707 of file contexts.cpp.

References goals_.

std::string ai::readonly_context_impl::get_grouping ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 692 of file contexts.cpp.

References grouping_.

const game_info & ai::readonly_context_impl::get_info ( ) const
overridevirtual
double ai::readonly_context_impl::get_leader_aggression ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 714 of file contexts.cpp.

References leader_aggression_.

Referenced by check_attack_action().

config ai::readonly_context_impl::get_leader_goal ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 723 of file contexts.cpp.

References leader_goal_.

bool ai::readonly_context_impl::get_leader_ignores_keep ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 732 of file contexts.cpp.

References leader_ignores_keep_.

double ai::readonly_context_impl::get_leader_value ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 741 of file contexts.cpp.

References leader_value_.

bool ai::readonly_context_impl::get_passive_leader ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 750 of file contexts.cpp.

References passive_leader_.

Referenced by recalculate_move_maps().

bool ai::readonly_context_impl::get_passive_leader_shares_keep ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 759 of file contexts.cpp.

References passive_leader_shares_keep_.

Referenced by recalculate_move_maps().

const moves_map & ai::readonly_context_impl::get_possible_moves ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 768 of file contexts.cpp.

References move_maps_valid_, possible_moves_, and recalculate_move_maps().

virtual readonly_context& ai::readonly_context_impl::get_readonly_context ( )
inlineoverridevirtual

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

:w

Implements ai::readonly_context.

Definition at line 1151 of file contexts.hpp.

const std::vector< unit_ptr > & ai::readonly_context_impl::get_recall_list ( ) const
overridevirtual
Todo:
1.9: check for (level_["disallow_recall"]))

Implements ai::readonly_context.

Definition at line 777 of file contexts.cpp.

References current_team(), team::recall_list(), and recall_list_manager::recall_list_.

double ai::readonly_context_impl::get_recruitment_diversity ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 784 of file contexts.cpp.

References recruitment_diversity_.

const config ai::readonly_context_impl::get_recruitment_instructions ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 793 of file contexts.cpp.

References recruitment_instructions_.

const std::vector< std::string > ai::readonly_context_impl::get_recruitment_more ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 802 of file contexts.cpp.

References recruitment_more_.

const std::vector< std::string > ai::readonly_context_impl::get_recruitment_pattern ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 811 of file contexts.cpp.

References recruitment_pattern_.

int ai::readonly_context_impl::get_recruitment_randomness ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 820 of file contexts.cpp.

References recruitment_randomness_.

const config ai::readonly_context_impl::get_recruitment_save_gold ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 829 of file contexts.cpp.

References recruitment_save_gold_.

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

Get the value of the recursion counter.

Reimplemented from ai::side_context_proxy.

Definition at line 81 of file contexts.cpp.

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

double ai::readonly_context_impl::get_scout_village_targeting ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 838 of file contexts.cpp.

References scout_village_targeting_.

bool ai::readonly_context_impl::get_simple_targeting ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 847 of file contexts.cpp.

References simple_targeting_.

const move_map & ai::readonly_context_impl::get_srcdst ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 856 of file contexts.cpp.

References move_maps_valid_, recalculate_move_maps(), and srcdst_.

bool ai::readonly_context_impl::get_support_villages ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 865 of file contexts.cpp.

References support_villages_.

double ai::readonly_context_impl::get_village_value ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 874 of file contexts.cpp.

References village_value_.

int ai::readonly_context_impl::get_villages_per_scout ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 883 of file contexts.cpp.

References villages_per_scout_.

void ai::readonly_context_impl::handle_generic_event ( const std::string &  event_name)
overridevirtual

Handle generic event.

Implements events::observer.

Definition at line 311 of file contexts.cpp.

References invalidate_move_maps().

void ai::readonly_context_impl::invalidate_defensive_position_cache ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 912 of file contexts.cpp.

References defensive_position_cache_.

void ai::readonly_context_impl::invalidate_keeps_cache ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 918 of file contexts.cpp.

References ai::keeps_cache::clear(), and keeps_.

void ai::readonly_context_impl::invalidate_move_maps ( ) const
overridevirtual
bool ai::readonly_context_impl::is_active ( const std::string &  time_of_day,
const std::string &  turns 
) const
overridevirtual
bool ai::readonly_context_impl::is_dst_src_enemy_valid_lua ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 897 of file contexts.cpp.

References dst_src_enemy_valid_lua_.

bool ai::readonly_context_impl::is_dst_src_valid_lua ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 892 of file contexts.cpp.

References dst_src_valid_lua_.

bool ai::readonly_context_impl::is_src_dst_enemy_valid_lua ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 907 of file contexts.cpp.

References src_dst_enemy_valid_lua_.

bool ai::readonly_context_impl::is_src_dst_valid_lua ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 902 of file contexts.cpp.

References src_dst_valid_lua_.

const std::set< map_location > & ai::readonly_context_impl::keeps ( ) const
overridevirtual

Implements ai::readonly_context.

Definition at line 943 of file contexts.cpp.

References ai::keeps_cache::get(), and keeps_.

Referenced by nearest_keep(), and suitable_keep().

bool ai::readonly_context_impl::leader_can_reach_keep ( ) const
overridevirtual
void ai::readonly_context_impl::log_message ( const std::string &  msg)
overridevirtual
const map_location & ai::readonly_context_impl::nearest_keep ( const map_location loc) const
overridevirtual
void ai::readonly_context_impl::on_create ( )
void ai::readonly_context_impl::on_readonly_context_create ( )
overridevirtual
double ai::readonly_context_impl::power_projection ( const map_location loc,
const move_map dstsrc 
) const
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 1054 of file contexts.cpp.

References unit::alignment(), unit::attacks(), defense, unit::defense_modifier(), unit_map::end(), gui2::event::find(), 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::on_board(), unit::side(), gui2::terrain, resources::tod_manager, tod_manager::turn(), game_board::units(), map_location::valid(), and WRN_AI.

Referenced by best_defensive_position().

void ai::readonly_context_impl::raise_user_interact ( ) const
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 93 of file contexts.cpp.

References ai::manager::raise_user_interact().

void ai::readonly_context_impl::recalculate_move_maps ( ) const
overridevirtual
void ai::readonly_context_impl::recalculate_move_maps_enemy ( ) const
overridevirtual
void ai::readonly_context_impl::set_dst_src_enemy_valid_lua ( )
overridevirtual

Implements ai::readonly_context.

Definition at line 1217 of file contexts.cpp.

References dst_src_enemy_valid_lua_.

void ai::readonly_context_impl::set_dst_src_valid_lua ( )
overridevirtual

Implements ai::readonly_context.

Definition at line 1212 of file contexts.cpp.

References dst_src_valid_lua_.

void ai::readonly_context_impl::set_src_dst_enemy_valid_lua ( )
overridevirtual

Implements ai::readonly_context.

Definition at line 1227 of file contexts.cpp.

References src_dst_enemy_valid_lua_.

void ai::readonly_context_impl::set_src_dst_valid_lua ( )
overridevirtual

Implements ai::readonly_context.

Definition at line 1222 of file contexts.cpp.

References src_dst_valid_lua_.

const map_location & ai::readonly_context_impl::suitable_keep ( const map_location leader_location,
const pathfind::paths leader_paths 
) const
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 1232 of file contexts.cpp.

References preferences::editor::TransitionUpdateMode::count, pathfind::paths::step::curr, pathfind::paths::destinations, gui2::event::find(), resources::gameboard, keeps(), pathfind::paths::step::move_left, nearest_keep(), map_location::null_location(), and resources::units.

config ai::readonly_context_impl::to_readonly_context_config ( ) const
overridevirtual

serialize to config

Implements ai::readonly_context.

Definition at line 291 of file contexts.cpp.

References a, config::add_child(), aspects_, e, engines_, g, and goals_.

readonly_context::unit_stats_cache_t & ai::readonly_context_impl::unit_stats_cache ( ) const
overridevirtual

Weapon choice cache, to speed simulations.

Implements ai::readonly_context.

Definition at line 1276 of file contexts.cpp.

References unit_stats_cache_.

Member Data Documentation

aspect_type< unit_advancements_aspect >::typesafe_ptr ai::readonly_context_impl::advancements_
private

Definition at line 1509 of file contexts.hpp.

Referenced by get_advancements(), and readonly_context_impl().

aspect_type<double>::typesafe_ptr ai::readonly_context_impl::aggression_
private

Definition at line 1510 of file contexts.hpp.

Referenced by get_aggression(), and readonly_context_impl().

aspect_map ai::readonly_context_impl::aspects_
private

Definition at line 1512 of file contexts.hpp.

Referenced by add_known_aspect(), get_aspects(), and to_readonly_context_config().

aspect_type<int>::typesafe_ptr ai::readonly_context_impl::attack_depth_
private

Definition at line 1511 of file contexts.hpp.

Referenced by get_attack_depth(), and readonly_context_impl().

aspect_type< attacks_vector >::typesafe_ptr ai::readonly_context_impl::attacks_
private

Definition at line 1513 of file contexts.hpp.

Referenced by get_attacks(), get_attacks_as_variant(), and readonly_context_impl().

aspect_type<terrain_filter>::typesafe_ptr ai::readonly_context_impl::avoid_
mutableprivate

Definition at line 1514 of file contexts.hpp.

Referenced by get_avoid(), and readonly_context_impl().

aspect_type<double>::typesafe_ptr ai::readonly_context_impl::caution_
private

Definition at line 1515 of file contexts.hpp.

Referenced by get_caution(), and readonly_context_impl().

const config ai::readonly_context_impl::cfg_
private

Definition at line 1500 of file contexts.hpp.

Referenced by on_readonly_context_create().

std::map<map_location,defensive_position> ai::readonly_context_impl::defensive_position_cache_
mutableprivate
bool ai::readonly_context_impl::dst_src_enemy_valid_lua_
mutableprivate
bool ai::readonly_context_impl::dst_src_valid_lua_
mutableprivate
move_map ai::readonly_context_impl::dstsrc_
mutableprivate

Definition at line 1517 of file contexts.hpp.

Referenced by get_dstsrc(), and recalculate_move_maps().

move_map ai::readonly_context_impl::enemy_dstsrc_
mutableprivate

Definition at line 1518 of file contexts.hpp.

Referenced by get_enemy_dstsrc(), and recalculate_move_maps_enemy().

moves_map ai::readonly_context_impl::enemy_possible_moves_
mutableprivate

Definition at line 1519 of file contexts.hpp.

Referenced by get_enemy_possible_moves(), and recalculate_move_maps_enemy().

move_map ai::readonly_context_impl::enemy_srcdst_
mutableprivate

Definition at line 1520 of file contexts.hpp.

Referenced by get_enemy_srcdst(), and recalculate_move_maps_enemy().

std::vector< engine_ptr > ai::readonly_context_impl::engines_
private

AI Support Engines.

Definition at line 1505 of file contexts.hpp.

Referenced by get_engine_by_cfg(), get_engines(), on_readonly_context_create(), and to_readonly_context_config().

std::vector< goal_ptr > ai::readonly_context_impl::goals_
private

Definition at line 1522 of file contexts.hpp.

Referenced by get_goals(), and to_readonly_context_config().

aspect_type< std::string >::typesafe_ptr ai::readonly_context_impl::grouping_
private

Definition at line 1521 of file contexts.hpp.

Referenced by get_grouping(), and readonly_context_impl().

keeps_cache ai::readonly_context_impl::keeps_
mutableprivate

Definition at line 1523 of file contexts.hpp.

Referenced by invalidate_keeps_cache(), keeps(), and readonly_context_impl().

known_aspect_map ai::readonly_context_impl::known_aspects_
private

Definition at line 1507 of file contexts.hpp.

Referenced by add_aspects(), add_facet(), and add_known_aspect().

aspect_type<double>::typesafe_ptr ai::readonly_context_impl::leader_aggression_
private

Definition at line 1524 of file contexts.hpp.

Referenced by get_leader_aggression(), and readonly_context_impl().

aspect_type< config >::typesafe_ptr ai::readonly_context_impl::leader_goal_
private

Definition at line 1525 of file contexts.hpp.

Referenced by get_leader_goal(), and readonly_context_impl().

aspect_type<bool>::typesafe_ptr ai::readonly_context_impl::leader_ignores_keep_
private

Definition at line 1526 of file contexts.hpp.

Referenced by get_leader_ignores_keep(), and readonly_context_impl().

aspect_type< double >::typesafe_ptr ai::readonly_context_impl::leader_value_
private

Definition at line 1527 of file contexts.hpp.

Referenced by get_leader_value(), and readonly_context_impl().

bool ai::readonly_context_impl::move_maps_enemy_valid_
mutableprivate
bool ai::readonly_context_impl::move_maps_valid_
mutableprivate
aspect_type<bool>::typesafe_ptr ai::readonly_context_impl::passive_leader_
private

Definition at line 1534 of file contexts.hpp.

Referenced by get_passive_leader(), and readonly_context_impl().

aspect_type<bool>::typesafe_ptr ai::readonly_context_impl::passive_leader_shares_keep_
private

Definition at line 1535 of file contexts.hpp.

Referenced by get_passive_leader_shares_keep(), and readonly_context_impl().

moves_map ai::readonly_context_impl::possible_moves_
mutableprivate

Definition at line 1536 of file contexts.hpp.

Referenced by get_possible_moves(), and recalculate_move_maps().

aspect_type< double >::typesafe_ptr ai::readonly_context_impl::recruitment_diversity_
private

Definition at line 1537 of file contexts.hpp.

Referenced by get_recruitment_diversity(), and readonly_context_impl().

aspect_type< config >::typesafe_ptr ai::readonly_context_impl::recruitment_instructions_
private

Definition at line 1538 of file contexts.hpp.

Referenced by get_recruitment_instructions(), and readonly_context_impl().

aspect_type< std::vector<std::string> >::typesafe_ptr ai::readonly_context_impl::recruitment_more_
private

Definition at line 1539 of file contexts.hpp.

Referenced by get_recruitment_more(), and readonly_context_impl().

aspect_type< std::vector<std::string> >::typesafe_ptr ai::readonly_context_impl::recruitment_pattern_
private

Definition at line 1540 of file contexts.hpp.

Referenced by get_recruitment_pattern(), and readonly_context_impl().

aspect_type< int >::typesafe_ptr ai::readonly_context_impl::recruitment_randomness_
private

Definition at line 1541 of file contexts.hpp.

Referenced by get_recruitment_randomness(), and readonly_context_impl().

aspect_type< config >::typesafe_ptr ai::readonly_context_impl::recruitment_save_gold_
private

Definition at line 1542 of file contexts.hpp.

Referenced by get_recruitment_save_gold(), and readonly_context_impl().

recursion_counter ai::readonly_context_impl::recursion_counter_
private

Definition at line 1543 of file contexts.hpp.

Referenced by get_recursion_count().

aspect_type< double >::typesafe_ptr ai::readonly_context_impl::scout_village_targeting_
private

Definition at line 1544 of file contexts.hpp.

Referenced by get_scout_village_targeting(), and readonly_context_impl().

aspect_type< bool >::typesafe_ptr ai::readonly_context_impl::simple_targeting_
private

Definition at line 1545 of file contexts.hpp.

Referenced by get_simple_targeting(), and readonly_context_impl().

bool ai::readonly_context_impl::src_dst_enemy_valid_lua_
mutableprivate
bool ai::readonly_context_impl::src_dst_valid_lua_
mutableprivate
move_map ai::readonly_context_impl::srcdst_
mutableprivate

Definition at line 1546 of file contexts.hpp.

Referenced by get_srcdst(), and recalculate_move_maps().

aspect_type< bool >::typesafe_ptr ai::readonly_context_impl::support_villages_
private

Definition at line 1547 of file contexts.hpp.

Referenced by get_support_villages(), and readonly_context_impl().

unit_stats_cache_t ai::readonly_context_impl::unit_stats_cache_
mutableprivate

Definition at line 1548 of file contexts.hpp.

Referenced by unit_stats_cache().

aspect_type< double >::typesafe_ptr ai::readonly_context_impl::village_value_
private

Definition at line 1549 of file contexts.hpp.

Referenced by get_village_value(), and readonly_context_impl().

aspect_type< int >::typesafe_ptr ai::readonly_context_impl::villages_per_scout_
private

Definition at line 1550 of file contexts.hpp.

Referenced by get_villages_per_scout(), and readonly_context_impl().


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