Freeciv-3.3: /fast/freeciv/nightly/main/ai/default/daidata.c Source File

Freeciv-3.3

Loading...
Searching...
No Matches
daidata.c
Go to the documentation of this file.
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
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* common */
19#include "game.h"
20#include "government.h"
21#include "map.h"
22#include "multipliers.h"
23#include "research.h"
24
25/* aicore */
26#include "aiactions.h"
27
28/* server */
29#include "cityturn.h"
30#include "plrhand.h"
31
32/* server/advisors */
33#include "advdata.h"
34
35/* ai/default */
36#include "aiferry.h"
37#include "daicity.h"
38#include "daidiplomacy.h"
39#include "daieffects.h"
40#include "daiplayer.h"
41#include "daisettler.h"
42#include "daiunit.h"
43
44#include "daidata.h"
45
46static void dai_diplomacy_new(struct ai_type *ait,
47 const struct player *plr1,
48 const struct player *plr2);
49static void dai_diplomacy_defaults(struct ai_type *ait,
50 const struct player *plr1,
51 const struct player *plr2);
52static void dai_diplomacy_destroy(struct ai_type *ait,
53 const struct player *plr1,
54 const struct player *plr2);
55
56/************************************************************************/
59 void dai_data_init(struct ai_type *ait, struct player *pplayer)
60{
61 struct ai_plr *ai = def_ai_player_data(pplayer, ait);
62
63 ai->phase_initialized = FALSE;
64
65 ai->last_num_continents = -1;
66 ai->last_num_oceans = -1;
67
68 ai->diplomacy.player_intel_slots
69 = fc_calloc(player_slot_count(),
70 sizeof(*ai->diplomacy.player_intel_slots));
71 player_slots_iterate(pslot) {
72 const struct ai_dip_intel **player_intel_slot
73 = ai->diplomacy.player_intel_slots + player_slot_index(pslot);
74 *player_intel_slot = NULL;
75 } player_slots_iterate_end;
76
77 players_iterate(aplayer) {
78 /* create ai diplomacy states for all other players */
79 dai_diplomacy_new(ait, pplayer, aplayer);
80 dai_diplomacy_defaults(ait, pplayer, aplayer);
81 /* create ai diplomacy state of this player */
82 if (aplayer != pplayer) {
83 dai_diplomacy_new(ait, aplayer, pplayer);
84 dai_diplomacy_defaults(ait, aplayer, pplayer);
85 }
86 } players_iterate_end;
87
88 ai->diplomacy.strategy = WIN_OPEN;
89 ai->diplomacy.timer = 0;
90 ai->diplomacy.love_coeff = 4; /* 4% */
91 ai->diplomacy.love_incr = MAX_AI_LOVE * 3 / 100;
92 ai->diplomacy.req_love_for_peace = MAX_AI_LOVE / 8;
93 ai->diplomacy.req_love_for_alliance = MAX_AI_LOVE / 4;
94
95 ai->settler = NULL;
96
97 /* Initialise autoworker. */
98 dai_auto_settler_init(ai);
99}
100
101/************************************************************************/
104 void dai_data_close(struct ai_type *ait, struct player *pplayer)
105{
106 struct ai_plr *ai = def_ai_player_data(pplayer, ait);
107
108 /* Finish the phase if it's open - free resources related to
109 * open/finish cycle */
110 dai_data_phase_finished(ait, pplayer);
111
112 /* Free autoworker. */
113 dai_auto_settler_free(ai);
114
115 if (ai->diplomacy.player_intel_slots != NULL) {
116 players_iterate(aplayer) {
117 /* destroy the ai diplomacy states of this player with others ... */
118 dai_diplomacy_destroy(ait, pplayer, aplayer);
119 /* and of others with this player. */
120 if (aplayer != pplayer) {
121 dai_diplomacy_destroy(ait, aplayer, pplayer);
122 }
123 } players_iterate_end;
124 free(ai->diplomacy.player_intel_slots);
125 }
126}
127
128/************************************************************************/
132 bool is_ai_data_phase_open(struct ai_type *ait, struct player *pplayer)
133{
134 struct ai_plr *ai = def_ai_player_data(pplayer, ait);
135
136 return ai->phase_initialized;
137}
138
139/************************************************************************/
142 void dai_data_phase_begin(struct ai_type *ait, struct player *pplayer,
143 bool is_new_phase)
144{
145 struct ai_plr *ai = def_ai_player_data(pplayer, ait);
146 bool caller_closes;
147
148 /* Note that this refreshes advisor data if needed. ai_plr_data_get()
149 is expected to refresh advisor data if needed, and ai_plr_data_get()
150 depends on this call
151 ai_plr_data_get()->ai_data_phase_begin()->adv_data_get() to do it.
152 If you change this, you may need to adjust ai_plr_data_get() also. */
153 struct adv_data *adv;
154
155 if (ai->phase_initialized) {
156 return;
157 }
158
159 ai->phase_initialized = TRUE;
160
161 adv = adv_data_get(pplayer, &caller_closes);
162
163 /* Store current number of known continents and oceans so we can compare
164 against it later in order to see if ai data needs refreshing. */
165 ai->last_num_continents = adv->num_continents;
166 ai->last_num_oceans = adv->num_oceans;
167
168 /*** Diplomacy ***/
169 if (is_ai(pplayer) && !is_barbarian(pplayer) && is_new_phase) {
170 dai_diplomacy_begin_new_phase(ait, pplayer);
171 }
172
173 /* Set per-player variables. We must set all players, since players
174 * can be created during a turn, and we don't want those to have
175 * invalid values. */
176 players_iterate(aplayer) {
177 struct ai_dip_intel *adip = dai_diplomacy_get(ait, pplayer, aplayer);
178
179 adip->is_allied_with_enemy = NULL;
180 adip->at_war_with_ally = NULL;
181 adip->is_allied_with_ally = NULL;
182
183 players_iterate(check_pl) {
184 if (check_pl == pplayer
185 || check_pl == aplayer
186 || !check_pl->is_alive) {
187 continue;
188 }
189 if (pplayers_allied(aplayer, check_pl)
190 && player_diplstate_get(pplayer, check_pl)->type == DS_WAR) {
191 adip->is_allied_with_enemy = check_pl;
192 }
193 if (pplayers_allied(pplayer, check_pl)
194 && player_diplstate_get(aplayer, check_pl)->type == DS_WAR) {
195 adip->at_war_with_ally = check_pl;
196 }
197 if (pplayers_allied(aplayer, check_pl)
198 && pplayers_allied(pplayer, check_pl)) {
199 adip->is_allied_with_ally = check_pl;
200 }
201 } players_iterate_end;
202 } players_iterate_end;
203
204 /*** Statistics ***/
205
206 ai->stats.workers = fc_calloc(adv->num_continents + 1, sizeof(int));
207 ai->stats.ocean_workers = fc_calloc(adv->num_oceans + 1, sizeof(int));
208 unit_list_iterate(pplayer->units, punit) {
209 struct tile *ptile = unit_tile(punit);
210
211 if (unit_has_type_flag(punit, UTYF_WORKERS)) {
212 Continent_id cont = tile_continent(ptile);
213
214 if (is_ocean_tile(ptile)) {
215 if (cont <= 0 && -cont <= adv->num_oceans) {
216 ai->stats.ocean_workers[(int)-cont]++;
217 } else {
218 /* Always fails */
219 fc_assert(cont <= 0 && -cont <= adv->num_oceans);
220 }
221 } else {
222 if (cont >= 0 && cont <= adv->num_continents) {
223 ai->stats.workers[(int)cont]++;
224 } else {
225 /* Always fails */
226 fc_assert(cont >= 0 && cont <= adv->num_continents);
227 }
228 }
229 }
230 } unit_list_iterate_end;
231
232 BV_CLR_ALL(ai->stats.diplomat_reservations);
233 unit_list_iterate(pplayer->units, punit) {
234 if (aia_utype_is_considered_spy_vs_city(unit_type_get(punit))
235 && def_ai_unit_data(punit, ait)->task == AIUNIT_ATTACK) {
236
237 fc_assert_msg(punit->goto_tile != NULL, "No target city for spy action");
238
239 if (punit->goto_tile != NULL) {
240 struct city *pcity = tile_city(punit->goto_tile);
241
242 if (pcity != NULL) {
243 /* Heading somewhere on a mission, reserve target. */
244 BV_SET(ai->stats.diplomat_reservations, pcity->id);
245 }
246 }
247 }
248 } unit_list_iterate_end;
249
250 aiferry_init_stats(ait, pplayer);
251
252 /*** Interception engine ***/
253
254 /* We are tracking a unit if punit->server.ai->cur_pos is not NULL. If we
255 * are not tracking, start tracking by setting cur_pos. If we are,
256 * fill prev_pos with previous cur_pos. This way we get the
257 * necessary coordinates to calculate a probable trajectory. */
258 players_iterate_alive(aplayer) {
259 if (aplayer == pplayer) {
260 continue;
261 }
262 unit_list_iterate(aplayer->units, punit) {
263 struct unit_ai *unit_data = def_ai_unit_data(punit, ait);
264
265 if (!unit_data->cur_pos) {
266 /* Start tracking */
267 unit_data->cur_pos = &unit_data->cur_struct;
268 unit_data->prev_pos = NULL;
269 } else {
270 unit_data->prev_struct = unit_data->cur_struct;
271 unit_data->prev_pos = &unit_data->prev_struct;
272 }
273 *unit_data->cur_pos = unit_tile(punit);
274 } unit_list_iterate_end;
275 } players_iterate_alive_end;
276
277 if (caller_closes) {
278 adv_data_phase_done(pplayer);
279 }
280}
281
282/************************************************************************/
285 void dai_data_phase_finished(struct ai_type *ait, struct player *pplayer)
286{
287 struct ai_plr *ai = def_ai_player_data(pplayer, ait);
288
289 if (!ai->phase_initialized) {
290 return;
291 }
292
293 free(ai->stats.workers);
294 ai->stats.workers = NULL;
295
296 free(ai->stats.ocean_workers);
297 ai->stats.ocean_workers = NULL;
298
299 ai->phase_initialized = FALSE;
300}
301
302/************************************************************************/
308 struct ai_plr *dai_plr_data_get(struct ai_type *ait, struct player *pplayer,
309 bool *caller_closes)
310{
311 struct ai_plr *ai = def_ai_player_data(pplayer, ait);
312
313 fc_assert_ret_val(ai != NULL, NULL);
314
315 /* This assert really is required. See longer comment
316 in adv_data_get() for equivalent code. */
317#if defined(FREECIV_DEBUG) || defined(IS_DEVEL_VERSION)
318 fc_assert(caller_closes != NULL || ai->phase_initialized);
319#endif
320
321 if (caller_closes != NULL) {
322 *caller_closes = FALSE;
323 }
324
325 if (ai->last_num_continents != wld.map.num_continents
326 || ai->last_num_oceans != wld.map.num_oceans) {
327 /* We have discovered more continents, recalculate! */
328
329 /* See adv_data_get() */
330 if (ai->phase_initialized) {
331 dai_data_phase_finished(ait, pplayer);
332 dai_data_phase_begin(ait, pplayer, FALSE);
333 } else {
334 /* wrong order */
335 log_debug("%s ai data phase closed when dai_plr_data_get() called",
336 player_name(pplayer));
337 dai_data_phase_begin(ait, pplayer, FALSE);
338 if (caller_closes != NULL) {
339 *caller_closes = TRUE;
340 } else {
341 dai_data_phase_finished(ait, pplayer);
342 }
343 }
344 } else {
345 if (!ai->phase_initialized && caller_closes != NULL) {
346 dai_data_phase_begin(ait, pplayer, FALSE);
347 *caller_closes = TRUE;
348 }
349 }
350
351 return ai;
352}
353
354/************************************************************************/
357 static void dai_diplomacy_new(struct ai_type *ait,
358 const struct player *plr1,
359 const struct player *plr2)
360{
361 struct ai_dip_intel *player_intel;
362
363 fc_assert_ret(plr1 != NULL);
364 fc_assert_ret(plr2 != NULL);
365
366 const struct ai_dip_intel **player_intel_slot
367 = def_ai_player_data(plr1, ait)->diplomacy.player_intel_slots
368 + player_index(plr2);
369
370 fc_assert_ret(*player_intel_slot == NULL);
371
372 player_intel = fc_calloc(1, sizeof(*player_intel));
373 *player_intel_slot = player_intel;
374}
375
376/************************************************************************/
379 static void dai_diplomacy_defaults(struct ai_type *ait,
380 const struct player *plr1,
381 const struct player *plr2)
382{
383 struct ai_dip_intel *player_intel = dai_diplomacy_get(ait, plr1, plr2);
384
385 fc_assert_ret(player_intel != NULL);
386
387 /* pseudorandom value */
388 player_intel->spam = (player_index(plr1) + player_index(plr2)) % 5;
389 player_intel->countdown = -1;
390 player_intel->war_reason = DAI_WR_NONE;
391 player_intel->distance = 1;
392 player_intel->ally_patience = 0;
393 player_intel->asked_about_peace = 0;
394 player_intel->asked_about_alliance = 0;
395 player_intel->asked_about_ceasefire = 0;
396 player_intel->warned_about_space = 0;
397}
398
399/************************************************************************/
402 struct ai_dip_intel *dai_diplomacy_get(struct ai_type *ait,
403 const struct player *plr1,
404 const struct player *plr2)
405{
406 fc_assert_ret_val(plr1 != NULL, NULL);
407 fc_assert_ret_val(plr2 != NULL, NULL);
408
409 const struct ai_dip_intel **player_intel_slot
410 = def_ai_player_data(plr1, ait)->diplomacy.player_intel_slots
411 + player_index(plr2);
412
413 fc_assert_ret_val(player_intel_slot != NULL, NULL);
414
415 return (struct ai_dip_intel *) *player_intel_slot;
416}
417
418/************************************************************************/
421 static void dai_diplomacy_destroy(struct ai_type *ait,
422 const struct player *plr1,
423 const struct player *plr2)
424{
425 fc_assert_ret(plr1 != NULL);
426 fc_assert_ret(plr2 != NULL);
427
428 const struct ai_dip_intel **player_intel_slot
429 = def_ai_player_data(plr1, ait)->diplomacy.player_intel_slots
430 + player_index(plr2);
431
432 if (*player_intel_slot != NULL) {
433 free(dai_diplomacy_get(ait, plr1, plr2));
434 }
435
436 *player_intel_slot = NULL;
437}
438
439/************************************************************************/
442 void dai_adjust_policies(struct ai_type *ait, struct player *pplayer)
443{
444 bool needs_back_rearrange = FALSE;
445 struct adv_data *adv;
446
447 adv = adv_data_get(pplayer, NULL);
448
449 multipliers_iterate(ppol) {
450 if (multiplier_can_be_changed(ppol, pplayer)) {
451 int orig_value = 0;
452 int mp_val = player_multiplier_value(pplayer, ppol);
453 int pidx = multiplier_index(ppol);
454 bool better_found = FALSE;
455
456 city_list_iterate(pplayer->cities, pcity) {
457 orig_value += dai_city_want(pplayer, pcity, adv, NULL);
458 } city_list_iterate_end;
459
460 /* Consider reducing policy value */
461 if (mp_val > ppol->start) {
462 int new_value = 0;
463
464 pplayer->multipliers[pidx].value = MAX(mp_val - ppol->step, ppol->start);
465
466 city_list_iterate(pplayer->cities, acity) {
467 auto_arrange_workers(acity);
468 } city_list_iterate_end;
469
470 city_list_iterate(pplayer->cities, pcity) {
471 new_value += dai_city_want(pplayer, pcity, adv, NULL);
472 } city_list_iterate_end;
473
474 if (new_value > orig_value) {
475 /* This is step to right direction, leave it in effect. */
476 pplayer->multipliers[pidx].target = pplayer->multipliers[pidx].value;
477
478 needs_back_rearrange = FALSE;
479 better_found = TRUE;
480 }
481 }
482
483 /* Consider increasing policy value */
484 if (!better_found && mp_val < ppol->stop) {
485 int new_value = 0;
486
487 pplayer->multipliers[pidx].value = MIN(mp_val + ppol->step, ppol->stop);
488
489 city_list_iterate(pplayer->cities, acity) {
490 auto_arrange_workers(acity);
491 } city_list_iterate_end;
492
493 city_list_iterate(pplayer->cities, pcity) {
494 new_value += dai_city_want(pplayer, pcity, adv, NULL);
495 } city_list_iterate_end;
496
497 if (new_value > orig_value) {
498 /* This is step to right direction, leave it in effect. */
499 pplayer->multipliers[pidx].target = pplayer->multipliers[pidx].value;
500
501 needs_back_rearrange = FALSE;
502 better_found = TRUE;
503 }
504 }
505
506 if (!better_found) {
507 /* Restore original multiplier value */
508 pplayer->multipliers[pidx].value = mp_val;
509 needs_back_rearrange = TRUE;
510 }
511 }
512 } multipliers_iterate_end;
513
514 if (needs_back_rearrange) {
515 city_list_iterate(pplayer->cities, acity) {
516 auto_arrange_workers(acity);
517 } city_list_iterate_end;
518 }
519}
520
521/************************************************************************/
524 void dai_gov_value(struct ai_type *ait, struct player *pplayer,
525 struct government *gov, adv_want *val, bool *override)
526{
527 int dist;
528 int bonus = 0; /* in percentage */
529 int revolution_turns;
530 struct universal source = { .kind = VUT_GOVERNMENT, .value.govern = gov };
531 struct adv_data *adv;
532 int turns = 9999; /* TODO: Set to correct value */
533 int nplayers;
534 const struct research *presearch;
535
536 /* Use default handling of no-cities case */
537 if (city_list_size(pplayer->cities) == 0) {
538 *override = FALSE;
539 return;
540 }
541
542 adv = adv_data_get(pplayer, NULL);
543 nplayers = normal_player_count();
544 presearch = research_get(pplayer);
545
546 pplayer->government = gov;
547 /* Ideally we should change tax rates here, but since
548 * this is a rather big CPU operation, we'd rather not. */
549 check_player_max_rates(pplayer);
550 city_list_iterate(pplayer->cities, acity) {
551 auto_arrange_workers(acity);
552 } city_list_iterate_end;
553 city_list_iterate(pplayer->cities, pcity) {
554 bool capital;
555 const struct req_context context = { .player = pplayer, .city = pcity };
556
557 *val += dai_city_want(pplayer, pcity, adv, NULL);
558 capital = is_capital(pcity);
559
560 effect_list_iterate(get_req_source_effects(&source), peffect) {
561 bool present = TRUE;
562 bool active = TRUE;
563
564 requirement_vector_iterate(&peffect->reqs, preq) {
565 /* Check if all the requirements for the currently evaluated effect
566 * are met, except for having the tech that we are evaluating.
567 * TODO: Consider requirements that could be met later. */
568 if (VUT_GOVERNMENT == preq->source.kind
569 && preq->source.value.govern == gov) {
570 present = preq->present;
571 continue;
572 }
573 if (!is_req_active(&context, NULL, preq, RPT_POSSIBLE)) {
574 active = FALSE;
575 break; /* presence doesn't matter for inactive effects. */
576 }
577
578 } requirement_vector_iterate_end;
579
580 if (active) {
581 adv_want v1;
582
583 v1 = dai_effect_value(pplayer, adv, pcity, capital,
584 turns, peffect, 1,
585 nplayers);
586
587 if (!present) {
588 /* Government removes the effect */
589 *val -= v1;
590 } else {
591 *val += v1;
592 }
593 }
594 } effect_list_iterate_end;
595 } city_list_iterate_end;
596
597 bonus += adv_gov_action_immunity_want(gov);
598 bonus += adv_gov_player_bonus_want(pplayer);
599
600 revolution_turns = get_player_bonus(pplayer, EFT_REVOLUTION_UNHAPPINESS);
601 if (revolution_turns > 0) {
602 bonus -= 6 / revolution_turns;
603 }
604
605 *val += (*val * bonus) / 100;
606
607 /* FIXME: handle reqs other than technologies. */
608 dist = 0;
609 requirement_vector_iterate(&gov->reqs, preq) {
610 if (VUT_ADVANCE == preq->source.kind) {
611 dist += MAX(1, research_goal_unknown_techs(presearch,
612 advance_number(preq->source.value.advance)));
613 }
614 } requirement_vector_iterate_end;
615 *val = amortize(*val, dist);
616
617 *override = TRUE;
618}
adv_gov_player_bonus_want
adv_want adv_gov_player_bonus_want(struct player *pplayer)
Definition advdata.c:951
adv_data_get
struct adv_data * adv_data_get(struct player *pplayer, bool *caller_closes)
Definition advdata.c:604
adv_data_phase_done
void adv_data_phase_done(struct player *pplayer)
Definition advdata.c:564
adv_gov_action_immunity_want
adv_want adv_gov_action_immunity_want(struct government *gov)
Definition advdata.c:823
advdata.h
amortize
adv_want amortize(adv_want benefit, int delay)
Definition advtools.c:29
aia_utype_is_considered_spy_vs_city
bool aia_utype_is_considered_spy_vs_city(const struct unit_type *putype)
Definition aiactions.c:27
aiactions.h
aiferry_init_stats
void aiferry_init_stats(struct ai_type *ait, struct player *pplayer)
Definition aiferry.c:92
aiferry.h
BV_CLR_ALL
#define BV_CLR_ALL(bv)
Definition bitvector.h:95
BV_SET
#define BV_SET(bv, bit)
Definition bitvector.h:81
is_capital
bool is_capital(const struct city *pcity)
Definition city.c:1575
city_list_iterate
#define city_list_iterate(citylist, pcity)
Definition city.h:508
city_list_iterate_end
#define city_list_iterate_end
Definition city.h:510
auto_arrange_workers
void auto_arrange_workers(struct city *pcity)
Definition cityturn.c:365
cityturn.h
incite_cost
char * incite_cost
Definition comments.c:74
dai_city_want
adv_want dai_city_want(struct player *pplayer, struct city *acity, struct adv_data *adv, struct impr_type *pimprove)
Definition daicity.c:1425
daicity.h
is_ai_data_phase_open
bool is_ai_data_phase_open(struct ai_type *ait, struct player *pplayer)
Definition daidata.c:132
dai_gov_value
void dai_gov_value(struct ai_type *ait, struct player *pplayer, struct government *gov, adv_want *val, bool *override)
Definition daidata.c:524
dai_plr_data_get
struct ai_plr * dai_plr_data_get(struct ai_type *ait, struct player *pplayer, bool *caller_closes)
Definition daidata.c:308
dai_diplomacy_destroy
static void dai_diplomacy_destroy(struct ai_type *ait, const struct player *plr1, const struct player *plr2)
Definition daidata.c:421
dai_adjust_policies
void dai_adjust_policies(struct ai_type *ait, struct player *pplayer)
Definition daidata.c:442
dai_diplomacy_new
static void dai_diplomacy_new(struct ai_type *ait, const struct player *plr1, const struct player *plr2)
Definition daidata.c:357
dai_diplomacy_get
struct ai_dip_intel * dai_diplomacy_get(struct ai_type *ait, const struct player *plr1, const struct player *plr2)
Definition daidata.c:402
dai_data_init
void dai_data_init(struct ai_type *ait, struct player *pplayer)
Definition daidata.c:59
dai_data_phase_begin
void dai_data_phase_begin(struct ai_type *ait, struct player *pplayer, bool is_new_phase)
Definition daidata.c:142
dai_diplomacy_defaults
static void dai_diplomacy_defaults(struct ai_type *ait, const struct player *plr1, const struct player *plr2)
Definition daidata.c:379
dai_data_phase_finished
void dai_data_phase_finished(struct ai_type *ait, struct player *pplayer)
Definition daidata.c:285
dai_data_close
void dai_data_close(struct ai_type *ait, struct player *pplayer)
Definition daidata.c:104
daidata.h
WIN_OPEN
@ WIN_OPEN
Definition daidata.h:32
dai_diplomacy_begin_new_phase
void dai_diplomacy_begin_new_phase(struct ai_type *ait, struct player *pplayer)
Definition daidiplomacy.c:1014
daidiplomacy.h
dai_effect_value
adv_want dai_effect_value(struct player *pplayer, const struct adv_data *adv, const struct city *pcity, const bool capital, int turns, const struct effect *peffect, const int c, const int nplayers)
Definition daieffects.c:138
daieffects.h
daiplayer.h
def_ai_player_data
static struct ai_plr * def_ai_player_data(const struct player *pplayer, struct ai_type *deftype)
Definition daiplayer.h:54
def_ai_unit_data
static struct unit_ai * def_ai_unit_data(const struct unit *punit, struct ai_type *deftype)
Definition daiplayer.h:48
dai_auto_settler_init
void dai_auto_settler_init(struct ai_plr *ai)
Definition daisettler.c:1013
dai_auto_settler_free
void dai_auto_settler_free(struct ai_plr *ai)
Definition daisettler.c:1250
daisettler.h
daiunit.h
AIUNIT_ATTACK
@ AIUNIT_ATTACK
Definition daiunit.h:28
punit
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
get_req_source_effects
struct effect_list * get_req_source_effects(const struct universal *psource)
Definition effects.c:153
get_player_bonus
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
Definition effects.c:824
effect_list_iterate_end
#define effect_list_iterate_end
Definition effects.h:81
effect_list_iterate
#define effect_list_iterate(effect_list, peffect)
Definition effects.h:79
adv_want
float adv_want
Definition fc_types.h:1335
RPT_POSSIBLE
@ RPT_POSSIBLE
Definition fc_types.h:677
Continent_id
signed short Continent_id
Definition fc_types.h:376
wld
struct world wld
Definition game.c:62
game.h
government.h
source
static GtkWidget * source
Definition gotodlg.c:58
type
GType type
Definition repodlgs.c:1313
fc_assert_msg
#define fc_assert_msg(condition, message,...)
Definition log.h:181
fc_assert_ret
#define fc_assert_ret(condition)
Definition log.h:191
fc_assert
#define fc_assert(condition)
Definition log.h:176
fc_assert_ret_val
#define fc_assert_ret_val(condition, val)
Definition log.h:194
log_debug
#define log_debug(message,...)
Definition log.h:115
map.h
fc_calloc
#define fc_calloc(n, esz)
Definition mem.h:38
multiplier_can_be_changed
bool multiplier_can_be_changed(struct multiplier *pmul, struct player *pplayer)
Definition multipliers.c:137
multiplier_index
Multiplier_type_id multiplier_index(const struct multiplier *pmul)
Definition multipliers.c:80
multipliers.h
multipliers_iterate
#define multipliers_iterate(_mul_)
Definition multipliers.h:61
multipliers_iterate_end
#define multipliers_iterate_end
Definition multipliers.h:67
player_slot_count
int player_slot_count(void)
Definition player.c:418
player_multiplier_value
int player_multiplier_value(const struct player *pplayer, const struct multiplier *pmul)
Definition player.c:1964
player_name
const char * player_name(const struct player *pplayer)
Definition player.c:895
player_slot_index
int player_slot_index(const struct player_slot *pslot)
Definition player.c:426
player_index
int player_index(const struct player *pplayer)
Definition player.c:829
player_diplstate_get
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Definition player.c:324
pplayers_allied
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1409
players_iterate_end
#define players_iterate_end
Definition player.h:539
players_iterate
#define players_iterate(_pplayer)
Definition player.h:534
MAX_AI_LOVE
#define MAX_AI_LOVE
Definition player.h:563
is_barbarian
static bool is_barbarian(const struct player *pplayer)
Definition player.h:491
player_slots_iterate
#define player_slots_iterate(_pslot)
Definition player.h:525
is_ai
#define is_ai(plr)
Definition player.h:232
players_iterate_alive_end
#define players_iterate_alive_end
Definition player.h:549
player_slots_iterate_end
#define player_slots_iterate_end
Definition player.h:529
players_iterate_alive
#define players_iterate_alive(_pplayer)
Definition player.h:544
normal_player_count
int normal_player_count(void)
Definition plrhand.c:3211
check_player_max_rates
void check_player_max_rates(struct player *pplayer)
Definition plrhand.c:776
plrhand.h
is_req_active
bool is_req_active(const struct req_context *context, const struct req_context *other_context, const struct requirement *req, const enum req_problem_type prob_type)
Definition requirements.c:5711
requirement_vector_iterate_end
#define requirement_vector_iterate_end
Definition requirements.h:94
requirement_vector_iterate
#define requirement_vector_iterate(req_vec, preq)
Definition requirements.h:92
research_goal_unknown_techs
int research_goal_unknown_techs(const struct research *presearch, Tech_type_id goal)
Definition research.c:750
research_get
struct research * research_get(const struct player *pplayer)
Definition research.c:128
research.h
MIN
#define MIN(x, y)
Definition shared.h:55
MAX
#define MAX(x, y)
Definition shared.h:54
adv_data
Definition advdata.h:50
adv_data::val
adv_want val
Definition advdata.h:132
adv_data::num_oceans
int num_oceans
Definition advdata.h:110
adv_data::num_continents
int num_continents
Definition advdata.h:109
adv_data::gov
struct government * gov
Definition advdata.h:131
ai_dip_intel
Definition daidata.h:53
ai_plr
Definition daidata.h:71
ai_plr::ocean_workers
int * ocean_workers
Definition daidata.h:83
ai_plr::last_num_oceans
int last_num_oceans
Definition daidata.h:75
ai_plr::diplomacy
struct ai_plr::@277 diplomacy
ai_plr::workers
int * workers
Definition daidata.h:82
ai_plr::last_num_continents
int last_num_continents
Definition daidata.h:74
ai_plr::phase_initialized
bool phase_initialized
Definition daidata.h:72
ai_plr::settler
struct ai_settler * settler
Definition daidata.h:101
ai_plr::req_love_for_alliance
int req_love_for_alliance
Definition daidata.h:96
ai_plr::timer
int timer
Definition daidata.h:92
ai_plr::love_incr
char love_incr
Definition daidata.h:94
ai_plr::love_coeff
char love_coeff
Definition daidata.h:93
ai_plr::diplomat_reservations
bv_id diplomat_reservations
Definition daidata.h:85
ai_plr::player_intel_slots
const struct ai_dip_intel ** player_intel_slots
Definition daidata.h:90
ai_plr::req_love_for_peace
int req_love_for_peace
Definition daidata.h:95
ai_plr::strategy
enum winning_strategy strategy
Definition daidata.h:91
ai_plr::stats
struct ai_plr::@276 stats
ai_type
Definition ai.h:50
city
Definition city.h:320
city::id
int id
Definition city.h:326
civ_map::num_continents
int num_continents
Definition map_types.h:82
civ_map::num_oceans
int num_oceans
Definition map_types.h:83
government
Definition government.h:52
government::reqs
struct requirement_vector reqs
Definition government.h:60
multiplier_value::value
int value
Definition player.h:241
multiplier_value::target
int target
Definition player.h:243
player
Definition player.h:249
player::cities
struct city_list * cities
Definition player.h:281
player::government
struct government * government
Definition player.h:258
player::units
struct unit_list * units
Definition player.h:282
player::is_alive
bool is_alive
Definition player.h:268
player::multipliers
struct multiplier_value multipliers[MAX_NUM_MULTIPLIERS]
Definition player.h:314
req_context
Definition requirements.h:100
req_context::player
const struct player * player
Definition requirements.h:101
research
Definition research.h:39
tile
Definition tile.h:50
unit_ai
Definition daiunit.h:32
unit::goto_tile
struct tile * goto_tile
Definition unit.h:157
universal
Definition fc_types.h:878
universal::kind
enum universals_n kind
Definition fc_types.h:880
world::map
struct civ_map map
Definition world_object.h:38
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
advance_number
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
is_ocean_tile
#define is_ocean_tile(ptile)
Definition terrain.h:196
tile_city
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
tile_continent
#define tile_continent(_tile)
Definition tile.h:93
unit_tile
#define unit_tile(_pu)
Definition unit.h:397
unit_list_iterate
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
unit_list_iterate_end
#define unit_list_iterate_end
Definition unitlist.h:33
unit_type_get
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
unit_has_type_flag
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Definition unittype.c:190