94#define RESULT_IS_ENOUGH 250
96#define FERRY_TECH_WANT 500
98#define GROWTH_PRIORITY 15
109#define GROWTH_POTENTIAL_DEEMPHASIS 8
112#define NAVAL_EMPHASIS 20
116#define DEFENSE_EMPHASIS 20
137#define SPECHASH_TAG tile_data_cache
138#define SPECHASH_INT_KEY_TYPE
139#define SPECHASH_IDATA_TYPE struct tile_data_cache *
140#define SPECHASH_IDATA_FREE tile_data_cache_destroy
198 struct tile *center);
245 result->best_other.cindex = 0;
312 bool city_center = (result->
tile == ptile);
345 if (
ptdc->food >= 2) {
617 defense_bonus += (defense_bonus *
extra_bonus) / 100;
666 log_test(
"cityresult for (x, y, radius_sq) = (%d, %d, %d) - Reservations:",
671 log_test(
"cityresult for (x, y, radius_sq) = (%d, %d, %d) - Food:",
676 log_test(
"cityresult for (x, y, radius_sq) = (%d, %d, %d) - Shield:",
681 log_test(
"cityresult for (x, y, radius_sq) = (%d, %d, %d) - Trade:",
690 log_test(
"city center (%d, %d) %d + best other (abs: %d, %d)"
704 log_test(
" ** RESOURCE STARVATION **");
833 turns = move_cost / parameter->
move_rate;
844 if ((!best && cr->
result > 0)
845 || (best && cr->
result > best->result)) {
854 TILE_XY(best->tile), best->result);
875 TILE_XY(best->tile), best->result);
877 log_debug(
"settler map search (final): no result");
950 "+ %d for %s to ferry settler",
976 cr2->virt_boat = (ferry->
id == 0);
979 if (ferry->
id == 0) {
1001 if (
cr1->result >
cr2->result) {
1108 if (pcity !=
NULL) {
1120 if (pcity ==
NULL) {
1154 if (
result->best_other.tile &&
result->best_other.tdc->sum >= 0) {
1191 if (pcity !=
NULL) {
1229 log_debug(
"[aisettler cache for %s] save: %d, miss: %d, old: %d, hit: %d",
1283 log_debug(
"%s: There is already a city at (%d, %d)!",
1291 if (!pcity &&
punit) {
1299 log_debug(
"%s: Failed to build city at (%d, %d)",
1303 log_error(
"%s: Failed to build city at (%d, %d). Reason id: %d",
1341 log_debug(
"No ACTION_FOUND_CITY role unit available");
1349 if (
is_ai(pplayer)) {
1360 " (%d, %d) and will %s to get there", result->
result,
1363 (result->
overseas ?
"use a boat" :
"walk")));
#define action_id_get_role(act_id)
void adv_init_choice(struct adv_choice *choice)
struct adv_data * adv_data_get(struct player *pplayer, bool *caller_closes)
bool adv_danger_at(struct unit *punit, struct tile *ptile)
int aiferry_find_boat(struct ai_type *ait, struct unit *punit, int cap, struct pf_path **path)
bool dai_is_ferry(struct unit *pferry, struct ai_type *ait)
void adv_unit_new_task(struct unit *punit, enum adv_unit_task task, struct tile *ptile)
bool auto_settler_setup_work(const struct civ_map *nmap, struct player *pplayer, struct unit *punit, struct settlermap *state, int recursion, struct pf_path *path, struct tile *best_tile, enum unit_activity best_act, struct extra_type **best_target, int completion_time)
struct city * settler_evaluate_city_requests(struct unit *punit, struct worker_task **best_task, struct pf_path **path, struct settlermap *state)
adv_want settler_evaluate_improvements(const struct civ_map *nmap, struct unit *punit, enum unit_activity *best_act, struct extra_type **best_target, struct tile **best_tile, struct pf_path **path, struct settlermap *state)
bool adv_settler_safe_tile(const struct civ_map *nmap, const struct player *pplayer, struct unit *punit, struct tile *ptile)
void city_choose_build_default(const struct civ_map *nmap, struct city *pcity)
int city_waste(const struct city *pcity, Output_type_id otype, int total, int *breakdown)
const char * city_name_get(const struct city *pcity)
void city_size_add(struct city *pcity, int add)
void citylog_map_data(enum log_level level, int radius_sq, int *map_data)
struct city * create_city_virtual(struct player *pplayer, struct tile *ptile, const char *name)
bool city_can_be_built_here(const struct civ_map *nmap, const struct tile *ptile, const struct unit *punit, bool hut_test)
int city_map_radius_sq_get(const struct city *pcity)
void destroy_city_virtual(struct city *pcity)
int city_tile_output(const struct city *pcity, const struct tile *ptile, bool is_celebrating, Output_type_id otype)
int city_map_tiles(int city_radius_sq)
#define city_tile(_pcity_)
#define city_tile_iterate_index(_nmap, _radius_sq, _city_tile, _tile, _index)
static citizens city_size_get(const struct city *pcity)
#define city_tile_iterate_index_end
#define city_owner(_pcity_)
#define city_map_iterate_end
#define city_map_iterate(_radius_sq, _index, _x, _y)
void citymap_reserve_tile(struct tile *ptile, int id)
bool citymap_is_reserved(struct tile *ptile)
int citymap_read(struct tile *ptile)
struct ai_plr * dai_plr_data_get(struct ai_type *ait, struct player *pplayer, bool *caller_closes)
void dai_data_phase_finished(struct ai_type *ait, struct player *pplayer)
#define TECH_LOG(ait, loglevel, pplayer, padvance, msg,...)
static struct ai_plr * def_ai_player_data(const struct player *pplayer, struct ai_type *deftype)
static struct ai_city * def_ai_city_data(const struct city *pcity, struct ai_type *deftype)
static struct unit_ai * def_ai_unit_data(const struct unit *punit, struct ai_type *deftype)
static adv_want result_defense_bonus(struct player *pplayer, const struct cityresult *result)
static void tdc_plr_set(struct ai_type *ait, struct player *plr, int tindex, const struct tile_data_cache *tdcache)
static struct cityresult * cityresult_new(struct tile *ptile)
static bool food_starvation(const struct cityresult *result)
static struct cityresult * cityresult_fill(struct ai_type *ait, struct player *pplayer, struct tile *center)
#define GROWTH_POTENTIAL_DEEMPHASIS
static void print_cityresult(struct player *pplayer, const struct cityresult *cr)
static adv_want naval_bonus(const struct cityresult *result)
void dai_auto_settler_init(struct ai_plr *ai)
struct tile_data_cache * tile_data_cache_copy(const struct tile_data_cache *ptdc)
void dai_auto_settler_cont(struct ai_type *ait, const struct civ_map *nmap, struct player *pplayer, struct unit *punit, struct settlermap *state)
static bool shield_starvation(const struct cityresult *result)
static struct cityresult * settler_map_iterate(struct ai_type *ait, struct pf_parameter *parameter, struct unit *punit, int boat_cost)
void dai_auto_settler_free(struct ai_plr *ai)
static enum cb_error_level dai_do_build_city(struct ai_type *ait, struct player *pplayer, struct unit *punit)
static void cityresult_destroy(struct cityresult *result)
void dai_auto_settler_reset(struct ai_type *ait, struct player *pplayer)
struct cityresult * city_desirability(struct ai_type *ait, struct player *pplayer, struct unit *punit, struct tile *ptile)
static const struct tile_data_cache * tdc_plr_get(struct ai_type *ait, struct player *plr, int tindex)
void contemplate_new_city(struct ai_type *ait, struct city *pcity)
static struct cityresult * find_best_city_placement(struct ai_type *ait, struct unit *punit, bool look_for_boat, bool use_virt_boat)
void dai_auto_settler_run(struct ai_type *ait, const struct civ_map *nmap, struct player *pplayer, struct unit *punit, struct settlermap *state)
static void tile_data_cache_destroy(struct tile_data_cache *ptdc)
struct tile_data_cache * tile_data_cache_new(void)
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
@ ANEK_CITY_TOO_CLOSE_TGT
signed short Continent_id
struct unit * game_unit_by_number(int id)
struct government * government_of_player(const struct player *pplayer)
bool has_handicap(const struct player *pplayer, enum handicap_type htype)
void initialize_infrastructure_cache(struct player *pplayer)
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define log_debug(message,...)
#define log_error(message,...)
bool same_pos(const struct tile *tile1, const struct tile *tile2)
#define square_iterate(nmap, center_tile, radius, tile_itr)
#define square_iterate_end
bool map_is_known(const struct tile *ptile, const struct player *pplayer)
bool upgrade_city_extras(struct city *pcity, struct extra_type **gained)
#define fc_calloc(n, esz)
const struct pf_position * pf_path_last_position(const struct pf_path *path)
void pf_path_destroy(struct pf_path *path)
struct pf_map * pf_map_new(const struct pf_parameter *parameter)
void pf_map_destroy(struct pf_map *pfm)
#define pf_map_move_costs_iterate_end
#define pf_map_move_costs_iterate(ARG_pfm, NAME_tile, NAME_cost, COND_from_start)
const char * player_name(const struct player *pplayer)
bool pplayers_in_peace(const struct player *pplayer, const struct player *pplayer2)
#define CITY_LOG(loglevel, pcity, msg,...)
#define UNIT_LOG(loglevel, punit, msg,...)
#define TIMING_LOG(timer, activity)
struct adv_data::@93 goal
struct adv_data::@93::@95 govt
struct ai_settler * settler
struct tile_data_cache_hash * tdc_hash
struct cityresult::@256 best_other
struct tile_data_cache * tdc
struct cityresult::@255 city_center
struct tile_data_cache_hash * tdc_hash
struct packet_game_info info
struct packet_scenario_info scenario
enum borders_mode borders
enum tile_behavior(* get_TB)(const struct tile *ptile, enum known_type known, const struct pf_parameter *param)
struct government * government
struct unit::@81::@84 server
Tech_type_id advance_index(const struct advance *padvance)
bool is_terrain_class_near_tile(const struct civ_map *nmap, const struct tile *ptile, enum terrain_class tclass)
void tile_virtual_destroy(struct tile *vtile)
void tile_set_owner(struct tile *ptile, struct player *pplayer, struct tile *claimer)
struct tile * tile_virtual_new(const struct tile *ptile)
const char * tile_get_info_text(const struct tile *ptile, bool include_nuisances, int linebreaks)
struct city * tile_city(const struct tile *ptile)
void tile_set_worked(struct tile *ptile, struct city *pcity)
#define tile_claimer(_tile)
#define tile_worked(_tile)
#define tile_terrain(_tile)
#define tile_continent(_tile)
#define tile_has_extra(ptile, pextra)
#define tile_owner(_tile)
void set_unit_activity(struct unit *punit, enum unit_activity new_activity)
bool unit_is_cityfounder(const struct unit *punit)
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
void unit_virtual_destroy(struct unit *punit)
void unit_tile_set(struct unit *punit, struct tile *ptile)
#define CHECK_UNIT(punit)
bool unit_activity_handling(struct unit *punit, enum unit_activity new_activity)
void unit_do_action(struct player *pplayer, const int actor_id, const int target_id, const int sub_tgt_id, const char *name, const action_id action_type)
enum ane_kind action_not_enabled_reason(struct unit *punit, action_id act_id, const struct tile *target_tile, const struct city *target_city, const struct unit *target_unit)
struct unit_type * best_role_unit(const struct city *pcity, int role)
struct unit_type * get_role_unit(int role, int role_index)
int unit_build_shield_cost_base(const struct unit *punit)
struct unit_type * best_role_unit_for_player(const struct player *pplayer, int role)
const char * utype_rule_name(const struct unit_type *punittype)
struct unit_class * unit_class_get(const struct unit *punit)
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
int unit_pop_value(const struct unit *punit)
#define unit_tech_reqs_iterate_end
#define unit_tech_reqs_iterate(_utype_, _p)