70#define WORKER_FACTOR 1024
135#define MAX_DEP_ROADS 5
139 int dx[12] = {-1, 0, 1, -1, 1, -1, 0, 1, 0, -2, 2, 0};
140 int dy[12] = {-1, -1, -1, 0, 0, 1, 1, 1, -2, 0, 0, 2};
163 for (
i = 0;
i < 12;
i++) {
183 is_slow[
i] = (build_time == 0 || build_time > 5);
216 for (
i = 0;
i < 12;
i++) {
517 if ((enroute && enroute->
id ==
punit->
id)
525 "Considering (%d, %d) because we're closer "
526 "(%d, %d) than %d (%d, %d)",
566 if (
pos.moves_left == 0) {
573 target, 0.0, base_value,
640 if (base_value >= 0) {
646 if (
pos.moves_left == 0) {
677 if (
proad->move_cost == 0) {
878 int value = (
ptask->want + 1) * 10 / (
pos.turn + 1);
891 && ((enroute && enroute->
id ==
punit->
id)
921#define LOG_SETTLER LOG_DEBUG
943 log_warn(
"Workers displacing each other recursing too much.");
1044 "%d (%d,%d) has displaced %d (%d,%d) for worksite %d,%d",
1075 "%d itself acted due to displacement recursion. "
1076 "Was going from (%d, %d) to (%d, %d). "
1077 "Now heading from (%d, %d) to (%d, %d).",
1086 "is heading to do %s(%s) at (%d, %d)",
1115 "reached its worksite and started work");
1119 "didn't start work yet; got to (%d, %d) with "
1125 "does not find path (%d, %d) -> (%d, %d)",
1176 if (
is_ai(pplayer)) {
1200 log_debug(
"Warmth = %d, game.globalwarming=%d",
1202 log_debug(
"Frost = %d, game.nuclearwinter=%d",
1215 log_debug(
"%s %s at (%d, %d) is controlled by server side agent %s.",
1227 if (!
is_ai(pplayer)) {
1237 if (!
is_ai(pplayer)) {
1246 if (
is_ai(pplayer)) {
1253 log_verbose(
"%s autosettlers consumed %g milliseconds.",
1290 const struct tile *ptile)
1341 log_debug(
"No action found for activity %d", activity);
struct act_prob action_speculate_unit_on_extras(const struct civ_map *nmap, action_id act_id, const struct unit *actor, const struct city *actor_home, const struct tile *actor_tile, bool omniscient_cheat, const struct tile *target_tile, const struct extra_type *target_extra)
enum action_actor_kind action_get_actor_kind(const struct action *paction)
bool action_prob_possible(const struct act_prob probability)
struct act_prob action_speculate_unit_on_stack(const struct civ_map *nmap, action_id act_id, const struct unit *actor, const struct city *actor_home, const struct tile *actor_tile, bool omniscient_cheat, const struct tile *target)
struct act_prob action_speculate_unit_on_self(const struct civ_map *nmap, action_id act_id, const struct unit *actor, const struct city *actor_home, const struct tile *actor_tile, bool omniscient_cheat)
void action_array_add_all_by_result(action_id *act_array, int *position, enum action_result result)
void action_array_end(action_id *act_array, int size)
struct act_prob action_speculate_unit_on_city(const struct civ_map *nmap, const action_id act_id, const struct unit *actor, const struct city *actor_home, const struct tile *actor_tile, const bool omniscient_cheat, const struct city *target)
struct act_prob action_speculate_unit_on_tile(const struct civ_map *nmap, action_id act_id, const struct unit *actor, const struct city *actor_home, const struct tile *actor_tile, bool omniscient_cheat, const struct tile *target_tile, const struct extra_type *target_extra)
enum action_target_kind action_get_target_kind(const struct action *paction)
#define action_by_activity_iterate(_paction_, _activity_)
static struct action * action_by_number(action_id act_id)
#define action_by_activity_iterate_end
#define action_get_activity(_pact_)
#define action_id_get_activity(act_id)
bool adv_follow_path(struct unit *punit, struct pf_path *path, struct tile *ptile)
#define CALL_PLR_AI_FUNC(_func, _player,...)
static void consider_settler_action(const struct player *pplayer, enum unit_activity act, struct extra_type *target, adv_want extra, adv_want new_tile_value, adv_want old_tile_value, bool in_use, int delay, adv_want *best_value, adv_want *best_old_tile_value, int *best_extra, bool *improve_worked, int *best_delay, enum unit_activity *best_act, struct extra_type **best_target, struct tile **best_tile, struct tile *ptile)
action_id as_actions_rmextra[MAX_NUM_ACTIONS]
void adv_unit_new_task(struct unit *punit, enum adv_unit_task task, struct tile *ptile)
action_id as_actions_transform[MAX_NUM_ACTIONS]
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)
void auto_settlers_ruleset_init(void)
static enum tile_behavior autosettler_tile_behavior(const struct tile *ptile, enum known_type known, const struct pf_parameter *param)
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)
void auto_settlers_player(struct player *pplayer)
action_id as_actions_extra[MAX_NUM_ACTIONS]
adv_want adv_settlers_road_bonus(const struct civ_map *nmap, struct tile *ptile, struct road_type *proad)
bool adv_settler_safe_tile(const struct civ_map *nmap, const struct player *pplayer, struct unit *punit, struct tile *ptile)
void adv_settlers_free(void)
static struct timer * as_timer
bool auto_settlers_speculate_can_act_at(const struct unit *punit, enum unit_activity activity, bool omniscient_cheat, struct extra_type *target, const struct tile *ptile)
void auto_settler_findwork(const struct civ_map *nmap, struct player *pplayer, struct unit *punit, struct settlermap *state, int recursion)
#define as_transform_action_iterate_end
#define as_rmextra_action_iterate(_act_)
#define as_rmextra_action_iterate_end
#define as_extra_action_iterate_end
#define as_extra_action_iterate(_act_)
#define as_transform_action_iterate(_act_)
int city_map_radius_sq_get(const struct city *pcity)
bool city_can_work_tile(const struct city *pcity, const struct tile *ptile)
#define city_list_iterate(citylist, pcity)
#define city_tile(_pcity_)
#define city_tile_iterate_index(_nmap, _radius_sq, _city_tile, _tile, _index)
#define city_tile_iterate_index_end
#define city_list_iterate_end
void citymap_turn_init(struct player *pplayer)
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
bool has_handicap(const struct player *pplayer, enum handicap_type htype)
adv_want adv_city_worker_act_get(const struct city *pcity, int city_tile_index, enum unit_activity act_id)
int adv_city_worker_extra_get(const struct city *pcity, int city_tile_index, const struct extra_type *pextra)
void initialize_infrastructure_cache(struct player *pplayer)
int adv_city_worker_rmextra_get(const struct city *pcity, int city_tile_index, const struct extra_type *pextra)
adv_want city_tile_value(const struct city *pcity, const struct tile *ptile, int foodneed, int prodneed)
#define fc_assert_ret(condition)
#define log_warn(message,...)
#define log_verbose(message,...)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define log_debug(message,...)
struct tile * map_pos_to_tile(const struct civ_map *nmap, int map_x, int map_y)
bool same_pos(const struct tile *tile1, const struct tile *tile2)
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
struct terrain_misc terrain_control
#define current_topo_has_flag(flag)
#define whole_map_iterate(_map, _tile)
#define whole_map_iterate_end
#define index_to_map_pos(pmap_x, pmap_y, mindex)
#define fc_calloc(n, esz)
const char * nation_rule_name(const struct nation_type *pnation)
struct nation_type * nation_of_player(const struct player *pplayer)
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)
struct pf_path * pf_map_path(struct pf_map *pfm, struct tile *ptile)
bool pf_map_position(struct pf_map *pfm, struct tile *ptile, struct pf_position *pos)
void pf_map_destroy(struct pf_map *pfm)
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
struct extra_type * road_extra_get(const struct road_type *proad)
Road_type_id road_number(const struct road_type *proad)
bool road_provides_move_bonus(const struct road_type *proad)
#define road_deps_iterate(_reqs, _dep)
#define road_deps_iterate_end
static int recursion[AIT_LAST]
#define UNIT_LOG(loglevel, punit, msg,...)
#define TIMING_LOG(timer, activity)
struct packet_game_info info
enum tile_behavior(* get_TB)(const struct tile *ptile, enum known_type known, const struct pf_parameter *param)
const struct player * owner
struct city_list * cities
struct player_ai ai_common
enum unit_activity activity
struct unit::@81::@84 server
struct extra_type * activity_target
enum server_side_agent ssa_controller
int terrain_extra_build_time(const struct terrain *pterrain, enum unit_activity activity, const struct extra_type *tgt)
bool tile_has_road(const struct tile *ptile, const struct road_type *proad)
struct city * tile_city(const struct tile *ptile)
#define tile_worked(_tile)
#define tile_terrain(_tile)
#define tile_has_extra(ptile, pextra)
#define tile_owner(_tile)
bool timer_in_use(struct timer *t)
void timer_destroy(struct timer *t)
void timer_start(struct timer *t)
double timer_read_seconds(struct timer *t)
struct timer * timer_renew(struct timer *t, enum timer_timetype type, enum timer_use use, const char *name)
static int best_value(const void *a, const void *b)
int get_turns_for_activity_at(const struct unit *punit, enum unit_activity activity, const struct tile *ptile, struct extra_type *tgt)
void set_unit_activity(struct unit *punit, enum unit_activity new_activity)
bool unit_is_cityfounder(const struct unit *punit)
const char * get_activity_text(enum unit_activity activity)
bool is_square_threatened(const struct civ_map *nmap, const struct player *pplayer, const struct tile *ptile, bool omniscient)
bool is_guard_unit(const struct unit *punit)
bool unit_has_orders(const struct unit *punit)
bool activity_requires_target(enum unit_activity activity)
#define CHECK_UNIT(punit)
bool unit_activity_handling(struct unit *punit, enum unit_activity new_activity)
bool unit_activity_handling_targeted(struct unit *punit, enum unit_activity new_activity, struct extra_type **new_target)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_safe(unitlist, _unit)
#define unit_list_iterate_end
#define unit_list_iterate_safe_end
const struct unit_type * unit_type_get(const struct unit *punit)
const char * unit_rule_name(const struct unit *punit)
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
#define worker_task_list_iterate(tasklist, ptask)
#define worker_task_list_iterate_end