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
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 */
38};
39
40struct adv_dipl {
41 /* Remember one example of each for text spam purposes. */
43};
44
46 int size;
47 bool threat;
48};
49
50struct adv_data {
51 /* Whether adv_data_phase_init() has been called or not. */
53
54 /* The Wonder City */
56
57 /* Precalculated info about city improvements */
60
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 */
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 */
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. */
87
88 /* Unit can do action counts. */
90
92
93 /* Upgradeable units */
96 int *cities; /* Number of cities we have on continent */
97 int *ocean_cities; /* Number of cities we have on ocean */
100
101 struct {
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 */
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 */
123
124 /* Government data */
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 */
137
138 /* Whether science would benefit player at all */
140
141 /* If the AI celebrates. */
143
144 /* AI doesn't like having more than this number of 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
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 */
void adv_data_analyze_rulesets(struct player *pplayer)
Definition advdata.c:192
void adv_data_close(struct player *pplayer)
Definition advdata.c:755
adv_want adv_gov_player_bonus_want(struct player *pplayer)
Definition advdata.c:957
struct adv_data * adv_data_get(struct player *pplayer, bool *close)
Definition advdata.c:606
void adv_data_init(struct player *pplayer)
Definition advdata.c:699
bool is_adv_data_phase_open(struct player *pplayer)
Definition advdata.c:243
bool adv_wants_science(struct player *pplayer)
Definition advdata.c:1102
bool adv_data_phase_init(struct player *pplayer, bool is_new_phase)
Definition advdata.c:263
void adv_data_phase_done(struct player *pplayer)
Definition advdata.c:566
bool adv_is_player_dangerous(struct player *pplayer, struct player *aplayer)
Definition advdata.c:1113
adv_want adv_gov_action_immunity_want(struct government *gov)
Definition advdata.c:826
void adv_best_government(struct player *pplayer)
Definition advdata.c:985
void adv_data_default(struct player *pplayer)
Definition advdata.c:732
adv_improvement_status
Definition advdata.h:33
@ ADV_IMPR_CALCULATE_FULL
Definition advdata.h:35
@ ADV_IMPR_LAST
Definition advdata.h:37
@ ADV_IMPR_ESTIMATE
Definition advdata.h:36
@ ADV_IMPR_CALCULATE
Definition advdata.h:34
char * incite_cost
Definition comments.c:76
float adv_want
Definition fc_types.h:1063
#define UCL_LAST
Definition fc_types.h:274
#define B_LAST
Definition improvement.h:42
bool threat
Definition advdata.h:47
bool wants_science
Definition advdata.h:139
int req
Definition advdata.h:133
short govt_reeval
Definition advdata.h:126
adv_want val
Definition advdata.h:132
int pollution_priority
Definition advdata.h:121
int shield_priority
Definition advdata.h:113
bool * ocean
Definition advdata.h:74
int coast_strict
Definition advdata.h:86
struct adv_data::@95 dipl
int average_production
Definition advdata.h:98
int * cities
Definition advdata.h:96
int * ocean_cities
Definition advdata.h:97
bool invasions
Definition advdata.h:66
struct government * revolution
Definition advdata.h:135
int infra_priority
Definition advdata.h:122
struct adv_dipl ** adv_dipl_slots
Definition advdata.h:102
bool igwall
Definition advdata.h:69
bool celebrate
Definition advdata.h:142
int num_oceans
Definition advdata.h:110
struct adv_data::@96 goal
int unhappy_priority
Definition advdata.h:119
int byclass[UCL_LAST]
Definition advdata.h:91
int luxury_priority
Definition advdata.h:115
int nuclear
Definition advdata.h:68
int angry_priority
Definition advdata.h:120
int upgradeable
Definition advdata.h:94
int food_priority
Definition advdata.h:114
int max_num_cities
Definition advdata.h:145
int num_continents
Definition advdata.h:109
adv_want * government_want
Definition advdata.h:125
struct adv_area_info * oceans
Definition advdata.h:62
bool suicide_attack
Definition advdata.h:67
struct player * production_leader
Definition advdata.h:106
struct adv_data::@92 threats
struct government * gov
Definition advdata.h:131
struct adv_area_info * continents
Definition advdata.h:61
int airliftable
Definition advdata.h:89
int happy_priority
Definition advdata.h:118
bool * continent
Definition advdata.h:75
struct adv_data::@93 explore
struct adv_data::@94::@97 units
bool sea_done
Definition advdata.h:77
enum adv_improvement_status impr_calc[B_LAST]
Definition advdata.h:58
int suicide_attackers
Definition advdata.h:89
bool phase_is_initialized
Definition advdata.h:52
int wonder_city
Definition advdata.h:55
enum req_range impr_range[B_LAST]
Definition advdata.h:59
int science_priority
Definition advdata.h:117
int gold_priority
Definition advdata.h:116
bool land_done
Definition advdata.h:76
struct player * tech_leader
Definition advdata.h:105
int paratroopers
Definition advdata.h:89
struct player * spacerace_leader
Definition advdata.h:104
struct adv_data::@94 stats
bool allied_with_enemy
Definition advdata.h:42