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++) {
518 if ((enroute && enroute->
id ==
punit->
id)
526 "Considering (%d, %d) because we're closer "
527 "(%d, %d) than %d (%d, %d)",
567 if (
pos.moves_left == 0) {
574 target, 0.0, base_value,
641 if (base_value >= 0) {
647 if (
pos.moves_left == 0) {
678 if (
proad->move_cost == 0) {
814 log_debug(
"Worker %d@(%d,%d) wants to %s at (%d,%d) with desire "
884 int value = (
ptask->want + 1) * 10 / (
pos.turn + 1);
897 && ((enroute && enroute->
id ==
punit->
id)
927#define LOG_WORKER LOG_DEBUG
949 log_warn(
"Workers displacing each other recursing too much.");
1050 "%d (%d,%d) has displaced %d (%d,%d) for worksite %d,%d",
1081 "%d itself acted due to displacement recursion. "
1082 "Was going from (%d, %d) to (%d, %d). "
1083 "Now heading from (%d, %d) to (%d, %d).",
1092 "is heading to do %s(%s) at (%d, %d)",
1124 "reached its worksite and started work");
1128 "didn't start work yet; got to (%d, %d) with "
1134 "does not find path (%d, %d) -> (%d, %d)",
1185 if (
is_ai(pplayer)) {
1209 log_debug(
"Warmth = %d, game.globalwarming=%d",
1211 log_debug(
"Frost = %d, game.nuclearwinter=%d",
1224 log_debug(
"%s %s at (%d, %d) is controlled by server side agent %s.",
1236 if (!
is_ai(pplayer)) {
1246 if (!
is_ai(pplayer)) {
1255 if (
is_ai(pplayer)) {
1262 log_verbose(
"%s autoworkers consumed %g milliseconds.",
1299 const struct tile *ptile)
1350 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,...)
void adv_unit_new_task(struct unit *punit, enum adv_unit_task task, struct tile *ptile)
static void consider_worker_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)
static enum tile_behavior autoworker_tile_behavior(const struct tile *ptile, enum known_type known, const struct pf_parameter *param)
void auto_worker_findwork(const struct civ_map *nmap, struct player *pplayer, struct unit *punit, struct workermap *state, int recursion)
bool adv_worker_safe_tile(const struct civ_map *nmap, const struct player *pplayer, struct unit *punit, struct tile *ptile)
static struct timer * aw_timer
void adv_workers_free(void)
action_id aw_actions_rmextra[MAX_NUM_ACTIONS]
adv_want adv_workers_road_bonus(const struct civ_map *nmap, struct tile *ptile, struct road_type *proad)
bool auto_workers_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_workers_player(struct player *pplayer)
struct city * worker_evaluate_city_requests(struct unit *punit, struct worker_task **best_task, struct pf_path **path, struct workermap *state)
bool auto_worker_setup_work(const struct civ_map *nmap, struct player *pplayer, struct unit *punit, struct workermap *state, int recursion, struct pf_path *path, struct tile *best_tile, enum unit_activity best_act, struct extra_type **best_target, int completion_time)
action_id aw_actions_extra[MAX_NUM_ACTIONS]
action_id aw_actions_transform[MAX_NUM_ACTIONS]
adv_want worker_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 workermap *state)
void auto_workers_ruleset_init(void)
#define aw_extra_action_iterate(_act_)
#define aw_transform_action_iterate(_act_)
#define aw_rmextra_action_iterate_end
#define aw_extra_action_iterate_end
#define aw_transform_action_iterate_end
#define aw_rmextra_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
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 const struct action *paction struct unit struct city * pcity
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::@84::@87 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)
bool unit_is_cityfounder(const struct unit *punit)
enum gen_action activity_default_action(enum unit_activity act)
const char * get_activity_text(enum unit_activity activity)
void set_unit_activity(struct unit *punit, enum unit_activity new_activity, enum gen_action trigger_action)
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_targeted(struct unit *punit, enum unit_activity new_activity, struct extra_type **new_target, enum gen_action trigger_action)
bool unit_activity_handling(struct unit *punit, enum unit_activity new_activity, enum gen_action trigger_action)
#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