Freeciv-3.1
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
45struct adv_data {
46 /* Whether adv_data_phase_init() has been called or not. */
48
49 /* The Wonder City */
51
52 /* Precalculated info about city improvements */
54 enum req_range impr_range[B_LAST];
55
56 /* Long-term threats, not to be confused with short-term danger */
57 struct {
58 bool invasions; /* check if we need to consider invasions */
59 bool *continent; /* non-allied cities on continent? */
60 bool *ocean; /* non-allied offensive ships in ocean? */
61 bool suicide_attack; /* check for non-allied missiles */
62 int nuclear; /* nuke check: 0=no, 1=capability, 2=built */
63 bool igwall; /* enemies have igwall units */
65
66 /* Keeps track of which continents are fully explored already */
67 struct {
68 bool *ocean; /* are we done exploring this ocean? */
69 bool *continent; /* are we done exploring this continent? */
70 bool land_done; /* nothing more on land to explore anywhere */
71 bool sea_done; /* nothing more to explore at sea */
73
74 /* This struct is used for statistical unit building, eg to ensure
75 * that we don't build too few or too many units of a given type. */
76 struct {
77 /* Counts of specific types of units. */
78 struct {
79 /* Unit-flag counts. */
81
82 /* Unit can do action counts. */
84
86
87 /* Upgradeable units */
90 int *cities; /* Number of cities we have on continent */
91 int *ocean_cities; /* Number of cities we have on ocean */
94
95 struct {
97
98 struct player *spacerace_leader; /* Who is leading the space pack */
99 struct player *tech_leader; /* Who is first to get spacerace techs */
100 struct player *production_leader; /* Who is quickest to build spaceship */
102
103 int num_continents; /* last time we updated our continent data */
104 int num_oceans; /* last time we updated our continent data */
105
106 /* Dynamic weights used in addition to Syela's hardcoded weights */
117
118 /* Government data */
121
122 /* Goals */
123 struct {
124 struct {
125 struct government *gov; /* The ideal government */
126 adv_want val; /* Its value (relative to the current gov) */
127 int req; /* The tech requirement for the ideal gov */
128 } govt;
129 struct government *revolution; /* The best gov of the now available */
131
132 /* Whether science would benefit player at all */
134
135 /* If the AI celebrates. */
137
138 /* AI doesn't like having more than this number of cities */
140};
141
142void adv_data_init(struct player *pplayer);
143void adv_data_default(struct player *pplayer);
144void adv_data_close(struct player *pplayer);
145
146bool adv_data_phase_init(struct player *pplayer, bool is_new_phase);
147void adv_data_phase_done(struct player *pplayer);
148bool is_adv_data_phase_open(struct player *pplayer);
149
150void adv_data_analyze_rulesets(struct player *pplayer);
151
152struct adv_data *adv_data_get(struct player *pplayer, bool *close);
153
156void adv_best_government(struct player *pplayer);
157
158bool adv_wants_science(struct player *pplayer);
159
160bool adv_is_player_dangerous(struct player *pplayer,
161 struct player *aplayer);
162
163#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:741
adv_want adv_gov_player_bonus_want(struct player *pplayer)
Definition advdata.c:932
struct adv_data * adv_data_get(struct player *pplayer, bool *close)
Definition advdata.c:593
void adv_data_init(struct player *pplayer)
Definition advdata.c:686
bool is_adv_data_phase_open(struct player *pplayer)
Definition advdata.c:242
bool adv_wants_science(struct player *pplayer)
Definition advdata.c:1076
bool adv_data_phase_init(struct player *pplayer, bool is_new_phase)
Definition advdata.c:262
void adv_data_phase_done(struct player *pplayer)
Definition advdata.c:553
bool adv_is_player_dangerous(struct player *pplayer, struct player *aplayer)
Definition advdata.c:1087
adv_want adv_gov_action_immunity_want(struct government *gov)
Definition advdata.c:812
void adv_best_government(struct player *pplayer)
Definition advdata.c:960
void adv_data_default(struct player *pplayer)
Definition advdata.c:718
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
float adv_want
Definition fc_types.h:1206
#define UCL_LAST
Definition fc_types.h:387
#define B_LAST
Definition improvement.h:42
bool wants_science
Definition advdata.h:133
struct adv_data::@90 threats
int req
Definition advdata.h:127
struct adv_data::@91 explore
short govt_reeval
Definition advdata.h:120
adv_want val
Definition advdata.h:126
int pollution_priority
Definition advdata.h:115
struct adv_data::@92 stats
int shield_priority
Definition advdata.h:107
bool * ocean
Definition advdata.h:60
struct adv_data::@92::@95 units
int coast_strict
Definition advdata.h:80
int average_production
Definition advdata.h:92
int * cities
Definition advdata.h:90
int * ocean_cities
Definition advdata.h:91
bool invasions
Definition advdata.h:58
struct government * revolution
Definition advdata.h:129
int infra_priority
Definition advdata.h:116
struct adv_dipl ** adv_dipl_slots
Definition advdata.h:96
bool igwall
Definition advdata.h:63
bool celebrate
Definition advdata.h:136
int num_oceans
Definition advdata.h:104
int unhappy_priority
Definition advdata.h:113
int byclass[UCL_LAST]
Definition advdata.h:85
int luxury_priority
Definition advdata.h:109
int nuclear
Definition advdata.h:62
int angry_priority
Definition advdata.h:114
int upgradeable
Definition advdata.h:88
int food_priority
Definition advdata.h:108
int max_num_cities
Definition advdata.h:139
int num_continents
Definition advdata.h:103
adv_want * government_want
Definition advdata.h:119
bool suicide_attack
Definition advdata.h:61
struct player * production_leader
Definition advdata.h:100
struct adv_data::@93 dipl
struct government * gov
Definition advdata.h:125
int airliftable
Definition advdata.h:83
int happy_priority
Definition advdata.h:112
bool * continent
Definition advdata.h:59
bool sea_done
Definition advdata.h:71
enum adv_improvement_status impr_calc[B_LAST]
Definition advdata.h:53
int suicide_attackers
Definition advdata.h:83
bool phase_is_initialized
Definition advdata.h:47
int wonder_city
Definition advdata.h:50
enum req_range impr_range[B_LAST]
Definition advdata.h:54
int science_priority
Definition advdata.h:111
struct adv_data::@94 goal
int gold_priority
Definition advdata.h:110
bool land_done
Definition advdata.h:70
struct player * tech_leader
Definition advdata.h:99
int paratroopers
Definition advdata.h:83
struct player * spacerace_leader
Definition advdata.h:98
bool allied_with_enemy
Definition advdata.h:42