Freeciv-3.2
Loading...
Searching...
No Matches
aihand.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
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
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* utility */
19#include "distribute.h"
20#include "log.h"
21#include "shared.h"
22#include "timing.h"
23
24/* common */
25#include "city.h"
26#include "game.h"
27#include "government.h"
28#include "map.h"
29#include "nation.h"
30#include "packets.h"
31#include "player.h"
32#include "research.h"
33#include "unit.h"
34#include "victory.h"
35
36/* common/aicore */
37#include "cm.h"
38
39/* server */
40#include "citytools.h"
41#include "cityturn.h"
42#include "plrhand.h"
43#include "sernet.h"
44#include "spacerace.h"
45#include "srv_log.h"
46#include "unithand.h"
47
48/* server/advisors */
49#include "advdata.h"
50#include "advspace.h"
51#include "advtools.h"
52
53/* ai */
54#include "handicaps.h"
55
56/* ai/default */
57#include "aitech.h"
58#include "aitools.h"
59#include "daicity.h"
60#include "daidata.h"
61#include "daidiplomacy.h"
62#include "dailog.h"
63#include "daimilitary.h"
64#include "daiplayer.h"
65
66#include "aihand.h"
67
68/*****************************************************************************
69 A man builds a city
70 With banks and cathedrals
71 A man melts the sand so he can
72 See the world outside
73 A man makes a car
74 And builds a road to run them on
75 A man dreams of leaving
76 but he always stays behind
77 And these are the days when our work has come assunder
78 And these are the days when we look for something other
79 /U2 Lemon.
80*****************************************************************************/
81
82#define LOGLEVEL_TAX LOG_DEBUG
83
84/* When setting rates, we accept negative balance if we have a lot of
85 * gold/bulb reserves. This is how long time gold/bulb reserves should last.
86 * For city grow due to rapture turns_for_rapture is added. */
87#define AI_GOLD_RESERVE_MIN_TURNS 10
88#define AI_BULBS_RESERVE_MIN_TURNS 10
89
90/* This factor is used for the delta between the estimated and real income to
91 * get 'real' rates for the AI player. */
92#define PCT_DELTA_TAX 50
93#define PCT_DELTA_SCI 10
94
95/*************************************************************************/
98static void dai_manage_spaceship(struct player *pplayer)
99{
101 if (pplayer->spaceship.state == SSHIP_STARTED) {
102 adv_spaceship_autoplace(pplayer, &pplayer->spaceship);
103
104 /* if we have built the best possible spaceship -- AJS 19990610 */
106 && (pplayer->spaceship.components == NUM_SS_COMPONENTS)
107 && (pplayer->spaceship.modules == NUM_SS_MODULES))
109 }
110 }
111}
112
113/*************************************************************************/
117void dai_calc_data(const struct player *pplayer, int *trade, int *expenses,
118 int *income)
119{
120 if (NULL != trade) {
121 *trade = 0;
122 }
123 if (NULL != expenses) {
124 *expenses = 0;
125 }
126 if (NULL != income) {
127 *income = 0;
128 }
129
130 /* Find total trade surplus, gold expenses, and gold income */
131 city_list_iterate(pplayer->cities, pcity) {
132 if (NULL != trade) {
133 *trade += pcity->surplus[O_TRADE];
134 }
135
136 if (NULL != expenses) {
137 *expenses += pcity->usage[O_GOLD];
138 }
139
140 if (NULL != income) {
141 /* Also the immediately used gold is part of income, not only surplus */
142 *income += pcity->usage[O_GOLD] + pcity->surplus[O_GOLD];
143 }
145
146 switch (game.info.gold_upkeep_style) {
147 case GOLD_UPKEEP_CITY:
148 break;
151 /* Account for units with gold upkeep paid for by the nation. */
152 unit_list_iterate(pplayer->units, punit) {
155 break;
156 }
157}
158
159/*****************************************************************************
160 Additional data needed for the AI rates calculation
161*****************************************************************************/
162enum {
168
174
175#define RATE_NOT_SET -1
176#define RATE_VALID(_rate) \
177 (_rate != RATE_NOT_SET)
178#define RATE_REMAINS(_rates) \
179 MAX(0, 100 - _rates[AI_RATE_SCI] - _rates[AI_RATE_TAX] \
180 - _rates[AI_RATE_LUX])
181
182/*************************************************************************/
211static void dai_manage_taxes(struct ai_type *ait, struct player *pplayer)
212{
213 int maxrate = (has_handicap(pplayer, H_RATES)
214 ? get_player_bonus(pplayer, EFT_MAX_RATES) : 100);
215 struct research *research = research_get(pplayer);
216 enum celebration celebrate = AI_CELEBRATION_UNCHECKED;
217 struct adv_data *ai = adv_data_get(pplayer, NULL);
218 int can_celebrate = 0, total_cities = 0;
219 int trade = 0; /* total amount of trade generated */
220 int expenses = 0; /* total amount of gold upkeep */
221 int income = 0; /* total amount of gold income */
222 int turns_for_rapture; /* additional reserve needed for rapture */
224 int rates[AI_RATE_COUNT];
225 int result[AI_RATE_COUNT];
231 int delta_tax = 0, delta_sci = 0;
232 const struct civ_map *nmap = &(wld.map);
233
234#ifdef DEBUG_TIMERS
235 struct timer *taxtimer = NULL;
236#endif
237
238 struct cm_parameter cmp;
239
240 if (!game.info.changable_tax) {
241 return; /* This ruleset does not support changing tax rates. */
242 }
243
244 maxrate = CLIP(34, maxrate, 100);
245
247 return; /* This government does not support changing tax rates. */
248 }
249
250#ifdef DEBUG_TIMERS
253#endif /* DEBUG_TIMERS */
254
255 /* City parameters needed for celebrations. */
257 cmp.require_happy = TRUE; /* note this one */
258 cmp.allow_disorder = FALSE;
259 cmp.allow_specialists = TRUE;
260 cmp.factor[O_FOOD] = 20;
261 cmp.minimal_surplus[O_GOLD] = -FC_INFINITY;
262
263 /* Define reserve (gold/bulbs) needed for rapture (celebration). */
264 turns_for_rapture = ai->celebrate ? 0 : (game.info.rapturedelay + 1) * 3;
265
266 log_base(LOGLEVEL_TAX, "%s [max] rate=%d", player_name(pplayer), maxrate);
267
268 /* Save AI rates. */
272
273 log_base(LOGLEVEL_TAX, "%s [old] (Sci/Lux/Tax)=%d/%d/%d",
276
277 /* Get some data for the AI player. */
278 dai_calc_data(pplayer, &trade, &expenses, &income);
279
280 /* Get the estimates for tax with the current rates. */
281 distribute(trade, AI_RATE_COUNT, rates_save, result);
282
283 /* The delta between the estimate and the real value. */
284 delta_tax = (result[AI_RATE_TAX] - expenses) - income;
285
286 log_base(LOGLEVEL_TAX, "%s [tax] estimated=%d real=%d (delta=%d)",
287 player_name(pplayer), result[AI_RATE_TAX] - expenses, income,
288 delta_tax);
289
290 /* Find minimum tax rate which gives us a positive balance for gold and
291 * science. We assume that we want science most and luxuries least here,
292 * and reverse or modify this assumption later.
293 * Furthermore, We assume our entire civilization is one big city, and
294 * distribute total income accordingly. This is a simplification that speeds
295 * up the code significantly. */
296
297 /* === Gold === */
298
299 /* First set tax (gold) to the minimal available number */
300 rates[AI_RATE_SCI] = maxrate; /* Assume we want science here */
301 rates[AI_RATE_TAX] = MAX(0, 100 - maxrate * 2); /* If maxrate < 50% */
303
304 /* Now find the minimum tax with positive gold balance
305 * Negative balance is acceptable if we have a lot of gold. */
306
307 log_base(LOGLEVEL_TAX, "%s [tax] trade=%d gold=%d expenses=%d",
308 player_name(pplayer), trade, pplayer->economic.gold, expenses);
309
310 while (rates[AI_RATE_TAX] <= maxrate
311 && rates[AI_RATE_SCI] >= 0
312 && rates[AI_RATE_LUX] >= 0) {
313 bool refill_coffers = pplayer->economic.gold < dai_gold_reserve(pplayer);
315 int i;
316
317 for (i = 0; i < AI_RATE_COUNT; i++) {
318 fc_assert(rates[i] >= 0);
319 rates_tmp[i] = rates[i];
320 }
321 distribute(trade, AI_RATE_COUNT, rates_tmp, result);
322
323 /* Consider the delta between the result and the real value from the
324 * last turn to get better estimates. */
325 balance_tax = (result[AI_RATE_TAX] - expenses)
326 - delta_tax * PCT_DELTA_TAX / 100;
327 balance_tax_min = -(pplayer->economic.gold
329
330 log_base(LOGLEVEL_TAX, "%s [tax] Tax=%d income=%d",
332
334 /* Just slightly negative; we can afford that for a while */
336 }
337
338 if (expenses == 0 || balance_tax > 0) {
339 /* Ok, got no expenses or positive balance */
341 /* Need to refill coffers, increase tax a bit */
342 rates[AI_RATE_TAX] += 10;
343 if (rates[AI_RATE_LUX] > 0) {
344 rates[AI_RATE_LUX] -= 10;
345 } else {
346 rates[AI_RATE_SCI] -= 10;
347 }
348
349 log_base(LOGLEVEL_TAX, "%s [tax] Tax=%d to refill coffers",
350 player_name(pplayer), rates[AI_RATE_TAX]);
351 }
352
353 /* This is the minimum rate for a balanced treasury (gold). */
355
356 /* Done! Break the while loop */
357 break;
358 }
359
360 /* Negative balance. Unacceptable - increase tax. */
361 rates[AI_RATE_TAX] += 10;
362 if (rates[AI_RATE_LUX] > 0) {
363 rates[AI_RATE_LUX] -= 10;
364 } else {
365 rates[AI_RATE_SCI] -= 10;
366 }
367 }
368
369 /* If no minimum value was found for the tax use the maximum tax rate. */
371
372 log_base(LOGLEVEL_TAX, "%s [tax] min=%d balanced=%d", player_name(pplayer),
374
375 /* === Science === */
376
378 /* Tech upkeep activated. */
379 int tech_upkeep = player_tech_upkeep(pplayer);
380 int bulbs_researched = research->bulbs_researched;
381
382 /* The delta between the estimate and the real value. */
383 delta_sci = (result[AI_RATE_SCI] - tech_upkeep)
384 - pplayer->server.bulbs_last_turn;
385 log_base(LOGLEVEL_TAX, "%s [sci] estimated=%d real=%d (delta=%d)",
386 player_name(pplayer),
387 result[AI_RATE_SCI] - tech_upkeep,
389
390 log_base(LOGLEVEL_TAX, "%s [sci] trade=%d bulbs=%d upkeep=%d",
391 player_name(pplayer), trade, research->bulbs_researched,
392 tech_upkeep);
393
394 rates[AI_RATE_TAX] = maxrate; /* Assume we want gold here */
395 rates[AI_RATE_SCI] = MAX(0, 100 - maxrate * 2);
397
398 /* Now find the minimum science tax with positive bulbs balance
399 * Negative balance is acceptable if we have a lots of bulbs. */
400 while (rates[AI_RATE_SCI] <= maxrate
401 && rates[AI_RATE_TAX] >= 0
402 && rates[AI_RATE_LUX] >= 0) {
404 int i;
405
406 for (i = 0; i < AI_RATE_COUNT; i++) {
407 fc_assert(rates[i] >= 0);
408 rates_tmp[i] = rates[i];
409 }
410 distribute(trade, AI_RATE_COUNT, rates_tmp, result);
411
412 /* Consider the delta between the result and the real value from the
413 * last turn. */
414 balance_sci = (result[AI_RATE_SCI] - tech_upkeep)
415 - delta_sci * PCT_DELTA_SCI / 100;
416 balance_sci_min = -(bulbs_researched
418 log_base(LOGLEVEL_TAX, "%s [sci] Sci=%d research=%d",
420
422 /* Just slightly negative, if we can afford that for a while */
424 }
425
426 if (tech_upkeep == 0 || balance_sci > 0) {
427 /* Ok, got no expenses or positive balance */
429
430 /* Done! Break the while loop */
431 break;
432 }
433
434 /* Negative balance. Unacceptable - increase science.*/
435 rates[AI_RATE_SCI] += 10;
436 if (rates[AI_RATE_LUX] > 0) {
437 rates[AI_RATE_LUX] -= 10;
438 } else {
439 rates[AI_RATE_TAX] -= 10;
440 }
441 }
442
443 /* If no minimum value was found for the science use the maximum science
444 * rate. */
446
447 log_base(LOGLEVEL_TAX, "%s [sci] min=%d balanced=%d",
449 } else {
450 /* No tech upkeep - minimum science value is 0. */
451 rate_sci_min = 0;
452 }
453
454 /* === Luxury === */
455
456 /* Should (and can) we celebrate? */
457 /* TODO: In the future, we should check if we should
458 * celebrate for other reasons than growth. Currently
459 * this is ignored. Maybe we need ruleset AI hints. */
460 /* TODO: Allow celebrate individual cities? No modpacks use this yet. */
461 if (get_player_bonus(pplayer, EFT_RAPTURE_GROW) > 0
462 && !has_handicap(pplayer, H_AWAY)
463 && 100 > rate_tax_min + rate_sci_min) {
464 celebrate = AI_CELEBRATION_NO;
465
466 /* Set the minimum tax for a positive science and gold balance and use the
467 * remaining trade goods for luxuries (max. luxuries). */
470 rates[AI_RATE_LUX] = 0;
471
478
479 /* Temporary set the new rates. */
480 pplayer->economic.luxury = rates[AI_RATE_LUX];
481 pplayer->economic.tax = rates[AI_RATE_TAX];
482 pplayer->economic.science = rates[AI_RATE_SCI];
483
484 /* Check if we celebrate - the city state must be restored at the end! */
485 city_list_iterate(pplayer->cities, pcity) {
486 struct cm_result *cmr = cm_result_new(pcity);
487 struct ai_city *city_data = def_ai_city_data(pcity, ait);
488
489 cm_clear_cache(pcity);
490 cm_query_result(pcity, &cmp, cmr, FALSE); /* burn some CPU */
491
492 total_cities++;
493
494 if (cmr->found_a_valid
495 && pcity->surplus[O_FOOD] > 0
497 && city_can_grow_to(pcity, city_size_get(pcity) + 1)) {
498 city_data->celebrate = TRUE;
500 } else {
501 city_data->celebrate = FALSE;
502 }
505
506 /* If more than half our cities can celebrate, go for it! */
507 if (can_celebrate * 2 > total_cities) {
510 log_base(LOGLEVEL_TAX, "%s [lux] celebration possible (Sci/Lux/Tax)>="
511 "%d/%d/%d (%d of %d cities)",
514 } else {
515 log_base(LOGLEVEL_TAX, "%s [lux] no celebration: only %d of %d cities",
517 }
518 }
519
521 /* TODO: Calculate a minimum luxury tax rate.
522 * Add general luxury code here. */
523 }
524
525 /* === Set the rates. === */
526
527 /* Reset rates values. */
528 rates[AI_RATE_SCI] = 0;
529 rates[AI_RATE_TAX] = 0;
530 rates[AI_RATE_LUX] = 0;
531
532 /* Now decide that to do ... */
535 /* Celebration! */
539
540 log_base(LOGLEVEL_TAX, "%s [res] celebration! (Sci/Lux/Tax)>=%d/%d/%d",
543 } else {
544 /* No celebration */
546 : celebrate;
547
550 if (100 >= rate_tax_balance + rate_sci_balance) {
551 /* A balanced treasury and research. */
554
555 log_base(LOGLEVEL_TAX, "%s [res] balanced! (Sci/Lux/Tax)>=%d/%d/%d",
556 player_name(pplayer), rates[AI_RATE_SCI],
558 } else {
559 /* Try to keep all tech and get as much gold as possible. */
562
563 log_base(LOGLEVEL_TAX, "%s [res] balanced sci! tax? "
564 "(Sci/Lux/Tax)>=%d/%d/%d",
565 player_name(pplayer), rates[AI_RATE_SCI],
567 }
568 } else {
569 /* A balanced tax and as much science as possible. */
572
573 log_base(LOGLEVEL_TAX, "%s [res] balanced tax! sci? "
574 "(Sci/Lux/Tax)>=%d/%d/%d",
575 player_name(pplayer), rates[AI_RATE_SCI],
577 }
578 } else if (RATE_VALID(rate_sci_balance)) {
579 /* Try to keep all techs and get as much gold as possible. */
582
583 log_base(LOGLEVEL_TAX, "%s [res] balanced sci! tax? "
584 "(Sci/Lux/Tax)>=%d/%d/%d",
585 player_name(pplayer), rates[AI_RATE_SCI],
587 } else {
588 /* We need more trade to get a positive gold and science balance. */
589 if (!adv_wants_science(pplayer) || dai_on_war_footing(ait, pplayer)) {
590 /* Go for gold (improvements and units) and risk the loss of a
591 * tech. */
594
595 log_base(LOGLEVEL_TAX, "%s [res] risk of tech loss! (Sci/Lux/Tax)>="
596 "%d/%d/%d", player_name(pplayer),
599 } else {
600 /* Go for science and risk the loss of improvements or units. */
603
604 log_base(LOGLEVEL_TAX, "%s [res] risk of empty treasury! "
605 "(Sci/Lux/Tax)>=%d/%d/%d",
606 player_name(pplayer), rates[AI_RATE_SCI],
608 };
609 }
610 }
611
612 /* Put the remaining to tax or science. */
613 if (!adv_wants_science(pplayer)) {
620 } else if (dai_on_war_footing(ait, pplayer)) {
627 } else {
634 }
635
636 /* Check and set the calculated rates. */
641 == 100);
642
643 log_base(LOGLEVEL_TAX, "%s [new] (Sci/Lux/Tax)=%d/%d/%d",
646
647 pplayer->economic.science = rates[AI_RATE_SCI];
648 pplayer->economic.tax = rates[AI_RATE_TAX];
649 pplayer->economic.luxury = rates[AI_RATE_LUX];
650
651 /* === Cleanup === */
652
653 /* Cancel all celebrations from the last turn. */
654 ai->celebrate = FALSE;
655
656 /* Now do celebrate or reset the city states if needed. */
658 log_base(LOGLEVEL_TAX, "*** %s CELEBRATES! ***", player_name(pplayer));
659
660 /* We do celebrate! */
661 ai->celebrate = TRUE;
662
663 city_list_iterate(pplayer->cities, pcity) {
664 struct cm_result *cmr = cm_result_new(pcity);
665
666 if (def_ai_city_data(pcity, ait)->celebrate) {
667 log_base(LOGLEVEL_TAX, "setting %s to celebrate", city_name_get(pcity));
668 cm_query_result(pcity, &cmp, cmr, FALSE);
669 if (cmr->found_a_valid) {
672 if (!city_happy(pcity)) {
673 CITY_LOG(LOG_ERROR, pcity, "is NOT happy when it should be!");
674 }
675 } else {
676 CITY_LOG(LOG_ERROR, pcity, "has NO valid state!");
677 }
678 }
681 } else if (celebrate == AI_CELEBRATION_NO) {
682 city_list_iterate(pplayer->cities, pcity) {
683 /* KLUDGE: Must refresh to restore the original values which
684 * were clobbered in cm_query_result(), after the tax rates
685 * were changed. */
688 }
689
690 send_player_info_c(pplayer, pplayer->connections);
691
692#ifdef DEBUG_TIMERS
694 log_base(LOGLEVEL_TAX, "Tax calculation for %s (player %d) in %.3f "
695 "seconds.", player_name(pplayer),
698#endif /* DEBUG_TIMERS */
699}
700#undef RATE_NOT_SET
701#undef RATE_VALID
702#undef RATE_REMAINS
703
704/*************************************************************************/
707static void dai_manage_government(struct ai_type *ait, struct player *pplayer)
708{
709 struct adv_data *adv = adv_data_get(pplayer, NULL);
710
711 if (!pplayer->is_alive || has_handicap(pplayer, H_AWAY)) {
712 return;
713 }
714
715 if (adv->goal.revolution != government_of_player(pplayer)) {
716 dai_government_change(pplayer, adv->goal.revolution); /* change */
717 }
718
719 /* Crank up tech want */
720 if (adv->goal.govt.req == A_UNSET
722 adv->goal.govt.req) == TECH_KNOWN) {
723 return; /* already got it! */
724 } else if (adv->goal.govt.val > 0) {
725 /* We have few cities in the beginning, compensate for this to ensure
726 * that we are sufficiently forward-looking. */
727 int want = MAX(adv->goal.govt.val, 100);
728 struct nation_type *pnation = nation_of_player(pplayer);
729 struct ai_plr *plr_data = def_ai_player_data(pplayer, ait);
730
731 if (government_of_player(pplayer) == init_government_of_nation(pnation)) {
732 /* Default government is the crappy one we start in (like Despotism).
733 * We want something better pretty soon! */
734 want += 25 * game.info.turn;
735 }
736 plr_data->tech_want[adv->goal.govt.req] += want;
737 TECH_LOG(ait, LOG_DEBUG, pplayer, advance_by_number(adv->goal.govt.req),
738 "dai_manage_government() + %d for %s",
739 want,
741 }
742}
743
744/*************************************************************************/
748void dai_do_first_activities(struct ai_type *ait, struct player *pplayer)
749{
751 dai_assess_danger_player(ait, &(wld.map), pplayer);
752 /* TODO: Make assess_danger save information on what is threatening
753 * us and make dai_manage_units and Co act upon this information, trying
754 * to eliminate the source of danger */
755
757 dai_manage_units(ait, pplayer);
759 /* STOP. Everything else is at end of turn. */
760
762
763 flush_packets(); /* AIs can be such spammers... */
764}
765
766/*************************************************************************/
774void dai_do_last_activities(struct ai_type *ait, struct player *pplayer)
775{
777 dai_clear_tech_wants(ait, pplayer);
778
779 dai_manage_government(ait, pplayer);
780 dai_adjust_policies(ait, pplayer);
782 dai_manage_taxes(ait, pplayer);
785 dai_manage_cities(ait, pplayer);
788 dai_manage_tech(ait, pplayer);
790 dai_manage_spaceship(pplayer);
791
793}
struct adv_data * adv_data_get(struct player *pplayer, bool *caller_closes)
Definition advdata.c:605
bool adv_wants_science(struct player *pplayer)
Definition advdata.c:1096
bool adv_spaceship_autoplace(struct player *pplayer, struct player_spaceship *ship)
Definition advspace.c:33
celebration
Definition aihand.c:169
@ AI_CELEBRATION_NO
Definition aihand.c:171
@ AI_CELEBRATION_UNCHECKED
Definition aihand.c:170
@ AI_CELEBRATION_YES
Definition aihand.c:172
void dai_calc_data(const struct player *pplayer, int *trade, int *expenses, int *income)
Definition aihand.c:117
static void dai_manage_government(struct ai_type *ait, struct player *pplayer)
Definition aihand.c:707
#define RATE_VALID(_rate)
Definition aihand.c:176
#define PCT_DELTA_TAX
Definition aihand.c:92
#define RATE_NOT_SET
Definition aihand.c:175
#define LOGLEVEL_TAX
Definition aihand.c:82
void dai_do_last_activities(struct ai_type *ait, struct player *pplayer)
Definition aihand.c:774
static void dai_manage_taxes(struct ai_type *ait, struct player *pplayer)
Definition aihand.c:211
@ AI_RATE_COUNT
Definition aihand.c:166
@ AI_RATE_TAX
Definition aihand.c:164
@ AI_RATE_SCI
Definition aihand.c:163
@ AI_RATE_LUX
Definition aihand.c:165
#define RATE_REMAINS(_rates)
Definition aihand.c:178
static void dai_manage_spaceship(struct player *pplayer)
Definition aihand.c:98
#define AI_GOLD_RESERVE_MIN_TURNS
Definition aihand.c:87
void dai_do_first_activities(struct ai_type *ait, struct player *pplayer)
Definition aihand.c:748
#define AI_BULBS_RESERVE_MIN_TURNS
Definition aihand.c:88
#define PCT_DELTA_SCI
Definition aihand.c:93
void dai_clear_tech_wants(struct ai_type *ait, struct player *pplayer)
Definition aitech.c:613
void dai_manage_tech(struct ai_type *ait, struct player *pplayer)
Definition aitech.c:335
void dai_government_change(struct player *pplayer, struct government *gov)
Definition aitools.c:1308
int dai_gold_reserve(struct player *pplayer)
Definition aitools.c:1327
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
bool city_can_grow_to(const struct city *pcity, int pop_size)
Definition city.c:2012
void city_refresh_from_main_map(const struct civ_map *nmap, struct city *pcity, bool *workers_map)
Definition city.c:3176
bool city_happy(const struct city *pcity)
Definition city.c:1614
static int cmp(int v1, int v2)
Definition city.c:325
#define city_list_iterate(citylist, pcity)
Definition city.h:508
static citizens city_size_get(const struct city *pcity)
Definition city.h:569
#define city_list_iterate_end
Definition city.h:510
void apply_cmresult_to_city(struct city *pcity, const struct cm_result *cmr)
Definition cityturn.c:282
void cm_clear_cache(struct city *pcity)
Definition cm.c:322
void cm_init_parameter(struct cm_parameter *dest)
Definition cm.c:2183
struct cm_result * cm_result_new(struct city *pcity)
Definition cm.c:345
void cm_result_destroy(struct cm_result *result)
Definition cm.c:368
void cm_query_result(struct city *pcity, const struct cm_parameter *param, struct cm_result *result, bool negative_ok)
Definition cm.c:2122
char * incite_cost
Definition comments.c:75
void dai_manage_cities(struct ai_type *ait, struct player *pplayer)
Definition daicity.c:851
void dai_adjust_policies(struct ai_type *ait, struct player *pplayer)
Definition daidata.c:442
bool dai_on_war_footing(struct ai_type *ait, struct player *pplayer)
#define TECH_LOG(ait, loglevel, pplayer, padvance, msg,...)
Definition dailog.h:36
void dai_assess_danger_player(struct ai_type *ait, const struct civ_map *nmap, struct player *pplayer)
static struct ai_plr * def_ai_player_data(const struct player *pplayer, struct ai_type *deftype)
Definition daiplayer.h:54
static struct ai_city * def_ai_city_data(const struct city *pcity, struct ai_type *deftype)
Definition daiplayer.h:42
void dai_manage_units(struct ai_type *ait, struct player *pplayer)
Definition daiunit.c:2861
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
Definition dialogs_g.h:74
void distribute(int number, unsigned groups, const unsigned *ratios, int *result)
Definition distribute.c:34
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
Definition effects.c:828
@ VC_SPACERACE
Definition fc_types.h:1271
@ O_FOOD
Definition fc_types.h:101
@ O_TRADE
Definition fc_types.h:101
@ O_GOLD
Definition fc_types.h:101
struct civ_game game
Definition game.c:62
struct world wld
Definition game.c:63
struct government * government_of_player(const struct player *pplayer)
Definition government.c:114
const char * government_rule_name(const struct government *pgovern)
Definition government.c:133
void handle_spaceship_launch(struct player *pplayer)
Definition spacerace.c:167
bool has_handicap(const struct player *pplayer, enum handicap_type htype)
Definition handicaps.c:66
@ H_RATES
Definition handicaps.h:23
@ H_AWAY
Definition handicaps.h:19
#define fc_assert_ret(condition)
Definition log.h:191
#define fc_assert(condition)
Definition log.h:176
#define log_base(level, message,...)
Definition log.h:94
@ LOG_ERROR
Definition log.h:30
@ LOG_DEBUG
Definition log.h:34
struct nation_type * nation_of_player(const struct player *pplayer)
Definition nation.c:444
struct government * init_government_of_nation(const struct nation_type *pnation)
Definition nation.c:659
const char * player_name(const struct player *pplayer)
Definition player.c:895
int player_index(const struct player *pplayer)
Definition player.c:829
void send_player_info_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:1146
int player_tech_upkeep(const struct player *pplayer)
Definition research.c:1050
struct research * research_get(const struct player *pplayer)
Definition research.c:128
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
void flush_packets(void)
Definition sernet.c:381
#define CLIP(lower, current, upper)
Definition shared.h:57
#define MIN(x, y)
Definition shared.h:55
#define FC_INFINITY
Definition shared.h:36
#define MAX(x, y)
Definition shared.h:54
#define NUM_SS_MODULES
Definition spaceship.h:89
#define NUM_SS_COMPONENTS
Definition spaceship.h:88
#define NUM_SS_STRUCTURALS
Definition spaceship.h:87
@ SSHIP_STARTED
Definition spaceship.h:84
#define CITY_LOG(loglevel, pcity, msg,...)
Definition srv_log.h:83
@ AIT_TAXES
Definition srv_log.h:48
@ AIT_UNITS
Definition srv_log.h:43
@ AIT_CITIES
Definition srv_log.h:49
@ AIT_TECH
Definition srv_log.h:53
@ AIT_ALL
Definition srv_log.h:41
@ TIMER_STOP
Definition srv_log.h:76
@ TIMER_START
Definition srv_log.h:76
#define TIMING_LOG(timer, activity)
Definition srv_log.h:125
int req
Definition advdata.h:133
adv_want val
Definition advdata.h:132
struct government * revolution
Definition advdata.h:135
bool celebrate
Definition advdata.h:142
struct government * gov
Definition advdata.h:131
struct adv_data::@93 goal
struct adv_data::@93::@95 govt
bool celebrate
Definition daicity.h:57
Definition ai.h:50
struct packet_game_info info
Definition game.h:89
struct government * government_during_revolution
Definition game.h:94
Definition cm.h:52
enum gold_upkeep_style gold_upkeep_style
enum tech_upkeep_style tech_upkeep_style
enum spaceship_state state
Definition spaceship.h:108
struct city_list * cities
Definition player.h:279
int bulbs_last_turn
Definition player.h:349
struct unit_list * units
Definition player.h:280
struct conn_list * connections
Definition player.h:296
bool is_alive
Definition player.h:266
struct player_economic economic
Definition player.h:282
struct player_spaceship spaceship
Definition player.h:284
struct player::@70::@72 server
int bulbs_researched
Definition research.h:53
Definition timing.c:81
int upkeep[O_LAST]
Definition unit.h:148
struct civ_map map
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
#define A_UNSET
Definition tech.h:48
void timer_destroy(struct timer *t)
Definition timing.c:208
void timer_start(struct timer *t)
Definition timing.c:264
void timer_stop(struct timer *t)
Definition timing.c:308
struct timer * timer_new(enum timer_timetype type, enum timer_use use, const char *name)
Definition timing.c:160
double timer_read_seconds(struct timer *t)
Definition timing.c:384
#define TIMER_DEBUG
Definition timing.h:61
@ TIMER_CPU
Definition timing.h:41
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
bool victory_enabled(enum victory_condition_type victory)
Definition victory.c:26