Freeciv21
Develop your civilization from humble roots to a global empire
texai.c
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 #include <fc_config.h>
15 
16 /* common */
17 #include "ai.h"
18 
19 /* ai/default */
20 #include "aidata.h"
21 #include "aiferry.h"
22 #include "aihand.h"
23 #include "ailog.h"
24 #include "aiplayer.h"
25 #include "aisettler.h"
26 #include "aitools.h"
27 #include "daicity.h"
28 #include "daidiplomacy.h"
29 #include "daidomestic.h"
30 #include "daimilitary.h"
31 
32 /* tex ai */
33 #include "texaicity.h"
34 #include "texaimsg.h"
35 #include "texaiplayer.h"
36 #include "texaiworld.h"
37 
38 const char *fc_ai_tex_capstr(void);
39 bool fc_ai_tex_setup(struct ai_type *ai);
40 
41 static void texai_init_self(struct ai_type *ai);
42 
43 static struct ai_type *self = NULL;
44 
45 /**********************************************************************/
48 static void texai_init_self(struct ai_type *ai)
49 {
50  self = ai;
51 
53 }
54 
55 /**********************************************************************/
58 struct ai_type *texai_get_self(void) { return self; }
59 
60 #define TEXAI_AIT struct ai_type *ait = texai_get_self();
61 #define TEXAI_TFUNC(_func, ...) _func(ait, ##__VA_ARGS__);
62 #define TEXAI_DFUNC(_func, ...) _func(ait, ##__VA_ARGS__);
63 
64 /**********************************************************************/
67 static void texai_module_close(void)
68 {
69  TEXAI_AIT;
70 
71  delete ait->private;
72  ait->private = nullptr;
73 }
74 
75 /**********************************************************************/
78 static void texwai_player_alloc(struct player *pplayer)
79 {
80  TEXAI_AIT;
82  /* Do not call default AI here, texai_player_alloc() does necessary parts
83  */
84 }
85 
86 /**********************************************************************/
89 static void texwai_player_free(struct player *pplayer)
90 {
91  TEXAI_AIT;
93  /* Do not call default AI here, texai_player_free() does necessary parts */
94 }
95 
96 /**********************************************************************/
99 static void texwai_player_save(struct player *pplayer,
100  struct section_file *file, int plrno)
101 {
102  TEXAI_AIT;
103  TEXAI_DFUNC(dai_player_save, "texai", pplayer, file, plrno);
104 }
105 
106 /**********************************************************************/
109 static void texwai_player_load(struct player *pplayer,
110  const struct section_file *file, int plrno)
111 {
112  TEXAI_AIT;
113  TEXAI_DFUNC(dai_player_load, "texai", pplayer, file, plrno);
114 }
115 
116 /**********************************************************************/
119 static void texwai_control_gained(struct player *pplayer)
120 {
121  TEXAI_AIT;
124 }
125 
126 /**********************************************************************/
129 static void texwai_control_lost(struct player *pplayer)
130 {
131  TEXAI_AIT;
133 }
134 
135 /**********************************************************************/
138 static void texwai_split_by_civil_war(struct player *original,
139  struct player *created)
140 {
141  TEXAI_AIT;
143 }
144 
145 /**********************************************************************/
148 static void texwai_created_by_civil_war(struct player *original,
149  struct player *created)
150 {
151  TEXAI_AIT;
152  TEXAI_DFUNC(dai_player_copy, original, created);
153 }
154 
155 /**********************************************************************/
158 static void texwai_phase_begin(struct player *pplayer, bool is_new_phase)
159 {
160  TEXAI_AIT;
161  TEXAI_DFUNC(dai_data_phase_begin, pplayer, is_new_phase);
162 }
163 
164 /**********************************************************************/
167 static void texwai_phase_finished(struct player *pplayer)
168 {
169  TEXAI_AIT;
172 }
173 
174 /**********************************************************************/
177 static void texwai_city_alloc(struct city *pcity)
178 {
179  TEXAI_AIT;
181 }
182 
183 /**********************************************************************/
186 static void texwai_city_free(struct city *pcity)
187 {
188  TEXAI_AIT;
190 }
191 
192 /**********************************************************************/
195 static void texwai_city_save(struct section_file *file,
196  const struct city *pcity, const char *citystr)
197 {
198  TEXAI_AIT;
199  TEXAI_DFUNC(dai_city_save, "texai", file, pcity, citystr);
200 }
201 
202 /**********************************************************************/
205 static void texwai_city_load(const struct section_file *file,
206  struct city *pcity, const char *citystr)
207 {
208  TEXAI_AIT;
209  TEXAI_DFUNC(dai_city_load, "texai", file, pcity, citystr);
210 }
211 
212 /**********************************************************************/
215 static void texwai_build_adv_override(struct city *pcity,
216  struct adv_choice *choice)
217 {
218  TEXAI_AIT;
219  TEXAI_DFUNC(dai_build_adv_override, pcity, choice);
220 }
221 
222 /**********************************************************************/
225 static void texwai_wonder_city_distance(struct player *pplayer,
226  struct adv_data *adv)
227 {
228  TEXAI_AIT;
229  TEXAI_DFUNC(dai_wonder_city_distance, pplayer, adv);
230 }
231 
232 /**********************************************************************/
235 static void texwai_build_adv_init(struct player *pplayer)
236 {
237  TEXAI_AIT;
239 }
240 
241 /**********************************************************************/
244 static void texwai_build_adv_adjust(struct player *pplayer,
245  struct city *wonder_city)
246 {
247  TEXAI_AIT;
248  TEXAI_DFUNC(dai_build_adv_adjust, pplayer, wonder_city);
249 }
250 
251 /**********************************************************************/
254 static void texwai_gov_value(struct player *pplayer, struct government *gov,
255  adv_want *val, bool *override)
256 {
257  TEXAI_AIT;
258  TEXAI_DFUNC(dai_gov_value, pplayer, gov, val, override);
259 }
260 
261 /**********************************************************************/
264 static void texwai_units_ruleset_init(void)
265 {
266  TEXAI_AIT;
268 }
269 
270 /**********************************************************************/
273 static void texwai_units_ruleset_close(void)
274 {
275  TEXAI_AIT;
277 }
278 
279 /**********************************************************************/
282 static void texwai_unit_alloc(struct unit *punit)
283 {
284  TEXAI_AIT;
285  TEXAI_DFUNC(dai_unit_init, punit);
286 }
287 
288 /**********************************************************************/
291 static void texwai_unit_free(struct unit *punit)
292 {
293  TEXAI_AIT;
294  TEXAI_DFUNC(dai_unit_close, punit);
295 }
296 
297 /**********************************************************************/
300 static void texwai_ferry_init_ferry(struct unit *ferry)
301 {
302  TEXAI_AIT;
304 }
305 
306 /**********************************************************************/
309 static void texwai_ferry_transformed(struct unit *ferry,
310  const struct unit_type *old)
311 {
312  TEXAI_AIT;
313  TEXAI_DFUNC(dai_ferry_transformed, ferry, old);
314 }
315 
316 /**********************************************************************/
319 static void texwai_ferry_lost(struct unit *punit)
320 {
321  TEXAI_AIT;
322  TEXAI_DFUNC(dai_ferry_lost, punit);
323 }
324 
325 /**********************************************************************/
328 static void texwai_unit_turn_end(struct unit *punit)
329 {
330  TEXAI_AIT;
332 }
333 
334 /**********************************************************************/
337 static void texwai_unit_move_or_attack(struct unit *punit,
338  struct tile *ptile,
339  struct pf_path *path, int step)
340 {
341  TEXAI_AIT;
342  TEXAI_DFUNC(dai_unit_move_or_attack, punit, ptile, path, step);
343 }
344 
345 /**********************************************************************/
348 static void texwai_unit_new_adv_task(struct unit *punit,
349  enum adv_unit_task task,
350  struct tile *ptile)
351 {
352  TEXAI_AIT;
353  TEXAI_DFUNC(dai_unit_new_adv_task, punit, task, ptile);
354 }
355 
356 /**********************************************************************/
359 static void texwai_unit_save(struct section_file *file,
360  const struct unit *punit, const char *unitstr)
361 {
362  TEXAI_AIT;
363  TEXAI_DFUNC(dai_unit_save, "texai", file, punit, unitstr);
364 }
365 
366 /**********************************************************************/
369 static void texwai_unit_load(const struct section_file *file,
370  struct unit *punit, const char *unitstr)
371 {
372  TEXAI_AIT;
373  TEXAI_DFUNC(dai_unit_load, "texai", file, punit, unitstr);
374 }
375 
376 /**********************************************************************/
379 static void texwai_auto_settler_reset(struct player *pplayer)
380 {
381  TEXAI_AIT;
383 }
384 
385 /**********************************************************************/
388 static void texwai_auto_settler_run(struct player *pplayer,
389  struct unit *punit,
390  struct settlermap *state)
391 {
392  TEXAI_AIT;
393  TEXAI_DFUNC(dai_auto_settler_run, pplayer, punit, state);
394 }
395 
396 /**********************************************************************/
399 static void texwai_auto_settler_cont(struct player *pplayer,
400  struct unit *punit,
401  struct settlermap *state)
402 {
403  TEXAI_AIT;
404  TEXAI_DFUNC(dai_auto_settler_cont, pplayer, punit, state);
405 }
406 
407 /**********************************************************************/
410 static void texwai_switch_to_explore(struct unit *punit, struct tile *target,
411  enum override_bool *allow)
412 {
413  TEXAI_AIT;
414  TEXAI_DFUNC(dai_switch_to_explore, punit, target, allow);
415 }
416 
417 /**********************************************************************/
420 static void texwai_first_activities(struct player *pplayer)
421 {
422  TEXAI_AIT;
425 }
426 
427 /**********************************************************************/
430 static void texwai_restart_phase(struct player *pplayer)
431 {
432  TEXAI_AIT;
434 }
435 
436 /**********************************************************************/
439 static void texwai_diplomacy_actions(struct player *pplayer)
440 {
441  TEXAI_AIT;
443 }
444 
445 /**********************************************************************/
448 static void texwai_last_activities(struct player *pplayer)
449 {
450  TEXAI_AIT;
452 }
453 
454 /**********************************************************************/
457 static void texwai_treaty_evaluate(struct player *pplayer,
458  struct player *aplayer,
459  struct Treaty *ptreaty)
460 {
461  TEXAI_AIT;
462  TEXAI_DFUNC(dai_treaty_evaluate, pplayer, aplayer, ptreaty);
463 }
464 
465 /**********************************************************************/
468 static void texwai_treaty_accepted(struct player *pplayer,
469  struct player *aplayer,
470  struct Treaty *ptreaty)
471 {
472  TEXAI_AIT;
473  TEXAI_DFUNC(dai_treaty_accepted, pplayer, aplayer, ptreaty);
474 }
475 
476 /**********************************************************************/
479 static void texwai_diplomacy_first_contact(struct player *pplayer,
480  struct player *aplayer)
481 {
482  TEXAI_AIT;
483  TEXAI_DFUNC(dai_diplomacy_first_contact, pplayer, aplayer);
484 }
485 
486 /**********************************************************************/
489 static void texwai_incident(enum incident_type type,
490  enum casus_belli_range scope,
491  const struct action *paction,
492  struct player *receiver, struct player *violator,
493  struct player *victim)
494 {
495  TEXAI_AIT;
496  TEXAI_DFUNC(dai_incident, type, scope, paction, receiver, violator,
497  victim);
498 }
499 
500 /**********************************************************************/
503 static void texwai_city_log(char *buffer, int buflength,
504  const struct city *pcity)
505 {
506  TEXAI_AIT;
507  TEXAI_DFUNC(dai_city_log, buffer, buflength, pcity);
508 }
509 
510 /**********************************************************************/
513 static void texwai_unit_log(char *buffer, int buflength,
514  const struct unit *punit)
515 {
516  TEXAI_AIT;
517  TEXAI_DFUNC(dai_unit_log, buffer, buflength, punit);
518 }
519 
520 /**********************************************************************/
523 static void texwai_consider_plr_dangerous(struct player *plr1,
524  struct player *plr2,
525  enum override_bool *result)
526 {
527  TEXAI_AIT;
528  TEXAI_DFUNC(dai_consider_plr_dangerous, plr1, plr2, result);
529 }
530 
531 /**********************************************************************/
534 static void texwai_consider_tile_dangerous(struct tile *ptile,
535  struct unit *punit,
536  enum override_bool *result)
537 {
538  TEXAI_AIT;
539  TEXAI_DFUNC(dai_consider_tile_dangerous, ptile, punit, result);
540 }
541 
542 /**********************************************************************/
545 static void texwai_consider_wonder_city(struct city *pcity, bool *result)
546 {
547  TEXAI_AIT;
548  TEXAI_DFUNC(dai_consider_wonder_city, pcity, result);
549 }
550 
551 /**********************************************************************/
554 static void texwai_refresh(struct player *pplayer)
555 {
556  TEXAI_AIT;
557  TEXAI_TFUNC(texai_refresh, pplayer);
558 }
559 
560 /**********************************************************************/
563 const char *fc_ai_tex_capstr(void) { return FC_AI_MOD_CAPSTR; }
564 
565 /**********************************************************************/
568 bool fc_ai_tex_setup(struct ai_type *ai)
569 {
570  if (!has_thread_cond_impl()) {
571  qCritical(_("This Freeciv21 compilation has no full threads "
572  "implementation, tex ai cannot be used."));
573  return false;
574  }
575 
576  qstrncpy(ai->name, "tex", sizeof(ai->name));
577 
578  ai->private = new struct dai_private_data {
579  };
580  ai->private->contemplace_workers =
581  false; /* We use custom code to set worker want and type */
582 
583  texai_init_self(ai);
584 
586 
590 
599 
602 
613 
615 
618 
621 
624 
628 
633 
636 
640 
642 
647 
652 
655 
659 
661 
665 
666  return true;
667 }
#define FC_AI_MOD_CAPSTR
Definition: ai.h:22
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_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_gained_control(struct ai_type *ait, struct player *pplayer)
Ai got control of the player.
Definition: aiplayer.cpp:144
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
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_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_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
#define _(String)
Definition: fcintl.h:50
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(* map_alloc)()
Definition: ai.h:59
void(* phase_finished)(struct player *pplayer)
Definition: ai.h:121
void(* tile_info)(struct tile *ptile)
Definition: ai.h:312
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(* refresh)(struct player *pplayer)
Definition: ai.h:309
void(* unit_created)(struct unit *punit)
Definition: ai.h:191
void(* unit_info)(struct unit *punit)
Definition: ai.h:324
void(* city_destroyed)(struct city *pcity)
Definition: ai.h:137
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(* city_info)(struct city *pcity)
Definition: ai.h:318
void(* player_load)(struct player *pplayer, const struct section_file *file, int plrno)
Definition: ai.h:79
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_created)(struct city *pcity)
Definition: ai.h:133
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(* city_free)(struct city *pcity)
Definition: ai.h:129
void(* choose_building)(struct city *pcity, struct adv_choice *choice)
Definition: ai.h:155
struct ai_type::@12 funcs
void(* city_load)(const struct section_file *file, struct city *pcity, const char *citystr)
Definition: ai.h:150
void(* unit_destroyed)(struct unit *punit)
Definition: ai.h:195
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(* player_save)(struct player *pplayer, struct section_file *file, int plrno)
Definition: ai.h:75
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(* lost_control)(struct player *pplayer)
Definition: ai.h:106
void(* units_ruleset_close)()
Definition: ai.h:179
void(* unit_move_seen)(struct unit *punit)
Definition: ai.h:215
void(* map_ready)()
Definition: ai.h:63
void(* map_free)()
Definition: ai.h:66
void(* want_to_explore)(struct unit *punit, struct tile *target, enum override_bool *allow)
Definition: ai.h:245
Definition: city.h:291
Definition: player.h:231
Definition: tile.h:42
Definition: unit.h:134
struct civ_map map
Definition: world_object.h:21
static void texwai_created_by_civil_war(struct player *original, struct player *created)
Call default ai with tex ai type as parameter.
Definition: texai.c:148
static void texwai_unit_load(const struct section_file *file, struct unit *punit, const char *unitstr)
Call default ai with tex ai type as parameter.
Definition: texai.c:369
static void texwai_player_alloc(struct player *pplayer)
Call default ai with tex ai type as parameter.
Definition: texai.c:78
const char * fc_ai_tex_capstr(void)
Return module capability string.
Definition: texai.c:563
static void texwai_diplomacy_first_contact(struct player *pplayer, struct player *aplayer)
Call default ai with tex ai type as parameter.
Definition: texai.c:479
bool fc_ai_tex_setup(struct ai_type *ai)
Setup player ai_funcs function pointers.
Definition: texai.c:568
static void texwai_ferry_transformed(struct unit *ferry, const struct unit_type *old)
Call default ai with tex ai type as parameter.
Definition: texai.c:309
static void texwai_city_alloc(struct city *pcity)
Call default ai with tex ai type as parameter.
Definition: texai.c:177
static void texwai_unit_new_adv_task(struct unit *punit, enum adv_unit_task task, struct tile *ptile)
Call default ai with tex ai type as parameter.
Definition: texai.c:348
static void texwai_restart_phase(struct player *pplayer)
Start working on the thread again.
Definition: texai.c:430
static void texwai_treaty_evaluate(struct player *pplayer, struct player *aplayer, struct Treaty *ptreaty)
Call default ai with tex ai type as parameter.
Definition: texai.c:457
static void texwai_auto_settler_reset(struct player *pplayer)
Call default ai with tex ai type as parameter.
Definition: texai.c:379
static void texwai_consider_plr_dangerous(struct player *plr1, struct player *plr2, enum override_bool *result)
Call default ai with tex ai type as parameter.
Definition: texai.c:523
static void texwai_build_adv_init(struct player *pplayer)
Call default ai with tex ai type as parameter.
Definition: texai.c:235
static void texwai_first_activities(struct player *pplayer)
Call default ai with tex ai type as parameter.
Definition: texai.c:420
static void texwai_phase_finished(struct player *pplayer)
Call default ai with tex ai type as parameter.
Definition: texai.c:167
#define TEXAI_TFUNC(_func,...)
Definition: texai.c:61
static void texwai_phase_begin(struct player *pplayer, bool is_new_phase)
Call default ai with tex ai type as parameter.
Definition: texai.c:158
static void texwai_gov_value(struct player *pplayer, struct government *gov, adv_want *val, bool *override)
Call default ai with tex ai type as parameter.
Definition: texai.c:254
static void texwai_wonder_city_distance(struct player *pplayer, struct adv_data *adv)
Call default ai with tex ai type as parameter.
Definition: texai.c:225
static void texwai_unit_log(char *buffer, int buflength, const struct unit *punit)
Call default ai with tex ai type as parameter.
Definition: texai.c:513
static void texwai_city_log(char *buffer, int buflength, const struct city *pcity)
Call default ai with tex ai type as parameter.
Definition: texai.c:503
static void texwai_auto_settler_cont(struct player *pplayer, struct unit *punit, struct settlermap *state)
Call default ai with tex ai type as parameter.
Definition: texai.c:399
static void texwai_city_free(struct city *pcity)
Call default ai with tex ai type as parameter.
Definition: texai.c:186
#define TEXAI_DFUNC(_func,...)
Definition: texai.c:62
static void texwai_build_adv_override(struct city *pcity, struct adv_choice *choice)
Call default ai with tex ai type as parameter.
Definition: texai.c:215
static void texwai_switch_to_explore(struct unit *punit, struct tile *target, enum override_bool *allow)
Call default ai with tex ai type as parameter.
Definition: texai.c:410
static void texwai_last_activities(struct player *pplayer)
Call default ai with tex ai type as parameter.
Definition: texai.c:448
static void texwai_ferry_init_ferry(struct unit *ferry)
Call default ai with tex ai type as parameter.
Definition: texai.c:300
static void texwai_unit_turn_end(struct unit *punit)
Call default ai with tex ai type as parameter.
Definition: texai.c:328
static void texwai_consider_tile_dangerous(struct tile *ptile, struct unit *punit, enum override_bool *result)
Call default ai with tex ai type as parameter.
Definition: texai.c:534
static void texwai_city_save(struct section_file *file, const struct city *pcity, const char *citystr)
Call default ai with tex ai type as parameter.
Definition: texai.c:195
static void texwai_unit_alloc(struct unit *punit)
Call default ai with tex ai type as parameter.
Definition: texai.c:282
static void texwai_unit_free(struct unit *punit)
Call default ai with tex ai type as parameter.
Definition: texai.c:291
struct ai_type * texai_get_self(void)
Get pointer to ai type of the tex ai.
Definition: texai.c:58
static void texai_init_self(struct ai_type *ai)
Set pointer to ai type of the tex ai.
Definition: texai.c:48
static void texwai_split_by_civil_war(struct player *original, struct player *created)
Call default ai with tex ai type as parameter.
Definition: texai.c:138
static void texwai_player_load(struct player *pplayer, const struct section_file *file, int plrno)
Call default ai with tex ai type as parameter.
Definition: texai.c:109
static void texwai_city_load(const struct section_file *file, struct city *pcity, const char *citystr)
Call default ai with tex ai type as parameter.
Definition: texai.c:205
#define TEXAI_AIT
Definition: texai.c:60
static void texwai_units_ruleset_close(void)
Call default ai with tex ai type as parameter.
Definition: texai.c:273
static void texwai_player_free(struct player *pplayer)
Call default ai with tex ai type as parameter.
Definition: texai.c:89
static void texwai_unit_move_or_attack(struct unit *punit, struct tile *ptile, struct pf_path *path, int step)
Call default ai with tex ai type as parameter.
Definition: texai.c:337
static void texwai_build_adv_adjust(struct player *pplayer, struct city *wonder_city)
Call default ai with tex ai type as parameter.
Definition: texai.c:244
static void texwai_consider_wonder_city(struct city *pcity, bool *result)
Call default ai with tex ai type as parameter.
Definition: texai.c:545
static void texwai_units_ruleset_init(void)
Call default ai with tex ai type as parameter.
Definition: texai.c:264
static void texwai_control_gained(struct player *pplayer)
Call default ai with tex ai type as parameter.
Definition: texai.c:119
static void texwai_unit_save(struct section_file *file, const struct unit *punit, const char *unitstr)
Call default ai with tex ai type as parameter.
Definition: texai.c:359
static void texwai_player_save(struct player *pplayer, struct section_file *file, int plrno)
Call default ai with tex ai type as parameter.
Definition: texai.c:99
static void texai_module_close(void)
Free resources allocated by the tex AI module.
Definition: texai.c:67
static void texwai_ferry_lost(struct unit *punit)
Call default ai with tex ai type as parameter.
Definition: texai.c:319
static void texwai_control_lost(struct player *pplayer)
Call default ai with tex ai type as parameter.
Definition: texai.c:129
static void texwai_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 tex ai type as parameter.
Definition: texai.c:489
static void texwai_treaty_accepted(struct player *pplayer, struct player *aplayer, struct Treaty *ptreaty)
Call default ai with tex ai type as parameter.
Definition: texai.c:468
static void texwai_refresh(struct player *pplayer)
Call default ai with tex ai type as parameter.
Definition: texai.c:554
static void texwai_auto_settler_run(struct player *pplayer, struct unit *punit, struct settlermap *state)
Call default ai with tex ai type as parameter.
Definition: texai.c:388
static void texwai_diplomacy_actions(struct player *pplayer)
Call default ai with tex ai type as parameter.
Definition: texai.c:439
void texai_city_alloc(struct ai_type *ait, struct city *pcity)
Initialize city for use with tex AI.
Definition: texaicity.c:584
void texai_city_free(struct ai_type *ait, struct city *pcity)
Free city from use with tex AI.
Definition: texaicity.c:598
void texai_first_activities(struct ai_type *ait, struct player *pplayer)
Time for phase first activities.
Definition: texaimsg.c:61
void texai_phase_finished(struct ai_type *ait, struct player *pplayer)
Player phase has finished.
Definition: texaimsg.c:69
void texai_player_alloc(struct ai_type *ait, struct player *pplayer)
Initialize player for use with tex AI.
Definition: texaiplayer.c:265
void texai_control_gained(struct ai_type *ait, struct player *pplayer)
We actually control the player.
Definition: texaiplayer.c:298
void texai_player_free(struct ai_type *ait, struct player *pplayer)
Free player from use with tex AI.
Definition: texaiplayer.c:280
void texai_control_lost(struct ai_type *ait, struct player *pplayer)
We no longer control the player.
Definition: texaiplayer.c:332
void texai_refresh(struct ai_type *ait, struct player *pplayer)
Check for messages sent by player thread.
Definition: texaiplayer.c:355
void texai_init_threading(void)
Initialize ai thread.
Definition: texaiplayer.c:68
void texai_map_alloc(void)
Main map has been allocated.
Definition: texaiplayer.c:109
void texai_whole_map_copy(void)
Send all tiles to tex thread.
Definition: texaiplayer.c:117
void texai_map_free(void)
Main map has been freed.
Definition: texaiplayer.c:131
void texai_city_created(struct city *pcity)
New city has been added to the main map.
Definition: texaiworld.c:143
void texai_city_destroyed(struct city *pcity)
City has been removed from the main map.
Definition: texaiworld.c:197
void texai_unit_destroyed(struct unit *punit)
Unit has been removed from the main map.
Definition: texaiworld.c:305
void texai_unit_changed(struct unit *punit)
Unit (potentially) changed in main map.
Definition: texaiworld.c:256
void texai_tile_info(struct tile *ptile)
Tile info updated on main map.
Definition: texaiworld.c:91
void texai_city_changed(struct city *pcity)
City on main map has (potentially) changed.
Definition: texaiworld.c:151
void texai_unit_move_seen(struct unit *punit)
Unit has moved in the main map.
Definition: texaiworld.c:341
void texai_unit_created(struct unit *punit)
New unit has been added to the main map.
Definition: texaiworld.c:248