Freeciv-3.1: /fast/freeciv/nightly/S3_1/server/advisors/advdata.h Source File

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
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_data {
46 /* Whether adv_data_phase_init() has been called or not. */
47 bool phase_is_initialized;
48
49 /* The Wonder City */
50 int wonder_city;
51
52 /* Precalculated info about city improvements */
53 enum adv_improvement_status impr_calc[B_LAST];
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 */
64 } threats;
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 */
72 } explore;
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. */
80 int coast_strict;
81
82 /* Unit can do action counts. */
83 int suicide_attackers, paratroopers, airliftable;
84
85 int byclass[UCL_LAST];
86
87 /* Upgradeable units */
88 int upgradeable;
89 } units;
90 int *cities; /* Number of cities we have on continent */
91 int *ocean_cities; /* Number of cities we have on ocean */
92 int average_production;
93 } stats;
94
95 struct {
96 struct adv_dipl **adv_dipl_slots;
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 */
101 } dipl;
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 */
107 int shield_priority;
108 int food_priority;
109 int luxury_priority;
110 int gold_priority;
111 int science_priority;
112 int happy_priority;
113 int unhappy_priority;
114 int angry_priority;
115 int pollution_priority;
116 int infra_priority;
117
118 /* Government data */
119 adv_want *government_want;
120 short govt_reeval;
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 */
130 } goal;
131
132 /* Whether science would benefit player at all */
133 bool wants_science;
134
135 /* If the AI celebrates. */
136 bool celebrate;
137
138 /* AI doesn't like having more than this number of cities */
139 int max_num_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
154 adv_want adv_gov_action_immunity_want(struct government *gov);
155 adv_want adv_gov_player_bonus_want(struct player *pplayer);
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 */
adv_data_analyze_rulesets
void adv_data_analyze_rulesets(struct player *pplayer)
Definition advdata.c:192
adv_data_close
void adv_data_close(struct player *pplayer)
Definition advdata.c:741
adv_gov_player_bonus_want
adv_want adv_gov_player_bonus_want(struct player *pplayer)
Definition advdata.c:932
adv_data_get
struct adv_data * adv_data_get(struct player *pplayer, bool *close)
Definition advdata.c:593
adv_data_init
void adv_data_init(struct player *pplayer)
Definition advdata.c:686
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:1076
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:553
adv_is_player_dangerous
bool adv_is_player_dangerous(struct player *pplayer, struct player *aplayer)
Definition advdata.c:1087
adv_gov_action_immunity_want
adv_want adv_gov_action_immunity_want(struct government *gov)
Definition advdata.c:812
adv_best_government
void adv_best_government(struct player *pplayer)
Definition advdata.c:960
adv_data_default
void adv_data_default(struct player *pplayer)
Definition advdata.c:718
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
fc_types.h
adv_want
float adv_want
Definition fc_types.h:1206
UCL_LAST
#define UCL_LAST
Definition fc_types.h:387
improvement.h
B_LAST
#define B_LAST
Definition improvement.h:42
adv_data
Definition advdata.h:45
adv_data::wants_science
bool wants_science
Definition advdata.h:133
adv_data::threats
struct adv_data::@90 threats
adv_data::req
int req
Definition advdata.h:127
adv_data::explore
struct adv_data::@91 explore
adv_data::govt_reeval
short govt_reeval
Definition advdata.h:120
adv_data::val
adv_want val
Definition advdata.h:126
adv_data::pollution_priority
int pollution_priority
Definition advdata.h:115
adv_data::stats
struct adv_data::@92 stats
adv_data::shield_priority
int shield_priority
Definition advdata.h:107
adv_data::ocean
bool * ocean
Definition advdata.h:60
adv_data::units
struct adv_data::@92::@95 units
adv_data::coast_strict
int coast_strict
Definition advdata.h:80
adv_data::average_production
int average_production
Definition advdata.h:92
adv_data::cities
int * cities
Definition advdata.h:90
adv_data::ocean_cities
int * ocean_cities
Definition advdata.h:91
adv_data::invasions
bool invasions
Definition advdata.h:58
adv_data::revolution
struct government * revolution
Definition advdata.h:129
adv_data::infra_priority
int infra_priority
Definition advdata.h:116
adv_data::adv_dipl_slots
struct adv_dipl ** adv_dipl_slots
Definition advdata.h:96
adv_data::igwall
bool igwall
Definition advdata.h:63
adv_data::celebrate
bool celebrate
Definition advdata.h:136
adv_data::num_oceans
int num_oceans
Definition advdata.h:104
adv_data::unhappy_priority
int unhappy_priority
Definition advdata.h:113
adv_data::byclass
int byclass[UCL_LAST]
Definition advdata.h:85
adv_data::luxury_priority
int luxury_priority
Definition advdata.h:109
adv_data::nuclear
int nuclear
Definition advdata.h:62
adv_data::angry_priority
int angry_priority
Definition advdata.h:114
adv_data::upgradeable
int upgradeable
Definition advdata.h:88
adv_data::food_priority
int food_priority
Definition advdata.h:108
adv_data::max_num_cities
int max_num_cities
Definition advdata.h:139
adv_data::num_continents
int num_continents
Definition advdata.h:103
adv_data::government_want
adv_want * government_want
Definition advdata.h:119
adv_data::suicide_attack
bool suicide_attack
Definition advdata.h:61
adv_data::production_leader
struct player * production_leader
Definition advdata.h:100
adv_data::dipl
struct adv_data::@93 dipl
adv_data::gov
struct government * gov
Definition advdata.h:125
adv_data::airliftable
int airliftable
Definition advdata.h:83
adv_data::happy_priority
int happy_priority
Definition advdata.h:112
adv_data::continent
bool * continent
Definition advdata.h:59
adv_data::sea_done
bool sea_done
Definition advdata.h:71
adv_data::impr_calc
enum adv_improvement_status impr_calc[B_LAST]
Definition advdata.h:53
adv_data::suicide_attackers
int suicide_attackers
Definition advdata.h:83
adv_data::phase_is_initialized
bool phase_is_initialized
Definition advdata.h:47
adv_data::wonder_city
int wonder_city
Definition advdata.h:50
adv_data::impr_range
enum req_range impr_range[B_LAST]
Definition advdata.h:54
adv_data::science_priority
int science_priority
Definition advdata.h:111
adv_data::goal
struct adv_data::@94 goal
adv_data::gold_priority
int gold_priority
Definition advdata.h:110
adv_data::land_done
bool land_done
Definition advdata.h:70
adv_data::tech_leader
struct player * tech_leader
Definition advdata.h:99
adv_data::paratroopers
int paratroopers
Definition advdata.h:83
adv_data::spacerace_leader
struct player * spacerace_leader
Definition advdata.h:98
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