#include <ca.hpp>


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_ |
Definition at line 176 of file ca.hpp.
typedef std::vector<std::pair<map_location , map_location > > ai::testing_ai_default::get_villages_phase::tmoves [private] |
typedef std::map<map_location , std::vector<map_location > > ai::testing_ai_default::get_villages_phase::treachmap [private] |
| ai::testing_ai_default::get_villages_phase::get_villages_phase | ( | rca_context & | context, | |
| const config & | cfg | |||
| ) |
| ai::testing_ai_default::get_villages_phase::~get_villages_phase | ( | ) | [virtual] |
| 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().


| 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().


| 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().


| 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().


| 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().

| double ai::testing_ai_default::get_villages_phase::evaluate | ( | ) | [virtual] |
Evaluate the candidate action, resetting the internal state of the action.
| >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.

| void ai::testing_ai_default::get_villages_phase::execute | ( | ) | [virtual] |
Execute the candidate action.
Implements ai::candidate_action.
Definition at line 844 of file ca.cpp.
References ai::readonly_context_proxy::current_team(), unit_map::end(), ai::readwrite_context_proxy::execute_move_action(), unit_map::find(), unit_map::find_leader(), find_visible_unit(), resources::game_map, ai::readonly_context_proxy::get_enemy_dstsrc(), ai::side_context_proxy::get_side(), LOG_AI_TESTING_AI_DEFAULT, moves_, ai::readonly_context_proxy::power_projection(), and resources::units.

| 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] |
Definition at line 955 of file ca.cpp.
References best_leader_loc_, ai::readonly_context_proxy::check_move_action(), ai::readonly_context_proxy::current_team(), DBG_AI_TESTING_AI_DEFAULT, unit::defense_modifier(), gui2::distance(), distance_between(), unit_map::find(), gui2::event::find(), resources::game_map, ai::readonly_context_proxy::get_passive_leader(), gamemap::get_terrain(), unit::hitpoints(), gamemap::is_village(), keep_loc_, leader_loc_, map_, next, map_location::null_location, ai::readonly_context_proxy::power_projection(), resources::teams, and resources::units.
Referenced by get_villages().


| 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().

| 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] |
Definition at line 895 of file ca.cpp.
References unit_map::begin(), best_leader_loc_, DBG_AI_TESTING_AI_DEFAULT, lg::debug, debug_, dispatch(), dump_reachmap(), unit_map::end(), find_villages(), ai::readonly_context_proxy::get_passive_leader(), ai::side_context_proxy::get_side(), keep_loc_, leader_loc_, LOG_AI_TESTING_AI_DEFAULT, log_ai_testing_ai_default, moves_, ai::readonly_context_proxy::nearest_keep(), map_location::null_location, remove_unit(), and resources::units.
Referenced by evaluate().


| 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().

| 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().


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().
bool ai::testing_ai_default::get_villages_phase::debug_ [private] |
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().
| Generated by doxygen 1.7.1 on Thu May 24 2012 01:19:08 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |