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)) {
205 void *data,
const struct city *pcity,
209 const struct unit *caravan,
211 struct tile *start_tile,
227 pfparam.omniscience = omniscient;
259 const struct city *src,
260 const struct city *dest,
291 const struct player *pplayer,
323 if (
pback->partner == pcity->
id) {
343 const struct city *src,
344 const struct city *dest,
371 "Unimplemented functionality: "
372 "using CM to calculate trade.");
385 const struct city *dest,
450 return (src == dest);
479 const struct city *src = result->
src;
480 const struct city *dest = result->
dest;
482 double discount = parameter->
discount;
488 bool consider_windfall;
530 if (consider_trade) {
535 trade =
annuity(trade, parameter->
horizon - arrival_time, discount);
542 if (consider_windfall) {
550 || (consider_windfall
585 const struct city *dest,
607 int arrival_time,
int moves_left)
628 const struct city *dest,
648 const struct city *dest,
710 *data->
best = current;
721 const struct unit *caravan,
729 struct tile *start_tile;
738 start_tile = src->
tile;
817 const struct city *pcity,
830 *data->
best = current;
839 *data->
best = current;
851 const struct unit *caravan,
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 bool cowt_callback(const struct civ_map *nmap, void *vdata, const struct city *pcity, int arrival_time, int moves_left)
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)
static void caravan_evaluate_notransit(const struct unit *caravan, const struct city *dest, const struct caravan_parameter *param, struct caravan_result *result)
static int one_city_trade_benefit(const struct city *pcity, const struct player *pplayer, bool countloser, int newtrade)
static void caravan_optimize_withtransit(const struct civ_map *nmap, const struct unit *caravan, const struct caravan_parameter *param, struct caravan_result *result, bool omniscient)
void caravan_result_init_zero(struct caravan_result *result)
static bool cewt_callback(const struct civ_map *nmap, void *vdata, const struct city *dest, int arrival_time, int moves_left)
static void caravan_optimize_notransit(const struct unit *caravan, const struct caravan_parameter *param, struct caravan_result *best)
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)
static void caravan_evaluate_withtransit(const struct civ_map *nmap, const struct unit *caravan, const struct city *dest, const struct caravan_parameter *param, struct caravan_result *result, bool omniscient)
int caravan_result_compare(const struct caravan_result *a, const struct caravan_result *b)
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)
void caravan_evaluate(const struct unit *caravan, const struct city *dest, const struct caravan_parameter *param, struct caravan_result *result, bool omniscient)
static bool get_discounted_reward(const struct unit *caravan, const struct caravan_parameter *parameter, struct caravan_result *result)
static double trade_benefit(const struct player *caravan_owner, const struct city *src, const struct city *dest, const struct caravan_parameter *param)
void caravan_parameter_init_default(struct caravan_parameter *parameter)
static double windfall_benefit(const struct unit *caravan, const struct city *src, const struct city *dest, const struct caravan_parameter *param)
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)
void caravan_optimize_allpairs(const struct unit *caravan, const struct caravan_parameter *param, struct caravan_result *result, bool omniscient)
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 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
const struct unit * caravan
const struct caravan_parameter * param
struct caravan_result * result
struct caravan_result * best
const struct unit * caravan
const struct caravan_parameter * param
struct universal production
const struct caravan_parameter * param
struct caravan_result * best
const struct unit * caravan
struct city_list * cities
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)
unsigned max_trade_routes(const struct city *pcity)
int city_trade_removable(const struct city *pcity, struct trade_route_list *would_remove)
bool can_establish_trade_route(const struct city *pc1, const struct city *pc2)
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)