Freeciv-3.2
Loading...
Searching...
No Matches
Functions
advdata.c File Reference
#include "log.h"
#include "mem.h"
#include "actions.h"
#include "ai.h"
#include "city.h"
#include "effects.h"
#include "game.h"
#include "government.h"
#include "map.h"
#include "movement.h"
#include "research.h"
#include "unit.h"
#include "unitlist.h"
#include "aisupport.h"
#include "path_finding.h"
#include "pf_tools.h"
#include "cityturn.h"
#include "diplhand.h"
#include "maphand.h"
#include "plrhand.h"
#include "srv_log.h"
#include "unittools.h"
#include "advbuilding.h"
#include "advcity.h"
#include "advtools.h"
#include "autosettlers.h"
#include "handicaps.h"
#include "advdata.h"

Go to the source code of this file.

Functions

static void adv_dipl_new (const struct player *plr1, const struct player *plr2)
 
static void adv_dipl_free (const struct player *plr1, const struct player *plr2)
 
static struct adv_dipladv_dipl_get (const struct player *plr1, const struct player *plr2)
 
static void adv_data_city_impr_calc (struct player *pplayer, struct adv_data *adv)
 
static bool player_has_really_useful_tech_parasite (struct player *pplayer)
 
void adv_data_analyze_rulesets (struct player *pplayer)
 
static void count_my_units (struct player *pplayer)
 
bool is_adv_data_phase_open (struct player *pplayer)
 
bool adv_data_phase_init (struct player *pplayer, bool is_new_phase)
 
void adv_data_phase_done (struct player *pplayer)
 
struct adv_dataadv_data_get (struct player *pplayer, bool *caller_closes)
 
void adv_data_init (struct player *pplayer)
 
void adv_data_default (struct player *pplayer)
 
void adv_data_close (struct player *pplayer)
 
adv_want adv_gov_action_immunity_want (struct government *gov)
 
adv_want adv_gov_player_bonus_want (struct player *pplayer)
 
void adv_best_government (struct player *pplayer)
 
bool adv_wants_science (struct player *pplayer)
 
bool adv_is_player_dangerous (struct player *pplayer, struct player *aplayer)
 

Function Documentation

◆ adv_best_government()

void adv_best_government ( struct player pplayer)

Find best government to aim for. We do it by setting our government to all possible values and calculating our GDP (total ai_eval_calc_city) under this government. If the very best of the governments is not available to us (it is not yet discovered), we record it in the goal.gov structure with the aim of wanting the necessary tech more. The best of the available governments is recorded in goal.revolution. We record the want of each government, and only recalculate this data every ai->govt_reeval_turns turns.

Note: Call this before doing taxes!

Definition at line 980 of file advdata.c.

Referenced by adv_data_phase_init().

◆ adv_data_analyze_rulesets()

void adv_data_analyze_rulesets ( struct player pplayer)

Analyze rulesets. Must be run after rulesets are loaded, unlike _init, which must be run before savegames are loaded, which is usually before rulesets.

Definition at line 192 of file advdata.c.

Referenced by srv_ready().

◆ adv_data_city_impr_calc()

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

Precalculates some important data about the improvements in the game that we use later in ai/default/daicity.c. We mark improvements as 'calculate' if we want to run a full test on them, as 'estimate' if we just want to do some guesses on them, or as 'unused' is they are useless to us. Then we find the largest range of calculable effects in the improvement and record it for later use.

Definition at line 74 of file advdata.c.

Referenced by adv_data_analyze_rulesets().

◆ adv_data_close()

void adv_data_close ( struct player pplayer)

Free memory for advisor data.

Definition at line 753 of file advdata.c.

Referenced by server_remove_player().

◆ adv_data_default()

void adv_data_default ( struct player pplayer)

Initialize with sane values.

Definition at line 730 of file advdata.c.

Referenced by adv_data_init(), server_player_init(), and srv_ready().

◆ adv_data_get()

struct adv_data * adv_data_get ( struct player pplayer,
bool caller_closes 
)

◆ adv_data_init()

void adv_data_init ( struct player pplayer)

Allocate memory for advisor data. Save to call multiple times.

Definition at line 698 of file advdata.c.

Referenced by server_create_player().

◆ adv_data_phase_done()

void adv_data_phase_done ( struct player pplayer)

◆ adv_data_phase_init()

bool adv_data_phase_init ( struct player pplayer,
bool  is_new_phase 
)

Make and cache lots of calculations needed for other functions.

Returns TRUE if new data was created, FALSE if data existed already.

Note: We use map.num_continents here rather than pplayer->num_continents because we are omniscient and don't care about such trivialities as who can see what.

FIXME: We should try to find the lowest common defense strength of our defending units, and ignore enemy units that are incapable of harming us, instead of just checking attack strength > 1.

Definition at line 263 of file advdata.c.

Referenced by adv_data_get(), begin_phase(), check_terrain_change(), init_new_game(), kill_player(), sg_load_sanitycheck(), sg_load_sanitycheck(), split_player(), try_summon_barbarians(), and unleash_barbarians().

◆ adv_dipl_free()

static void adv_dipl_free ( const struct player plr1,
const struct player plr2 
)
static

Free resources allocated for diplomacy information between two players.

Definition at line 797 of file advdata.c.

Referenced by adv_data_close().

◆ adv_dipl_get()

static struct adv_dipl * adv_dipl_get ( const struct player plr1,
const struct player plr2 
)
static

Returns diplomatic state type between two players

Definition at line 812 of file advdata.c.

Referenced by adv_data_phase_init(), and adv_is_player_dangerous().

◆ adv_dipl_new()

static void adv_dipl_new ( const struct player plr1,
const struct player plr2 
)
static

Allocate new advisor diplomacy slot

Definition at line 785 of file advdata.c.

Referenced by adv_data_init().

◆ adv_gov_action_immunity_want()

adv_want adv_gov_action_immunity_want ( struct government gov)

Get value of government provided action immunities.

Definition at line 824 of file advdata.c.

Referenced by adv_best_government(), and dai_gov_value().

◆ adv_gov_player_bonus_want()

adv_want adv_gov_player_bonus_want ( struct player pplayer)

Get value of currently set government provided misc player bonuses.

Caller can set player's government temporarily to another one to evaluate that government instead of the one player actually have.

Definition at line 952 of file advdata.c.

Referenced by adv_best_government(), and dai_gov_value().

◆ adv_is_player_dangerous()

bool adv_is_player_dangerous ( struct player pplayer,
struct player aplayer 
)

There are some signs that a player might be dangerous: We are at war with them, they have done lots of ignoble things to us, they are an ally of one of our enemies (a ticking bomb to be sure), we don't like them, diplomatic state is neutral or we have cease fire.

Definition at line 1107 of file advdata.c.

Referenced by adv_data_phase_init(), assess_danger(), compute_tech_sell_price(), and dai_hunter_manage().

◆ adv_wants_science()

bool adv_wants_science ( struct player pplayer)

Return whether science would help us at all.

Definition at line 1096 of file advdata.c.

Referenced by adv_data_phase_init(), dai_effect_value(), and dai_manage_taxes().

◆ count_my_units()

static void count_my_units ( struct player pplayer)
static

This function is called each turn to initialize pplayer->ai.stats.units.

Definition at line 204 of file advdata.c.

Referenced by adv_data_phase_init().

◆ is_adv_data_phase_open()

bool is_adv_data_phase_open ( struct player pplayer)

Return whether data phase is currently open. Data phase is open between adv_data_phase_init() and adv_data_phase_done() calls.

Definition at line 243 of file advdata.c.

Referenced by check_terrain_change().

◆ player_has_really_useful_tech_parasite()

static bool player_has_really_useful_tech_parasite ( struct player pplayer)
static

Check if the player still takes advantage of EFT_TECH_PARASITE. Research is useless if there are still techs which may be given to the player for free.

Definition at line 148 of file advdata.c.

Referenced by adv_data_phase_init().