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[MAX_NUM_ITEMS]; 54 enum req_range impr_range[MAX_NUM_ITEMS]; 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 missile; /* 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 triremes, missiles, paratroopers, airliftable; 81 82 int byclass[UCL_LAST]; 83 84 /* Upgradeable units */ 85 int upgradeable; 86 } units; 87 int *cities; /* number of cities we have on continent */ 88 int average_production; 89 } stats; 90 91 struct { 92 struct adv_dipl **adv_dipl_slots; 93 94 struct player *spacerace_leader; /* Who is leading the space pack */ 95 struct player *tech_leader; /* Who is first to get spacerace techs */ 96 struct player *production_leader; /* Who is quickest to build spaceship */ 97 } dipl; 98 99 int num_continents; /* last time we updated our continent data */ 100 int num_oceans; /* last time we updated our continent data */ 101 102 /* Dynamic weights used in addition to Syela's hardcoded weights */ 103 int shield_priority; 104 int food_priority; 105 int luxury_priority; 106 int gold_priority; 107 int science_priority; 108 int happy_priority; 109 int unhappy_priority; 110 int angry_priority; 111 int pollution_priority; 112 113 /* Government data */ 114 adv_want *government_want; 115 short govt_reeval; 116 117 /* Goals */ 118 struct { 119 struct { 120 struct government *gov; /* The ideal government */ 121 adv_want val; /* Its value (relative to the current gov) */ 122 int req; /* The tech requirement for the ideal gov */ 123 } govt; 124 struct government *revolution; /* The best gov of the now available */ 125 } goal; 126 127 /* Whether science would benefit player at all */ 128 bool wants_science; 129 130 /* If the AI celebrates. */ 131 bool celebrate; 132 133 /* AI doesn't like having more than this number of cities */ 134 int max_num_cities; 135 }; 136 137 void adv_data_init(struct player *pplayer); 138 void adv_data_default(struct player *pplayer); 139 void adv_data_close(struct player *pplayer); 140 141 bool adv_data_phase_init(struct player *pplayer, bool is_new_phase); 142 void adv_data_phase_done(struct player *pplayer); 143 bool is_adv_data_phase_open(struct player *pplayer); 144 145 void adv_data_analyze_rulesets(struct player *pplayer); 146 147 struct adv_data *adv_data_get(struct player *pplayer, bool *close); 148 149 adv_want adv_gov_action_immunity_want(struct government *gov); 150 adv_want adv_gov_player_bonus_want(struct player *pplayer); 151 void adv_best_government(struct player *pplayer); 152 153 bool adv_wants_science(struct player *pplayer); 154 155 bool adv_is_player_dangerous(struct player *pplayer, 156 struct player *aplayer); 157 158 #endif /* FC__ADVDATA_H */ 159