Freeciv-3.2
|
#include <math.h>
#include "log.h"
#include "game.h"
#include "traderoutes.h"
#include "path_finding.h"
#include "pf_tools.h"
#include "caravan.h"
Go to the source code of this file.
Data Structures | |
struct | cewt_data |
struct | cfbdw_data |
struct | cowt_data |
Typedefs | |
typedef bool(* | search_callback) (const struct civ_map *nmap, void *data, const struct city *pcity, int arrival_turn, int arrival_moves_left) |
Compute the net present value of an annuity given the discount rate. An annuity is an annual payment for a fixed term (number of turns).
Definition at line 437 of file caravan.c.
Referenced by get_discounted_reward().
|
static |
Ignoring the transit time, return the value of moving the caravan to dest.
Definition at line 584 of file caravan.c.
Referenced by caravan_evaluate().
|
static |
Using the caravan_search function to take transit time into account, evaluate the benefit of sending the caravan to dest.
Definition at line 626 of file caravan.c.
Referenced by caravan_evaluate().
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 | ||
) |
Find the best destination city for the caravan. Store it in *destout (if destout is non-null); return the value of the trade route.
Definition at line 752 of file caravan.c.
Referenced by dai_manage_caravan().
|
static |
Find the best destination for the caravan, ignoring transit time.
Definition at line 665 of file caravan.c.
Referenced by caravan_find_best_destination().
|
static |
Using caravan_search, find the best destination.
Definition at line 719 of file caravan.c.
Referenced by caravan_find_best_destination(), and cowt_callback().
void caravan_optimize_allpairs | ( | const struct unit * | caravan, |
const struct caravan_parameter * | param, | ||
struct caravan_result * | result, | ||
bool | omniscient | ||
) |
|
static |
Find the best pair-wise trade route, ignoring transit time.
Definition at line 772 of file caravan.c.
Referenced by caravan_optimize_allpairs().
|
static |
Find the best src/dest pair (including possibly changing home city), taking account of the trip time.
Definition at line 850 of file caravan.c.
Referenced by caravan_optimize_allpairs().
void caravan_parameter_init_default | ( | struct caravan_parameter * | parameter | ) |
Create a valid parameter with default values.
Definition at line 36 of file caravan.c.
Referenced by caravan_parameter_init_from_unit().
void caravan_parameter_init_from_unit | ( | struct caravan_parameter * | parameter, |
const struct unit * | caravan | ||
) |
Create a valid parameter with default values based on the caravan.
Definition at line 53 of file caravan.c.
Referenced by dai_manage_caravan().
bool caravan_parameter_is_legal | ( | const struct caravan_parameter * | parameter | ) |
int caravan_result_compare | ( | const struct caravan_result * | a, |
const struct caravan_result * | b | ||
) |
Compare the two results for sorting.
Definition at line 183 of file caravan.c.
Referenced by caravan_find_best_destination_notransit(), caravan_optimize_notransit(), cfbdw_callback(), and cowt_callback().
|
static |
Initialize the result to go from src to dest with the given amount of time. This is useful for calling get_discounted_reward() and the such.
Definition at line 157 of file caravan.c.
Referenced by caravan_evaluate_notransit(), caravan_evaluate_withtransit(), caravan_find_best_destination_notransit(), caravan_find_best_destination_withtransit(), caravan_optimize_notransit(), cfbdw_callback(), and cowt_callback().
void caravan_result_init_zero | ( | struct caravan_result * | result | ) |
Initialize the result to be worth zero and go from nowhere to nowhere.
Definition at line 144 of file caravan.c.
Referenced by caravan_optimize_withtransit(), and get_discounted_reward().
|
static |
Definition at line 208 of file caravan.c.
Referenced by caravan_evaluate_withtransit(), caravan_find_best_destination_withtransit(), and caravan_optimize_withtransit().
|
static |
Definition at line 605 of file caravan.c.
Referenced by caravan_evaluate_withtransit().
|
static |
Definition at line 699 of file caravan.c.
Referenced by caravan_find_best_destination_withtransit().
|
static |
Callback for the caravan_search invocation in caravan_optimize_withtransit().
For every city we can reach, use caravan_find_best_destination_withtransit() as a subroutine.
Definition at line 816 of file caravan.c.
Referenced by caravan_optimize_withtransit().
|
static |
Are the two players allowed to trade by the parameter settings?
Definition at line 445 of file caravan.c.
Referenced by caravan_find_best_destination_notransit(), caravan_optimize_notransit(), and get_discounted_reward().
|
static |
Human readable name of the foreign_trade_limit
Definition at line 96 of file caravan.c.
Referenced by caravan_parameter_log_real().
|
static |
Compute the discounted reward from the trade route that is indicated by the src, dest, and arrival_time fields of the result: Fills in the value and help_wonder fields. Assumes the owner of src is the owner of the caravan.
Definition at line 472 of file caravan.c.
Referenced by caravan_evaluate_notransit(), caravan_find_best_destination_notransit(), caravan_optimize_notransit(), cewt_callback(), cfbdw_callback(), and cowt_callback().
|
static |
How much does the city benefit from the new trade route? How much does the former partner lose?
Definition at line 290 of file caravan.c.
Referenced by trade_benefit().
Compute the net present value of an perpetuity given the discount rate. A perpetuity is an annual payment for an infinite number of turns.
Definition at line 428 of file caravan.c.
Referenced by annuity(), and get_discounted_reward().
Discount a value by the given discount rate. The payment occurs as a lump sum in 'term' turns.
Definition at line 419 of file caravan.c.
Referenced by get_discounted_reward().
|
static |
Compute one_trade_benefit for both cities and do some other logic. This yields the total benefit in terms of trade per turn of establishing a route from src to dest.
Definition at line 342 of file caravan.c.
Referenced by get_discounted_reward().
|
static |
When the caravan arrives, compute the benefit from the immediate windfall, taking into account the parameter's objective.
Definition at line 258 of file caravan.c.
Referenced by get_discounted_reward().
|
static |
Check the benefit of helping build the wonder in dest. This is based on how much the caravan would help if it arrived after turns_delay turns during which the city managed the same production it currently gets (i.e. no other caravans, no population growth or terrain improvement, ...)
Definition at line 384 of file caravan.c.
Referenced by get_discounted_reward().