OpenTTD Source  14.0-RC1
ai_core.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "../stdafx.h"
11 #include "../core/backup_type.hpp"
12 #include "../core/bitmath_func.hpp"
13 #include "../company_base.h"
14 #include "../company_func.h"
15 #include "../network/network.h"
16 #include "../window_func.h"
17 #include "../framerate_type.h"
18 #include "ai_scanner.hpp"
19 #include "ai_instance.hpp"
20 #include "ai_config.hpp"
21 #include "ai_info.hpp"
22 #include "ai.hpp"
23 
24 #include "../safeguards.h"
25 
26 /* static */ uint AI::frame_counter = 0;
27 /* static */ AIScannerInfo *AI::scanner_info = nullptr;
28 /* static */ AIScannerLibrary *AI::scanner_library = nullptr;
29 
30 /* static */ bool AI::CanStartNew()
31 {
32  /* Only allow new AIs on the server and only when that is allowed in multiplayer */
34 }
35 
36 /* static */ void AI::StartNew(CompanyID company, bool deviate)
37 {
38  assert(Company::IsValidID(company));
39 
40  /* Clients shouldn't start AIs */
41  if (_networking && !_network_server) return;
42 
43  Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
44  Company *c = Company::Get(company);
45 
46  AIConfig *config = c->ai_config.get();
47  if (config == nullptr) {
48  c->ai_config = std::make_unique<AIConfig>(AIConfig::GetConfig(company, AIConfig::SSS_FORCE_GAME));
49  config = c->ai_config.get();
50  }
51 
52  AIInfo *info = config->GetInfo();
53  if (info == nullptr) {
55  assert(info != nullptr);
56  /* Load default data and store the name in the settings */
57  config->Change(info->GetName(), -1, false);
58  }
59  if (deviate) config->AddRandomDeviation(company);
61 
62  c->ai_info = info;
63  assert(c->ai_instance == nullptr);
64  c->ai_instance = new AIInstance();
65  c->ai_instance->Initialize(info);
66  c->ai_instance->LoadOnStack(config->GetToLoadData());
67  config->SetToLoadData(nullptr);
68 
69  cur_company.Restore();
70 
72  return;
73 }
74 
75 /* static */ void AI::GameLoop()
76 {
77  /* If we are in networking, only servers run this function, and that only if it is allowed */
79 
80  /* The speed with which AIs go, is limited by the 'competitor_speed' */
83  if ((AI::frame_counter & ((1 << (4 - _settings_game.difficulty.competitor_speed)) - 1)) != 0) return;
84 
85  Backup<CompanyID> cur_company(_current_company, FILE_LINE);
86  for (const Company *c : Company::Iterate()) {
87  if (c->is_ai) {
88  PerformanceMeasurer framerate((PerformanceElement)(PFE_AI0 + c->index));
89  cur_company.Change(c->index);
90  c->ai_instance->GameLoop();
91  /* Occasionally collect garbage; every 255 ticks do one company.
92  * Effectively collecting garbage once every two months per AI. */
93  if ((AI::frame_counter & 255) == 0 && (CompanyID)GB(AI::frame_counter, 8, 4) == c->index) {
94  c->ai_instance->CollectGarbage();
95  }
96  } else {
98  }
99  }
100  cur_company.Restore();
101 }
102 
103 /* static */ uint AI::GetTick()
104 {
105  return AI::frame_counter;
106 }
107 
108 /* static */ void AI::Stop(CompanyID company)
109 {
110  if (_networking && !_network_server) return;
112 
113  Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
114  Company *c = Company::Get(company);
115 
116  delete c->ai_instance;
117  c->ai_instance = nullptr;
118  c->ai_info = nullptr;
119  c->ai_config.reset();
120 
121  cur_company.Restore();
122 
124 }
125 
126 /* static */ void AI::Pause(CompanyID company)
127 {
128  /* The reason why dedicated servers are forbidden to execute this
129  * command is not because it is unsafe, but because there is no way
130  * for the server owner to unpause the script again. */
131  if (_network_dedicated) return;
132 
133  Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
134  Company::Get(company)->ai_instance->Pause();
135 
136  cur_company.Restore();
137 }
138 
139 /* static */ void AI::Unpause(CompanyID company)
140 {
141  Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
142  Company::Get(company)->ai_instance->Unpause();
143 
144  cur_company.Restore();
145 }
146 
147 /* static */ bool AI::IsPaused(CompanyID company)
148 {
149  Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
150  bool paused = Company::Get(company)->ai_instance->IsPaused();
151 
152  cur_company.Restore();
153 
154  return paused;
155 }
156 
157 /* static */ void AI::KillAll()
158 {
159  /* It might happen there are no companies .. than we have nothing to loop */
160  if (Company::GetPoolSize() == 0) return;
161 
162  for (const Company *c : Company::Iterate()) {
163  if (c->is_ai) AI::Stop(c->index);
164  }
165 }
166 
167 /* static */ void AI::Initialize()
168 {
169  if (AI::scanner_info != nullptr) AI::Uninitialize(true);
170 
171  AI::frame_counter = 0;
172  if (AI::scanner_info == nullptr) {
175  AI::scanner_info->Initialize();
177  AI::scanner_library->Initialize();
178  }
179 }
180 
181 /* static */ void AI::Uninitialize(bool keepConfig)
182 {
183  AI::KillAll();
184 
185  if (keepConfig) {
186  /* Run a rescan, which indexes all AIInfos again, and check if we can
187  * still load all the AIS, while keeping the configs in place */
188  Rescan();
189  } else {
190  delete AI::scanner_info;
191  delete AI::scanner_library;
192  AI::scanner_info = nullptr;
193  AI::scanner_library = nullptr;
194 
195  for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
196  if (_settings_game.ai_config[c] != nullptr) {
197  delete _settings_game.ai_config[c];
198  _settings_game.ai_config[c] = nullptr;
199  }
200  if (_settings_newgame.ai_config[c] != nullptr) {
201  delete _settings_newgame.ai_config[c];
202  _settings_newgame.ai_config[c] = nullptr;
203  }
204  }
205  }
206 }
207 
208 /* static */ void AI::ResetConfig()
209 {
210  /* Check for both newgame as current game if we can reload the AIInfo inside
211  * the AIConfig. If not, remove the AI from the list (which will assign
212  * a random new AI on reload). */
213  for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
214  if (_settings_game.ai_config[c] != nullptr && _settings_game.ai_config[c]->HasScript()) {
215  if (!_settings_game.ai_config[c]->ResetInfo(true)) {
216  Debug(script, 0, "After a reload, the AI by the name '{}' was no longer found, and removed from the list.", _settings_game.ai_config[c]->GetName());
217  _settings_game.ai_config[c]->Change(std::nullopt);
218  if (Company::IsValidAiID(c)) {
219  /* The code belonging to an already running AI was deleted. We can only do
220  * one thing here to keep everything sane and that is kill the AI. After
221  * killing the offending AI we start a random other one in it's place, just
222  * like what would happen if the AI was missing during loading. */
223  AI::Stop(c);
224  AI::StartNew(c, false);
225  }
226  } else if (Company::IsValidAiID(c)) {
227  /* Update the reference in the Company struct. */
228  Company::Get(c)->ai_info = _settings_game.ai_config[c]->GetInfo();
229  }
230  }
231  if (_settings_newgame.ai_config[c] != nullptr && _settings_newgame.ai_config[c]->HasScript()) {
232  if (!_settings_newgame.ai_config[c]->ResetInfo(false)) {
233  Debug(script, 0, "After a reload, the AI by the name '{}' was no longer found, and removed from the list.", _settings_newgame.ai_config[c]->GetName());
234  _settings_newgame.ai_config[c]->Change(std::nullopt);
235  }
236  }
237  }
238 }
239 
240 /* static */ void AI::NewEvent(CompanyID company, ScriptEvent *event)
241 {
242  /* AddRef() and Release() need to be called at least once, so do it here */
243  event->AddRef();
244 
245  /* Clients should ignore events */
246  if (_networking && !_network_server) {
247  event->Release();
248  return;
249  }
250 
251  /* Only AIs can have an event-queue */
252  if (!Company::IsValidAiID(company)) {
253  event->Release();
254  return;
255  }
256 
257  /* Queue the event */
258  Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
259  Company::Get(_current_company)->ai_instance->InsertEvent(event);
260  cur_company.Restore();
261 
262  event->Release();
263 }
264 
265 /* static */ void AI::BroadcastNewEvent(ScriptEvent *event, CompanyID skip_company)
266 {
267  /* AddRef() and Release() need to be called at least once, so do it here */
268  event->AddRef();
269 
270  /* Clients should ignore events */
271  if (_networking && !_network_server) {
272  event->Release();
273  return;
274  }
275 
276  /* Try to send the event to all AIs */
277  for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
278  if (c != skip_company) AI::NewEvent(c, event);
279  }
280 
281  event->Release();
282 }
283 
284 /* static */ void AI::Save(CompanyID company)
285 {
286  if (!_networking || _network_server) {
287  Company *c = Company::GetIfValid(company);
288  assert(c != nullptr && c->ai_instance != nullptr);
289 
290  Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
291  c->ai_instance->Save();
292  cur_company.Restore();
293  } else {
295  }
296 }
297 
298 /* static */ void AI::GetConsoleList(std::back_insert_iterator<std::string> &output_iterator, bool newest_only)
299 {
300  AI::scanner_info->GetConsoleList(output_iterator, newest_only);
301 }
302 
303 /* static */ void AI::GetConsoleLibraryList(std::back_insert_iterator<std::string> &output_iterator)
304 {
305  AI::scanner_library->GetConsoleList(output_iterator, true);
306 }
307 
308 /* static */ const ScriptInfoList *AI::GetInfoList()
309 {
310  return AI::scanner_info->GetInfoList();
311 }
312 
314 {
316 }
317 
318 /* static */ AIInfo *AI::FindInfo(const std::string &name, int version, bool force_exact_match)
319 {
320  return AI::scanner_info->FindInfo(name, version, force_exact_match);
321 }
322 
323 /* static */ AILibrary *AI::FindLibrary(const std::string &library, int version)
324 {
325  return AI::scanner_library->FindLibrary(library, version);
326 }
327 
328 /* static */ void AI::Rescan()
329 {
331 
334  ResetConfig();
335 
339 }
340 
347 /* static */ bool AI::HasAI(const ContentInfo *ci, bool md5sum)
348 {
349  return AI::scanner_info->HasScript(ci, md5sum);
350 }
351 
352 /* static */ bool AI::HasAILibrary(const ContentInfo *ci, bool md5sum)
353 {
354  return AI::scanner_library->HasScript(ci, md5sum);
355 }
356 
358 {
359  return AI::scanner_info;
360 }
361 
363 {
364  return AI::scanner_library;
365 }
366 
AI::Uninitialize
static void Uninitialize(bool keepConfig)
Uninitialize the AI system.
Definition: ai_core.cpp:181
Backup::Change
void Change(const U &new_value)
Change the value of the variable.
Definition: backup_type.hpp:84
InvalidateWindowData
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
Definition: window.cpp:3200
WC_SCRIPT_DEBUG
@ WC_SCRIPT_DEBUG
Script debug window; Window numbers:
Definition: window_type.h:669
AIConfig
Definition: ai_config.hpp:16
ScriptInfoList
std::map< std::string, class ScriptInfo *, CaseInsensitiveComparator > ScriptInfoList
Type for the list of scripts.
Definition: script_scanner.hpp:16
GameSettings::ai_config
class AIConfig * ai_config[MAX_COMPANIES]
settings per company
Definition: settings_type.h:623
Pool::PoolItem<&_company_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:339
AI::GetScannerInfo
static AIScannerInfo * GetScannerInfo()
Gets the ScriptScanner instance that is used to find AIs.
Definition: ai_core.cpp:357
Pool::PoolItem<&_company_pool >::GetIfValid
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:350
ScriptInstance::Save
void Save()
Call the script Save function and save all data in the savegame.
Definition: script_instance.cpp:476
Backup
Class to backup a specific variable and restore it later.
Definition: backup_type.hpp:21
AIScannerLibrary::FindLibrary
class AILibrary * FindLibrary(const std::string &library, int version)
Find a library in the pool.
Definition: ai_scanner.cpp:148
TarScanner::DoScan
uint DoScan(Subdirectory sd)
Perform the scanning of a particular subdirectory.
Definition: fileio.cpp:427
_network_server
bool _network_server
network-server is active
Definition: network.cpp:60
AIScannerLibrary
Definition: ai_scanner.hpp:53
GB
constexpr static debug_inline uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
Definition: bitmath_func.hpp:32
GameSettings::difficulty
DifficultySettings difficulty
settings related to the difficulty
Definition: settings_type.h:618
AIInstance::Initialize
void Initialize(class AIInfo *info)
Initialize the AI and prepare it for its first run.
Definition: ai_instance.cpp:40
PerformanceMeasurer
RAII class for measuring simple elements of performance.
Definition: framerate_type.h:92
AI::CanStartNew
static bool CanStartNew()
Is it possible to start a new AI company?
Definition: ai_core.cpp:30
ScriptScanner::GetConsoleList
void GetConsoleList(std::back_insert_iterator< std::string > &output_iterator, bool newest_only) const
Get the list of registered scripts to print on the console.
Definition: script_scanner.cpp:141
DifficultySettings::competitor_speed
byte competitor_speed
the speed at which the AI builds
Definition: settings_type.h:106
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
AI::StartNew
static void StartNew(CompanyID company, bool deviate=true)
Start a new AI company.
Definition: ai_core.cpp:36
PerformanceMeasurer::SetInactive
static void SetInactive(PerformanceElement elem)
Mark a performance element as not currently in use.
Definition: framerate_gui.cpp:286
ScriptScanner::RescanDir
void RescanDir()
Rescan the script dir.
Definition: script_scanner.cpp:75
Debug
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
Definition: debug.h:37
PerformanceElement
PerformanceElement
Elements of game performance that can be measured.
Definition: framerate_type.h:47
ScriptScanner::GetUniqueInfoList
const ScriptInfoList * GetUniqueInfoList()
Get the list of the latest version of all registered scripts.
Definition: script_scanner.hpp:49
ScriptInfo::version
int version
Version of the script.
Definition: script_info.hpp:152
ai.hpp
ScriptConfig::Change
void Change(std::optional< const std::string > name, int version=-1, bool force_exact_match=false)
Set another Script to be loaded in this slot.
Definition: script_config.cpp:21
ai_info.hpp
COMPANY_FIRST
@ COMPANY_FIRST
First company, same as owner.
Definition: company_type.h:22
AI::Unpause
static void Unpause(CompanyID company)
Resume execution of the AI.
Definition: ai_core.cpp:139
Pool::PoolItem<&_company_pool >::GetPoolSize
static size_t GetPoolSize()
Returns first unused index.
Definition: pool_type.hpp:360
AI::GetConsoleLibraryList
static void GetConsoleLibraryList(std::back_insert_iterator< std::string > &output_iterator)
Wrapper function for AIScanner::GetAIConsoleLibraryList.
Definition: ai_core.cpp:303
AI::NewEvent
static void NewEvent(CompanyID company, ScriptEvent *event)
Queue a new event for an AI.
Definition: ai_core.cpp:240
AI::scanner_library
static class AIScannerLibrary * scanner_library
ScriptScanner instance that is used to find AI Libraries.
Definition: ai.hpp:144
AI::Save
static void Save(CompanyID company)
Save data from an AI to a savegame.
Definition: ai_core.cpp:284
ContentInfo
Container for all important information about a piece of content.
Definition: tcp_content_type.h:52
ScriptInstance::SaveEmpty
static void SaveEmpty()
Don't save any data in the savegame.
Definition: script_instance.cpp:470
AILibrary
All static information from an AI library like name, version, etc.
Definition: ai_info.hpp:57
ai_instance.hpp
AIConfig::GetConfig
static AIConfig * GetConfig(CompanyID company, ScriptSettingSource source=SSS_DEFAULT)
Get the config of a company.
Definition: ai_config.cpp:20
AI::Pause
static void Pause(CompanyID company)
Suspend the AI and then pause execution of the script.
Definition: ai_core.cpp:126
AI::GetScannerLibrary
static AIScannerLibrary * GetScannerLibrary()
Gets the ScriptScanner instance that is used to find AI Libraries.
Definition: ai_core.cpp:362
AI::Initialize
static void Initialize()
Initialize the AI system.
Definition: ai_core.cpp:167
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:55
AI::scanner_info
static class AIScannerInfo * scanner_info
ScriptScanner instance that is used to find AIs.
Definition: ai.hpp:143
MAX_COMPANIES
@ MAX_COMPANIES
Maximum number of companies.
Definition: company_type.h:23
AI::HasAI
static bool HasAI(const struct ContentInfo *ci, bool md5sum)
Wrapper function for AIScanner::HasAI.
Definition: ai_core.cpp:347
AI::BroadcastNewEvent
static void BroadcastNewEvent(ScriptEvent *event, CompanyID skip_company=MAX_COMPANIES)
Broadcast a new event to all active AIs.
Definition: ai_core.cpp:265
ScriptInfo::GetName
const std::string & GetName() const
Get the Name of the script.
Definition: script_info.hpp:46
AI::GetInfoList
static const ScriptInfoList * GetInfoList()
Wrapper function for AIScanner::GetAIInfoList.
Definition: ai_core.cpp:308
Company::IsValidAiID
static bool IsValidAiID(size_t index)
Is this company a valid company, controlled by the computer (a NoAI program)?
Definition: company_base.h:139
AIScannerInfo
Definition: ai_scanner.hpp:15
_networking
bool _networking
are we in networking mode?
Definition: network.cpp:59
AI::GetTick
static uint GetTick()
Get the current AI tick.
Definition: ai_core.cpp:103
_network_dedicated
bool _network_dedicated
are we a dedicated server?
Definition: network.cpp:62
AI::GameLoop
static void GameLoop()
Called every game-tick to let AIs do something.
Definition: ai_core.cpp:75
AI::FindLibrary
static class AILibrary * FindLibrary(const std::string &library, int version)
Wrapper function for AIScanner::FindLibrary.
Definition: ai_core.cpp:323
AI::IsPaused
static bool IsPaused(CompanyID company)
Checks if the AI is paused.
Definition: ai_core.cpp:147
AI::frame_counter
static uint frame_counter
Tick counter for the AI code.
Definition: ai.hpp:142
GameSettings::ai
AISettings ai
what may the AI do?
Definition: settings_type.h:621
_current_company
CompanyID _current_company
Company currently doing an action.
Definition: company_cmd.cpp:51
Pool::PoolItem<&_company_pool >::Iterate
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Definition: pool_type.hpp:388
ScriptScanner::HasScript
bool HasScript(const struct ContentInfo *ci, bool md5sum)
Check whether we have a script with the exact characteristics as ci.
Definition: script_scanner.cpp:237
ScriptConfig::AnchorUnchangeableSettings
void AnchorUnchangeableSettings()
As long as the default of a setting has not been changed, the value of the setting is not stored.
Definition: script_config.cpp:73
ScriptScanner::GetInfoList
const ScriptInfoList * GetInfoList()
Get the list of all registered scripts.
Definition: script_scanner.hpp:44
AI::KillAll
static void KillAll()
Kill any and all AIs we manage.
Definition: ai_core.cpp:157
Backup::Restore
void Restore()
Restore the variable.
Definition: backup_type.hpp:112
TarScanner::AI
@ AI
Scan for AIs and its libraries.
Definition: fileio_func.h:67
InvalidateWindowClassesData
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
Definition: window.cpp:3217
ScriptInfo::name
std::string name
Full name of the script.
Definition: script_info.hpp:147
ScriptInstance::LoadOnStack
void LoadOnStack(ScriptData *data)
Store loaded data on the stack.
Definition: script_instance.cpp:690
ai_scanner.hpp
AIInfo
All static information from an AI like name, version, etc.
Definition: ai_info.hpp:16
AI::GetUniqueInfoList
static const ScriptInfoList * GetUniqueInfoList()
Wrapper function for AIScanner::GetUniqueAIInfoList.
Definition: ai_core.cpp:313
AIInstance
Runtime information about an AI like a pointer to the squirrel vm and the current state.
Definition: ai_instance.hpp:16
AI::GetConsoleList
static void GetConsoleList(std::back_insert_iterator< std::string > &output_iterator, bool newest_only)
Wrapper function for AIScanner::GetAIConsoleList.
Definition: ai_core.cpp:298
AI::FindInfo
static class AIInfo * FindInfo(const std::string &name, int version, bool force_exact_match)
Wrapper function for AIScanner::FindInfo.
Definition: ai_core.cpp:318
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:328
PFE_AI0
@ PFE_AI0
AI execution for player slot 1.
Definition: framerate_type.h:63
AI::Stop
static void Stop(CompanyID company)
Stop a company to be controlled by an AI.
Definition: ai_core.cpp:108
WC_SCRIPT_SETTINGS
@ WC_SCRIPT_SETTINGS
Script settings; Window numbers:
Definition: window_type.h:175
ScriptConfig::AddRandomDeviation
void AddRandomDeviation(CompanyID owner)
Randomize all settings the Script requested to be randomized.
Definition: script_config.cpp:126
WC_SCRIPT_LIST
@ WC_SCRIPT_LIST
Scripts list; Window numbers:
Definition: window_type.h:284
AI::Rescan
static void Rescan()
Rescans all searchpaths for available AIs.
Definition: ai_core.cpp:328
Company
Definition: company_base.h:116
SetWindowClassesDirty
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
Definition: window.cpp:3108
ScriptConfig::SSS_FORCE_GAME
@ SSS_FORCE_GAME
Get the Script config from the current game.
Definition: script_config.hpp:98
AI::ResetConfig
static void ResetConfig()
Reset all AIConfigs, and make them reload their AIInfo.
Definition: ai_core.cpp:208
ScriptConfig::HasScript
bool HasScript() const
Is this config attached to an Script? In other words, is there a Script that is assigned to this slot...
Definition: script_config.cpp:135
AIScannerInfo::FindInfo
class AIInfo * FindInfo(const std::string &name, int version, bool force_exact_match)
Check if we have an AI by name and version available in our list.
Definition: ai_scanner.cpp:95
AISettings::ai_in_multiplayer
bool ai_in_multiplayer
so we allow AIs in multiplayer
Definition: settings_type.h:399
AIScannerInfo::SelectRandomAI
class AIInfo * SelectRandomAI() const
Select a random AI.
Definition: ai_scanner.cpp:61
_settings_newgame
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
Definition: settings.cpp:56
AIConfig::ResetInfo
bool ResetInfo(bool force_exact_match)
When ever the AI Scanner is reloaded, all infos become invalid.
Definition: ai_config.cpp:48
ai_config.hpp
ScriptConfig::GetName
const std::string & GetName() const
Get the name of the Script.
Definition: script_config.cpp:140