![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include "log.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 "cityturn.h"#include "maphand.h"#include "plrhand.h"#include "srv_log.h"#include "unittools.h"#include "advbuilding.h"#include "advcity.h"#include "advtools.h"#include "handicaps.h"#include "advdata.h"
Include dependency graph for advdata.cpp:Go to the source code of this file.
Functions | |
| static void | adv_dipl_new (const struct player *plr1, const struct player *plr2) |
| Allocate new advisor diplomacy slot. More... | |
| static void | adv_dipl_free (const struct player *plr1, const struct player *plr2) |
| Free resources allocated for diplomacy information between two players. More... | |
| static struct adv_dipl * | adv_dipl_get (const struct player *plr1, const struct player *plr2) |
| Returns diplomatic state type between two players. More... | |
| static void | adv_data_city_impr_calc (struct player *pplayer, struct adv_data *adv) |
| Precalculates some important data about the improvements in the game that we use later in ai/aicity.c. More... | |
| static bool | player_has_really_useful_tech_parasite (struct player *pplayer) |
| Check if the player still takes advantage of EFT_TECH_PARASITE. More... | |
| void | adv_data_analyze_rulesets (struct player *pplayer) |
| Analyze rulesets. More... | |
| static void | count_my_units (struct player *pplayer) |
| This function is called each turn to initialize pplayer->ai.stats.units. More... | |
| bool | adv_data_phase_init (struct player *pplayer, bool is_new_phase) |
| Make and cache lots of calculations needed for other functions. More... | |
| void | adv_data_phase_done (struct player *pplayer) |
| Clean up our mess. More... | |
| struct adv_data * | adv_data_get (struct player *pplayer, bool *caller_closes) |
| Return a pointer to our data. More... | |
| void | adv_data_init (struct player *pplayer) |
| Allocate memory for advisor data. More... | |
| void | adv_data_default (struct player *pplayer) |
| Initialize with sane values. More... | |
| void | adv_data_close (struct player *pplayer) |
| Free memory for advisor data. More... | |
| void | adv_best_government (struct player *pplayer) |
| Find best government to aim for. More... | |
| bool | adv_wants_science (struct player *pplayer) |
| Return whether science would help us at all. More... | |
| 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 him, he has done lots of ignoble things to us, he is an ally of one of our enemies (a ticking bomb to be sure), we don't like him, diplomatic state is neutral or we have cease fire. More... | |
| 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 816 of file advdata.cpp.
Referenced by adv_data_phase_init().
| 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 194 of file advdata.cpp.
Referenced by srv_ready().
Precalculates some important data about the improvements in the game that we use later in ai/aicity.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 calculatable effects in the improvement and record it for later use.
Definition at line 63 of file advdata.cpp.
Referenced by adv_data_analyze_rulesets().
| void adv_data_close | ( | struct player * | pplayer | ) |
Free memory for advisor data.
Definition at line 739 of file advdata.cpp.
Referenced by player_limit_to_max_rates().
| void adv_data_default | ( | struct player * | pplayer | ) |
Initialize with sane values.
Definition at line 720 of file advdata.cpp.
Referenced by adv_data_init(), server_player_init(), and srv_ready().
Return a pointer to our data.
If caller_closes is set, data phase will be opened even if it's currently closed, and the boolean will be set accordingly to tell caller that phase needs closing.
Definition at line 591 of file advdata.cpp.
Referenced by adjust_improvement_wants_by_effects(), adv_best_government(), adv_wants_science(), base_want(), building_advisor(), calculate_want_for_paratrooper(), city_desirability(), cityresult_fill(), contemplate_terrain_improvements(), count_my_units(), dai_adjust_policies(), dai_build_adv_init(), dai_city_choose_build(), dai_data_phase_begin(), dai_diplomacy_actions(), dai_diplomacy_begin_new_phase(), dai_gov_value(), dai_manage_government(), dai_manage_taxes(), dai_tech_base_want(), dai_tech_effect_values(), dai_war_desire(), domestic_advisor_choose_build(), military_advisor_choose_build(), military_amortize(), and texai_city_worker_wants().
| void adv_data_init | ( | struct player * | pplayer | ) |
Allocate memory for advisor data.
Safe to call multiple times.
Definition at line 685 of file advdata.cpp.
Referenced by server_create_player().
| void adv_data_phase_done | ( | struct player * | pplayer | ) |
Clean up our mess.
Definition at line 556 of file advdata.cpp.
Referenced by adv_data_close(), adv_data_get(), dai_data_phase_begin(), end_phase(), init_new_game(), server_quit(), sg_load_sanitycheck(), and try_summon_barbarians().
| 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 defence 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 250 of file advdata.cpp.
Referenced by adv_data_get(), begin_phase(), init_new_game(), kill_player(), sg_load_sanitycheck(), split_player(), try_summon_barbarians(), and unleash_barbarians().
Free resources allocated for diplomacy information between two players.
Definition at line 780 of file advdata.cpp.
Referenced by adv_data_close().
|
static |
Returns diplomatic state type between two players.
Definition at line 795 of file advdata.cpp.
Referenced by adv_data_phase_init(), and adv_is_player_dangerous().
Allocate new advisor diplomacy slot.
Definition at line 768 of file advdata.cpp.
Referenced by adv_data_init().
There are some signs that a player might be dangerous: We are at war with him, he has done lots of ignoble things to us, he is an ally of one of our enemies (a ticking bomb to be sure), we don't like him, diplomatic state is neutral or we have cease fire.
Definition at line 1062 of file advdata.cpp.
Referenced by adv_data_phase_init(), assess_danger(), compute_tech_sell_price(), and dai_hunter_manage().
| bool adv_wants_science | ( | struct player * | pplayer | ) |
Return whether science would help us at all.
Definition at line 1051 of file advdata.cpp.
Referenced by adv_data_phase_init(), dai_effect_value(), and dai_manage_taxes().
|
static |
This function is called each turn to initialize pplayer->ai.stats.units.
Definition at line 206 of file advdata.cpp.
Referenced by adv_data_phase_init().
|
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 146 of file advdata.cpp.
Referenced by adv_data_phase_init().