Freeciv21
Develop your civilization from humble roots to a global empire
classicai.cpp
Go to the documentation of this file.
1 /*__ ___ ***************************************
2 / \ / \ Copyright (c) 1996-2020 Freeciv21 and Freeciv
3 \_ \ / __/ contributors. This file is part of Freeciv21.
4  _\ \ / /__ Freeciv21 is free software: you can redistribute it
5  \___ \____/ __/ and/or modify it under the terms of the GNU General
6  \_ _/ Public License as published by the Free Software
7  | @ @ \_ Foundation, either version 3 of the License,
8  | or (at your option) any later version.
9  _/ /\ You should have received a copy of the GNU
10  /o) (o/\ \_ General Public License along with Freeciv21.
11  \_____/ / If not, see https://www.gnu.org/licenses/.
12  \____/ ********************************************************/
13 
14 // common
15 #include "ai.h"
16 #include "player.h"
17 
18 /* server/advisors */
19 #include "advdata.h"
20 #include "autosettlers.h"
21 
22 /* ai/default */
23 #include "aidata.h"
24 #include "aiferry.h"
25 #include "aihand.h"
26 #include "ailog.h"
27 #include "aiplayer.h"
28 #include "aisettler.h"
29 #include "aitools.h"
30 #include "aiunit.h"
31 #include "daicity.h"
32 #include "daidiplomacy.h"
33 #include "daidomestic.h"
34 #include "daimilitary.h"
35 
36 #include "classicai.h"
37 
38 class PFPath;
39 
40 static struct ai_type *self = nullptr;
41 
45 static void classic_ai_set_self(struct ai_type *ai) { self = ai; }
46 
50 static struct ai_type *classic_ai_get_self() { return self; }
51 
55 static void cai_module_close()
56 {
57  struct ai_type *deftype = classic_ai_get_self();
58 
59  delete static_cast<dai_private_data *>(deftype->pprivate);
60 }
61 
65 static void cai_player_alloc(struct player *pplayer)
66 {
67  struct ai_type *deftype = classic_ai_get_self();
68 
69  dai_player_alloc(deftype, pplayer);
70 }
71 
75 static void cai_player_free(struct player *pplayer)
76 {
77  struct ai_type *deftype = classic_ai_get_self();
78 
79  dai_player_free(deftype, pplayer);
80 }
81 
86 static void cai_player_save_relations(struct player *pplayer,
87  struct player *other,
88  struct section_file *file, int plrno)
89 {
90  struct ai_type *deftype = classic_ai_get_self();
91 
92  dai_player_save_relations(deftype, "ai", pplayer, other, file, plrno);
93 }
94 
98 static void cai_player_load_relations(struct player *pplayer,
99  struct player *other,
100  const struct section_file *file,
101  int plrno)
102 {
103  struct ai_type *deftype = classic_ai_get_self();
104 
105  dai_player_load_relations(deftype, "ai", pplayer, other, file, plrno);
106 }
107 
111 static void cai_gained_control(struct player *pplayer)
112 {
113  struct ai_type *deftype = classic_ai_get_self();
114 
115  dai_gained_control(deftype, pplayer);
116 }
117 
121 static void cai_split_by_civil_war(struct player *original,
122  struct player *created)
123 {
124  struct ai_type *deftype = classic_ai_get_self();
125 
126  dai_assess_danger_player(deftype, original, &(wld.map));
127 }
128 
132 static void cai_created_by_civil_war(struct player *original,
133  struct player *created)
134 {
135  struct ai_type *deftype = classic_ai_get_self();
136 
137  dai_player_copy(deftype, original, created);
138 }
139 
143 static void cai_data_phase_begin(struct player *pplayer, bool is_new_phase)
144 {
145  struct ai_type *deftype = classic_ai_get_self();
146 
147  dai_data_phase_begin(deftype, pplayer, is_new_phase);
148 }
149 
153 static void cai_data_phase_finished(struct player *pplayer)
154 {
155  struct ai_type *deftype = classic_ai_get_self();
156 
157  dai_data_phase_finished(deftype, pplayer);
158 }
159 
163 static void cai_city_alloc(struct city *pcity)
164 {
165  struct ai_type *deftype = classic_ai_get_self();
166 
167  dai_city_alloc(deftype, pcity);
168 }
169 
173 static void cai_city_free(struct city *pcity)
174 {
175  struct ai_type *deftype = classic_ai_get_self();
176 
177  dai_city_free(deftype, pcity);
178 }
179 
183 static void cai_city_save(struct section_file *file,
184  const struct city *pcity, const char *citystr)
185 {
186  struct ai_type *deftype = classic_ai_get_self();
187 
188  dai_city_save(deftype, "ai", file, pcity, citystr);
189 }
190 
194 static void cai_city_load(const struct section_file *file,
195  struct city *pcity, const char *citystr)
196 {
197  struct ai_type *deftype = classic_ai_get_self();
198 
199  dai_city_load(deftype, "ai", file, pcity, citystr);
200 }
201 
205 static void cai_build_adv_override(struct city *pcity,
206  struct adv_choice *choice)
207 {
208  struct ai_type *deftype = classic_ai_get_self();
209 
210  dai_build_adv_override(deftype, pcity, choice);
211 }
212 
216 static void cai_wonder_city_distance(struct player *pplayer,
217  struct adv_data *adv)
218 {
219  struct ai_type *deftype = classic_ai_get_self();
220 
221  dai_wonder_city_distance(deftype, pplayer, adv);
222 }
223 
227 static void cai_build_adv_init(struct player *pplayer)
228 {
229  struct ai_type *deftype = classic_ai_get_self();
230 
231  dai_build_adv_init(deftype, pplayer);
232 }
233 
237 static void cai_build_adv_adjust(struct player *pplayer,
238  struct city *wonder_city)
239 {
240  struct ai_type *deftype = classic_ai_get_self();
241 
242  dai_build_adv_adjust(deftype, pplayer, wonder_city);
243 }
244 
248 static void cai_gov_value(struct player *pplayer, struct government *gov,
249  adv_want *val, bool *override)
250 {
251  struct ai_type *deftype = classic_ai_get_self();
252 
253  dai_gov_value(deftype, pplayer, gov, val, override);
254 }
255 
260 {
261  struct ai_type *deftype = classic_ai_get_self();
262 
263  dai_units_ruleset_init(deftype);
264 }
265 
270 {
271  struct ai_type *deftype = classic_ai_get_self();
272 
273  dai_units_ruleset_close(deftype);
274 }
275 
279 static void cai_unit_init(struct unit *punit)
280 {
281  struct ai_type *deftype = classic_ai_get_self();
282 
283  dai_unit_init(deftype, punit);
284 }
285 
289 static void cai_unit_close(struct unit *punit)
290 {
291  struct ai_type *deftype = classic_ai_get_self();
292 
293  dai_unit_close(deftype, punit);
294 }
295 
299 static void cai_ferry_init_ferry(struct unit *ferry)
300 {
301  struct ai_type *deftype = classic_ai_get_self();
302 
303  dai_ferry_init_ferry(deftype, ferry);
304 }
305 
309 static void cai_ferry_transformed(struct unit *ferry,
310  const struct unit_type *old)
311 {
312  struct ai_type *deftype = classic_ai_get_self();
313 
314  dai_ferry_transformed(deftype, ferry, old);
315 }
316 
320 static void cai_ferry_lost(struct unit *punit)
321 {
322  struct ai_type *deftype = classic_ai_get_self();
323 
324  dai_ferry_lost(deftype, punit);
325 }
326 
330 static void cai_unit_turn_end(struct unit *punit)
331 {
332  struct ai_type *deftype = classic_ai_get_self();
333 
334  dai_unit_turn_end(deftype, punit);
335 }
336 
340 static void cai_unit_move_or_attack(struct unit *punit, struct tile *ptile,
341  const PFPath &path, int step)
342 {
343  struct ai_type *deftype = classic_ai_get_self();
344 
345  dai_unit_move_or_attack(deftype, punit, ptile, path, step);
346 }
347 
351 static void cai_unit_new_adv_task(struct unit *punit,
352  enum adv_unit_task task,
353  struct tile *ptile)
354 {
355  struct ai_type *deftype = classic_ai_get_self();
356 
357  dai_unit_new_adv_task(deftype, punit, task, ptile);
358 }
359 
363 static void cai_unit_save(struct section_file *file,
364  const struct unit *punit, const char *unitstr)
365 {
366  struct ai_type *deftype = classic_ai_get_self();
367 
368  dai_unit_save(deftype, "", file, punit, unitstr);
369 }
370 
374 static void cai_unit_load(const struct section_file *file,
375  struct unit *punit, const char *unitstr)
376 {
377  struct ai_type *deftype = classic_ai_get_self();
378 
379  dai_unit_load(deftype, "", file, punit, unitstr);
380 }
381 
385 static void cai_auto_settler_reset(struct player *pplayer)
386 {
387  struct ai_type *deftype = classic_ai_get_self();
388 
389  dai_auto_settler_reset(deftype, pplayer);
390 }
391 
395 static void cai_auto_settler_run(struct player *pplayer, struct unit *punit,
396  struct settlermap *state)
397 {
398  struct ai_type *deftype = classic_ai_get_self();
399 
400  dai_auto_settler_run(deftype, pplayer, punit, state);
401 }
402 
406 static void cai_auto_settler_cont(struct player *pplayer, struct unit *punit,
407  struct settlermap *state)
408 {
409  struct ai_type *deftype = classic_ai_get_self();
410 
411  dai_auto_settler_cont(deftype, pplayer, punit, state);
412 }
413 
417 static void cai_switch_to_explore(struct unit *punit, struct tile *target,
418  enum override_bool *allow)
419 {
420  struct ai_type *deftype = classic_ai_get_self();
421 
422  dai_switch_to_explore(deftype, punit, target, allow);
423 }
424 
428 static void cai_do_first_activities(struct player *pplayer)
429 {
430  struct ai_type *deftype = classic_ai_get_self();
431 
432  dai_do_first_activities(deftype, pplayer);
433 
434  pplayer->ai_phase_done = true;
435 }
436 
440 static void cai_restart_phase(struct player *pplayer)
441 {
442  pplayer->ai_phase_done = true;
443 }
444 
448 static void cai_diplomacy_actions(struct player *pplayer)
449 {
450  struct ai_type *deftype = classic_ai_get_self();
451 
452  dai_diplomacy_actions(deftype, pplayer);
453 }
454 
458 static void cai_do_last_activities(struct player *pplayer)
459 {
460  struct ai_type *deftype = classic_ai_get_self();
461 
462  dai_do_last_activities(deftype, pplayer);
463 }
464 
468 static void cai_treaty_evaluate(struct player *pplayer,
469  struct player *aplayer,
470  struct Treaty *ptreaty)
471 {
472  struct ai_type *deftype = classic_ai_get_self();
473 
474  dai_treaty_evaluate(deftype, pplayer, aplayer, ptreaty);
475 }
476 
480 static void cai_treaty_accepted(struct player *pplayer,
481  struct player *aplayer,
482  struct Treaty *ptreaty)
483 {
484  struct ai_type *deftype = classic_ai_get_self();
485 
486  dai_treaty_accepted(deftype, pplayer, aplayer, ptreaty);
487 }
488 
492 static void cai_diplomacy_first_contact(struct player *pplayer,
493  struct player *aplayer)
494 {
495  struct ai_type *deftype = classic_ai_get_self();
496 
497  dai_diplomacy_first_contact(deftype, pplayer, aplayer);
498 }
499 
503 static void cai_incident(enum incident_type type,
504  enum casus_belli_range scope,
505  const struct action *paction,
506  struct player *receiver, struct player *violator,
507  struct player *victim)
508 {
509  struct ai_type *deftype = classic_ai_get_self();
510 
511  dai_incident(deftype, type, scope, paction, receiver, violator, victim);
512 }
513 
517 static void cai_city_log(char *buffer, int buflength,
518  const struct city *pcity)
519 {
520  struct ai_type *deftype = classic_ai_get_self();
521 
522  dai_city_log(deftype, buffer, buflength, pcity);
523 }
524 
528 static void cai_unit_log(char *buffer, int buflength,
529  const struct unit *punit)
530 {
531  struct ai_type *deftype = classic_ai_get_self();
532 
533  dai_unit_log(deftype, buffer, buflength, punit);
534 }
535 
539 static void cai_consider_plr_dangerous(struct player *plr1,
540  struct player *plr2,
541  enum override_bool *result)
542 {
543  struct ai_type *deftype = classic_ai_get_self();
544 
545  dai_consider_plr_dangerous(deftype, plr1, plr2, result);
546 }
547 
551 static void cai_consider_tile_dangerous(struct tile *ptile,
552  struct unit *punit,
553  enum override_bool *result)
554 {
555  struct ai_type *deftype = classic_ai_get_self();
556 
557  dai_consider_tile_dangerous(deftype, ptile, punit, result);
558 }
559 
563 static void cai_consider_wonder_city(struct city *pcity, bool *result)
564 {
565  struct ai_type *deftype = classic_ai_get_self();
566 
567  dai_consider_wonder_city(deftype, pcity, result);
568 }
569 
573 bool fc_ai_classic_setup(struct ai_type *ai)
574 {
575  struct dai_private_data *pprivate;
576 
578 
579  qstrncpy(ai->name, "classic", sizeof(ai->name));
580 
581  pprivate = new dai_private_data;
582  pprivate->contemplace_workers = true;
583  ai->pprivate = pprivate;
584 
586 
587  // ai->funcs.map_alloc = nullptr;
588  // ai->funcs.map_ready = nullptr;
589  // ai->funcs.map_free = nullptr;
590  // ai->funcs.game_start = nullptr;
591  // ai->funcs.game_free = nullptr;
592 
595  // ai->funcs.player_save = nullptr;
596  // ai->funcs.player_load = nullptr;
600  // ai->funcs.lost_control = nullptr;
603 
606 
609  /*
610  ai->funcs.city_created = nullptr;
611  ai->funcs.city_destroyed = nullptr;
612  ai->funcs.city_got = nullptr;
613  ai->funcs.city_lost = nullptr;
614  */
621 
623 
626 
627  /* FIXME: We should allocate memory only for units owned by
628  default ai in unit_got. We track no data
629  about enemy units.
630  But advisors code still depends on some default ai data (role) to be
631  always allocated. */
632  /*
633  ai->funcs.unit_alloc = nullptr;
634  ai->funcs.unit_free = nullptr;
635  ai->funcs.unit_created = nullptr;
636  ai->funcs.unit_destroyed = nullptr;
637  ai->funcs.unit_got = dai_unit_init;
638  ai->funcs.unit_lost = dai_unit_close;
639  */
645 
648  // ai->funcs.unit_move_seen = nullptr;
650 
653 
657 
659 
668 
671 
675 
676  // ai->funcs.refresh = nullptr;
677 
678  // ai->funcs.tile_info = nullptr;
679  // ai->funcs.city_info = nullptr;
680  // ai->funcs.unit_info = nullptr;
681 
682  return true;
683 }
incident_type
Definition: ai.h:40
void dai_gov_value(struct ai_type *ait, struct player *pplayer, struct government *gov, adv_want *val, bool *override)
Set value of the government.
Definition: aidata.cpp:533
void dai_data_phase_begin(struct ai_type *ait, struct player *pplayer, bool is_new_phase)
Make and cache lots of calculations needed for other functions.
Definition: aidata.cpp:138
void dai_data_phase_finished(struct ai_type *ait, struct player *pplayer)
Clean up ai data after phase finished.
Definition: aidata.cpp:281
void dai_ferry_lost(struct ai_type *ait, struct unit *punit)
Close ferry when player loses it.
Definition: aiferry.cpp:218
void dai_ferry_transformed(struct ai_type *ait, struct unit *ferry, const struct unit_type *old)
Update ferry system when unit is transformed.
Definition: aiferry.cpp:186
void dai_ferry_init_ferry(struct ai_type *ait, struct unit *ferry)
Initialize new ferry when player gets it.
Definition: aiferry.cpp:165
void dai_do_last_activities(struct ai_type *ait, struct player *pplayer)
Activities to be done by AI after human turn.
Definition: aihand.cpp:757
void dai_do_first_activities(struct ai_type *ait, struct player *pplayer)
Activities to be done by AI before human turn.
Definition: aihand.cpp:731
void dai_unit_log(struct ai_type *ait, char *buffer, int buflength, const struct unit *punit)
Produce logline fragment for srv_log.
Definition: ailog.cpp:44
void dai_city_log(struct ai_type *ait, char *buffer, int buflength, const struct city *pcity)
Produce logline fragment for srv_log.
Definition: ailog.cpp:32
void dai_player_alloc(struct ai_type *ait, struct player *pplayer)
Initialize player for use with default AI.
Definition: aiplayer.cpp:34
void dai_player_copy(struct ai_type *ait, struct player *original, struct player *created)
Copy default ai data from player to player.
Definition: aiplayer.cpp:117
void dai_player_save_relations(struct ai_type *ait, const char *aitstr, struct player *pplayer, struct player *other, struct section_file *file, int plrno)
Store player specific data to savegame.
Definition: aiplayer.cpp:62
void dai_player_free(struct ai_type *ait, struct player *pplayer)
Free player from use with default AI.
Definition: aiplayer.cpp:46
void dai_gained_control(struct ai_type *ait, struct player *pplayer)
Ai got control of the player.
Definition: aiplayer.cpp:144
void dai_player_load_relations(struct ai_type *ait, const char *aitstr, struct player *pplayer, struct player *other, const struct section_file *file, int plrno)
Load player vs player specific data from savegame.
Definition: aiplayer.cpp:87
void dai_auto_settler_cont(struct ai_type *ait, struct player *pplayer, struct unit *punit, struct settlermap *state)
Auto settler continuing its work.
Definition: aisettler.cpp:1113
void dai_auto_settler_run(struct ai_type *ait, struct player *pplayer, struct unit *punit, struct settlermap *state)
Auto settler that can also build cities.
Definition: aisettler.cpp:964
void dai_auto_settler_reset(struct ai_type *ait, struct player *pplayer)
Reset ai settler engine.
Definition: aisettler.cpp:1124
void dai_build_adv_override(struct ai_type *ait, struct city *pcity, struct adv_choice *choice)
Consider overriding building target selected by common advisor code.
Definition: aitools.cpp:1155
void dai_unit_move_or_attack(struct ai_type *ait, struct unit *punit, struct tile *ptile, const PFPath &path, int step)
Ai unit moving function called from AI interface.
Definition: aitools.cpp:928
void dai_consider_plr_dangerous(struct ai_type *ait, struct player *plr1, struct player *plr2, enum override_bool *result)
There are some signs that a player might be dangerous: We are at war with him, he has done lots of ig...
Definition: aitools.cpp:156
void dai_unit_new_adv_task(struct ai_type *ait, struct unit *punit, enum adv_unit_task task, struct tile *ptile)
Adviser task for unit has been changed.
Definition: aitools.cpp:624
void dai_unit_save(struct ai_type *ait, const char *aitstr, struct section_file *file, const struct unit *punit, const char *unitstr)
Save AI data of a unit.
Definition: aiunit.cpp:3283
void dai_units_ruleset_init(struct ai_type *ait)
Initialise the unit data from the ruleset for the AI.
Definition: aiunit.cpp:3101
void dai_switch_to_explore(struct ai_type *ait, struct unit *punit, struct tile *target, enum override_bool *allow)
Switch to autoexploring.
Definition: aiunit.cpp:3390
void dai_unit_turn_end(struct ai_type *ait, struct unit *punit)
Free unit from use with default AI.
Definition: aiunit.cpp:3252
void dai_unit_init(struct ai_type *ait, struct unit *punit)
Initialize unit for use with default AI.
Definition: aiunit.cpp:3229
void dai_consider_tile_dangerous(struct ai_type *ait, struct tile *ptile, struct unit *punit, enum override_bool *result)
Are there dangerous enemies at or adjacent to the tile 'ptile'?
Definition: aiunit.cpp:3017
void dai_unit_load(struct ai_type *ait, const char *aitstr, const struct section_file *file, struct unit *punit, const char *unitstr)
Load AI data of a unit.
Definition: aiunit.cpp:3302
void dai_unit_close(struct ai_type *ait, struct unit *punit)
Free unit from use with default AI.
Definition: aiunit.cpp:3264
void dai_units_ruleset_close(struct ai_type *ait)
Close AI unit type data.
Definition: aiunit.cpp:3208
static void cai_units_ruleset_close()
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:269
static void cai_restart_phase(struct player *pplayer)
Mark turn done as we have already done everything before game was saved.
Definition: classicai.cpp:440
static void cai_city_log(char *buffer, int buflength, const struct city *pcity)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:517
static void cai_ferry_lost(struct unit *punit)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:320
static void cai_module_close()
Free resources allocated by the classic AI module.
Definition: classicai.cpp:55
static void cai_city_free(struct city *pcity)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:173
static void cai_player_load_relations(struct player *pplayer, struct player *other, const struct section_file *file, int plrno)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:98
static void cai_city_alloc(struct city *pcity)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:163
static void cai_wonder_city_distance(struct player *pplayer, struct adv_data *adv)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:216
static void cai_build_adv_adjust(struct player *pplayer, struct city *wonder_city)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:237
static void cai_diplomacy_first_contact(struct player *pplayer, struct player *aplayer)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:492
static void cai_unit_save(struct section_file *file, const struct unit *punit, const char *unitstr)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:363
static void cai_unit_move_or_attack(struct unit *punit, struct tile *ptile, const PFPath &path, int step)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:340
static void cai_do_last_activities(struct player *pplayer)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:458
static void cai_unit_turn_end(struct unit *punit)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:330
static void cai_player_alloc(struct player *pplayer)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:65
static void cai_created_by_civil_war(struct player *original, struct player *created)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:132
static void cai_switch_to_explore(struct unit *punit, struct tile *target, enum override_bool *allow)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:417
static void cai_gov_value(struct player *pplayer, struct government *gov, adv_want *val, bool *override)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:248
bool fc_ai_classic_setup(struct ai_type *ai)
Setup player ai_funcs function pointers.
Definition: classicai.cpp:573
static void cai_data_phase_finished(struct player *pplayer)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:153
static void cai_ferry_init_ferry(struct unit *ferry)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:299
static void cai_auto_settler_run(struct player *pplayer, struct unit *punit, struct settlermap *state)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:395
static void cai_unit_init(struct unit *punit)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:279
static void cai_units_ruleset_init()
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:259
static void cai_diplomacy_actions(struct player *pplayer)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:448
static void cai_build_adv_init(struct player *pplayer)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:227
static void cai_data_phase_begin(struct player *pplayer, bool is_new_phase)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:143
static void cai_incident(enum incident_type type, enum casus_belli_range scope, const struct action *paction, struct player *receiver, struct player *violator, struct player *victim)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:503
static void cai_consider_tile_dangerous(struct tile *ptile, struct unit *punit, enum override_bool *result)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:551
static struct ai_type * classic_ai_get_self()
Get pointer to ai type of the classic ai.
Definition: classicai.cpp:50
static void cai_do_first_activities(struct player *pplayer)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:428
static void cai_gained_control(struct player *pplayer)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:111
static void cai_build_adv_override(struct city *pcity, struct adv_choice *choice)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:205
static void cai_city_load(const struct section_file *file, struct city *pcity, const char *citystr)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:194
static void cai_unit_log(char *buffer, int buflength, const struct unit *punit)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:528
static void cai_treaty_accepted(struct player *pplayer, struct player *aplayer, struct Treaty *ptreaty)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:480
static void cai_ferry_transformed(struct unit *ferry, const struct unit_type *old)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:309
static void cai_consider_wonder_city(struct city *pcity, bool *result)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:563
static void cai_unit_load(const struct section_file *file, struct unit *punit, const char *unitstr)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:374
static void cai_treaty_evaluate(struct player *pplayer, struct player *aplayer, struct Treaty *ptreaty)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:468
static void classic_ai_set_self(struct ai_type *ai)
Set pointer to ai type of the classic ai.
Definition: classicai.cpp:45
static void cai_player_free(struct player *pplayer)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:75
static void cai_player_save_relations(struct player *pplayer, struct player *other, struct section_file *file, int plrno)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:86
static void cai_consider_plr_dangerous(struct player *plr1, struct player *plr2, enum override_bool *result)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:539
static void cai_unit_new_adv_task(struct unit *punit, enum adv_unit_task task, struct tile *ptile)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:351
static void cai_auto_settler_cont(struct player *pplayer, struct unit *punit, struct settlermap *state)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:406
static void cai_auto_settler_reset(struct player *pplayer)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:385
static void cai_split_by_civil_war(struct player *original, struct player *created)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:121
static void cai_city_save(struct section_file *file, const struct city *pcity, const char *citystr)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:183
static void cai_unit_close(struct unit *punit)
Call default ai with classic ai type as parameter.
Definition: classicai.cpp:289
void dai_city_save(struct ai_type *ait, const char *aitstr, struct section_file *file, const struct city *pcity, const char *citystr)
Write ai city segments to savefile.
Definition: daicity.cpp:1157
void dai_city_load(struct ai_type *ait, const char *aitstr, const struct section_file *file, struct city *pcity, const char *citystr)
Load ai city segment from savefile.
Definition: daicity.cpp:1185
void dai_city_alloc(struct ai_type *ait, struct city *pcity)
Initialize city for use with default AI.
Definition: daicity.cpp:1129
void dai_consider_wonder_city(struct ai_type *ait, struct city *pcity, bool *result)
Is it ok for advisor code to consider given city as wonder city?
Definition: daicity.cpp:2079
void dai_build_adv_adjust(struct ai_type *ait, struct player *pplayer, struct city *wonder_city)
Calculate how much an AI player should want to build particular improvements, because of the effects ...
Definition: daicity.cpp:1947
void dai_city_free(struct ai_type *ait, struct city *pcity)
Free city from use with default AI.
Definition: daicity.cpp:1142
void dai_build_adv_init(struct ai_type *ait, struct player *pplayer)
Initialize building advisor.
Definition: daicity.cpp:1928
void dai_treaty_accepted(struct ai_type *ait, struct player *pplayer, struct player *aplayer, struct Treaty *ptreaty)
This function is called when a treaty has been concluded, to deal with followup issues like comments ...
void dai_incident(struct ai_type *ait, enum incident_type type, enum casus_belli_range scope, const struct action *paction, struct player *receiver, struct player *violator, struct player *victim)
Handle incident caused by violator.
void dai_diplomacy_actions(struct ai_type *ait, struct player *pplayer)
Do diplomatic actions.
void dai_treaty_evaluate(struct ai_type *ait, struct player *pplayer, struct player *aplayer, struct Treaty *ptreaty)
pplayer is AI player, aplayer is the other player involved, treaty is the treaty being considered.
void dai_diplomacy_first_contact(struct ai_type *ait, struct player *pplayer, struct player *aplayer)
What to do when we first meet.
void dai_wonder_city_distance(struct ai_type *ait, struct player *pplayer, struct adv_data *adv)
Calculate walking distances to wonder city from nearby cities.
void dai_assess_danger_player(struct ai_type *ait, struct player *pplayer, const struct civ_map *dmap)
Call assess_danger() for all cities owned by pplayer.
float adv_want
Definition: fc_types.h:1144
adv_unit_task
Definition: fc_types.h:287
override_bool
Definition: fc_types.h:78
struct world wld
Definition: game.cpp:48
int step
Definition: specpq.h:83
Definition: ai.h:42
void(* log_fragment_unit)(char *buffer, int buflength, const struct unit *punit)
Definition: ai.h:292
void(* city_alloc)(struct city *pcity)
Definition: ai.h:125
void(* created_by_civil_war)(struct player *original, struct player *created)
Definition: ai.h:113
void(* consider_tile_dangerous)(struct tile *ptile, struct unit *punit, enum override_bool *result)
Definition: ai.h:301
void(* unit_lost)(struct unit *punit)
Definition: ai.h:205
void(* treaty_evaluate)(struct player *pplayer, struct player *aplayer, struct Treaty *ptreaty)
Definition: ai.h:265
void(* gov_value)(struct player *pplayer, struct government *gov, adv_want *val, bool *override)
Definition: ai.h:172
void(* treaty_accepted)(struct player *pplayer, struct player *aplayer, struct Treaty *ptreaty)
Definition: ai.h:270
void(* unit_transformed)(struct unit *punit, const struct unit_type *old_type)
Definition: ai.h:201
void(* log_fragment_city)(char *buffer, int buflength, const struct city *pcity)
Definition: ai.h:287
void(* unit_move)(struct unit *punit, struct tile *ptile, const PFPath &path, int step)
Definition: ai.h:211
void(* settler_run)(struct player *pplayer, struct unit *punit, struct settlermap *state)
Definition: ai.h:235
void(* unit_load)(const struct section_file *file, struct unit *punit, const char *unitstr)
Definition: ai.h:227
void(* unit_free)(struct unit *punit)
Definition: ai.h:187
void(* phase_finished)(struct player *pplayer)
Definition: ai.h:121
void(* restart_phase)(struct player *pplayer)
Definition: ai.h:254
void(* settler_reset)(struct player *pplayer)
Definition: ai.h:232
void(* unit_save)(struct section_file *file, const struct unit *punit, const char *unitstr)
Definition: ai.h:223
void(* diplomacy_actions)(struct player *pplayer)
Definition: ai.h:258
void(* player_alloc)(struct player *pplayer)
Definition: ai.h:69
void(* build_adv_prepare)(struct player *pplayer, struct adv_data *adv)
Definition: ai.h:159
void(* build_adv_adjust_want)(struct player *pplayer, struct city *wonder_city)
Definition: ai.h:168
void(* build_adv_init)(struct player *pplayer)
Definition: ai.h:163
void(* unit_task)(struct unit *punit, enum adv_unit_task task, struct tile *ptile)
Definition: ai.h:219
void(* last_activities)(struct player *pplayer)
Definition: ai.h:261
void(* incident)(enum incident_type type, enum casus_belli_range scope, const struct action *paction, struct player *receiver, struct player *violator, struct player *victim)
Definition: ai.h:281
void(* settler_cont)(struct player *pplayer, struct unit *punit, struct settlermap *state)
Definition: ai.h:240
void(* first_contact)(struct player *pplayer, struct player *aplayer)
Definition: ai.h:277
void(* city_save)(struct section_file *file, const struct city *pcity, const char *citystr)
Definition: ai.h:146
void(* consider_wonder_city)(struct city *pcity, bool *result)
Definition: ai.h:306
void * pprivate
Definition: ai.h:45
void(* city_free)(struct city *pcity)
Definition: ai.h:129
void(* choose_building)(struct city *pcity, struct adv_choice *choice)
Definition: ai.h:155
void(* player_save_relations)(struct player *pplayer, struct player *other, struct section_file *file, int plrno)
Definition: ai.h:88
struct ai_type::@12 funcs
void(* city_load)(const struct section_file *file, struct city *pcity, const char *citystr)
Definition: ai.h:150
void(* player_load_relations)(struct player *pplayer, struct player *other, const struct section_file *file, int plrno)
Definition: ai.h:94
void(* phase_begin)(struct player *pplayer, bool new_phase)
Definition: ai.h:118
void(* player_free)(struct player *pplayer)
Definition: ai.h:72
void(* split_by_civil_war)(struct player *original, struct player *created)
Definition: ai.h:109
void(* unit_turn_end)(struct unit *punit)
Definition: ai.h:208
void(* unit_alloc)(struct unit *punit)
Definition: ai.h:183
void(* gained_control)(struct player *pplayer)
Definition: ai.h:103
char name[MAX_LEN_NAME]
Definition: ai.h:43
void(* unit_got)(struct unit *punit)
Definition: ai.h:198
void(* module_close)()
Definition: ai.h:49
void(* first_activities)(struct player *pplayer)
Definition: ai.h:250
void(* consider_plr_dangerous)(struct player *plr1, struct player *plr2, enum override_bool *result)
Definition: ai.h:296
void(* units_ruleset_init)()
Definition: ai.h:176
void(* units_ruleset_close)()
Definition: ai.h:179
void(* want_to_explore)(struct unit *punit, struct tile *target, enum override_bool *allow)
Definition: ai.h:245
Definition: city.h:291
bool contemplace_workers
Definition: aiplayer.h:54
Definition: player.h:231
bool ai_phase_done
Definition: player.h:246
Definition: tile.h:42
Definition: unit.h:134
struct civ_map map
Definition: world_object.h:21