Freeciv-3.2
Loading...
Searching...
No Matches
daidomestic.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#include <string.h>
19#include <math.h> /* pow, ceil */
20
21/* utility */
22#include "log.h"
23#include "mem.h"
24
25/* common */
26#include "city.h"
27#include "game.h"
28#include "government.h"
29#include "map.h"
30#include "movement.h"
31#include "traderoutes.h"
32#include "unit.h"
33#include "unitlist.h"
34#include "unittype.h"
35
36/* common/aicore */
37#include "pf_tools.h"
38
39/* server */
40#include "citytools.h"
41#include "unittools.h"
42#include "srv_log.h"
43
44/* server/advisors */
45#include "advbuilding.h"
46#include "advchoice.h"
47#include "advdata.h"
48#include "autosettlers.h"
49#include "infracache.h" /* adv_city */
50
51/* ai */
52#include "aitraits.h"
53#include "handicaps.h"
54
55/* ai/default */
56#include "aitech.h"
57#include "aitools.h"
58#include "daicity.h"
59#include "daidata.h"
60#include "daimilitary.h"
61#include "daiplayer.h"
62
63#include "daidomestic.h"
64
65
66/***********************************************************************/
72static void dai_choose_help_wonder(struct ai_type *ait,
73 struct city *pcity,
74 struct adv_choice *choice,
75 struct adv_data *ai)
76{
77 struct player *pplayer = city_owner(pcity);
78 Continent_id continent = tile_continent(pcity->tile);
79 struct ai_city *city_data = def_ai_city_data(pcity, ait);
80 /* Total count of caravans available or already being built
81 * on this continent */
82 int caravans = 0;
83 /* The type of the caravan */
84 struct unit_type *unit_type;
85 struct city *wonder_city = game_city_by_number(ai->wonder_city);
86
88 /* No such units available in the ruleset */
89 return;
90 }
91
92 if (pcity == wonder_city
93 || wonder_city == NULL
94 || city_data->distance_to_wonder_city <= 0
96 /* TODO: Should helping to build a unit be considered when legal? */
97 || VUT_UTYPE == wonder_city->production.kind
98 /* TODO: Should helping to build an improvement be considered when
99 * legal? */
100 || !is_wonder(wonder_city->production.value.building)) {
101 /* A distance of zero indicates we are very far away, possibly
102 * on another continent. */
103 return;
104 }
105
106 /* Count existing caravans */
107 unit_list_iterate(pplayer->units, punit) {
109 && tile_continent(unit_tile(punit)) == continent)
110 caravans++;
112
113 /* Count caravans being built */
114 city_list_iterate(pplayer->cities, acity) {
115 if (VUT_UTYPE == acity->production.kind
116 && utype_can_do_action(acity->production.value.utype,
118 && tile_continent(acity->tile) == continent) {
119 caravans++;
120 }
122
124
125 if (!unit_type) {
126 /* We cannot build such units yet
127 * but we will consider it to stimulate science */
129 }
130
132 "Non existence of wonder helper unit not caught");
133
134 /* Check if wonder needs a little help. */
135 if (build_points_left(wonder_city)
137 const struct impr_type *wonder = wonder_city->production.value.building;
139 int dist = city_data->distance_to_wonder_city /
141
143
144 want /= MAX(dist, 1);
145 CITY_LOG(LOG_DEBUG, pcity, "want %s to help wonder in %s with " ADV_WANT_PRINTF,
147 city_name_get(wonder_city),
148 want);
149 if (want > choice->want) {
150 /* This sets our tech want in cases where we cannot actually build
151 * the unit. */
152 unit_type = dai_wants_role_unit(ait, pplayer, pcity,
154 want);
155 if (unit_type != NULL) {
156 choice->want = want;
157 choice->type = CT_CIVILIAN;
158 choice->value.utype = unit_type;
159 } else {
160 CITY_LOG(LOG_DEBUG, pcity,
161 "would but could not build ACTION_HELP_WONDER unit, "
162 "bumped reqs");
163 }
164 }
165 }
166}
167
168/***********************************************************************/
173static void dai_choose_trade_route(struct ai_type *ait, struct city *pcity,
174 struct adv_choice *choice,
175 struct adv_data *ai)
176{
177 struct player *pplayer = city_owner(pcity);
178 struct unit_type *unit_type;
179 adv_want want;
180 int income, bonus;
181 int trade_routes;
182 int caravan_units;
184 int max_routes;
185 Continent_id continent = tile_continent(pcity->tile);
186 bool dest_city_found = FALSE;
192 int pct = 0;
193 int trader_trait;
195 bool need_boat = FALSE;
196 int trade_action;
197
198 if (city_list_size(pplayer->cities) < 5) {
199 /* Consider trade routes only if enough destination cities.
200 * This is just a quick check. We make more detailed check below. */
201 return;
202 }
203
206 /* No such units available in the ruleset */
207 return;
208 }
209
212
213 if (!unit_type) {
214 /* Can't establish trade route yet. What about entering a marketplace? */
215 /* TODO: Should a future unit capable of establishing trade routes be
216 * prioritized above a present unit capable of entering a market place?
217 * In that case this should be below the check for a future unit
218 * capable of establishing a trade route. */
221 }
222
223 if (!unit_type) {
224 /* We cannot build such units yet
225 * but we will consider it to stimulate science */
227 }
228
229 if (!unit_type) {
230 /* We'll never be able to establish a trade route. Consider a unit that
231 * can enter the marketplace instead, to stimulate science. */
233 }
234
236 "Non-existence of trade unit not caught");
237
238 if (unit_type) {
240
241 /* Hope there is no "water cities in lakes" ruleset? */
242 can_move_ic = pclass->adv.sea_move != MOVE_NONE;
243 has_boats = pclass->adv.ferry_types > 0;
244 }
245
248 && (can_move_ic || has_boats)) {
250 } else {
252 }
253
254 /* Look for proper destination city for trade. */
257 /* National trade routes have value */
258 city_list_iterate(pplayer->cities, acity) {
259 if (can_cities_trade(pcity, acity)) {
260 if (tile_continent(acity->tile) != continent) {
261 if (!(can_move_ic || has_boats)) {
262 /* FIXME: get by roads/rivers? */
263 continue;
264 }
268 break;
269 }
270 } else {
274 break;
275 }
276 }
277 }
279 }
280
281 /* FIXME: This check should consider more about relative
282 * income from different trade route types. This works just
283 * with more typical ruleset setups. */
288 } else {
290 }
291
293 if (aplayer == pplayer || !aplayer->is_alive) {
294 continue;
295 }
296 if (pplayers_allied(pplayer, aplayer)) {
298 if (can_cities_trade(pcity, acity)) {
299 if (tile_continent(acity->tile) != continent) {
300 if (!(can_move_ic || has_boats)) {
301 /* FIXME: get by roads/rivers? */
302 continue;
303 }
307 break;
308 }
309 } else {
313 break;
314 }
315 }
316 }
318 }
321 break;
322 }
324 }
325
326 if (!dest_city_found) {
327 /* No proper destination city. */
328 return;
329 }
330
332 /* Count also caravans enroute to establish trade routes */
333 caravan_units = 0;
337 }
339
343
344 /* We consider only initial benefit from establishing trade route.
345 * We may actually get only initial benefit if both cities already
346 * have four trade routes, if there already is route between them
347 * or if the Establish Trade Route action is illegal. */
348
349 /* The calculations of get_caravan_enter_city_trade_bonus() have to be
350 * duplicated here because the city traded with is imaginary. */
351
352 /* We assume that we are creating trade route to city with 75% of
353 * pcitys trade 10 squares away (FIXME: another estimation?). */
355 int wd = ((100 - game.info.trade_world_rel_pct) * 10
357 * (10 * 40 / MAX(wld.map.xsize, wld.map.ysize))) / 100;
358
359 income = pow(log(wd + 20 + 1.75 * max_trade_prod(pcity)) * 2, 2);
360 } else /* assume CBS_CLASSIC */ {
361 income = (10 + 10) * (1.75 * pcity->surplus[O_TRADE]) / 24;
362 }
363
364 /* A ruleset may use the Trade_Revenue_Bonus effect to reduce the one
365 * time bonus if no trade route is established. Make sure it gets the
366 * correct action. */
370 &(const struct req_context) {
371 .player = pplayer,
372 .city = pcity,
373 .tile = city_tile(pcity),
374 .unittype = unit_type,
375 .action =
377 },
378 NULL,
380
381 /* Be mercy full to players with small amounts. Round up. */
382 income = ceil((float)income * pow(2.0, (double)bonus / 1000.0));
383
386 }
389
390 pct = MAX(pct, typepct);
391 }
394
395 if (typepct > pct) {
396 pct = typepct;
397 need_boat = TRUE;
398 }
399 }
402
403 if (typepct > pct) {
404 pct = typepct;
405 need_boat = TRUE;
406 }
407 }
408
409 need_boat = need_boat && !can_move_ic;
410 income = pct * income / 100;
411
412 want = income * ai->gold_priority + income * ai->science_priority;
413
414 /* We get this income only once after all.
415 * This value is adjusted for most interesting gameplay.
416 * For optimal performance AI should build more caravans, but
417 * we want it to build less valued buildings too. */
419 want /= (130 * TRAIT_DEFAULT_VALUE / trader_trait);
420
421 /* Increase want for trade routes if our economy is very weak.
422 * We may have enough gold, but only because we have already set
423 * tax rate to 100%. So don't check gold directly, but tax rate.
424 * This method helps us out of deadlocks of completely stalled
425 * scientific progress.
426 */
427 if (pplayer->economic.science < 50 && trade_routes < max_routes
429 want *=
430 (6 - pplayer->economic.science / 10) * (6 - pplayer->economic.science / 10);
431 }
432
433 if (trade_routes == 0 && max_routes > 0
435 /* If we have no trade routes at all, we are certainly creating a new one. */
436 want += trader_trait;
437 } else if (trade_routes < max_routes
439 /* Possibly creating a new trade route */
440 want += trader_trait / 4;
441 }
442
444
445 /* Don't pile too many of them */
446 if (unassigned_caravans * 10 > want && want > 0.0) {
447 want = 0.1;
448 } else {
449 want -= unassigned_caravans * 10; /* Don't pile too many of them */
450 }
451
452 CITY_LOG(LOG_DEBUG, pcity,
453 "want for trade route unit is " ADV_WANT_PRINTF " (expected initial income %d)",
454 want,
455 income);
456
457 if (want > choice->want) {
458 /* This sets our tech want in cases where we cannot actually build
459 * the unit. */
460 unit_type = dai_wants_role_unit(ait, pplayer, pcity,
462 want);
463
464 if (unit_type == NULL) {
465 unit_type = dai_wants_role_unit(ait, pplayer, pcity,
467 want);
468 }
469
470 /* We don't want to build caravan that wouldn't be able to reach the
471 * destination by any means. It would be useless. */
472 if (unit_type != NULL && (!need_boat || has_boats)) {
473 choice->want = want;
474 choice->type = CT_CIVILIAN;
475 choice->value.utype = unit_type;
476 choice->need_boat = need_boat;
477 } else {
478 CITY_LOG(LOG_DEBUG, pcity,
479 "would but could not build trade route unit, bumped reqs");
480 }
481 }
482}
483
484/***********************************************************************/
490 struct player *pplayer,
491 struct city *pcity)
492{
493 struct adv_data *adv = adv_data_get(pplayer, NULL);
494 /* Unit type with certain role */
495 struct unit_type *worker_type;
496 struct unit_type *founder_type;
497 adv_want worker_want, founder_want;
498 struct ai_city *city_data = def_ai_city_data(pcity, ait);
499 struct adv_choice *choice = adv_new_choice();
500
501 /* Find out desire for workers (terrain improvers) */
502 worker_type = city_data->worker_type;
503
504 /* The worker want is calculated in daicity.c called from
505 * dai_manage_cities(). The expand value is the % that the AI should
506 * value expansion (basically to handicap easier difficulty levels)
507 * and is set when the difficulty level is changed (difficulty.c). */
508 worker_want = city_data->worker_want * pplayer->ai_common.expand / 100;
509
510 if (adv->wonder_city == pcity->id) {
511 if (worker_type == NULL || worker_type->pop_cost > 0) {
512 worker_want /= 5;
513 } else {
514 worker_want /= 2;
515 }
516 }
517
518 if (worker_type != NULL
519 && pcity->surplus[O_FOOD] > utype_upkeep_cost(worker_type,
520 pplayer, O_FOOD)) {
521 if (worker_want > 0) {
522 CITY_LOG(LOG_DEBUG, pcity,
523 "desires terrain improvers with passion " ADV_WANT_PRINTF,
524 worker_want);
525 dai_choose_role_unit(ait, pplayer, pcity, choice, CT_CIVILIAN,
526 UTYF_SETTLERS, worker_want, FALSE);
527 adv_choice_set_use(choice, "worker");
528 }
529 /* Terrain improvers don't use boats (yet) */
530
531 } else if (worker_type == NULL && worker_want > 0) {
532 /* Can't build workers. Lets stimulate science */
533 dai_wants_role_unit(ait, pplayer, pcity, UTYF_SETTLERS, worker_want);
534 }
535
536 /* Find out desire for city founders */
537 /* Basically, copied from above and adjusted. -- jjm */
541
542 /* founder_want calculated in daisettlers.c */
543 founder_want = city_data->founder_want;
544
545 if (adv->wonder_city == pcity->id) {
546 if (founder_type == NULL || founder_type->pop_cost > 0) {
547 founder_want /= 5;
548 } else {
549 founder_want /= 2;
550 }
551 }
552
553 if (adv->max_num_cities <= city_list_size(pplayer->cities)) {
554 founder_want /= 100;
555 }
556
557 /* Adjust founder want by traits */
558 founder_want *= (double)ai_trait_get_value(TRAIT_EXPANSIONIST, pplayer)
560
561 if (founder_type
563 pplayer, O_FOOD)) {
564
565 if (founder_want > choice->want) {
566 CITY_LOG(LOG_DEBUG, pcity,
567 "desires founders with passion " ADV_WANT_PRINTF,
568 founder_want);
569 dai_choose_role_unit(ait, pplayer, pcity, choice, CT_CIVILIAN,
571 founder_want,
572 city_data->founder_boat);
573 adv_choice_set_use(choice, "founder");
574
575 } else if (founder_want < -choice->want) {
576 /* We need boats to colonize! */
577 /* We might need boats even if there are boats free,
578 * if they are blockaded or in inland seas. */
579 struct ai_plr *ai = dai_plr_data_get(ait, pplayer, NULL);
580
581 CITY_LOG(LOG_DEBUG, pcity,
582 "desires founders with passion " ADV_WANT_PRINTF
583 " and asks for a new boat (%d of %d free)",
584 -founder_want, ai->stats.available_boats, ai->stats.boats);
585
586 /* First fill choice with founder information */
587 choice->want = 0 - founder_want;
588 choice->type = CT_CIVILIAN;
589 choice->value.utype = founder_type; /* Default */
590 choice->need_boat = TRUE;
591
592 /* Then try to overwrite it with ferryboat information
593 * If no ferryboat is found, above founder choice stays. */
594 dai_choose_role_unit(ait, pplayer, pcity, choice, CT_CIVILIAN,
595 L_FERRYBOAT, -founder_want, TRUE);
596 adv_choice_set_use(choice, "founder's boat");
597 }
598 } else if (!founder_type
599 && (founder_want > choice->want || founder_want < -choice->want)) {
600 /* Can't build founders. Lets stimulate science */
601 dai_wants_role_unit(ait, pplayer, pcity,
603 founder_want);
604 }
605 }
606
607 {
608 struct adv_choice *cur;
609
610 /* Consider building caravan-type units to aid wonder construction */
612 adv_choice_set_use(cur, "wonder");
613 dai_choose_help_wonder(ait, pcity, cur, adv);
614 choice = adv_better_choice_free(choice, cur);
615
616 /* Consider city improvements */
618 adv_choice_set_use(cur, "improvement");
620 cur->want = cur->want * (0.5 + (ai_trait_get_value(TRAIT_BUILDER, pplayer)
621 / TRAIT_DEFAULT_VALUE / 2));
622 choice = adv_better_choice_free(choice, cur);
623
624 /* Consider building caravan-type units for trade route */
626 adv_choice_set_use(cur, "trade route");
627 dai_choose_trade_route(ait, pcity, cur, adv);
628 choice = adv_better_choice_free(choice, cur);
629 }
630
631 if (choice->want > DAI_WANT_DOMESTIC_MAX) {
632 /* If we don't do following, we buy caravans in city X when we should be
633 * saving money to buy defenses for city Y. -- Syela */
634 choice->want = DAI_WANT_DOMESTIC_MAX;
635 }
636
637 return choice;
638}
639
640/***********************************************************************/
643void dai_wonder_city_distance(struct ai_type *ait, struct player *pplayer,
644 struct adv_data *adv)
645{
646 struct pf_map *pfm;
647 struct pf_parameter parameter;
648 struct unit_type *punittype;
649 struct unit *ghost;
650 int maxrange;
651 struct city *wonder_city = game_city_by_number(adv->wonder_city);
652 const struct civ_map *nmap = &(wld.map);
653
654 city_list_iterate(pplayer->cities, acity) {
655 /* Mark unavailable */
658
659 if (wonder_city == NULL) {
660 return;
661 }
662
665
666 if (!punittype) {
667 return;
668 }
669
671 "Non existence of wonder helper unit not caught");
672
673 ghost = unit_virtual_create(pplayer, wonder_city, punittype, 0);
675
676 pft_fill_unit_parameter(&parameter, nmap, ghost);
677 parameter.omniscience = !has_handicap(pplayer, H_MAP);
678 pfm = pf_map_new(&parameter);
679
680 pf_map_move_costs_iterate(pfm, ptile, move_cost, FALSE) {
681 struct city *acity = tile_city(ptile);
682
683 if (move_cost > maxrange) {
684 break;
685 }
686 if (!acity) {
687 continue;
688 }
689 if (city_owner(acity) == pplayer) {
691 }
693
696}
static struct action * action_by_number(action_id act_id)
Definition actions.h:635
#define action_id_get_role(act_id)
Definition actions.h:696
void building_advisor_choose(struct city *pcity, struct adv_choice *choice)
#define SHIELD_WEIGHTING
Definition advbuilding.h:20
struct adv_choice * adv_better_choice_free(struct adv_choice *first, struct adv_choice *second)
Definition advchoice.c:98
struct adv_choice * adv_new_choice(void)
Definition advchoice.c:59
#define adv_choice_set_use(_choice, _use)
Definition advchoice.h:85
@ CT_CIVILIAN
Definition advchoice.h:39
struct adv_data * adv_data_get(struct player *pplayer, bool *caller_closes)
Definition advdata.c:605
struct unit_type * dai_wants_role_unit(struct ai_type *ait, struct player *pplayer, struct city *pcity, int role, int want)
Definition aitech.c:522
bool dai_choose_role_unit(struct ai_type *ait, struct player *pplayer, struct city *pcity, struct adv_choice *choice, enum choice_type type, int role, int want, bool need_boat)
Definition aitools.c:1346
#define DAI_WANT_DOMESTIC_MAX
Definition aitools.h:33
int ai_trait_get_value(enum trait tr, struct player *pplayer)
Definition aitraits.c:69
bool city_production_gets_caravan_shields(const struct universal *tgt)
Definition city.c:1860
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
#define city_list_iterate(citylist, pcity)
Definition city.h:508
#define city_tile(_pcity_)
Definition city.h:564
#define city_owner(_pcity_)
Definition city.h:563
#define city_list_iterate_end
Definition city.h:510
int build_points_left(struct city *pcity)
Definition citytools.c:576
char * incite_cost
Definition comments.c:75
struct ai_plr * dai_plr_data_get(struct ai_type *ait, struct player *pplayer, bool *caller_closes)
Definition daidata.c:308
void dai_wonder_city_distance(struct ai_type *ait, struct player *pplayer, struct adv_data *adv)
struct adv_choice * domestic_advisor_choose_build(struct ai_type *ait, struct player *pplayer, struct city *pcity)
static void dai_choose_trade_route(struct ai_type *ait, struct city *pcity, struct adv_choice *choice, struct adv_data *ai)
static void dai_choose_help_wonder(struct ai_type *ait, struct city *pcity, struct adv_choice *choice, struct adv_data *ai)
Definition daidomestic.c:72
static struct ai_city * def_ai_city_data(const struct city *pcity, struct ai_type *deftype)
Definition daiplayer.h:42
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
int get_target_bonus_effects(struct effect_list *plist, const struct req_context *context, const struct player *other_player, enum effect_type effect_type)
Definition effects.c:748
float adv_want
Definition fc_types.h:1354
#define ADV_WANT_PRINTF
Definition fc_types.h:1355
@ O_FOOD
Definition fc_types.h:101
@ O_TRADE
Definition fc_types.h:101
signed short Continent_id
Definition fc_types.h:372
struct civ_game game
Definition game.c:62
struct world wld
Definition game.c:63
struct city * game_city_by_number(int id)
Definition game.c:107
bool has_handicap(const struct player *pplayer, enum handicap_type htype)
Definition handicaps.c:66
@ H_MAP
Definition handicaps.h:28
Impr_type_id improvement_index(const struct impr_type *pimprove)
bool is_wonder(const struct impr_type *pimprove)
#define fc_assert_msg(condition, message,...)
Definition log.h:181
#define fc_assert_ret(condition)
Definition log.h:191
@ LOG_DEBUG
Definition log.h:34
int unit_move_rate(const struct unit *punit)
Definition movement.c:90
struct pf_map * pf_map_new(const struct pf_parameter *parameter)
void pf_map_destroy(struct pf_map *pfm)
#define pf_map_move_costs_iterate_end
#define pf_map_move_costs_iterate(ARG_pfm, NAME_tile, NAME_cost, COND_from_start)
void pft_fill_unit_parameter(struct pf_parameter *parameter, const struct civ_map *nmap, const struct unit *punit)
Definition pf_tools.c:840
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1405
#define players_iterate_end
Definition player.h:537
#define players_iterate(_pplayer)
Definition player.h:532
#define MAX(x, y)
Definition shared.h:54
#define CITY_LOG(loglevel, pcity, msg,...)
Definition srv_log.h:83
enum choice_type type
Definition advchoice.h:46
adv_want want
Definition advchoice.h:48
universals_u value
Definition advchoice.h:47
bool need_boat
Definition advchoice.h:49
adv_want building_want[B_LAST]
Definition infracache.h:32
int max_num_cities
Definition advdata.h:145
int wonder_city
Definition advdata.h:55
int science_priority
Definition advdata.h:117
int gold_priority
Definition advdata.h:116
int distance_to_wonder_city
Definition daicity.h:54
struct ai_plr::@253 stats
int boats
Definition daidata.h:79
int available_boats
Definition daidata.h:80
Definition ai.h:50
Definition city.h:320
int surplus[O_LAST]
Definition city.h:355
int id
Definition city.h:326
struct universal production
Definition city.h:396
struct adv_city * adv
Definition city.h:452
struct tile * tile
Definition city.h:322
struct city::@17::@19 server
struct unit_list * units_supported
Definition city.h:406
struct packet_game_info info
Definition game.h:89
struct packet_scenario_info scenario
Definition game.h:87
int xsize
Definition map_types.h:78
int ysize
Definition map_types.h:78
enum caravan_bonus_style caravan_bonus_style
int expand
Definition player.h:116
struct city_list * cities
Definition player.h:279
struct player_ai ai_common
Definition player.h:286
struct unit_list * units
Definition player.h:280
bool is_alive
Definition player.h:266
struct player_economic economic
Definition player.h:282
int pop_cost
Definition unittype.h:513
int move_rate
Definition unittype.h:517
Definition unit.h:138
enum universals_n kind
Definition fc_types.h:902
universals_u value
Definition fc_types.h:901
struct civ_map map
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_continent(_tile)
Definition tile.h:92
int max_trade_prod(const struct city *pcity)
bool can_cities_trade(const struct city *pc1, const struct city *pc2)
int trade_route_type_trade_pct(enum trade_route_type type)
int city_num_trade_routes(const struct city *pcity)
unsigned max_trade_routes(const struct city *pcity)
Definition traderoutes.c:48
@ TRT_NATIONAL_IC
Definition traderoutes.h:39
@ TRT_IN_IC
Definition traderoutes.h:41
@ TRT_NATIONAL
Definition traderoutes.h:38
@ TRT_IN
Definition traderoutes.h:40
#define TRAIT_DEFAULT_VALUE
Definition traits.h:32
const struct unit_type * utype
Definition fc_types.h:721
const struct impr_type * building
Definition fc_types.h:714
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:359
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Definition unit.c:1624
void unit_virtual_destroy(struct unit *punit)
Definition unit.c:1729
#define unit_tile(_pu)
Definition unit.h:397
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
struct unit_type * best_role_unit(const struct city *pcity, int role)
Definition unittype.c:2271
int utype_upkeep_cost(const struct unit_type *ut, struct player *pplayer, Output_type_id otype)
Definition unittype.c:132
struct unit_type * get_role_unit(int role, int role_index)
Definition unittype.c:2253
int utype_build_shield_cost_base(const struct unit_type *punittype)
Definition unittype.c:1468
int num_role_units(int role)
Definition unittype.c:2203
struct unit_type * best_role_unit_for_player(const struct player *pplayer, int role)
Definition unittype.c:2298
const char * utype_rule_name(const struct unit_type *punittype)
Definition unittype.c:1578
int utype_build_shield_cost(const struct city *pcity, const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1438
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:371
#define utype_class(_t_)
Definition unittype.h:749
@ MOVE_NONE
Definition unittype.h:144