Freeciv21
Develop your civilization from humble roots to a global empire
classicai.cpp File Reference
#include "ai.h"
#include "player.h"
#include "advdata.h"
#include "autosettlers.h"
#include "aidata.h"
#include "aiferry.h"
#include "aihand.h"
#include "ailog.h"
#include "aiplayer.h"
#include "aisettler.h"
#include "aitools.h"
#include "aiunit.h"
#include "daicity.h"
#include "daidiplomacy.h"
#include "daidomestic.h"
#include "daimilitary.h"
#include "classicai.h"
+ Include dependency graph for classicai.cpp:

Go to the source code of this file.

Functions

static void classic_ai_set_self (struct ai_type *ai)
 Set pointer to ai type of the classic ai. More...
 
static struct ai_typeclassic_ai_get_self ()
 Get pointer to ai type of the classic ai. More...
 
static void cai_module_close ()
 Free resources allocated by the classic AI module. More...
 
static void cai_player_alloc (struct player *pplayer)
 Call default ai with classic ai type as parameter. More...
 
static void cai_player_free (struct player *pplayer)
 Call default ai with classic ai type as parameter. More...
 
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. More...
 
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. More...
 
static void cai_gained_control (struct player *pplayer)
 Call default ai with classic ai type as parameter. More...
 
static void cai_split_by_civil_war (struct player *original, struct player *created)
 Call default ai with classic ai type as parameter. More...
 
static void cai_created_by_civil_war (struct player *original, struct player *created)
 Call default ai with classic ai type as parameter. More...
 
static void cai_data_phase_begin (struct player *pplayer, bool is_new_phase)
 Call default ai with classic ai type as parameter. More...
 
static void cai_data_phase_finished (struct player *pplayer)
 Call default ai with classic ai type as parameter. More...
 
static void cai_city_alloc (struct city *pcity)
 Call default ai with classic ai type as parameter. More...
 
static void cai_city_free (struct city *pcity)
 Call default ai with classic ai type as parameter. More...
 
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. More...
 
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. More...
 
static void cai_build_adv_override (struct city *pcity, struct adv_choice *choice)
 Call default ai with classic ai type as parameter. More...
 
static void cai_wonder_city_distance (struct player *pplayer, struct adv_data *adv)
 Call default ai with classic ai type as parameter. More...
 
static void cai_build_adv_init (struct player *pplayer)
 Call default ai with classic ai type as parameter. More...
 
static void cai_build_adv_adjust (struct player *pplayer, struct city *wonder_city)
 Call default ai with classic ai type as parameter. More...
 
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. More...
 
static void cai_units_ruleset_init ()
 Call default ai with classic ai type as parameter. More...
 
static void cai_units_ruleset_close ()
 Call default ai with classic ai type as parameter. More...
 
static void cai_unit_init (struct unit *punit)
 Call default ai with classic ai type as parameter. More...
 
static void cai_unit_close (struct unit *punit)
 Call default ai with classic ai type as parameter. More...
 
static void cai_ferry_init_ferry (struct unit *ferry)
 Call default ai with classic ai type as parameter. More...
 
static void cai_ferry_transformed (struct unit *ferry, const struct unit_type *old)
 Call default ai with classic ai type as parameter. More...
 
static void cai_ferry_lost (struct unit *punit)
 Call default ai with classic ai type as parameter. More...
 
static void cai_unit_turn_end (struct unit *punit)
 Call default ai with classic ai type as parameter. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
static void cai_auto_settler_reset (struct player *pplayer)
 Call default ai with classic ai type as parameter. More...
 
static void cai_auto_settler_run (struct player *pplayer, struct unit *punit, struct settlermap *state)
 Call default ai with classic ai type as parameter. More...
 
static void cai_auto_settler_cont (struct player *pplayer, struct unit *punit, struct settlermap *state)
 Call default ai with classic ai type as parameter. More...
 
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. More...
 
static void cai_do_first_activities (struct player *pplayer)
 Call default ai with classic ai type as parameter. More...
 
static void cai_restart_phase (struct player *pplayer)
 Mark turn done as we have already done everything before game was saved. More...
 
static void cai_diplomacy_actions (struct player *pplayer)
 Call default ai with classic ai type as parameter. More...
 
static void cai_do_last_activities (struct player *pplayer)
 Call default ai with classic ai type as parameter. More...
 
static void cai_treaty_evaluate (struct player *pplayer, struct player *aplayer, struct Treaty *ptreaty)
 Call default ai with classic ai type as parameter. More...
 
static void cai_treaty_accepted (struct player *pplayer, struct player *aplayer, struct Treaty *ptreaty)
 Call default ai with classic ai type as parameter. More...
 
static void cai_diplomacy_first_contact (struct player *pplayer, struct player *aplayer)
 Call default ai with classic ai type as parameter. More...
 
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. More...
 
static void cai_city_log (char *buffer, int buflength, const struct city *pcity)
 Call default ai with classic ai type as parameter. More...
 
static void cai_unit_log (char *buffer, int buflength, const struct unit *punit)
 Call default ai with classic ai type as parameter. More...
 
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. More...
 
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. More...
 
static void cai_consider_wonder_city (struct city *pcity, bool *result)
 Call default ai with classic ai type as parameter. More...
 
bool fc_ai_classic_setup (struct ai_type *ai)
 Setup player ai_funcs function pointers. More...
 

Variables

static struct ai_typeself = nullptr
 

Function Documentation

◆ cai_auto_settler_cont()

static void cai_auto_settler_cont ( struct player pplayer,
struct unit punit,
struct settlermap state 
)
static

Call default ai with classic ai type as parameter.

Definition at line 406 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_auto_settler_reset()

static void cai_auto_settler_reset ( struct player pplayer)
static

Call default ai with classic ai type as parameter.

Definition at line 385 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_auto_settler_run()

static void cai_auto_settler_run ( struct player pplayer,
struct unit punit,
struct settlermap state 
)
static

Call default ai with classic ai type as parameter.

Definition at line 395 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_build_adv_adjust()

static void cai_build_adv_adjust ( struct player pplayer,
struct city wonder_city 
)
static

Call default ai with classic ai type as parameter.

Definition at line 237 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_build_adv_init()

static void cai_build_adv_init ( struct player pplayer)
static

Call default ai with classic ai type as parameter.

Definition at line 227 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_build_adv_override()

static void cai_build_adv_override ( struct city pcity,
struct adv_choice choice 
)
static

Call default ai with classic ai type as parameter.

Definition at line 205 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_city_alloc()

static void cai_city_alloc ( struct city pcity)
static

Call default ai with classic ai type as parameter.

Definition at line 163 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_city_free()

static void cai_city_free ( struct city pcity)
static

Call default ai with classic ai type as parameter.

Definition at line 173 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_city_load()

static void cai_city_load ( const struct section_file file,
struct city pcity,
const char *  citystr 
)
static

Call default ai with classic ai type as parameter.

Definition at line 194 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_city_log()

static void cai_city_log ( char *  buffer,
int  buflength,
const struct city pcity 
)
static

Call default ai with classic ai type as parameter.

Definition at line 517 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_city_save()

static void cai_city_save ( struct section_file file,
const struct city pcity,
const char *  citystr 
)
static

Call default ai with classic ai type as parameter.

Definition at line 183 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_consider_plr_dangerous()

static void cai_consider_plr_dangerous ( struct player plr1,
struct player plr2,
enum override_bool result 
)
static

Call default ai with classic ai type as parameter.

Definition at line 539 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_consider_tile_dangerous()

static void cai_consider_tile_dangerous ( struct tile ptile,
struct unit punit,
enum override_bool result 
)
static

Call default ai with classic ai type as parameter.

Definition at line 551 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_consider_wonder_city()

static void cai_consider_wonder_city ( struct city pcity,
bool *  result 
)
static

Call default ai with classic ai type as parameter.

Definition at line 563 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_created_by_civil_war()

static void cai_created_by_civil_war ( struct player original,
struct player created 
)
static

Call default ai with classic ai type as parameter.

Definition at line 132 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_data_phase_begin()

static void cai_data_phase_begin ( struct player pplayer,
bool  is_new_phase 
)
static

Call default ai with classic ai type as parameter.

Definition at line 143 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_data_phase_finished()

static void cai_data_phase_finished ( struct player pplayer)
static

Call default ai with classic ai type as parameter.

Definition at line 153 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_diplomacy_actions()

static void cai_diplomacy_actions ( struct player pplayer)
static

Call default ai with classic ai type as parameter.

Definition at line 448 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_diplomacy_first_contact()

static void cai_diplomacy_first_contact ( struct player pplayer,
struct player aplayer 
)
static

Call default ai with classic ai type as parameter.

Definition at line 492 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_do_first_activities()

static void cai_do_first_activities ( struct player pplayer)
static

Call default ai with classic ai type as parameter.

Definition at line 428 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_do_last_activities()

static void cai_do_last_activities ( struct player pplayer)
static

Call default ai with classic ai type as parameter.

Definition at line 458 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_ferry_init_ferry()

static void cai_ferry_init_ferry ( struct unit ferry)
static

Call default ai with classic ai type as parameter.

Definition at line 299 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_ferry_lost()

static void cai_ferry_lost ( struct unit punit)
static

Call default ai with classic ai type as parameter.

Definition at line 320 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_ferry_transformed()

static void cai_ferry_transformed ( struct unit ferry,
const struct unit_type old 
)
static

Call default ai with classic ai type as parameter.

Definition at line 309 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_gained_control()

static void cai_gained_control ( struct player pplayer)
static

Call default ai with classic ai type as parameter.

Definition at line 111 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_gov_value()

static void cai_gov_value ( struct player pplayer,
struct government gov,
adv_want val,
bool *  override 
)
static

Call default ai with classic ai type as parameter.

Definition at line 248 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_incident()

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 
)
static

Call default ai with classic ai type as parameter.

Definition at line 503 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_module_close()

static void cai_module_close ( )
static

Free resources allocated by the classic AI module.

Definition at line 55 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_player_alloc()

static void cai_player_alloc ( struct player pplayer)
static

Call default ai with classic ai type as parameter.

Definition at line 65 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_player_free()

static void cai_player_free ( struct player pplayer)
static

Call default ai with classic ai type as parameter.

Definition at line 75 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_player_load_relations()

static void cai_player_load_relations ( struct player pplayer,
struct player other,
const struct section_file file,
int  plrno 
)
static

Call default ai with classic ai type as parameter.

Definition at line 98 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_player_save_relations()

static void cai_player_save_relations ( struct player pplayer,
struct player other,
struct section_file file,
int  plrno 
)
static

Call default ai with classic ai type as parameter.

Classicai stores information to "ai" like the default ai common code.

Definition at line 86 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_restart_phase()

static void cai_restart_phase ( struct player pplayer)
static

Mark turn done as we have already done everything before game was saved.

Definition at line 440 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_split_by_civil_war()

static void cai_split_by_civil_war ( struct player original,
struct player created 
)
static

Call default ai with classic ai type as parameter.

Definition at line 121 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_switch_to_explore()

static void cai_switch_to_explore ( struct unit punit,
struct tile target,
enum override_bool allow 
)
static

Call default ai with classic ai type as parameter.

Definition at line 417 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_treaty_accepted()

static void cai_treaty_accepted ( struct player pplayer,
struct player aplayer,
struct Treaty ptreaty 
)
static

Call default ai with classic ai type as parameter.

Definition at line 480 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_treaty_evaluate()

static void cai_treaty_evaluate ( struct player pplayer,
struct player aplayer,
struct Treaty ptreaty 
)
static

Call default ai with classic ai type as parameter.

Definition at line 468 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_unit_close()

static void cai_unit_close ( struct unit punit)
static

Call default ai with classic ai type as parameter.

Definition at line 289 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_unit_init()

static void cai_unit_init ( struct unit punit)
static

Call default ai with classic ai type as parameter.

Definition at line 279 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_unit_load()

static void cai_unit_load ( const struct section_file file,
struct unit punit,
const char *  unitstr 
)
static

Call default ai with classic ai type as parameter.

Definition at line 374 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_unit_log()

static void cai_unit_log ( char *  buffer,
int  buflength,
const struct unit punit 
)
static

Call default ai with classic ai type as parameter.

Definition at line 528 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_unit_move_or_attack()

static void cai_unit_move_or_attack ( struct unit punit,
struct tile ptile,
const PFPath path,
int  step 
)
static

Call default ai with classic ai type as parameter.

Definition at line 340 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_unit_new_adv_task()

static void cai_unit_new_adv_task ( struct unit punit,
enum adv_unit_task  task,
struct tile ptile 
)
static

Call default ai with classic ai type as parameter.

Definition at line 351 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_unit_save()

static void cai_unit_save ( struct section_file file,
const struct unit punit,
const char *  unitstr 
)
static

Call default ai with classic ai type as parameter.

Definition at line 363 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_unit_turn_end()

static void cai_unit_turn_end ( struct unit punit)
static

Call default ai with classic ai type as parameter.

Definition at line 330 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_units_ruleset_close()

static void cai_units_ruleset_close ( )
static

Call default ai with classic ai type as parameter.

Definition at line 269 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_units_ruleset_init()

static void cai_units_ruleset_init ( )
static

Call default ai with classic ai type as parameter.

Definition at line 259 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ cai_wonder_city_distance()

static void cai_wonder_city_distance ( struct player pplayer,
struct adv_data adv 
)
static

Call default ai with classic ai type as parameter.

Definition at line 216 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ classic_ai_get_self()

◆ classic_ai_set_self()

static void classic_ai_set_self ( struct ai_type ai)
static

Set pointer to ai type of the classic ai.

Definition at line 45 of file classicai.cpp.

Referenced by fc_ai_classic_setup().

◆ fc_ai_classic_setup()

bool fc_ai_classic_setup ( struct ai_type ai)

Setup player ai_funcs function pointers.

Definition at line 573 of file classicai.cpp.

Referenced by ai_init().

Variable Documentation

◆ self

struct ai_type* self = nullptr
static