14 #include <fc_config.h>
113 twant -= 20 * ptype->pop_cost;
114 twant -= ptype->build_cost;
128 twant =
MAX(twant, 0);
130 if (twant > maxwant) {
155 int cindex,
struct unit_list *units,
struct worker_task *worked,
160 bool potential_worst_worked =
false;
168 if (
tile_worked(ptile) == pcity && orig_value < state->worst_worked) {
171 potential_worst_worked =
true;
176 bool consider =
true;
177 bool possible =
false;
178 enum extra_cause cause;
179 enum extra_rmcause rmcause;
210 act, punit,
unit_home(punit), ptile,
true, ptile, tgt))) {
222 if ((value - orig_value) *
TWMP > worked->
want) {
223 worked->
want =
TWMP * (value - orig_value);
224 worked->
ptile = ptile;
231 act, punit,
unit_home(punit), ptile,
true, ptile,
242 potential_worst_worked =
false;
247 if (value > orig_value && value > state->
uw_max) {
250 unworked->
want =
TWMP * (value - orig_value);
251 unworked->
ptile = ptile;
253 unworked->
tgt = NULL;
258 act, punit,
unit_home(punit), ptile,
true, ptile,
274 struct action *paction = NULL;
285 try_act, punit,
unit_home(punit), ptile,
true, ptile,
298 try_act, punit,
unit_home(punit), ptile,
true, ptile,
309 if (paction != NULL) {
313 bool consider =
true;
342 int mc_multiplier = 1;
371 mc_multiplier += old_move_cost;
385 value = base_value + extra;
388 if ((value - orig_value) *
TWMP > worked->
want) {
389 worked->
want =
TWMP * (value - orig_value);
390 worked->
ptile = ptile;
410 potential_worst_worked =
false;
415 if (value > orig_value && value > state->
uw_max) {
418 unworked->
want =
TWMP * (value - orig_value);
419 unworked->
ptile = ptile;
442 if (potential_worst_worked) {
458 .
ptile = NULL, .want = 0, .act = ACTIVITY_IDLE, .tgt = NULL};
460 .
ptile = NULL, .want = 0, .act = ACTIVITY_IDLE, .tgt = NULL};
464 .orig_worst_worked = 0,
466 struct unit_list *units = NULL;
474 units = unit_list_new();
478 unit_list_append(units,
491 &worked, &unworked, &state, limit);
495 if (worked.
ptile == NULL
503 selected = &unworked;
511 unit_list_destroy(units);
514 if (selected->
ptile != NULL) {
517 if (selected->
tgt == NULL) {
523 enum extra_rmcause rmcause =
532 target = selected->
tgt;
536 task->
act = selected->
act;
559 struct worker_task *ptask = worker_task_list_get(pcity->task_reqs, 0);
564 worker_task_list_append(pcity->task_reqs, ptask);
567 log_debug(
"%s storing req for act %d at (%d,%d)", pcity->name,
602 if (city_data != NULL) {
bool action_prob_possible(const struct act_prob probability)
Returns TRUE iff the given action probability belongs to an action that may be possible.
struct action * action_by_number(action_id act_id)
Return the action with the given id.
enum unit_activity action_get_activity(const struct action *paction)
Returns the unit activity this action may cause or ACTIVITY_LAST if the action doesn't result in a un...
enum action_target_kind action_get_target_kind(const struct action *paction)
Get the target kind of an action.
struct act_prob action_speculate_unit_on_tile(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)
Returns a speculation about the actor unit's probability of successfully performing the chosen action...
#define action_id_get_activity(act_id)
void adv_deinit_choice(struct adv_choice *choice)
Clear choice without freeing it itself.
void adv_init_choice(struct adv_choice *choice)
Sets the values of the choice to initial values.
struct adv_data * adv_data_get(struct player *pplayer, bool *caller_closes)
Return a pointer to our data.
struct ai_plr * dai_plr_data_get(struct ai_type *ait, struct player *pplayer, bool *caller_closes)
Get current default ai data related to player.
adv_want adv_settlers_road_bonus(struct tile *ptile, struct road_type *proad)
Calculate the attractiveness of building a road/rail at the given tile.
#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)
Attach ai data to city.
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
int city_map_radius_sq_get(const struct city *pcity)
Returns the current squared radius of the city.
bool city_can_work_tile(const struct city *pcity, const struct tile *ptile)
Returns TRUE when a tile is available to be worked, or the city itself is currently working the tile ...
bool can_city_build_unit_now(const struct city *pcity, const struct unit_type *punittype)
Return whether given city can build given unit; returns FALSE if unit is obsolete.
#define city_tile_iterate_end
#define city_tile_iterate_index(_radius_sq, _city_tile, _tile, _index)
#define BUILDING_WAIT_MINIMUM
signed short Continent_id
struct city * game_city_by_number(int id)
Often used function to get a city pointer from a city ID.
int adv_city_worker_act_get(const struct city *pcity, int city_tile_index, enum unit_activity act_id)
Return the value for activity 'doing' on tile 'city_tile_index' of city 'pcity'.
int adv_city_worker_extra_get(const struct city *pcity, int city_tile_index, const struct extra_type *pextra)
Return the value for extra on tile 'city_tile_index' of city 'pcity'.
int adv_city_worker_rmextra_get(const struct city *pcity, int city_tile_index, const struct extra_type *pextra)
Return the value for extra removal on tile 'city_tile_index' of city 'pcity'.
int city_tile_value(const struct city *pcity, const struct tile *ptile, int foodneed, int prodneed)
Returns a measure of goodness of a tile to pcity.
#define fc_assert_action(condition, action)
#define log_debug(message,...)
struct terrain_misc terrain_control
bool road_provides_move_bonus(const struct road_type *proad)
Does road type provide move bonus.
struct adv_data::@87 stats
struct unit_type * worker_type
struct ai_plr::@155 stats
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)
Select worker task suitable for the tile.
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)
Select worker task suitable for the city.
void texai_city_alloc(struct ai_type *ait, struct city *pcity)
Initialize city for use with tex AI.
void texai_city_free(struct ai_type *ait, struct city *pcity)
Free city from use with tex AI.
void texai_city_worker_requests_create(struct ai_type *ait, struct player *pplayer, struct city *pcity)
Create worker request for the city.
void texai_city_worker_wants(struct ai_type *ait, struct player *pplayer, struct city *pcity)
Set wants for worker-type units.
void texai_req_worker_task_rcv(struct texai_req *req)
Receive message from thread to main thread.
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)
Construct and send request from player thread.
struct unit_list * texai_player_units(struct player *pplayer)
Callback that returns unit list from player tex ai data.
#define tile_worked(_tile)
#define tile_terrain(_tile)
#define tile_continent(_tile)
#define tile_has_extra(ptile, pextra)
void unit_virtual_destroy(struct unit *punit)
Free the memory used by virtual unit.
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Create a virtual unit skeleton.
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Return whether the unit has the given flag.
Unit_type_id utype_index(const struct unit_type *punittype)
Return the unit type index.
#define unit_type_iterate(_p)
#define unit_type_iterate_end
void worker_task_init(struct worker_task *ptask)
Initialize empty worker_task.