54 const struct unit *caravan)
106 return "anything but enemies";
123 " objective = <%s,%s,%s>\n"
124 " account-broken = %s\n"
125 " allow-foreign = %s\n"
126 " ignore-transit = %s\n"
127 " convert-trade = %s\n"
158 const struct city *src,
159 const struct city *dest,
169 if ((src !=
NULL) && (dest !=
NULL)) {
209 const struct unit *caravan,
211 struct tile *start_tile,
259 const struct city *src,
260 const struct city *dest,
269 pgood->replace_priority));
293 const struct player *pplayer,
348 const struct city *src,
349 const struct city *dest,
380 "Unimplemented functionality: "
381 "using CM to calculate trade.");
394 const struct city *dest,
459 return (src == dest);
488 const struct city *src = result->
src;
489 const struct city *dest = result->
dest;
491 double discount = parameter->
discount;
497 bool consider_windfall;
542 if (consider_trade) {
547 trade =
annuity(trade, parameter->
horizon - arrival_time, discount);
554 if (consider_windfall) {
562 || (consider_windfall
640 *data->
best = current;
651 const struct unit *caravan,
659 struct tile *start_tile;
668 start_tile = src->
tile;
bool action_prob_possible(const struct act_prob probability)
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)
static double wonder_benefit(const struct unit *caravan, int arrival_time, const struct city *dest, const struct caravan_parameter *param)
static double perpetuity(double payment, double rate)
void caravan_find_best_destination(const struct civ_map *nmap, const struct unit *caravan, const struct caravan_parameter *parameter, struct caravan_result *result, bool omniscient)
static bool does_foreign_trade_param_allow(const struct caravan_parameter *param, struct player *src, struct player *dest)
static void caravan_search_from(const struct civ_map *nmap, const struct unit *caravan, const struct caravan_parameter *param, struct tile *start_tile, int turns_before, int moves_left_before, bool omniscient, search_callback callback, void *callback_data)
bool caravan_parameter_is_legal(const struct caravan_parameter *parameter)
static void caravan_find_best_destination_notransit(const struct unit *caravan, const struct caravan_parameter *param, struct caravan_result *best)
void caravan_result_init_zero(struct caravan_result *result)
static double annuity(double payment, int term, double rate)
static bool cfbdw_callback(const struct civ_map *nmap, void *vdata, const struct city *dest, int arrival_time, int moves_left)
static const char * ftl_name(enum foreign_trade_limit ftl)
bool(* search_callback)(const struct civ_map *nmap, void *data, const struct city *pcity, int arrival_turn, int arrival_moves_left)
int caravan_result_compare(const struct caravan_result *a, const struct caravan_result *b)
static int one_city_trade_benefit(const struct city *pcity, const struct player *pplayer, const struct goods_type *pgood, bool countloser, int newtrade)
static void caravan_find_best_destination_withtransit(const struct civ_map *nmap, const struct unit *caravan, const struct caravan_parameter *param, const struct city *src, int turns_before, int moves_left, bool omniscient, struct caravan_result *result)
void caravan_parameter_log_real(const struct caravan_parameter *parameter, enum log_level level, const char *file, const char *function, int line)
static double trade_benefit(const struct player *caravan_owner, const struct city *src, const struct city *dest, const struct goods_type *pgood, const struct caravan_parameter *param)
static bool get_discounted_reward(const struct unit *caravan, const struct caravan_parameter *parameter, struct caravan_result *result)
static double windfall_benefit(const struct unit *caravan, const struct city *src, const struct city *dest, const struct goods_type *pgood, const struct caravan_parameter *param)
void caravan_parameter_init_default(struct caravan_parameter *parameter)
static double presentvalue(double payment, int term, double rate)
void caravan_parameter_init_from_unit(struct caravan_parameter *parameter, const struct unit *caravan)
static void caravan_result_init(struct caravan_result *result, const struct city *src, const struct city *dest, int arrival_time)
bool city_production_gets_caravan_shields(const struct universal *tgt)
#define city_list_iterate(citylist, pcity)
#define city_tile(_pcity_)
#define city_owner(_pcity_)
#define city_list_iterate_end
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
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 cost
struct city * game_city_by_number(int id)
int impr_buy_gold_cost(const struct city *pcity, const struct impr_type *pimprove, int shields_in_stock)
bool is_wonder(const struct impr_type *pimprove)
void do_log(const char *file, const char *function, int line, bool print_from_where, enum log_level level, const char *message,...)
#define fc_assert_msg(condition, message,...)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
struct pf_map * pf_map_new(const struct pf_parameter *parameter)
void pf_map_destroy(struct pf_map *pfm)
#define pf_map_positions_iterate_end
#define pf_map_positions_iterate(ARG_pfm, NAME_pos, COND_from_start)
bool pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
bool pplayers_in_peace(const struct player *pplayer, const struct player *pplayer2)
#define players_iterate_end
#define players_iterate(_pplayer)
struct setting_list * level[OLEVELS_NUM]
void(* callback)(const struct caravan_result *result, void *data)
enum foreign_trade_limit allow_foreign_trade
bool account_for_broken_routes
struct caravan_result * best
const struct unit * caravan
const struct caravan_parameter * param
struct universal production
struct city * tile_city(const struct tile *ptile)
#define tile_continent(_tile)
bool can_cities_trade(const struct city *pc1, const struct city *pc2)
enum trade_route_type cities_trade_route_type(const struct city *pcity1, const struct city *pcity2)
int trade_base_between_cities(const struct city *pc1, const struct city *pc2)
int city_num_trade_routes(const struct city *pcity)
struct trade_route_settings * trade_route_settings_by_type(enum trade_route_type type)
struct goods_type * goods_from_city_to_unit(const struct city *src, const struct unit *punit)
unsigned max_trade_routes(const struct city *pcity)
int city_trade_removable(const struct city *pcity, int priority, struct trade_route_list *would_remove)
bool can_establish_trade_route(const struct city *pc1, const struct city *pc2, int priority)
int get_caravan_enter_city_trade_bonus(const struct city *pc1, const struct city *pc2, const struct unit_type *ut, struct goods_type *pgood, const bool establish_trade)
#define trade_route_list_iterate(trade_route_list, proute)
#define trade_routes_iterate_end
#define trade_route_list_iterate_end
#define trade_routes_iterate(c, proute)
const struct impr_type * building
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
const struct unit_type * unit_type_get(const struct unit *punit)
int unit_build_shield_cost(const struct city *pcity, const struct unit *punit)
int unit_build_shield_cost_base(const struct unit *punit)