#include "global.hpp"
#include "ai.hpp"
#include "log.hpp"
#include <cassert>
#include <numeric>
Go to the source code of this file.
Defines | |
#define | DBG_AI LOG_STREAM(debug, ai) |
#define | LOG_AI LOG_STREAM(info, ai) |
#define | WRN_AI LOG_STREAM(warn, ai) |
Typedefs | |
typedef std::map < gamemap::location, std::vector< gamemap::location > > | treachmap |
typedef std::vector< std::pair < gamemap::location, gamemap::location > > | tmoves |
Functions | |
static void | dispatch (treachmap &reachmap, tmoves &moves) |
Dispatches all units to their best location. | |
static bool | dispatch_unit_simple (treachmap &reachmap, tmoves &moves) |
Dispatches all units who can reach one village. | |
static bool | dispatch_village_simple (treachmap &reachmap, tmoves &moves, size_t &village_count) |
Dispatches units to villages which can only be reached by one unit. | |
static bool | remove_village (treachmap &reachmap, tmoves &moves, const gamemap::location &village) |
Removes a village for all units, returns true if anything is deleted. | |
static treachmap::iterator | remove_unit (treachmap &reachmap, tmoves &moves, treachmap::iterator unit) |
Removes a unit which can't reach any village anymore. | |
static void | dispatch_complex (treachmap &reachmap, tmoves &moves, const size_t village_count) |
Dispatches the units to a village after the simple dispatching failed. | |
static void | full_dispatch (treachmap &reachmap, tmoves &moves) |
Dispatches all units to a village, every unit can reach every village. | |
static void | dump_reachmap (treachmap &reachmap) |
Shows which villages every unit can reach (debug function). | |
Variables | |
gamemap::location | keep_loc = gamemap::location::null_location |
Location of the keep the closest to our leader. | |
gamemap::location | leader_loc = gamemap::location::null_location |
Locaton of our leader. | |
gamemap::location | best_leader_loc = gamemap::location::null_location |
The best possible location for our leader if it can't reach a village. | |
bool | debug = false |
debug log level for AI enabled? |
ai::get_villages and ai::find_villages are based on ai::get_villages is ai.cpp
Definition in file ai_village.cpp.
Definition at line 27 of file ai_village.cpp.
Referenced by dispatch(), dispatch_complex(), dispatch_unit_simple(), dispatch_village_simple(), full_dispatch(), ai::get_villages(), and remove_unit().
#define LOG_AI LOG_STREAM(info, ai) |
Definition at line 28 of file ai_village.cpp.
#define WRN_AI LOG_STREAM(warn, ai) |
Definition at line 29 of file ai_village.cpp.
typedef std::vector<std::pair<gamemap::location , gamemap::location > > tmoves [static] |
Definition at line 115 of file ai_village.cpp.
typedef std::map<gamemap::location , std::vector<gamemap::location > > treachmap [static] |
Definition at line 112 of file ai_village.cpp.
Dispatches all units to their best location.
Definition at line 374 of file ai_village.cpp.
References DBG_AI, dispatch_complex(), dispatch_unit_simple(), dispatch_village_simple(), and dump_reachmap().
Referenced by dispatch_complex(), and ai::get_villages().
static void dispatch_complex | ( | treachmap & | reachmap, | |
tmoves & | moves, | |||
const size_t | village_count | |||
) | [static] |
Dispatches the units to a village after the simple dispatching failed.
Definition at line 564 of file ai_village.cpp.
References DBG_AI, debug, dispatch(), full_dispatch(), leader_loc, remove_unit(), remove_village(), and units.
Referenced by dispatch().
Dispatches all units who can reach one village.
Returns true if it modified reachmap isn't empty
Definition at line 434 of file ai_village.cpp.
References DBG_AI, and remove_village().
Referenced by dispatch().
static bool dispatch_village_simple | ( | treachmap & | reachmap, | |
tmoves & | moves, | |||
size_t & | village_count | |||
) | [static] |
Dispatches units to villages which can only be reached by one unit.
Returns true if modified reachmap and reachmap isn't empty
Definition at line 479 of file ai_village.cpp.
References DBG_AI, map, and remove_village().
Referenced by dispatch().
static void dump_reachmap | ( | treachmap & | reachmap | ) | [static] |
Shows which villages every unit can reach (debug function).
Definition at line 896 of file ai_village.cpp.
References debug.
Referenced by dispatch(), and ai::get_villages().
Dispatches all units to a village, every unit can reach every village.
Definition at line 886 of file ai_village.cpp.
References DBG_AI.
Referenced by dispatch_complex().
static treachmap::iterator remove_unit | ( | treachmap & | reachmap, | |
tmoves & | moves, | |||
treachmap::iterator | unit | |||
) | [static] |
Removes a unit which can't reach any village anymore.
Definition at line 548 of file ai_village.cpp.
References best_leader_loc, DBG_AI, leader_loc, and gamemap::location::null_location.
Referenced by dispatch_complex(), ai::get_villages(), and remove_village().
static bool remove_village | ( | treachmap & | reachmap, | |
tmoves & | moves, | |||
const gamemap::location & | village | |||
) | [static] |
Removes a village for all units, returns true if anything is deleted.
Definition at line 531 of file ai_village.cpp.
References halo::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 106 of file ai_village.cpp.
Referenced by ai::get_villages(), and remove_unit().
bool debug = false [static] |
Location of the keep the closest to our leader.
Definition at line 101 of file ai_village.cpp.
Referenced by ai::get_villages().
Locaton of our leader.
Definition at line 103 of file ai_village.cpp.
Referenced by dispatch_complex(), ai::get_villages(), remove_unit(), and unit_display::unit_attack().
Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |