Public Member Functions | Private Types | Private Member Functions | Private Attributes

ai::testing_ai_default::get_villages_phase Class Reference

#include <ca.hpp>

Inheritance diagram for ai::testing_ai_default::get_villages_phase:
Inheritance graph
[legend]
Collaboration diagram for ai::testing_ai_default::get_villages_phase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 get_villages_phase (rca_context &context, const config &cfg)
virtual ~get_villages_phase ()
virtual double evaluate ()
 Evaluate the candidate action, resetting the internal state of the action.
virtual void execute ()
 Execute the candidate action.

Private Types

typedef std::map< map_location,
std::vector< map_location > > 
treachmap
typedef std::vector< std::pair
< map_location, map_location > > 
tmoves

Private Member Functions

void dispatch (treachmap &reachmap, tmoves &moves)
 Dispatches all units to their best location.
bool dispatch_unit_simple (treachmap &reachmap, tmoves &moves)
 Dispatches all units who can reach one village.
bool dispatch_village_simple (treachmap &reachmap, tmoves &moves, size_t &village_count)
bool remove_village (treachmap &reachmap, tmoves &moves, const map_location &village)
 Removes a village for all units, returns true if anything is deleted.
treachmap::iterator remove_unit (treachmap &reachmap, tmoves &moves, treachmap::iterator unit)
 Removes a unit which can't reach any village anymore.
void dispatch_complex (treachmap &reachmap, tmoves &moves, const size_t village_count)
 Dispatches the units to a village after the simple dispatching failed.
void full_dispatch (treachmap &reachmap, tmoves &moves)
 Dispatches all units to a village, every unit can reach every village.
void dump_reachmap (treachmap &reachmap)
 Shows which villages every unit can reach (debug function).
void get_villages (const move_map &dstsrc, const move_map &enemy_dstsrc, unit_map::const_iterator &leader)
void find_villages (treachmap &reachmap, tmoves &moves, const std::multimap< map_location, map_location > &dstsrc, const std::multimap< map_location, map_location > &enemy_dstsrc)

Private Attributes

map_location keep_loc_
 Location of the keep the closest to our leader.
map_location leader_loc_
 Locaton of our leader.
map_location best_leader_loc_
 The best possible location for our leader if it can't reach a village.
bool debug_
 debug log level for AI enabled?
tmoves moves_

Detailed Description

Definition at line 176 of file ca.hpp.


Member Typedef Documentation

typedef std::vector<std::pair<map_location , map_location > > ai::testing_ai_default::get_villages_phase::tmoves [private]

Definition at line 203 of file ca.hpp.

Definition at line 200 of file ca.hpp.


Constructor & Destructor Documentation

ai::testing_ai_default::get_villages_phase::get_villages_phase ( rca_context context,
const config cfg 
)

Definition at line 818 of file ca.cpp.

ai::testing_ai_default::get_villages_phase::~get_villages_phase (  )  [virtual]

Definition at line 828 of file ca.cpp.


Member Function Documentation

void ai::testing_ai_default::get_villages_phase::dispatch ( treachmap reachmap,
tmoves moves 
) [private]

Dispatches all units to their best location.

Definition at line 1074 of file ca.cpp.

References DBG_AI_TESTING_AI_DEFAULT, dispatch_complex(), dispatch_unit_simple(), dispatch_village_simple(), and dump_reachmap().

Referenced by dispatch_complex(), and get_villages().

Here is the call graph for this function:

Here is the caller graph for this function:

void ai::testing_ai_default::get_villages_phase::dispatch_complex ( treachmap reachmap,
tmoves moves,
const size_t  village_count 
) [private]

Dispatches the units to a village after the simple dispatching failed.

Definition at line 1264 of file ca.cpp.

References preferences::editor::TransitionUpdateMode::count, DBG_AI_TESTING_AI_DEFAULT, debug_, dispatch(), gui2::event::find(), full_dispatch(), leader_loc_, remove_unit(), remove_village(), and resources::units.

Referenced by dispatch().

Here is the call graph for this function:

Here is the caller graph for this function:

bool ai::testing_ai_default::get_villages_phase::dispatch_unit_simple ( treachmap reachmap,
tmoves moves 
) [private]

Dispatches all units who can reach one village.

Returns true if it modified reachmap isn't empty.

Definition at line 1134 of file ca.cpp.

References DBG_AI_TESTING_AI_DEFAULT, and remove_village().

Referenced by dispatch().

Here is the call graph for this function:

Here is the caller graph for this function:

bool ai::testing_ai_default::get_villages_phase::dispatch_village_simple ( treachmap reachmap,
tmoves moves,
size_t &  village_count 
) [private]

Definition at line 1179 of file ca.cpp.

References DBG_AI_TESTING_AI_DEFAULT, preferences::map(), and remove_village().

Referenced by dispatch().

Here is the call graph for this function:

Here is the caller graph for this function:

void ai::testing_ai_default::get_villages_phase::dump_reachmap ( treachmap reachmap  )  [private]

Shows which villages every unit can reach (debug function).

Definition at line 1596 of file ca.cpp.

References debug_.

Referenced by dispatch(), and get_villages().

Here is the caller graph for this function:

double ai::testing_ai_default::get_villages_phase::evaluate (  )  [virtual]

Evaluate the candidate action, resetting the internal state of the action.

Returns:
the score
Return values:
>0 if the action is good
<=0 if the action is not good

Implements ai::candidate_action.

Definition at line 832 of file ca.cpp.

References ai::candidate_action::BAD_SCORE, unit_map::find_leader(), ai::readonly_context_proxy::get_dstsrc(), ai::readonly_context_proxy::get_enemy_dstsrc(), ai::candidate_action::get_score(), ai::side_context_proxy::get_side(), get_villages(), moves_, and resources::units.

Here is the call graph for this function:

void ai::testing_ai_default::get_villages_phase::execute (  )  [virtual]
void ai::testing_ai_default::get_villages_phase::find_villages ( treachmap reachmap,
tmoves moves,
const std::multimap< map_location, map_location > &  dstsrc,
const std::multimap< map_location, map_location > &  enemy_dstsrc 
) [private]
void ai::testing_ai_default::get_villages_phase::full_dispatch ( treachmap reachmap,
tmoves moves 
) [private]

Dispatches all units to a village, every unit can reach every village.

Definition at line 1586 of file ca.cpp.

References DBG_AI_TESTING_AI_DEFAULT.

Referenced by dispatch_complex().

Here is the caller graph for this function:

void ai::testing_ai_default::get_villages_phase::get_villages ( const move_map dstsrc,
const move_map enemy_dstsrc,
unit_map::const_iterator leader 
) [private]
get_villages_phase::treachmap::iterator ai::testing_ai_default::get_villages_phase::remove_unit ( treachmap reachmap,
tmoves moves,
treachmap::iterator  unit 
) [private]

Removes a unit which can't reach any village anymore.

Definition at line 1248 of file ca.cpp.

References best_leader_loc_, DBG_AI_TESTING_AI_DEFAULT, leader_loc_, and map_location::null_location.

Referenced by dispatch_complex(), get_villages(), and remove_village().

Here is the caller graph for this function:

bool ai::testing_ai_default::get_villages_phase::remove_village ( treachmap reachmap,
tmoves moves,
const map_location village 
) [private]

Removes a village for all units, returns true if anything is deleted.

Definition at line 1231 of file ca.cpp.

References schema_validation::remove, and remove_unit().

Referenced by dispatch_complex(), dispatch_unit_simple(), and dispatch_village_simple().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

The best possible location for our leader if it can't reach a village.

Definition at line 194 of file ca.hpp.

Referenced by find_villages(), get_villages(), and remove_unit().

debug log level for AI enabled?

Definition at line 197 of file ca.hpp.

Referenced by dispatch_complex(), dump_reachmap(), and get_villages().

Location of the keep the closest to our leader.

Definition at line 188 of file ca.hpp.

Referenced by find_villages(), and get_villages().

Locaton of our leader.

Definition at line 191 of file ca.hpp.

Referenced by dispatch_complex(), find_villages(), get_villages(), and remove_unit().

Definition at line 207 of file ca.hpp.

Referenced by evaluate(), execute(), and get_villages().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:19:08 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs