Freeciv-3.3: /fast/freeciv/nightly/main/server/advisors/advdata.h Source File

Freeciv-3.3

Loading...
Searching...
No Matches
advdata.h
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2002 - The Freeciv Project
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13#ifndef FC__ADVDATA_H
14#define FC__ADVDATA_H
15
16/* utility */
17#include "bitvector.h"
18#include "support.h" /* bool type */
19
20/* common */
21#include "fc_types.h"
22#include "improvement.h"
23
24/* server/advisors */
25#include "advtools.h"
26
27/*
28 * This file and advdata.c contains global data structures for the AI
29 * and some of the functions that fill them with useful values at the
30 * start of every turn.
31 */
32
33 enum adv_improvement_status {
34 ADV_IMPR_CALCULATE, /* Calculate exactly its effect */
35 ADV_IMPR_CALCULATE_FULL, /* Calculate including tile changes */
36 ADV_IMPR_ESTIMATE, /* Estimate its effect using wild guesses */
37 ADV_IMPR_LAST
38};
39
40 struct adv_dipl {
41 /* Remember one example of each for text spam purposes. */
42 bool allied_with_enemy;
43};
44
45 struct adv_area_info {
46 int size;
47 bool threat;
48};
49
50 struct adv_data {
51 /* Whether adv_data_phase_init() has been called or not. */
52 bool phase_is_initialized;
53
54 /* The Wonder City */
55 int wonder_city;
56
57 /* Precalculated info about city improvements */
58 enum adv_improvement_status impr_calc[B_LAST];
59 enum req_range impr_range[B_LAST];
60
61 struct adv_area_info *continents;
62 struct adv_area_info *oceans;
63
64 /* Long-term threats, not to be confused with short-term danger */
65 struct {
66 bool invasions; /* check if we need to consider invasions */
67 bool suicide_attack; /* check for non-allied missiles */
68 int nuclear; /* nuke check: 0 = no, 1 = capability, 2 = built */
69 bool igwall; /* enemies have igwall units */
70 } threats;
71
72 /* Keeps track of which continents are fully explored already */
73 struct {
74 bool *ocean; /* are we done exploring this ocean? */
75 bool *continent; /* are we done exploring this continent? */
76 bool land_done; /* nothing more on land to explore anywhere */
77 bool sea_done; /* nothing more to explore at sea */
78 } explore;
79
80 /* This struct is used for statistical unit building, eg to ensure
81 * that we don't build too few or too many units of a given type. */
82 struct {
83 /* Counts of specific types of units. */
84 struct {
85 /* Unit-flag counts. */
86 int coast_strict;
87
88 /* Unit can do action counts. */
89 int suicide_attackers, paratroopers, airliftable;
90
91 int byclass[UCL_LAST];
92
93 /* Upgradeable units */
94 int upgradeable;
95 } units;
96 int *cities; /* Number of cities we have on continent */
97 int *ocean_cities; /* Number of cities we have on ocean */
98 int average_production;
99 } stats;
100
101 struct {
102 struct adv_dipl **adv_dipl_slots;
103
104 struct player *spacerace_leader; /* Who is leading the space pack */
105 struct player *tech_leader; /* Who is first to get spacerace techs */
106 struct player *production_leader; /* Who is quickest to build spaceship */
107 } dipl;
108
109 int num_continents; /* last time we updated our continent data */
110 int num_oceans; /* last time we updated our continent data */
111
112 /* Dynamic weights used in addition to Syela's hardcoded weights */
113 int shield_priority;
114 int food_priority;
115 int luxury_priority;
116 int gold_priority;
117 int science_priority;
118 int happy_priority;
119 int unhappy_priority;
120 int angry_priority;
121 int pollution_priority;
122 int infra_priority;
123
124 /* Government data */
125 adv_want *government_want;
126 short govt_reeval;
127
128 /* Goals */
129 struct {
130 struct {
131 struct government *gov; /* The ideal government */
132 adv_want val; /* Its value (relative to the current gov) */
133 int req; /* The tech requirement for the ideal gov */
134 } govt;
135 struct government *revolution; /* The best gov of the now available */
136 } goal;
137
138 /* Whether science would benefit player at all */
139 bool wants_science;
140
141 /* If the AI celebrates. */
142 bool celebrate;
143
144 /* AI doesn't like having more than this number of cities */
145 int max_num_cities;
146};
147
148void adv_data_init(struct player *pplayer);
149void adv_data_default(struct player *pplayer);
150void adv_data_close(struct player *pplayer);
151
152bool adv_data_phase_init(struct player *pplayer, bool is_new_phase);
153void adv_data_phase_done(struct player *pplayer);
154bool is_adv_data_phase_open(struct player *pplayer);
155
156void adv_data_analyze_rulesets(struct player *pplayer);
157
158struct adv_data *adv_data_get(struct player *pplayer, bool *close);
159
160 adv_want adv_gov_action_immunity_want(struct government *gov);
161 adv_want adv_gov_player_bonus_want(struct player *pplayer);
162void adv_best_government(struct player *pplayer);
163
164bool adv_wants_science(struct player *pplayer);
165
166bool adv_is_player_dangerous(struct player *pplayer,
167 struct player *aplayer);
168
169#endif /* FC__ADVDATA_H */
adv_data_analyze_rulesets
void adv_data_analyze_rulesets(struct player *pplayer)
Definition advdata.c:191
adv_data_close
void adv_data_close(struct player *pplayer)
Definition advdata.c:752
adv_gov_player_bonus_want
adv_want adv_gov_player_bonus_want(struct player *pplayer)
Definition advdata.c:951
adv_data_get
struct adv_data * adv_data_get(struct player *pplayer, bool *close)
Definition advdata.c:604
adv_data_init
void adv_data_init(struct player *pplayer)
Definition advdata.c:697
is_adv_data_phase_open
bool is_adv_data_phase_open(struct player *pplayer)
Definition advdata.c:242
adv_wants_science
bool adv_wants_science(struct player *pplayer)
Definition advdata.c:1095
adv_data_phase_init
bool adv_data_phase_init(struct player *pplayer, bool is_new_phase)
Definition advdata.c:262
adv_data_phase_done
void adv_data_phase_done(struct player *pplayer)
Definition advdata.c:564
adv_is_player_dangerous
bool adv_is_player_dangerous(struct player *pplayer, struct player *aplayer)
Definition advdata.c:1106
adv_gov_action_immunity_want
adv_want adv_gov_action_immunity_want(struct government *gov)
Definition advdata.c:823
adv_best_government
void adv_best_government(struct player *pplayer)
Definition advdata.c:979
adv_data_default
void adv_data_default(struct player *pplayer)
Definition advdata.c:729
adv_improvement_status
adv_improvement_status
Definition advdata.h:33
ADV_IMPR_CALCULATE_FULL
@ ADV_IMPR_CALCULATE_FULL
Definition advdata.h:35
ADV_IMPR_LAST
@ ADV_IMPR_LAST
Definition advdata.h:37
ADV_IMPR_ESTIMATE
@ ADV_IMPR_ESTIMATE
Definition advdata.h:36
ADV_IMPR_CALCULATE
@ ADV_IMPR_CALCULATE
Definition advdata.h:34
advtools.h
bitvector.h
incite_cost
char * incite_cost
Definition comments.c:74
fc_types.h
adv_want
float adv_want
Definition fc_types.h:1365
UCL_LAST
#define UCL_LAST
Definition fc_types.h:421
improvement.h
B_LAST
#define B_LAST
Definition improvement.h:42
adv_area_info
Definition advdata.h:45
adv_area_info::size
int size
Definition advdata.h:46
adv_area_info::threat
bool threat
Definition advdata.h:47
adv_data
Definition advdata.h:50
adv_data::wants_science
bool wants_science
Definition advdata.h:139
adv_data::req
int req
Definition advdata.h:133
adv_data::govt_reeval
short govt_reeval
Definition advdata.h:126
adv_data::val
adv_want val
Definition advdata.h:132
adv_data::pollution_priority
int pollution_priority
Definition advdata.h:121
adv_data::shield_priority
int shield_priority
Definition advdata.h:113
adv_data::ocean
bool * ocean
Definition advdata.h:74
adv_data::threats
struct adv_data::@89 threats
adv_data::coast_strict
int coast_strict
Definition advdata.h:86
adv_data::average_production
int average_production
Definition advdata.h:98
adv_data::cities
int * cities
Definition advdata.h:96
adv_data::ocean_cities
int * ocean_cities
Definition advdata.h:97
adv_data::invasions
bool invasions
Definition advdata.h:66
adv_data::revolution
struct government * revolution
Definition advdata.h:135
adv_data::infra_priority
int infra_priority
Definition advdata.h:122
adv_data::adv_dipl_slots
struct adv_dipl ** adv_dipl_slots
Definition advdata.h:102
adv_data::igwall
bool igwall
Definition advdata.h:69
adv_data::celebrate
bool celebrate
Definition advdata.h:142
adv_data::dipl
struct adv_data::@92 dipl
adv_data::units
struct adv_data::@91::@94 units
adv_data::num_oceans
int num_oceans
Definition advdata.h:110
adv_data::unhappy_priority
int unhappy_priority
Definition advdata.h:119
adv_data::byclass
int byclass[UCL_LAST]
Definition advdata.h:91
adv_data::luxury_priority
int luxury_priority
Definition advdata.h:115
adv_data::nuclear
int nuclear
Definition advdata.h:68
adv_data::angry_priority
int angry_priority
Definition advdata.h:120
adv_data::upgradeable
int upgradeable
Definition advdata.h:94
adv_data::food_priority
int food_priority
Definition advdata.h:114
adv_data::max_num_cities
int max_num_cities
Definition advdata.h:145
adv_data::num_continents
int num_continents
Definition advdata.h:109
adv_data::government_want
adv_want * government_want
Definition advdata.h:125
adv_data::oceans
struct adv_area_info * oceans
Definition advdata.h:62
adv_data::suicide_attack
bool suicide_attack
Definition advdata.h:67
adv_data::production_leader
struct player * production_leader
Definition advdata.h:106
adv_data::gov
struct government * gov
Definition advdata.h:131
adv_data::goal
struct adv_data::@93 goal
adv_data::continents
struct adv_area_info * continents
Definition advdata.h:61
adv_data::airliftable
int airliftable
Definition advdata.h:89
adv_data::happy_priority
int happy_priority
Definition advdata.h:118
adv_data::continent
bool * continent
Definition advdata.h:75
adv_data::stats
struct adv_data::@91 stats
adv_data::sea_done
bool sea_done
Definition advdata.h:77
adv_data::impr_calc
enum adv_improvement_status impr_calc[B_LAST]
Definition advdata.h:58
adv_data::suicide_attackers
int suicide_attackers
Definition advdata.h:89
adv_data::phase_is_initialized
bool phase_is_initialized
Definition advdata.h:52
adv_data::wonder_city
int wonder_city
Definition advdata.h:55
adv_data::impr_range
enum req_range impr_range[B_LAST]
Definition advdata.h:59
adv_data::explore
struct adv_data::@90 explore
adv_data::science_priority
int science_priority
Definition advdata.h:117
adv_data::gold_priority
int gold_priority
Definition advdata.h:116
adv_data::land_done
bool land_done
Definition advdata.h:76
adv_data::tech_leader
struct player * tech_leader
Definition advdata.h:105
adv_data::paratroopers
int paratroopers
Definition advdata.h:89
adv_data::spacerace_leader
struct player * spacerace_leader
Definition advdata.h:104
adv_dipl
Definition advdata.h:40
adv_dipl::allied_with_enemy
bool allied_with_enemy
Definition advdata.h:42
government
Definition government.h:52
player
Definition player.h:249
support.h