83#define LOGLEVEL_TAX LOG_DEBUG
88#define AI_GOLD_RESERVE_MIN_TURNS 10
89#define AI_BULBS_RESERVE_MIN_TURNS 10
93#define PCT_DELTA_TAX 50
94#define PCT_DELTA_SCI 10
124 if (NULL != expenses) {
127 if (NULL != income) {
134 *trade += pcity->surplus[
O_TRADE];
137 if (NULL != expenses) {
138 *expenses += pcity->usage[
O_GOLD];
141 if (NULL != income) {
143 *income += pcity->usage[
O_GOLD] + pcity->surplus[
O_GOLD];
148 case GOLD_UPKEEP_CITY:
150 case GOLD_UPKEEP_MIXED:
151 case GOLD_UPKEEP_NATION:
176#define RATE_NOT_SET -1
177#define RATE_VALID(_rate) \
178 (_rate != RATE_NOT_SET)
179#define RATE_REMAINS(_rates) \
180 MAX(0, 100 - _rates[AI_RATE_SCI] - _rates[AI_RATE_TAX] \
181 - _rates[AI_RATE_LUX])
219 int can_celebrate = 0, total_cities = 0;
223 int turns_for_rapture;
231 int rate_lux_min_celebrate = maxrate;
232 int delta_tax = 0, delta_sci = 0;
236 struct timer *taxtimer= NULL;
245 maxrate =
CLIP(34, maxrate, 100);
285 delta_tax = (result[
AI_RATE_TAX] - expenses) - income;
315 int balance_tax, balance_tax_min;
320 rates_tmp[i] = rates[i];
334 if (!
RATE_VALID(rate_tax_min) && balance_tax > balance_tax_min) {
339 if (expenses == 0 || balance_tax > 0) {
341 if (refill_coffers && rates[
AI_RATE_TAX] < maxrate) {
371 rate_tax_min =
RATE_VALID(rate_tax_min) ? rate_tax_min : maxrate;
374 rate_tax_min, rate_tax_balance);
404 int balance_sci, balance_sci_min;
409 rates_tmp[i] = rates[i];
417 balance_sci_min = -(bulbs_researched
422 if (!
RATE_VALID(rate_sci_min) && balance_sci > balance_sci_min) {
427 if (tech_upkeep == 0 || balance_sci > 0) {
446 rate_sci_min =
RATE_VALID(rate_sci_min) ? rate_sci_min : maxrate;
449 player_name(pplayer), rate_sci_min, rate_sci_balance);
464 && 100 > rate_tax_min + rate_sci_min) {
496 && pcity->surplus[
O_FOOD] > 0
508 if (can_celebrate * 2 > total_cities) {
512 "%d/%d/%d (%d of %d cities)",
513 player_name(pplayer), rate_sci_min, rate_lux_min_celebrate,
514 rate_tax_min, can_celebrate, total_cities);
517 player_name(pplayer), can_celebrate, total_cities);
535 && rate_tax_min + rate_sci_min + rate_lux_min_celebrate <= 100) {
551 if (100 >= rate_tax_balance + rate_sci_balance) {
565 "(Sci/Lux/Tax)>=%d/%d/%d",
575 "(Sci/Lux/Tax)>=%d/%d/%d",
585 "(Sci/Lux/Tax)>=%d/%d/%d",
606 "(Sci/Lux/Tax)>=%d/%d/%d",
739 "dai_manage_government() + %d for %s",
struct adv_data * adv_data_get(struct player *pplayer, bool *caller_closes)
bool adv_wants_science(struct player *pplayer)
bool adv_spaceship_autoplace(struct player *pplayer, struct player_spaceship *ship)
void dai_adjust_policies(struct ai_type *ait, struct player *pplayer)
@ AI_CELEBRATION_UNCHECKED
void dai_calc_data(const struct player *pplayer, int *trade, int *expenses, int *income)
static void dai_manage_government(struct ai_type *ait, struct player *pplayer)
#define RATE_VALID(_rate)
void dai_do_last_activities(struct ai_type *ait, struct player *pplayer)
static void dai_manage_taxes(struct ai_type *ait, struct player *pplayer)
#define RATE_REMAINS(_rates)
static void dai_manage_spaceship(struct player *pplayer)
#define AI_GOLD_RESERVE_MIN_TURNS
void dai_do_first_activities(struct ai_type *ait, struct player *pplayer)
#define AI_BULBS_RESERVE_MIN_TURNS
#define TECH_LOG(ait, loglevel, pplayer, padvance, msg,...)
static struct ai_plr * def_ai_player_data(const struct player *pplayer, struct ai_type *deftype)
static struct ai_city * def_ai_city_data(const struct city *pcity, struct ai_type *deftype)
void dai_clear_tech_wants(struct ai_type *ait, struct player *pplayer)
void dai_manage_tech(struct ai_type *ait, struct player *pplayer)
void dai_manage_units(struct ai_type *ait, struct player *pplayer)
const char * city_name_get(const struct city *pcity)
bool city_can_grow_to(const struct city *pcity, int pop_size)
void city_refresh_from_main_map(const struct civ_map *nmap, struct city *pcity, bool *workers_map)
bool city_happy(const struct city *pcity)
static int cmp(int v1, int v2)
#define city_list_iterate(citylist, pcity)
static citizens city_size_get(const struct city *pcity)
#define city_list_iterate_end
void apply_cmresult_to_city(struct city *pcity, const struct cm_result *cmr)
void cm_clear_cache(struct city *pcity)
void cm_init_parameter(struct cm_parameter *dest)
struct cm_result * cm_result_new(struct city *pcity)
void cm_result_destroy(struct cm_result *result)
void cm_query_result(struct city *pcity, const struct cm_parameter *param, struct cm_result *result, bool negative_ok)
void dai_manage_cities(struct ai_type *ait, struct player *pplayer)
bool dai_on_war_footing(struct ai_type *ait, struct player *pplayer)
void dai_assess_danger_player(struct ai_type *ait, const struct civ_map *nmap, struct player *pplayer)
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
void distribute(int number, unsigned groups, const unsigned *ratios, int *result)
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
struct government * government_of_player(const struct player *pplayer)
const char * government_rule_name(const struct government *pgovern)
void handle_spaceship_launch(struct player *pplayer)
bool has_handicap(const struct player *pplayer, enum handicap_type htype)
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define log_base(level, message,...)
struct nation_type * nation_of_player(const struct player *pplayer)
struct government * init_government_of_nation(const struct nation_type *pnation)
const char * player_name(const struct player *pplayer)
int player_index(const struct player *pplayer)
void send_player_info_c(struct player *src, struct conn_list *dest)
int player_tech_upkeep(const struct player *pplayer)
struct research * research_get(const struct player *pplayer)
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
#define CLIP(lower, current, upper)
#define NUM_SS_COMPONENTS
#define NUM_SS_STRUCTURALS
#define CITY_LOG(loglevel, pcity, msg,...)
#define TIMING_LOG(timer, activity)
struct government * revolution
struct adv_data::@94::@96 govt
struct adv_data::@94 goal
adv_want tech_want[A_LAST+1]
struct packet_game_info info
struct government * government_during_revolution
enum gold_upkeep_style gold_upkeep_style
enum tech_upkeep_style tech_upkeep_style
enum spaceship_state state
struct city_list * cities
struct conn_list * connections
struct player_economic economic
struct player_spaceship spaceship
struct player::@69::@71 server
struct advance * advance_by_number(const Tech_type_id atype)
struct timer * timer_new(enum timer_timetype type, enum timer_use use)
void timer_destroy(struct timer *t)
void timer_start(struct timer *t)
void timer_stop(struct timer *t)
double timer_read_seconds(struct timer *t)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
bool victory_enabled(enum victory_condition_type victory)