Class that manages AIs for all sides and manages AI redeployment. More...
#include <manager.hpp>

Static Public Member Functions | |
| static void | set_ai_info (const game_info &info) |
| Sets AI information. | |
| static void | clear_ai_info () |
| Clears AI information. | |
| static void | add_observer (events::observer *event_observer) |
| Adds observer of game events. | |
| static void | remove_observer (events::observer *event_observer) |
| Removes an observer of game events. | |
| static void | add_gamestate_observer (events::observer *event_observer) |
| Adds observer of game events except ai_user_interact event and ai_sync_network event. | |
| static void | remove_gamestate_observer (events::observer *event_observer) |
| Removes an observer of game events except ai_user_interact event and ai_sync_network event. | |
| static void | raise_user_interact () |
| Notifies all observers of 'ai_user_interact' event. | |
| static void | raise_sync_network () |
| Notifies all observers of 'ai_sync_network' event. | |
| static void | raise_gamestate_changed () |
| Notifies all observers of 'ai_gamestate_changed' event. | |
| static void | raise_recruit_list_changed () |
| Notifies all observers of 'ai_recruit_list_changed' event. | |
| static void | raise_turn_started () |
| Notifies all observers of 'ai_turn_started' event. | |
| static void | raise_map_changed () |
| Notifies all observers of 'ai_map_changed' event. | |
| static void | add_map_changed_observer (events::observer *event_observer) |
| Adds an observer of 'ai_map_changed' event. | |
| static void | add_recruit_list_changed_observer (events::observer *event_observer) |
| Adds an observer of 'ai_recruit_list_changed' event. | |
| static void | add_turn_started_observer (events::observer *event_observer) |
| Adds an observer of 'ai_turn_started' event. | |
| static void | remove_map_changed_observer (events::observer *event_observer) |
| Deletes an observer of 'ai_map_changed' event. | |
| static void | remove_recruit_list_changed_observer (events::observer *event_observer) |
| Deletes an observer of 'ai_recruit_list_changed' event. | |
| static void | remove_turn_started_observer (events::observer *event_observer) |
| Deletes an observer of 'ai_turn_started' event. | |
| static const std::string | evaluate_command (side_number side, const std::string &str) |
| Evaluates a string command using command AI. | |
| static bool | add_ai_for_side_from_file (side_number side, const std::string &file, bool replace=true) |
| Adds active AI for specified side from file. | |
| static bool | add_ai_for_side_from_config (side_number side, const config &cfg, bool replace=true) |
| Adds active AI for specified side from cfg. | |
| static bool | add_ai_for_side (side_number side, const std::string &ai_algorithm_type, bool replace=true) |
| Adds active AI for specified side from parameters. | |
| static ai_ptr | create_transient_ai (const std::string &ai_algorithm_type, const config &cfg, ai_context *ai_context) |
| Returns a smart pointer to a new AI. | |
| static void | remove_ai_for_side (side_number side) |
| Removes top-level AI from side. | |
| static void | remove_all_ais_for_side (side_number side) |
| Removes all AIs from side. | |
| static void | clear_ais () |
| Clears all the AIs. | |
| static game_info & | get_active_ai_info_for_side (side_number side) |
| Gets AI info for active AI of the given side. | |
| static std::string | get_active_ai_overview_for_side (side_number side) |
| Gets AI Overview for active AI of the given side. | |
| static std::string | get_active_ai_structure_for_side (side_number side) |
| Gets AI Structure for active AI of the given side. | |
| static std::string | get_active_ai_identifier_for_side (side_number side) |
| Gets AI algorithm identifier for active AI of the given side. | |
| static config | to_config (side_number side) |
| Gets AI config for active AI of the given side. | |
| static game_info & | get_ai_info () |
| Gets global AI-game info. | |
| static void | modify_active_ai_config_old_for_side (side_number side, const config::const_child_itors &ai_parameters) |
| Modifies AI parameters for active AI of the given side. | |
| static void | modify_active_ai_for_side (ai::side_number, const config &cfg) |
| Modifies AI parameters for active AI of the given side. | |
| static void | play_turn (side_number side) |
| Plays a turn for the specified side using its active AI. | |
Static Public Attributes | |
| static const size_t | MAX_HISTORY_SIZE = 200 |
| static const std::string | AI_TYPE_COMPOSITE_AI |
| static const std::string | AI_TYPE_SAMPLE_AI |
| static const std::string | AI_TYPE_IDLE_AI |
| static const std::string | AI_TYPE_FORMULA_AI |
| static const std::string | AI_TYPE_DFOOL_AI |
| static const std::string | AI_TYPE_AI2 |
| static const std::string | AI_TYPE_DEFAULT |
Private Types | |
| typedef std::map< side_number, std::stack< holder > > | AI_map_of_stacks |
Private Member Functions | |
| manager () | |
Static Private Member Functions | |
| static const std::string | internal_evaluate_command (side_number side, const std::string &str) |
| Evaluates an internal manager command. | |
| static bool | should_intercept (const std::string &str) |
| Determines if the command should be intercepted and evaluated as internal command. | |
| static std::stack< holder > & | get_or_create_ai_stack_for_side (side_number side) |
| Gets the AI stack for the specified side, create it if it doesn't exist. | |
| static holder & | get_active_ai_holder_for_side (side_number side) |
| Gets active holder for specified side. | |
| static interface & | get_active_ai_for_side (side_number side) |
| Gets active AI for specified side. | |
Static Private Attributes | |
| static AI_map_of_stacks | ai_map_ |
| static std::deque < command_history_item > | history_ |
| static long | history_item_counter_ |
| static game_info * | ai_info_ |
| static events::generic_event | map_changed_ |
| static events::generic_event | recruit_list_changed_ |
| static events::generic_event | user_interact_ |
| static events::generic_event | sync_network_ |
| static events::generic_event | gamestate_changed_ |
| static events::generic_event | turn_started_ |
| static int | last_interact_ |
| static int | num_interact_ |
Class that manages AIs for all sides and manages AI redeployment.
This class is responsible for managing the AI lifecycle It can be accessed like this: ai::manager::foo(...);
Definition at line 116 of file manager.hpp.
typedef std::map< side_number, std::stack< holder > > ai::manager::AI_map_of_stacks [private] |
Definition at line 449 of file manager.hpp.
| ai::manager::manager | ( | ) | [private] |
| static bool ai::manager::add_ai_for_side | ( | side_number | side, | |
| const std::string & | ai_algorithm_type, | |||
| bool | replace = true | |||
| ) | [static] |
Adds active AI for specified side from parameters.
| side | side number (1-based, as in game_info). | |
| ai_algorithm_type | type of AI algorithm to create. | |
| replace | should new ai replace the current ai or 'be placed on top of it'. |
| static bool ai::manager::add_ai_for_side_from_config | ( | side_number | side, | |
| const config & | cfg, | |||
| bool | replace = true | |||
| ) | [static] |
Adds active AI for specified side from cfg.
| side | side number (1-based, as in game_info). | |
| cfg | the config from which all ai parameters are to be read. | |
| replace | should new ai replace the current ai or 'be placed on top of it'. |
Referenced by team::team_info::read().

| static bool ai::manager::add_ai_for_side_from_file | ( | side_number | side, | |
| const std::string & | file, | |||
| bool | replace = true | |||
| ) | [static] |
Adds active AI for specified side from file.
| side | side number (1-based, as in game_info). | |
| file | file name, follows the usual WML convention. | |
| replace | should new ai replace the current ai or 'be placed on top of it'. |
Referenced by team::team_info::read(), and WML_HANDLER_FUNCTION().

| static void ai::manager::add_gamestate_observer | ( | events::observer * | event_observer | ) | [static] |
Adds observer of game events except ai_user_interact event and ai_sync_network event.
Referenced by ai::formula_ai::gamestate_change_observer::gamestate_change_observer(), ai::gamestate_observer::gamestate_observer(), ai::readonly_context_impl::readonly_context_impl(), and ai::aspect::redeploy().

| static void ai::manager::add_map_changed_observer | ( | events::observer * | event_observer | ) | [static] |
Adds an observer of 'ai_map_changed' event.
Referenced by ai::keeps_cache::keeps_cache().

| static void ai::manager::add_observer | ( | events::observer * | event_observer | ) | [static] |
Adds observer of game events.
Should be called in playsingle_controller 's constructor.
Referenced by playsingle_controller::playsingle_controller().

| static void ai::manager::add_recruit_list_changed_observer | ( | events::observer * | event_observer | ) | [static] |
Adds an observer of 'ai_recruit_list_changed' event.
Referenced by ai::ai_default_recruitment_stage::recruit_situation_change_observer::recruit_situation_change_observer().

| static void ai::manager::add_turn_started_observer | ( | events::observer * | event_observer | ) | [static] |
Adds an observer of 'ai_turn_started' event.
Referenced by ai::keeps_cache::keeps_cache(), ai::ai_default_recruitment_stage::recruit_situation_change_observer::recruit_situation_change_observer(), and ai::aspect::redeploy().

| static void ai::manager::clear_ai_info | ( | ) | [static] |
Clears AI information.
Should be called in playsingle_controller 's destructor.
| static void ai::manager::clear_ais | ( | ) | [static] |
Clears all the AIs.
Referenced by playsingle_controller::~playsingle_controller().

| static ai_ptr ai::manager::create_transient_ai | ( | const std::string & | ai_algorithm_type, | |
| const config & | cfg, | |||
| ai_context * | ai_context | |||
| ) | [static] |
Returns a smart pointer to a new AI.
| ai_algorithm_type | type of AI algorithm to create | |
| cfg | a config of the ai | |
| context | context in which this ai is created |
Referenced by ai::formula_ai::execute_variant(), and ai::testing_ai_default::fallback_to_other_ai::on_create().

| static const std::string ai::manager::evaluate_command | ( | side_number | side, | |
| const std::string & | str | |||
| ) | [static] |
Evaluates a string command using command AI.
| side | side number (1-based). | |
| str | string to evaluate. |
Referenced by events::menu_handler::do_ai_formula().

| static interface& ai::manager::get_active_ai_for_side | ( | side_number | side | ) | [static, private] |
Gets active AI for specified side.
| side | side number (1-based, as in game_info). |
| static holder& ai::manager::get_active_ai_holder_for_side | ( | side_number | side | ) | [static, private] |
Gets active holder for specified side.
| static std::string ai::manager::get_active_ai_identifier_for_side | ( | side_number | side | ) | [static] |
Gets AI algorithm identifier for active AI of the given side.
| side | side number (1-based). |
Referenced by play_controller::check_victory(), and ai_testing::log_game_start().

| static game_info& ai::manager::get_active_ai_info_for_side | ( | side_number | side | ) | [static] |
Gets AI info for active AI of the given side.
| side | side number (1-based). |
Referenced by ai::readonly_context_impl::get_info(), ai::readwrite_context_impl::get_info_w(), and ai::action_result::get_my_team().

| static std::string ai::manager::get_active_ai_overview_for_side | ( | side_number | side | ) | [static] |
Gets AI Overview for active AI of the given side.
| side | side number (1-based) |
Referenced by gui2::team_mode_controller::handle_stuff_list_selection().

| static std::string ai::manager::get_active_ai_structure_for_side | ( | side_number | side | ) | [static] |
Gets AI Structure for active AI of the given side.
| side | side number (1-based) |
Referenced by gui2::team_mode_controller::handle_stuff_list_selection().

| static game_info& ai::manager::get_ai_info | ( | ) | [static] |
Gets global AI-game info.
Referenced by ai::attack_analysis::attack_close().

| static std::stack< holder >& ai::manager::get_or_create_ai_stack_for_side | ( | side_number | side | ) | [static, private] |
Gets the AI stack for the specified side, create it if it doesn't exist.
| static const std::string ai::manager::internal_evaluate_command | ( | side_number | side, | |
| const std::string & | str | |||
| ) | [static, private] |
Evaluates an internal manager command.
| side | side number (1-based). | |
| str | string to evaluate. |
| static void ai::manager::modify_active_ai_config_old_for_side | ( | side_number | side, | |
| const config::const_child_itors & | ai_parameters | |||
| ) | [static] |
Modifies AI parameters for active AI of the given side.
This function is provided for backward-compatibility with [modify_side][ai]...[/ai][/modify_side] It can only add new facets to aspects
| side | side_number (1-based, as in game_info). | |
| ai_parameters | AI parameters to be modified. |
Referenced by WML_HANDLER_FUNCTION().

| static void ai::manager::modify_active_ai_for_side | ( | ai::side_number | , | |
| const config & | cfg | |||
| ) | [static] |
Modifies AI parameters for active AI of the given side.
This function is a backend for [modify_ai] tag
| side | side_number (1-based, as in game_info). | |
| cfg | - content of [modify_ai] tag |
Referenced by intf_modify_ai(), ai::testing_ai_default::candidate_action_evaluation_loop::remove_completed_cas(), ai::testing_ai_default::move_leader_to_goals_phase::remove_goal(), and WML_HANDLER_FUNCTION().

| static void ai::manager::play_turn | ( | side_number | side | ) | [static] |
Plays a turn for the specified side using its active AI.
| side | side number (1-based, as in game_info). |
| static void ai::manager::raise_gamestate_changed | ( | ) | [static] |
Notifies all observers of 'ai_gamestate_changed' event.
| static void ai::manager::raise_map_changed | ( | ) | [static] |
Notifies all observers of 'ai_map_changed' event.
Referenced by WML_HANDLER_FUNCTION().

| static void ai::manager::raise_recruit_list_changed | ( | ) | [static] |
Notifies all observers of 'ai_recruit_list_changed' event.
Referenced by team::add_recruit(), and team::set_recruits().

| static void ai::manager::raise_sync_network | ( | ) | [static] |
Notifies all observers of 'ai_sync_network' event.
Basically a request from the AI to sync the network.
Referenced by verify_and_get_global_variable().

| static void ai::manager::raise_turn_started | ( | ) | [static] |
Notifies all observers of 'ai_turn_started' event.
Referenced by playsingle_controller::before_human_turn().

| static void ai::manager::raise_user_interact | ( | ) | [static] |
Notifies all observers of 'ai_user_interact' event.
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.
Referenced by verify_and_get_global_variable().

| static void ai::manager::remove_ai_for_side | ( | side_number | side | ) | [static] |
Removes top-level AI from side.
| side | side number (1-based, as in game_info). |
| static void ai::manager::remove_all_ais_for_side | ( | side_number | side | ) | [static] |
Removes all AIs from side.
| side | side number (1-based, as in game_info). |
| static void ai::manager::remove_gamestate_observer | ( | events::observer * | event_observer | ) | [static] |
Removes an observer of game events except ai_user_interact event and ai_sync_network event.
Referenced by ai::aspect::redeploy(), ai::aspect::~aspect(), ai::formula_ai::gamestate_change_observer::~gamestate_change_observer(), ai::gamestate_observer::~gamestate_observer(), and ai::readonly_context_impl::~readonly_context_impl().

| static void ai::manager::remove_map_changed_observer | ( | events::observer * | event_observer | ) | [static] |
Deletes an observer of 'ai_map_changed' event.
Referenced by ai::keeps_cache::~keeps_cache().

| static void ai::manager::remove_observer | ( | events::observer * | event_observer | ) | [static] |
Removes an observer of game events.
Should be called in playsingle_controller 's destructor.
Referenced by playsingle_controller::~playsingle_controller().

| static void ai::manager::remove_recruit_list_changed_observer | ( | events::observer * | event_observer | ) | [static] |
Deletes an observer of 'ai_recruit_list_changed' event.
Referenced by ai::ai_default_recruitment_stage::recruit_situation_change_observer::~recruit_situation_change_observer().

| static void ai::manager::remove_turn_started_observer | ( | events::observer * | event_observer | ) | [static] |
Deletes an observer of 'ai_turn_started' event.
Referenced by ai::aspect::redeploy(), ai::aspect::~aspect(), ai::keeps_cache::~keeps_cache(), and ai::ai_default_recruitment_stage::recruit_situation_change_observer::~recruit_situation_change_observer().

| static void ai::manager::set_ai_info | ( | const game_info & | info | ) | [static] |
Sets AI information.
| info | ai_information to be set. |
Referenced by playsingle_controller::playsingle_controller().

| static bool ai::manager::should_intercept | ( | const std::string & | str | ) | [static, private] |
Determines if the command should be intercepted and evaluated as internal command.
| str | command string to check. |
| static config ai::manager::to_config | ( | side_number | side | ) | [static] |
Gets AI config for active AI of the given side.
| side | side number (1-based). |
Referenced by gui2::team_mode_controller::handle_stuff_list_selection(), and team::team_info::write().

game_info* ai::manager::ai_info_ [static, private] |
Definition at line 453 of file manager.hpp.
AI_map_of_stacks ai::manager::ai_map_ [static, private] |
Definition at line 450 of file manager.hpp.
const std::string ai::manager::AI_TYPE_AI2 [static] |
Definition at line 131 of file manager.hpp.
const std::string ai::manager::AI_TYPE_COMPOSITE_AI [static] |
Definition at line 126 of file manager.hpp.
const std::string ai::manager::AI_TYPE_DEFAULT [static] |
Definition at line 132 of file manager.hpp.
const std::string ai::manager::AI_TYPE_DFOOL_AI [static] |
Definition at line 130 of file manager.hpp.
const std::string ai::manager::AI_TYPE_FORMULA_AI [static] |
Definition at line 129 of file manager.hpp.
const std::string ai::manager::AI_TYPE_IDLE_AI [static] |
Definition at line 128 of file manager.hpp.
const std::string ai::manager::AI_TYPE_SAMPLE_AI [static] |
Definition at line 127 of file manager.hpp.
events::generic_event ai::manager::gamestate_changed_ [static, private] |
Definition at line 459 of file manager.hpp.
std::deque< command_history_item > ai::manager::history_ [static, private] |
Definition at line 451 of file manager.hpp.
long ai::manager::history_item_counter_ [static, private] |
Definition at line 452 of file manager.hpp.
int ai::manager::last_interact_ [static, private] |
Definition at line 461 of file manager.hpp.
events::generic_event ai::manager::map_changed_ [static, private] |
Definition at line 455 of file manager.hpp.
const size_t ai::manager::MAX_HISTORY_SIZE = 200 [static] |
Definition at line 124 of file manager.hpp.
int ai::manager::num_interact_ [static, private] |
Definition at line 462 of file manager.hpp.
events::generic_event ai::manager::recruit_list_changed_ [static, private] |
Definition at line 456 of file manager.hpp.
events::generic_event ai::manager::sync_network_ [static, private] |
Definition at line 458 of file manager.hpp.
events::generic_event ai::manager::turn_started_ [static, private] |
Definition at line 460 of file manager.hpp.
events::generic_event ai::manager::user_interact_ [static, private] |
Definition at line 457 of file manager.hpp.
| Generated by doxygen 1.7.1 on Thu May 24 2012 01:19:03 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |