The Battle for Wesnoth  1.13.4+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 ()
 
   Unwrap - this class is not a proxy, so return *this

:w More...

 
virtual void on_readonly_context_create ()
 
virtual void handle_generic_event (const std::string &event_name)
 Handle generic event. More...
 
const teamcurrent_team () const
 Return a reference to the 'team' object for the AI. More...
 
void diagnostic (const std::string &msg)
 Show a diagnostic message on the screen. More...
 
void log_message (const std::string &msg)
 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)
 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)
 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())
 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())
 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)
 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())
 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
 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
 A more fundamental version of calculate_possible_moves which allows the use of a speculative unit map. More...
 
virtual const game_infoget_info () const
 
void raise_user_interact () const
 Function which should be called frequently to allow the user to interact with the interface. More...
 
virtual int get_recursion_count () const
 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
 
virtual std::map< map_location,
defensive_position > & 
defensive_position_cache () const
 
virtual const
unit_advancements_aspect
get_advancements () const
 
virtual double get_aggression () const
 
virtual int get_attack_depth () const
 
virtual const aspect_mapget_aspects () const
 
virtual aspect_mapget_aspects ()
 
virtual const attacks_vectorget_attacks () const
 
virtual const variantget_attacks_as_variant () const
 
virtual const terrain_filterget_avoid () const
 
virtual double get_caution () const
 
virtual const move_mapget_dstsrc () const
 
virtual const move_mapget_enemy_dstsrc () const
 
virtual const moves_mapget_enemy_possible_moves () const
 
virtual const move_mapget_enemy_srcdst () const
 
virtual engine_ptr get_engine_by_cfg (const config &cfg)
 get engine by cfg, creating it if it is not created yet but known More...
 
virtual const std::vector
< engine_ptr > & 
get_engines () const
 
virtual std::vector< engine_ptr > & get_engines ()
 
virtual std::string get_grouping () const
 
virtual const std::vector
< goal_ptr > & 
get_goals () const
 
virtual std::vector< goal_ptr > & get_goals ()
 
virtual double get_leader_aggression () const
 
virtual config get_leader_goal () const
 
virtual bool get_leader_ignores_keep () const
 
virtual double get_leader_value () const
 
virtual bool get_passive_leader () const
 
virtual bool get_passive_leader_shares_keep () const
 
virtual const moves_mapget_possible_moves () const
 
virtual const std::vector
< unit_ptr > & 
get_recall_list () const
 
virtual double get_recruitment_diversity () const
 
virtual const config get_recruitment_instructions () const
 
virtual const std::vector
< std::string
get_recruitment_more () const
 
virtual const std::vector
< std::string
get_recruitment_pattern () const
 
virtual int get_recruitment_randomness () const
 
virtual const config get_recruitment_save_gold () const
 
virtual double get_scout_village_targeting () const
 
virtual bool get_simple_targeting () const
 
virtual const move_mapget_srcdst () const
 
virtual bool get_support_villages () const
 
virtual double get_village_value () const
 
virtual int get_villages_per_scout () const
 
virtual bool is_active (const std::string &time_of_day, const std::string &turns) const
 
virtual bool is_dst_src_valid_lua () const
 
virtual bool is_dst_src_enemy_valid_lua () const
 
virtual bool is_src_dst_valid_lua () const
 
virtual bool is_src_dst_enemy_valid_lua () const
 
virtual void invalidate_defensive_position_cache () const
 
virtual void invalidate_move_maps () const
 
virtual void invalidate_keeps_cache () const
 
virtual const std::set
< map_location > & 
keeps () const
 
virtual bool leader_can_reach_keep () const
 
virtual const map_locationnearest_keep (const map_location &loc) const
 
virtual double power_projection (const map_location &loc, const move_map &dstsrc) const
 Function which finds how much 'power' a side can attack a certain location with. More...
 
virtual void recalculate_move_maps () const
 
virtual void recalculate_move_maps_enemy () const
 
virtual void add_aspects (std::vector< aspect_ptr > &aspects)
 
virtual void add_facet (const std::string &id, const config &cfg) const
 
void on_create ()
 
virtual void set_dst_src_valid_lua ()
 
virtual void set_dst_src_enemy_valid_lua ()
 
virtual void set_src_dst_valid_lua ()
 
virtual void set_src_dst_enemy_valid_lua ()
 
virtual const map_locationsuitable_keep (const map_location &leader_location, const pathfind::paths &leader_paths)
 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
 serialize to config More...
 
virtual unit_stats_cache_tunit_stats_cache () const
 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
 Get the side number. More...
 
virtual void set_side (side_number side)
 Set the side number. More...
 
virtual side_contextget_side_context ()
 unwrap More...
 
virtual config to_side_context_config () const
 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, boost::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 1135 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 311 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)
virtual

Implements ai::readonly_context.

Definition at line 459 of file contexts.cpp.

References 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
virtual

Implements ai::readonly_context.

Definition at line 472 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,
boost::shared_ptr< typesafe_aspect< T > > &  where 
)
private

Definition at line 182 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
virtual
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
virtual

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::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::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 361 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(), resources::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
virtual

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 354 of file contexts.cpp.

References calculate_moves(), 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 
)
virtual

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 123 of file contexts.cpp.

References ai::actions::execute_attack_action(), unit_map::find(), get_advancements(), get_aggression(), get_leader_aggression(), ai::side_context_proxy::get_side(), i, resources::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 
)
virtual

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 136 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() 
)
virtual

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 151 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() 
)
virtual

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 156 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 
)
virtual

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 166 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() 
)
virtual

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 176 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
virtual

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

Implements ai::readonly_context.

Definition at line 339 of file contexts.cpp.

References ai::side_context_proxy::get_side(), and resources::teams.

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
virtual

Implements ai::readonly_context.

Definition at line 529 of file contexts.cpp.

References defensive_position_cache_.

void ai::readonly_context_impl::diagnostic ( const std::string msg)
virtual

Show a diagnostic message on the screen.

Implements ai::readonly_context.

Definition at line 331 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
virtual

Implements ai::readonly_context.

Definition at line 535 of file contexts.cpp.

References advancements_.

Referenced by check_attack_action().

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

Implements ai::readonly_context.

Definition at line 546 of file contexts.cpp.

References aggression_.

Referenced by check_attack_action().

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

Implements ai::readonly_context.

Definition at line 564 of file contexts.cpp.

References aspects_.

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

Implements ai::readonly_context.

Definition at line 570 of file contexts.cpp.

References aspects_.

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

Implements ai::readonly_context.

Definition at line 555 of file contexts.cpp.

References attack_depth_.

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

Implements ai::readonly_context.

Definition at line 576 of file contexts.cpp.

References attacks_.

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

Implements ai::readonly_context.

Definition at line 586 of file contexts.cpp.

References attacks_.

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

Implements ai::readonly_context.

Definition at line 595 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
virtual

Implements ai::readonly_context.

Definition at line 607 of file contexts.cpp.

References caution_.

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

Implements ai::readonly_context.

Definition at line 615 of file contexts.cpp.

References dstsrc_, move_maps_valid_, and recalculate_move_maps().

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

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

Implements ai::readonly_context.

Definition at line 651 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
virtual

Implements ai::readonly_context.

Definition at line 688 of file contexts.cpp.

References engines_.

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

Implements ai::readonly_context.

Definition at line 694 of file contexts.cpp.

References engines_.

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

Implements ai::readonly_context.

Definition at line 709 of file contexts.cpp.

References goals_.

Referenced by on_readonly_context_create().

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

Implements ai::readonly_context.

Definition at line 715 of file contexts.cpp.

References goals_.

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

Implements ai::readonly_context.

Definition at line 700 of file contexts.cpp.

References grouping_.

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

Implements ai::readonly_context.

Definition at line 722 of file contexts.cpp.

References leader_aggression_.

Referenced by check_attack_action().

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

Implements ai::readonly_context.

Definition at line 731 of file contexts.cpp.

References leader_goal_.

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

Implements ai::readonly_context.

Definition at line 740 of file contexts.cpp.

References leader_ignores_keep_.

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

Implements ai::readonly_context.

Definition at line 749 of file contexts.cpp.

References leader_value_.

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

Implements ai::readonly_context.

Definition at line 758 of file contexts.cpp.

References passive_leader_.

Referenced by recalculate_move_maps().

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

Implements ai::readonly_context.

Definition at line 767 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
virtual

Implements ai::readonly_context.

Definition at line 776 of file contexts.cpp.

References move_maps_valid_, possible_moves_, and recalculate_move_maps().

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

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

:w

Implements ai::readonly_context.

Definition at line 1154 of file contexts.hpp.

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

Implements ai::readonly_context.

Definition at line 785 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
virtual

Implements ai::readonly_context.

Definition at line 792 of file contexts.cpp.

References recruitment_diversity_.

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

Implements ai::readonly_context.

Definition at line 801 of file contexts.cpp.

References recruitment_instructions_.

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

Implements ai::readonly_context.

Definition at line 810 of file contexts.cpp.

References recruitment_more_.

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

Implements ai::readonly_context.

Definition at line 819 of file contexts.cpp.

References recruitment_pattern_.

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

Implements ai::readonly_context.

Definition at line 828 of file contexts.cpp.

References recruitment_randomness_.

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

Implements ai::readonly_context.

Definition at line 837 of file contexts.cpp.

References recruitment_save_gold_.

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

Get the value of the recursion counter.

Reimplemented from ai::side_context_proxy.

Definition at line 86 of file contexts.cpp.

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

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

Implements ai::readonly_context.

Definition at line 846 of file contexts.cpp.

References scout_village_targeting_.

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

Implements ai::readonly_context.

Definition at line 855 of file contexts.cpp.

References simple_targeting_.

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

Implements ai::readonly_context.

Definition at line 864 of file contexts.cpp.

References move_maps_valid_, recalculate_move_maps(), and srcdst_.

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

Implements ai::readonly_context.

Definition at line 873 of file contexts.cpp.

References support_villages_.

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

Implements ai::readonly_context.

Definition at line 882 of file contexts.cpp.

References village_value_.

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

Implements ai::readonly_context.

Definition at line 891 of file contexts.cpp.

References villages_per_scout_.

void ai::readonly_context_impl::handle_generic_event ( const std::string event_name)
virtual

Handle generic event.

Implements events::observer.

Definition at line 316 of file contexts.cpp.

References invalidate_move_maps().

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

Implements ai::readonly_context.

Definition at line 920 of file contexts.cpp.

References defensive_position_cache_.

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

Implements ai::readonly_context.

Definition at line 926 of file contexts.cpp.

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

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

Implements ai::readonly_context.

Definition at line 905 of file contexts.cpp.

References dst_src_enemy_valid_lua_.

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

Implements ai::readonly_context.

Definition at line 900 of file contexts.cpp.

References dst_src_valid_lua_.

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

Implements ai::readonly_context.

Definition at line 915 of file contexts.cpp.

References src_dst_enemy_valid_lua_.

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

Implements ai::readonly_context.

Definition at line 910 of file contexts.cpp.

References src_dst_valid_lua_.

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

Implements ai::readonly_context.

Definition at line 951 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
virtual
void ai::readonly_context_impl::log_message ( const std::string msg)
virtual
const map_location & ai::readonly_context_impl::nearest_keep ( const map_location loc) const
virtual
void ai::readonly_context_impl::on_create ( )
void ai::readonly_context_impl::on_readonly_context_create ( )
virtual
double ai::readonly_context_impl::power_projection ( const map_location loc,
const move_map dstsrc 
) const
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

Implements ai::readonly_context.

Definition at line 1062 of file contexts.cpp.

References unit::alignment(), unit::attacks(), 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, int(), gamemap::is_village(), time_of_day::lawful_bonus, game_board::map(), map_, unit::max_hitpoints(), gamemap::on_board(), pos, unit::side(), gui2::terrain, resources::tod_manager, tod_manager::turn(), resources::units, units_, and map_location::valid().

Referenced by best_defensive_position().

void ai::readonly_context_impl::raise_user_interact ( ) const
virtual

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 98 of file contexts.cpp.

References ai::manager::raise_user_interact().

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

Implements ai::readonly_context.

Definition at line 1221 of file contexts.cpp.

References dst_src_enemy_valid_lua_.

void ai::readonly_context_impl::set_dst_src_valid_lua ( )
virtual

Implements ai::readonly_context.

Definition at line 1216 of file contexts.cpp.

References dst_src_valid_lua_.

void ai::readonly_context_impl::set_src_dst_enemy_valid_lua ( )
virtual

Implements ai::readonly_context.

Definition at line 1231 of file contexts.cpp.

References src_dst_enemy_valid_lua_.

void ai::readonly_context_impl::set_src_dst_valid_lua ( )
virtual

Implements ai::readonly_context.

Definition at line 1226 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 
)
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

Implements ai::readonly_context.

Definition at line 1236 of file contexts.cpp.

References 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
virtual

serialize to config

Implements ai::readonly_context.

Definition at line 296 of file contexts.cpp.

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

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

Weapon choice cache, to speed simulations.

Implements ai::readonly_context.

Definition at line 1280 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 1512 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 1513 of file contexts.hpp.

Referenced by get_aggression(), and readonly_context_impl().

aspect_map ai::readonly_context_impl::aspects_
private

Definition at line 1515 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 1514 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 1516 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 1517 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 1518 of file contexts.hpp.

Referenced by get_caution(), and readonly_context_impl().

const config ai::readonly_context_impl::cfg_
private

Definition at line 1503 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 1520 of file contexts.hpp.

Referenced by get_dstsrc(), and recalculate_move_maps().

move_map ai::readonly_context_impl::enemy_dstsrc_
mutableprivate

Definition at line 1521 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 1522 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 1523 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 1508 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 1525 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 1524 of file contexts.hpp.

Referenced by get_grouping(), and readonly_context_impl().

keeps_cache ai::readonly_context_impl::keeps_
mutableprivate

Definition at line 1526 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 1510 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 1527 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 1528 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 1529 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 1530 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 1537 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 1538 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 1539 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 1540 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 1541 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 1542 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 1543 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 1544 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 1545 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 1546 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 1547 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 1548 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 1549 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 1550 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 1551 of file contexts.hpp.

Referenced by unit_stats_cache().

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

Definition at line 1552 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 1553 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: