The Battle for Wesnoth  1.15.5+dev
configuration.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2018 by Yurii Chernyi <terraninfo@terraninfo.net>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 /**
16  * Managing the AIs configuration - headers
17  * @file
18  * */
19 
20 #pragma once
21 
22 #include "config.hpp"
23 #include "ai/game_info.hpp"
24 #include "game_config_view.hpp"
25 
26 namespace ai {
27 
28 /**
29  * AI parameters. class to deal with AI parameters. It is an implementation detail.
30  * We need implementation which will allow easy access to all the parameters
31  * which match any of the pre-defined set of filters
32  * such as 'select from ai_parameters where time_of_day=first watch'
33  * or 'select from ai_parameters where active(current_game_state)=true'
34  * it should be noted that there may be several variables with a same name but
35  * different filters. the proposed rules, in general, are:
36  * 1) scenario_parameter_in_SIDE_section > scenario_parameter_in_AI_section > default_value
37  * then, if (1) is equal:
38  * 2) use scenario-creator supplied priority ( 'not set' = 0)
39  * then, if (2) is equal:
40  * 3) more restricted parameter > less restricted parameter
41  * then, if (3) is equal:
42  * use any and loudly complain.
43  */
44 
45 struct description {
46 public:
48  : text()
49  , id()
50  , mp_rank()
51  , cfg()
52  {
53  }
54 
57  int mp_rank;
59 };
60 
62 public:
63 
64  /**
65  * Init the parameters of ai configuration parser
66  * @param game_config game config
67  */
68  static void init(const game_config_view &game_config);
69  static void add_era_ai_from_config(const config &game_config);
70  static void add_mod_ai_from_config(config::const_child_itors configs);
71 
72 
73  /**
74  * get default AI parameters
75  * @return default AI parameters
76  */
77  static const config& get_default_ai_parameters();
78 
79 
80  /**
81  * Return the config for a specified ai
82  */
83  static const config& get_ai_config_for(const std::string &id);
84 
85 
86  /**
87  * Returns a list of available AIs.
88  * @return the list of available AIs.
89  */
90  static std::vector<description*> get_available_ais();
91 
92 
93  /**
94  * get side config from file
95  * @param file the file name to open. follows usual WML convention.
96  * @param[out] cfg the config to be written from file.
97  * @return was all ok?
98  * @retval true success
99  * @retval false failure
100  */
101  static bool get_side_config_from_file( const std::string& file, config& cfg );
102 
103 
104  /**
105  * @param[in] original_cfg the config to be read
106  * @param[out] cfg parsed config
107  * @return was all ok?
108  * @retval true success
109  * @retval false failure
110  */
111  static bool parse_side_config(side_number side, const config& original_cfg, config &cfg);
112 
113 
114  /**
115  * Expand simplified aspects, similar to the change from 1.7.2 to 1.7.3
116  * but with some additional syntax options.
117  */
118  static void expand_simplified_aspects(side_number side, config &cfg);
119 private:
120 
121  typedef std::map<std::string, description> description_map;
122  static description_map ai_configurations_;
123  static description_map era_ai_configurations_;
124  static description_map mod_ai_configurations_;
127 
128 };
129 
130 } //end of namespace ai
AI parameters.
static config default_config_
Definitions for the interface to Wesnoth Markup Language (WML).
std::string id
A small explanation about what&#39;s going on here: Each action has access to two game_info objects First...
Definition: actions.cpp:59
struct utils::detail::formula_initer init
static description_map era_ai_configurations_
static description_map ai_configurations_
boost::iterator_range< const_child_iterator > const_child_itors
Definition: config.hpp:210
Game information for the AI.
Game configuration data as global variables.
Definition: build_info.cpp:55
std::map< std::string, description > description_map
static description_map mod_ai_configurations_
int side_number
Definition: game_info.hpp:39
static std::string default_ai_algorithm_
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:68