94 if (pcity == wonder_city
95 || wonder_city == NULL
117 if (VUT_UTYPE == acity->production.kind
134 "Non existence of wonder helper unit not caught");
146 want /=
MAX(dist, 1);
151 if (want > choice->
want) {
163 "would but could not build ACTION_HELP_WONDER unit, "
185 int unassigned_caravans;
188 bool dest_city_found =
FALSE;
189 bool dest_city_nat_different_cont =
FALSE;
190 bool dest_city_nat_same_cont =
FALSE;
191 bool dest_city_in_different_cont =
FALSE;
192 bool dest_city_in_same_cont =
FALSE;
193 bool prefer_different_cont;
196 bool can_move_ic =
FALSE, has_boats =
TRUE;
197 bool need_boat =
FALSE;
200 if (city_list_size(pplayer->
cities) < 5) {
238 "Non-existence of trade unit not caught");
250 && (can_move_ic || has_boats)) {
251 prefer_different_cont =
TRUE;
253 prefer_different_cont =
FALSE;
263 if (!(can_move_ic || has_boats)) {
267 dest_city_found =
TRUE;
268 dest_city_nat_different_cont =
TRUE;
269 if (prefer_different_cont) {
273 dest_city_found =
TRUE;
274 dest_city_nat_same_cont =
TRUE;
275 if (!prefer_different_cont) {
286 if (prefer_different_cont && !dest_city_nat_different_cont) {
289 prefer_different_cont =
TRUE;
291 prefer_different_cont =
FALSE;
295 if (aplayer == pplayer || !aplayer->
is_alive) {
302 if (!(can_move_ic || has_boats)) {
306 dest_city_found =
TRUE;
307 dest_city_in_different_cont =
TRUE;
308 if (prefer_different_cont) {
312 dest_city_found =
TRUE;
313 dest_city_in_same_cont =
TRUE;
314 if (!prefer_different_cont) {
321 if ((dest_city_in_different_cont && prefer_different_cont)
322 || (dest_city_in_same_cont && !prefer_different_cont)) {
328 if (!dest_city_found) {
343 unassigned_caravans = caravan_units - (max_routes - trade_routes);
344 trade_routes += caravan_units;
370 ACTION_TRADE_ROUTE : ACTION_MARKETPLACE;
380 EFT_TRADE_REVENUE_BONUS);
383 income = ceil((
float)income * pow(2.0, (
double)bonus / 1000.0));
385 if (dest_city_nat_same_cont) {
388 if (dest_city_in_same_cont) {
391 pct =
MAX(pct, typepct);
393 if (dest_city_nat_different_cont) {
401 if (dest_city_in_different_cont) {
410 need_boat = need_boat && !can_move_ic;
411 income = pct * income / 100;
434 if (trade_routes == 0 && max_routes > 0
437 want += trader_trait;
438 }
else if (trade_routes < max_routes
441 want += trader_trait / 4;
447 if (unassigned_caravans * 10 > want && want > 0.0) {
450 want -= unassigned_caravans * 10;
454 "want for trade route unit is " ADV_WANT_PRINTF " (expected initial income %d)",
458 if (want > choice->
want) {
473 if (
unit_type != NULL && (!need_boat || has_boats)) {
480 "would but could not build trade route unit, bumped reqs");
512 if (worker_type == NULL || worker_type->
pop_cost > 0) {
519 if (worker_type != NULL
522 if (worker_want > 0) {
527 UTYF_SETTLERS, worker_want,
FALSE);
532 }
else if (worker_type == NULL && worker_want > 0) {
547 if (founder_type == NULL || founder_type->
pop_cost > 0) {
566 if (founder_want > choice->
want) {
576 }
else if (founder_want < -choice->
want) {
584 " and asks for a new boat (%d of %d free)",
588 choice->
want = 0 - founder_want;
596 L_FERRYBOAT, -founder_want,
TRUE);
599 }
else if (!founder_type
600 && (founder_want > choice->
want || founder_want < -choice->want)) {
660 if (wonder_city == NULL) {
672 "Non existence of wonder helper unit not caught");
684 if (move_cost > maxrange) {
static struct action * action_by_number(action_id act_id)
#define action_id_get_role(act_id)
void building_advisor_choose(struct city *pcity, struct adv_choice *choice)
struct adv_choice * adv_better_choice_free(struct adv_choice *first, struct adv_choice *second)
struct adv_choice * adv_new_choice(void)
#define adv_choice_set_use(_choice, _use)
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)
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)
int ai_trait_get_value(enum trait tr, struct player *pplayer)
bool city_production_gets_caravan_shields(const struct universal *tgt)
const char * city_name_get(const struct city *pcity)
#define city_list_iterate(citylist, pcity)
#define city_tile(_pcity_)
#define city_owner(_pcity_)
#define city_list_iterate_end
void dai_wonder_city_distance(struct ai_type *ait, struct player *pplayer, struct adv_data *adv)
struct adv_choice * domestic_advisor_choose_build(struct ai_type *ait, struct player *pplayer, struct city *pcity)
static void dai_choose_trade_route(struct ai_type *ait, struct city *pcity, struct adv_choice *choice, struct adv_data *ai)
static void dai_choose_help_wonder(struct ai_type *ait, struct city *pcity, struct adv_choice *choice, struct adv_data *ai)
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
int get_target_bonus_effects(struct effect_list *plist, const struct req_context *context, const struct player *other_player, enum effect_type effect_type)
signed short Continent_id
struct city * game_city_by_number(int id)
bool has_handicap(const struct player *pplayer, enum handicap_type htype)
Impr_type_id improvement_index(const struct impr_type *pimprove)
bool is_wonder(const struct impr_type *pimprove)
#define fc_assert_msg(condition, message,...)
#define fc_assert_ret(condition)
int unit_move_rate(const struct unit *punit)
struct pf_map * pf_map_new(const struct pf_parameter *parameter)
void pf_map_destroy(struct pf_map *pfm)
#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)
#define players_iterate_end
#define players_iterate(_pplayer)
#define CITY_LOG(loglevel, pcity, msg,...)
adv_want building_want[B_LAST]
int distance_to_wonder_city
struct unit_type * worker_type
struct ai_plr::@267 stats
struct universal production
struct city::@17::@19 server
struct unit_list * units_supported
struct packet_game_info info
struct packet_scenario_info scenario
enum caravan_bonus_style caravan_bonus_style
struct city_list * cities
struct player_ai ai_common
struct player_economic economic
struct unit_class::@84 adv
struct city * tile_city(const struct tile *ptile)
#define tile_continent(_tile)
int max_trade_prod(const struct city *pcity)
bool can_cities_trade(const struct city *pc1, const struct city *pc2)
int trade_route_type_trade_pct(enum trade_route_type type)
int city_num_trade_routes(const struct city *pcity)
unsigned max_trade_routes(const struct city *pcity)
#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)
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
struct unit_type * best_role_unit(const struct city *pcity, int role)
int utype_upkeep_cost(const struct unit_type *ut, struct player *pplayer, Output_type_id otype)
struct unit_type * get_role_unit(int role, int role_index)
int utype_build_shield_cost_base(const struct unit_type *punittype)
int num_role_units(int role)
struct unit_type * best_role_unit_for_player(const struct player *pplayer, int role)
const char * utype_rule_name(const struct unit_type *punittype)
int utype_build_shield_cost(const struct city *pcity, const struct player *pplayer, const struct unit_type *punittype)
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)