Freeciv21
Develop your civilization from humble roots to a global empire
aidata.h
Go to the documentation of this file.
1 /**************************************************************************
2  Copyright (c) 1996-2020 Freeciv21 and Freeciv contributors. This file is
3  part of Freeciv21. Freeciv21 is free software: you can redistribute it
4  and/or modify it under the terms of the GNU General Public License as
5  published by the Free Software Foundation, either version 3 of the
6  License, or (at your option) any later version. You should have received
7  a copy of the GNU General Public License along with Freeciv21. If not,
8  see https://www.gnu.org/licenses/.
9 **************************************************************************/
10 #pragma once
11 
12 #include <QHash>
13 // utility
14 #include "support.h"
15 
16 // common
17 #include "fc_types.h"
18 #include "tech.h"
19 
20 /* server/advisors */
21 #include "advtools.h"
22 
23 struct player;
24 
26  WIN_OPEN, // still undetermined
27  WIN_SPACE, // we will race for space, peace very important
28  WIN_CAPITAL // we cannot win unless we take war_target's capital
29 };
30 
31 #define SPECENUM_NAME war_reason
32 #define SPECENUM_VALUE0 DAI_WR_BEHAVIOUR
33 #define SPECENUM_VALUE0NAME "Behaviour"
34 #define SPECENUM_VALUE1 DAI_WR_SPACE
35 #define SPECENUM_VALUE1NAME "Space"
36 #define SPECENUM_VALUE2 DAI_WR_EXCUSE
37 #define SPECENUM_VALUE2NAME "Excuse"
38 #define SPECENUM_VALUE3 DAI_WR_HATRED
39 #define SPECENUM_VALUE3NAME "Hatred"
40 #define SPECENUM_VALUE4 DAI_WR_ALLIANCE
41 #define SPECENUM_VALUE4NAME "Alliance"
42 #define SPECENUM_VALUE5 DAI_WR_NONE
43 #define SPECENUM_VALUE5NAME "None"
44 #include "specenum_gen.h"
45 
46 struct ai_dip_intel {
47  // Remember one example of each for text spam purposes.
51 
52  signed char spam; // timer to avoid spamming a player with chat
53  int distance; // average distance to that player's cities
54  int countdown; // we're on a countdown to war declaration
55  enum war_reason war_reason; // why we declare war
56  signed char ally_patience; // we EXPECT our allies to help us!
57  signed char asked_about_peace; // don't ask again
58  signed char asked_about_alliance; // don't nag!
59  signed char asked_about_ceasefire; // don't ... you get the point
60  signed char warned_about_space;
61 };
62 
63 struct ai_plr {
65 
68 
69  struct {
70  int passengers; // number of passengers waiting for boats
71  int boats;
73 
74  int *workers; // cities to workers on continent
76 
78  } stats;
79 
80  // AI diplomacy and opinions on other players
81  struct {
84  int timer; // pursue our goals with some stubbornness, in turns
85  char love_coeff; // Reduce love with this % each turn
86  char love_incr; // Modify love with this fixed amount
90 
91  // Cache map for AI settlers; defined in aisettler.c.
93 
94  // The units of tech_want seem to be shields
96 };
97 
98 void dai_data_init(struct ai_type *ait, struct player *pplayer);
99 void dai_data_close(struct ai_type *ait, struct player *pplayer);
100 
101 void dai_data_phase_begin(struct ai_type *ait, struct player *pplayer,
102  bool is_new_phase);
103 void dai_data_phase_finished(struct ai_type *ait, struct player *pplayer);
104 bool is_ai_data_phase_open(struct ai_type *ait, struct player *pplayer);
105 
106 struct ai_plr *dai_plr_data_get(struct ai_type *ait, struct player *pplayer,
107  bool *caller_closes);
108 
109 struct ai_dip_intel *dai_diplomacy_get(struct ai_type *ait,
110  const struct player *plr1,
111  const struct player *plr2);
112 
113 void dai_gov_value(struct ai_type *ait, struct player *pplayer,
114  struct government *gov, adv_want *val, bool *override);
115 
116 void dai_adjust_policies(struct ai_type *ait, struct player *pplayer);
winning_strategy
Definition: aidata.h:25
@ WIN_SPACE
Definition: aidata.h:27
@ WIN_CAPITAL
Definition: aidata.h:28
@ WIN_OPEN
Definition: aidata.h:26
bool is_ai_data_phase_open(struct ai_type *ait, struct player *pplayer)
Return whether data phase is currently open.
Definition: aidata.cpp:128
void dai_gov_value(struct ai_type *ait, struct player *pplayer, struct government *gov, adv_want *val, bool *override)
Set value of the government.
Definition: aidata.cpp:533
struct ai_dip_intel * dai_diplomacy_get(struct ai_type *ait, const struct player *plr1, const struct player *plr2)
Returns diplomatic state type between two players.
Definition: aidata.cpp:397
void dai_adjust_policies(struct ai_type *ait, struct player *pplayer)
Adjust multiplier values.
Definition: aidata.cpp:437
void dai_data_init(struct ai_type *ait, struct player *pplayer)
Initialize ai data structure.
Definition: aidata.cpp:50
void dai_data_phase_begin(struct ai_type *ait, struct player *pplayer, bool is_new_phase)
Make and cache lots of calculations needed for other functions.
Definition: aidata.cpp:138
void dai_data_phase_finished(struct ai_type *ait, struct player *pplayer)
Clean up ai data after phase finished.
Definition: aidata.cpp:281
struct ai_plr * dai_plr_data_get(struct ai_type *ait, struct player *pplayer, bool *caller_closes)
Get current default ai data related to player.
Definition: aidata.cpp:304
void dai_data_close(struct ai_type *ait, struct player *pplayer)
Deinitialize ai data structure.
Definition: aidata.cpp:98
float adv_want
Definition: fc_types.h:1144
struct player * at_war_with_ally
Definition: aidata.h:49
signed char asked_about_alliance
Definition: aidata.h:58
enum war_reason war_reason
Definition: aidata.h:55
signed char spam
Definition: aidata.h:52
signed char asked_about_peace
Definition: aidata.h:57
int distance
Definition: aidata.h:53
struct player * is_allied_with_ally
Definition: aidata.h:50
signed char warned_about_space
Definition: aidata.h:60
int countdown
Definition: aidata.h:54
signed char ally_patience
Definition: aidata.h:56
struct player * is_allied_with_enemy
Definition: aidata.h:48
signed char asked_about_ceasefire
Definition: aidata.h:59
Definition: aidata.h:63
int passengers
Definition: aidata.h:70
int * ocean_workers
Definition: aidata.h:75
int last_num_oceans
Definition: aidata.h:67
int * workers
Definition: aidata.h:74
int last_num_continents
Definition: aidata.h:66
bool phase_initialized
Definition: aidata.h:64
struct ai_plr::@156 diplomacy
int boats
Definition: aidata.h:71
struct ai_settler * settler
Definition: aidata.h:92
adv_want tech_want[A_LAST+1]
Definition: aidata.h:95
int req_love_for_alliance
Definition: aidata.h:88
int timer
Definition: aidata.h:84
char love_incr
Definition: aidata.h:86
char love_coeff
Definition: aidata.h:85
QSet< int > diplomat_reservations
Definition: aidata.h:77
const struct ai_dip_intel ** player_intel_slots
Definition: aidata.h:82
int available_boats
Definition: aidata.h:72
struct ai_plr::@155 stats
int req_love_for_peace
Definition: aidata.h:87
enum winning_strategy strategy
Definition: aidata.h:83
Definition: ai.h:42
Definition: player.h:231
#define A_LAST
Definition: tech.h:38