114 twant -= 20 * ptype->pop_cost;
115 twant -= ptype->build_cost;
128 twant =
MAX(twant, 0);
130 if (twant > maxwant) {
154 struct city *pcity,
struct tile *ptile,
155 int cindex,
struct unit_list *units,
162 bool potential_worst_worked =
FALSE;
172 && orig_value < state->worst_worked) {
175 potential_worst_worked =
TRUE;
179 bool consider =
TRUE;
180 bool possible =
FALSE;
181 enum extra_cause cause;
182 enum extra_rmcause rmcause;
224 if ((value - orig_value) *
TWMP > worked->
want) {
225 worked->
want =
TWMP * (value - orig_value);
226 worked->
ptile = ptile;
244 potential_worst_worked =
FALSE;
249 if (value > orig_value && value > state->
uw_max) {
252 unworked->
want =
TWMP * (value - orig_value);
253 unworked->
ptile = ptile;
255 unworked->
tgt = NULL;
274 struct action *paction = NULL;
309 if (paction != NULL) {
313 bool consider =
TRUE;
340 int mc_multiplier = 1;
367 mc_multiplier += old_move_cost;
372 * mc_multiplier / mc_divisor;
381 value = base_value + extra;
384 if ((value - orig_value) *
TWMP > worked->
want) {
385 worked->
want =
TWMP * (value - orig_value);
386 worked->
ptile = ptile;
405 potential_worst_worked =
FALSE;
410 if (value > orig_value && value > state->
uw_max) {
413 unworked->
want =
TWMP * (value - orig_value);
414 unworked->
ptile = ptile;
435 if (potential_worst_worked) {
450 struct worker_task worked = { .
ptile = NULL, .want = 0, .act = ACTIVITY_IDLE, .tgt = NULL };
451 struct worker_task unworked = { .
ptile = NULL, .want = 0, .act = ACTIVITY_IDLE, .tgt = NULL };
453 .orig_worst_worked = 0, .old_worst_worked =
FC_INFINITY };
454 struct unit_list *units = NULL;
463 units = unit_list_new();
476 &worked, &unworked, &state, limit);
479 if (worked.
ptile == NULL
486 selected = &unworked;
495 unit_list_destroy(units);
498 if (selected->
ptile != NULL) {
501 if (selected->
tgt == NULL) {
514 target = selected->
tgt;
518 task->
act = selected->
act;
545 worker_task_list_append(pcity->
task_reqs, ptask);
548 log_debug(
"%s storing req for act %d at (%d,%d)",
582 if (city_data != NULL) {
bool action_prob_possible(const struct act_prob probability)
enum unit_activity actres_get_activity(enum action_result result)
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)
static struct action * action_by_number(action_id act_id)
#define action_id_get_activity(act_id)
void adv_deinit_choice(struct adv_choice *choice)
void adv_init_choice(struct adv_choice *choice)
struct adv_data * adv_data_get(struct player *pplayer, bool *caller_closes)
struct ai_plr * dai_plr_data_get(struct ai_type *ait, struct player *pplayer, bool *caller_closes)
adv_want adv_settlers_road_bonus(const struct civ_map *nmap, struct tile *ptile, struct road_type *proad)
#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_)
void city_set_ai_data(struct city *pcity, const struct ai_type *ai, void *data)
int city_map_radius_sq_get(const struct city *pcity)
bool can_city_build_unit_now(const struct civ_map *nmap, const struct city *pcity, const struct unit_type *punittype)
bool city_can_work_tile(const struct city *pcity, const struct tile *ptile)
#define city_tile(_pcity_)
#define city_tile_iterate_index(_nmap, _radius_sq, _city_tile, _tile, _index)
#define city_owner(_pcity_)
#define city_tile_iterate_end
#define BUILDING_WAIT_MINIMUM
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
signed short Continent_id
struct city * game_city_by_number(int id)
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)
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_action(condition, action)
#define log_debug(message,...)
struct terrain_misc terrain_control
#define fc_calloc(n, esz)
bool road_provides_move_bonus(const struct road_type *proad)
enum action_result result
struct adv_data::@92 stats
struct unit_type * worker_type
struct ai_plr::@267 stats
struct worker_task_list * task_reqs
enum unit_activity activity
texai_worker_task_limitation
static void texai_tile_worker_task_select(struct player *pplayer, struct city *pcity, struct tile *ptile, int cindex, struct unit_list *units, struct worker_task *worked, struct worker_task *unworked, struct texai_tile_state *state, enum texai_worker_task_limitation limit)
static bool texai_city_worker_task_select(struct ai_type *ait, struct player *pplayer, struct city *pcity, struct worker_task *task, enum texai_worker_task_limitation limit)
void texai_city_alloc(struct ai_type *ait, struct city *pcity)
void texai_city_free(struct ai_type *ait, struct city *pcity)
void texai_city_worker_requests_create(struct ai_type *ait, struct player *pplayer, struct city *pcity)
void texai_city_worker_wants(struct ai_type *ait, struct player *pplayer, struct city *pcity)
void texai_req_worker_task_rcv(struct texai_req *req)
static struct texai_city * texai_city_data(struct ai_type *ait, const struct city *pcity)
void texai_send_req(enum texaireqtype type, struct player *pplayer, void *data)
struct unit_list * texai_player_units(struct player *pplayer)
#define tile_worked(_tile)
#define tile_terrain(_tile)
#define tile_continent(_tile)
#define tile_has_extra(ptile, pextra)
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)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const struct unit_type * unit_type_get(const struct unit *punit)
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Unit_type_id utype_index(const struct unit_type *punittype)
#define unit_type_iterate(_p)
#define unit_type_iterate_end
void worker_task_init(struct worker_task *ptask)