1
/* $Id: ai.hpp 15324 2009-02-03 18:08:07Z smatz $ */
3
/** @file ai.hpp Base functions for all AIs. */
8
#include "api/ai_event_types.hpp"
9
#include "../date_type.h"
10
#include "../core/string_compare_type.hpp"
12
typedef std::map<const char *, class AIInfo *, StringCompare> AIInfoList;
15
void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2);
20
* The default months AIs start after eachother.
23
START_NEXT_EASY = DAYS_IN_YEAR * 2,
24
START_NEXT_MEDIUM = DAYS_IN_YEAR,
25
START_NEXT_HARD = DAYS_IN_YEAR / 2,
27
START_NEXT_MAX = 3600,
28
START_NEXT_DEVIATION = 60,
32
* Is it possible to start a new AI company?
33
* @return True if a new AI company can be started.
35
static bool CanStartNew();
38
* Start a new AI company.
39
* @param company At which slot the AI company should start.
41
static void StartNew(CompanyID company);
44
* Called every game-tick to let AIs do something.
46
static void GameLoop();
49
* Get the current AI tick.
51
static uint GetTick();
54
* Stop a company to be controlled by an AI.
55
* @param company The company from which the AI needs to detach.
56
* @pre !IsHumanCompany(company).
58
static void Stop(CompanyID company);
61
* Kill any and all AIs we manage.
63
static void KillAll();
66
* Initialize the AI system.
68
static void Initialize();
71
* Uninitialize the AI system
72
* @param keepConfig Should we keep AIConfigs, or can we free that memory?
74
static void Uninitialize(bool keepConfig);
77
* Reset all AIConfigs, and make them reload their AIInfo.
78
* If the AIInfo could no longer be found, an error is reported to the user.
80
static void ResetConfig();
83
* Queue a new event for an AI.
85
static void NewEvent(CompanyID company, AIEvent *event);
88
* Broadcast a new event to all active AIs.
90
static void BroadcastNewEvent(AIEvent *event, CompanyID skip_company = MAX_COMPANIES);
93
* Save data from an AI to a savegame.
95
static void Save(CompanyID company);
98
* Load data for an AI from a savegame.
100
static void Load(CompanyID company, int version);
103
* Get the number of days before the next AI should start.
105
static int GetStartNextTime();
107
static char *GetConsoleList(char *p, const char *last);
108
static const AIInfoList *GetInfoList();
109
static const AIInfoList *GetUniqueInfoList();
110
static AIInfo *FindInfo(const char *name, int version);
111
static bool ImportLibrary(const char *library, const char *class_name, int version, HSQUIRRELVM vm);
112
static void Rescan();
113
#if defined(ENABLE_NETWORK)
114
static bool HasAI(const struct ContentInfo *ci, bool md5sum);
117
static uint frame_counter;
118
static class AIScanner *ai_scanner;