The Battle for Wesnoth  1.15.0-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 
25 namespace ai {
26 
27 /**
28  * AI parameters. class to deal with AI parameters. It is an implementation detail.
29  * We need implementation which will allow easy access to all the parameters
30  * which match any of the pre-defined set of filters
31  * such as 'select from ai_parameters where time_of_day=first watch'
32  * or 'select from ai_parameters where active(current_game_state)=true'
33  * it should be noted that there may be several variables with a same name but
34  * different filters. the proposed rules, in general, are:
35  * 1) scenario_parameter_in_SIDE_section > scenario_parameter_in_AI_section > default_value
36  * then, if (1) is equal:
37  * 2) use scenario-creator supplied priority ( 'not set' = 0)
38  * then, if (2) is equal:
39  * 3) more restricted parameter > less restricted parameter
40  * then, if (3) is equal:
41  * use any and loudly complain.
42  */
43 
44 struct description {
45 public:
47  : text()
48  , id()
49  , mp_rank()
50  , cfg()
51  {
52  }
53 
55  std::string id;
56  int mp_rank;
58 };
59 
61 public:
62 
63  /**
64  * Init the parameters of ai configuration parser
65  * @param game_config game config
66  */
67  static void init(const config &game_config);
68  static void add_era_ai_from_config(const config &game_config);
69  static void add_mod_ai_from_config(config::const_child_itors configs);
70 
71 
72  /**
73  * get default AI parameters
74  * @return default AI parameters
75  */
76  static const config& get_default_ai_parameters();
77 
78 
79  /**
80  * Return the config for a specified ai
81  */
82  static const config& get_ai_config_for(const std::string &id);
83 
84 
85  /**
86  * Returns a list of available AIs.
87  * @return the list of available AIs.
88  */
89  static std::vector<description*> get_available_ais();
90 
91 
92  /**
93  * get side config from file
94  * @param file the file name to open. follows usual WML convention.
95  * @param[out] cfg the config to be written from file.
96  * @return was all ok?
97  * @retval true success
98  * @retval false failure
99  */
100  static bool get_side_config_from_file( const std::string& file, config& cfg );
101 
102 
103  /**
104  * @param[in] original_cfg the config to be read
105  * @param[out] cfg parsed config
106  * @return was all ok?
107  * @retval true success
108  * @retval false failure
109  */
110  static bool parse_side_config(side_number side, const config& original_cfg, config &cfg);
111 
112 
113  /**
114  * Expand simplified aspects, similar to the change from 1.7.2 to 1.7.3
115  * but with some additional syntax options.
116  */
117  static void expand_simplified_aspects(side_number side, config &cfg);
118 private:
119 
120  typedef std::map<std::string, description> description_map;
121  static description_map ai_configurations_;
122  static description_map era_ai_configurations_;
123  static description_map mod_ai_configurations_;
125  static std::string default_ai_algorithm_;
126 
127 };
128 
129 } //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:58
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:238
Game information for the AI.
Game configuration data as global variables.
Definition: build_info.cpp:49
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:92