Freeciv21
Develop your civilization from humble roots to a global empire
daicity.h
Go to the documentation of this file.
1 /*__ ___ ***************************************
2 / \ / \ Copyright (c) 1996-2020 Freeciv21 and Freeciv
3 \_ \ / __/ contributors. This file is part of Freeciv21.
4  _\ \ / /__ Freeciv21 is free software: you can redistribute it
5  \___ \____/ __/ and/or modify it under the terms of the GNU General
6  \_ _/ Public License as published by the Free Software
7  | @ @ \_ Foundation, either version 3 of the License,
8  | or (at your option) any later version.
9  _/ /\ You should have received a copy of the GNU
10  /o) (o/\ \_ General Public License along with Freeciv21.
11  \_____/ / If not, see https://www.gnu.org/licenses/.
12  \____/ ********************************************************/
13 #pragma once
14 
15 // common
16 #include "effects.h" // enum effect_type
17 #include "fc_types.h"
18 
19 /* server/advisors */
20 #include "advchoice.h"
21 
22 struct adv_data;
23 struct tech_vector;
24 
25 // Who's coming to kill us, for attack co-ordination
26 struct ai_invasion {
27  int attack; // Units capable of attacking city
28  int occupy; // Units capable of occupying city
29 };
30 
31 struct ai_city {
32  adv_want worth; // Cache city worth here, sum of all weighted incomes
33 
34  int building_turn; // only recalculate every Nth turn
35  int building_wait; // for weighting values
36 #define BUILDING_WAIT_MINIMUM (1)
37 
38  struct adv_choice choice; // to spend gold in the right place only
39 
40  struct ai_invasion invasion;
41  int attack, bcost; /* This is also for invasion - total power and value of
42  * all units coming to kill us. */
43 
44  int danger; // danger to be compared to assess_defense
45  int grave_danger; // danger, should show positive feedback
46  int urgency; /* how close the danger is; if zero,
47  bodyguards can leave */
48  int wallvalue; /* how much it helps for defenders to be
49  ground units */
50 
51  int distance_to_wonder_city; /* wondercity will set this for us,
52  avoiding paradox */
53 
54  bool celebrate; // try to celebrate in this city
55  bool diplomat_threat; // enemy diplomat or spy is near the city
56  bool has_diplomat; // this city has diplomat or spy defender
57 
58  /* These values are for builder (UTYF_SETTLERS) and founder (UTYF_CITIES)
59  * units. Negative values indicate that the city needs a boat first;
60  * -value is the degree of want in that case. */
61  bool founder_boat; // city founder will need a boat
62  int founder_turn; // only recalculate every Nth turn
66 };
67 
68 void dai_manage_cities(struct ai_type *ait, struct player *pplayer);
69 
70 void dai_city_alloc(struct ai_type *ait, struct city *pcity);
71 void dai_city_free(struct ai_type *ait, struct city *pcity);
72 
73 struct section_file;
74 void dai_city_save(struct ai_type *ait, const char *aitstr,
75  struct section_file *file, const struct city *pcity,
76  const char *citystr);
77 void dai_city_load(struct ai_type *ait, const char *aitstr,
78  const struct section_file *file, struct city *pcity,
79  const char *citystr);
80 
82  struct player *pplayer,
83  const struct city *pcity,
84  const struct impr_type *pimprove,
85  struct tech_vector *needed_techs,
86  adv_want building_want);
87 
89  struct player *pplayer,
90  const struct city *pcity,
91  const struct impr_type *pimprove,
92  adv_want building_want);
93 
94 void dai_build_adv_init(struct ai_type *ait, struct player *pplayer);
95 void dai_build_adv_adjust(struct ai_type *ait, struct player *pplayer,
96  struct city *wonder_city);
97 
98 void dai_consider_wonder_city(struct ai_type *ait, struct city *pcity,
99  bool *result);
100 
102  enum effect_type effect_type,
103  const struct unit_type *utype);
104 
105 adv_want dai_city_want(struct player *pplayer, struct city *acity,
106  struct adv_data *adv, struct impr_type *pimprove);
void want_techs_for_improvement_effect(struct ai_type *ait, struct player *pplayer, const struct city *pcity, const struct impr_type *pimprove, struct tech_vector *needed_techs, adv_want building_want)
Increase want for a technologies because of the value of that technology in providing an improvement ...
Definition: daicity.cpp:152
void dai_city_save(struct ai_type *ait, const char *aitstr, struct section_file *file, const struct city *pcity, const char *citystr)
Write ai city segments to savefile.
Definition: daicity.cpp:1157
void dai_city_load(struct ai_type *ait, const char *aitstr, const struct section_file *file, struct city *pcity, const char *citystr)
Load ai city segment from savefile.
Definition: daicity.cpp:1185
void dai_manage_cities(struct ai_type *ait, struct player *pplayer)
One of the top level AI functions.
Definition: daicity.cpp:861
void dai_city_alloc(struct ai_type *ait, struct city *pcity)
Initialize city for use with default AI.
Definition: daicity.cpp:1129
void dai_consider_wonder_city(struct ai_type *ait, struct city *pcity, bool *result)
Is it ok for advisor code to consider given city as wonder city?
Definition: daicity.cpp:2079
void dont_want_tech_obsoleting_impr(struct ai_type *ait, struct player *pplayer, const struct city *pcity, const struct impr_type *pimprove, adv_want building_want)
Decrease want for a technology because of the value of that technology in obsoleting an improvement e...
Definition: daicity.cpp:173
void dai_build_adv_adjust(struct ai_type *ait, struct player *pplayer, struct city *wonder_city)
Calculate how much an AI player should want to build particular improvements, because of the effects ...
Definition: daicity.cpp:1947
void dai_city_free(struct ai_type *ait, struct city *pcity)
Free city from use with default AI.
Definition: daicity.cpp:1142
Impr_type_id dai_find_source_building(struct city *pcity, enum effect_type effect_type, const struct unit_type *utype)
Returns a buildable, non-obsolete building that can provide the effect.
Definition: daicity.cpp:2095
void dai_build_adv_init(struct ai_type *ait, struct player *pplayer)
Initialize building advisor.
Definition: daicity.cpp:1928
adv_want dai_city_want(struct player *pplayer, struct city *acity, struct adv_data *adv, struct impr_type *pimprove)
Calculates city want from some input values.
Definition: daicity.cpp:1419
float adv_want
Definition: fc_types.h:1144
int Impr_type_id
Definition: fc_types.h:293
int urgency
Definition: daicity.h:46
struct adv_choice choice
Definition: daicity.h:38
int danger
Definition: daicity.h:44
bool founder_boat
Definition: daicity.h:61
int building_wait
Definition: daicity.h:35
bool celebrate
Definition: daicity.h:54
int founder_turn
Definition: daicity.h:62
bool has_diplomat
Definition: daicity.h:56
int founder_want
Definition: daicity.h:63
int bcost
Definition: daicity.h:41
int worker_want
Definition: daicity.h:64
int building_turn
Definition: daicity.h:34
int distance_to_wonder_city
Definition: daicity.h:51
bool diplomat_threat
Definition: daicity.h:55
adv_want worth
Definition: daicity.h:32
int wallvalue
Definition: daicity.h:48
int grave_danger
Definition: daicity.h:45
int attack
Definition: daicity.h:41
struct ai_invasion invasion
Definition: daicity.h:40
struct unit_type * worker_type
Definition: daicity.h:65
int attack
Definition: daicity.h:27
int occupy
Definition: daicity.h:28
Definition: ai.h:42
Definition: city.h:291
Definition: player.h:231