79 if (pcity == wonder_city || wonder_city ==
nullptr
105 if (VUT_UTYPE == acity->production.kind
123 "Non existence of wonder helper unit not caught");
135 want /=
MAX(dist, 1);
139 if (want > choice->
want) {
150 "would but could not build ACTION_HELP_WONDER unit, "
172 int unassigned_caravans;
175 bool dest_city_found =
false;
176 bool dest_city_nat_different_cont =
false;
177 bool dest_city_nat_same_cont =
false;
178 bool dest_city_in_different_cont =
false;
179 bool dest_city_in_same_cont =
false;
180 bool prefer_different_cont;
183 bool need_boat =
false;
185 if (city_list_size(pplayer->
cities) < 5) {
207 dest_city_found =
true;
209 dest_city_nat_different_cont =
true;
210 if (prefer_different_cont) {
214 dest_city_nat_same_cont =
true;
215 if (!prefer_different_cont) {
227 if (prefer_different_cont && !dest_city_nat_different_cont) {
233 if (aplayer == pplayer || !aplayer->
is_alive) {
240 dest_city_found =
true;
242 dest_city_in_different_cont =
true;
243 if (prefer_different_cont) {
247 dest_city_in_same_cont =
true;
248 if (!prefer_different_cont) {
256 if ((dest_city_in_different_cont && prefer_different_cont)
257 || (dest_city_in_same_cont && !prefer_different_cont)) {
264 if (!dest_city_found) {
307 unassigned_caravans = caravan_units - (max_routes - trade_routes);
308 trade_routes += caravan_units;
319 pcity,
nullptr, pplayer,
nullptr,
322 if (dest_city_nat_same_cont) {
325 if (dest_city_in_same_cont) {
328 pct =
MAX(pct, typepct);
330 if (dest_city_nat_different_cont) {
338 if (dest_city_in_different_cont) {
347 income = pct * income / 100;
370 if (trade_routes == 0 && max_routes > 0
374 want += trader_trait;
375 }
else if (trade_routes < max_routes
378 want += trader_trait / 4;
384 if (unassigned_caravans * 10 > want && want > 0.0) {
387 want -= unassigned_caravans * 10;
392 " (expected initial income %d)",
395 if (want > choice->
want) {
413 "would but could not build trade route unit, bumped reqs");
445 if (worker_type ==
nullptr || worker_type->
pop_cost > 0) {
452 if (worker_type !=
nullptr
455 if (worker_want > 0) {
460 UTYF_SETTLERS, worker_want,
false);
465 }
else if (worker_type ==
nullptr && worker_want > 0) {
480 if (founder_type ==
nullptr || founder_type->
pop_cost > 0) {
499 if (founder_want > choice->
want) {
508 }
else if (founder_want < -choice->
want) {
516 " and asks for a new boat (%d of %d free)",
520 choice->
want = 0 - founder_want;
528 L_FERRYBOAT, -founder_want,
true);
531 }
else if (!founder_type
532 && (founder_want > choice->
want
533 || founder_want < -choice->want)) {
567 if (choice->
want >= 200) {
596 if (wonder_city ==
nullptr) {
608 "Non existence of wonder helper unit not caught");
621 if (move_cost > maxrange) {
#define action_id_get_role(act_id)
void building_advisor_choose(struct city *pcity, struct adv_choice *choice)
Choose improvement we like most and put it into adv_choice.
struct adv_choice * adv_new_choice()
Dynamically allocate a new choice.
struct adv_choice * adv_better_choice_free(struct adv_choice *first, struct adv_choice *second)
Return better one of the choices given, and free the other.
#define adv_choice_set_use(_choice, _use)
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.
static struct ai_city * def_ai_city_data(const struct city *pcity, struct ai_type *deftype)
struct unit_type * dai_wants_role_unit(struct ai_type *ait, struct player *pplayer, struct city *pcity, int role, int want)
Returns the best unit we can build, or nullptr if none.
int ai_trait_get_value(enum trait tr, struct player *pplayer)
Get current value of player trait.
bool city_production_gets_caravan_shields(const struct universal *tgt)
Returns TRUE iff the specified production should get shields from units that has done ACTION_HELP_WON...
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
const char * city_name_get(const struct city *pcity)
Return the name of the city.
#define city_list_iterate(citylist, pcity)
#define city_list_iterate_end
void dai_wonder_city_distance(struct ai_type *ait, struct player *pplayer, struct adv_data *adv)
Calculate walking distances to wonder city from nearby cities.
static void dai_choose_trade_route(struct ai_type *ait, struct city *pcity, struct adv_choice *choice, struct adv_data *ai)
Evaluate the need for units (like caravans) that create trade routes.
struct adv_choice * domestic_advisor_choose_build(struct ai_type *ait, struct player *pplayer, struct city *pcity)
This function should fill the supplied choice structure.
static void dai_choose_help_wonder(struct ai_type *ait, struct city *pcity, struct adv_choice *choice, struct adv_data *ai)
Evaluate the need for units (like caravans) that aid wonder construction.
signed short Continent_id
struct city * game_city_by_number(int id)
Often used function to get a city pointer from a city ID.
bool has_handicap(const struct player *pplayer, enum handicap_type htype)
AI players may have handicaps - allowing them to cheat or preventing them from using certain algorith...
Impr_type_id improvement_index(const struct impr_type *pimprove)
Return the improvement index.
bool is_wonder(const struct impr_type *pimprove)
Returns whether improvement is some kind of wonder.
#define fc_assert_msg(condition, message,...)
#define fc_assert_ret(condition)
int unit_move_rate(const struct unit *punit)
This function calculates the move rate of the unit.
struct pf_map * pf_map_new(const struct pf_parameter *parameter)
Factory function to create a new map according to the parameter.
void pf_map_destroy(struct pf_map *pfm)
After usage the map must be destroyed.
#define pf_map_move_costs_iterate_end
#define pf_map_move_costs_iterate(ARG_pfm, NAME_tile, NAME_cost, COND_from_start)
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players are allied.
#define players_iterate_end
#define players_iterate(_pplayer)
#define CITY_LOG(_, pcity, msg,...)
int distance_to_wonder_city
struct unit_type * worker_type
struct ai_plr::@155 stats
struct universal production
struct city::@15::@17 server
struct unit_list * units_supported
struct packet_scenario_info scenario
struct city_list * cities
struct player_ai ai_common
struct player_economic economic
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
#define tile_continent(_tile)
bool can_cities_trade(const struct city *pc1, const struct city *pc2)
Return TRUE iff the two cities are capable of trade; i.e., if a caravan from one city can enter the o...
int trade_route_type_trade_pct(enum trade_route_type type)
Return percentage bonus for trade route type.
int max_trade_routes(const struct city *pcity)
Return current maximum number of trade routes city can have.
int city_num_trade_routes(const struct city *pcity)
Return number of trade route city has.
int get_caravan_enter_city_trade_bonus(const struct city *pc1, const struct city *pc2, const player *seen_as, struct goods_type *pgood, const bool establish_trade)
Returns the revenue trade bonus - you get this when establishing a trade route and also when you simp...
#define TRAIT_DEFAULT_VALUE
const struct unit_type * utype
const struct impr_type * building
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Return TRUE iff this unit can do the specified generalized (ruleset defined) action enabler controlle...
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
struct unit_type * best_role_unit(const struct city *pcity, int role)
Return "best" unit this city can build, with given role/flag.
int utype_upkeep_cost(const struct unit_type *ut, struct player *pplayer, Output_type_id otype)
Returns the upkeep of a unit of this type under the given government.
const char * utype_rule_name(const struct unit_type *punittype)
Return the (untranslated) rule name of the unit type.
struct unit_type * best_role_unit_for_player(const struct player *pplayer, int role)
Return "best" unit the player can build, with given role/flag.
int utype_build_shield_cost(const struct city *pcity, const struct unit_type *punittype)
Returns the number of shields it takes to build this unit type.
int utype_build_shield_cost_base(const struct unit_type *punittype)
Returns the number of shields this unit type represents.
int num_role_units(int role)
How many unit types have specified role/flag.
struct unit_type * get_role_unit(int role, int role_index)
Return index-th unit with specified role/flag.
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Return TRUE iff units of the given type can do the specified generalized (ruleset defined) action ena...