Freeciv-3.3
Loading...
Searching...
No Matches
caravan.h
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13#ifndef FC__CARAVAN_H
14#define FC__CARAVAN_H
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20
21/* utility */
22#include "log.h" /* enum log_level */
23#include "shared.h"
24
25/* common */
26#include "fc_types.h"
27
35
36
52 const struct city *src;
53 const struct city *dest;
55
56 double value;
59};
60
62 /*
63 * How many turns to consider when optimizing.
64 */
66
67 /*
68 * Discount factor (that is, 1 / interest rate).
69 * The worth of a trade route is equivalent to:
70 * sum_{i=0}^{horizon} value in i turns * discount^i
71 * The discount should be in (0..1].
72 * A discount of 1 means future earnings are worth the same as immediate
73 * earnings. A discount of .95 means a dollar next turn is worth only 95
74 * cents today; or, in other words, 95 cents in the bank today would yield
75 * a dollar next turn.
76 */
77 double discount;
78
79 /*
80 * What to consider:
81 * - the immediate windfall when the caravan reaches destination
82 * - the trade
83 * - the reduction in cost of helping build a wonder
84 */
88
89 /*
90 * A new trade route may break old routes.
91 * Account for the loss of old routes.
92 */
94
95 /*
96 * Allow trading with allies and peaceful neighbors.
97 * BUG: currently we only consider allies.
98 */
100
101 /*
102 * Normally, we'd want to compute the time it takes to establish the
103 * trade route.
104 * There are two reasons to ignore the transit time:
105 * (1) it may be infinite (i.e. requires crossing an ocean)
106 * (2) it's slow to compute it.
107 */
109
110 /*
111 * The 'effect of trade' can be computed exactly by an expensive
112 * calculation which will take into account buildings, tax rates, etc; or
113 * by a cheap calculation that just says that each trade is worth one
114 * science or gold.
115 */
117
118 /*
119 * This callback, if non-null, is called whenever a trade route
120 * is evaluated. One intended usage is for collecting all the
121 * trade routes into a sorted list.
122 * Note that the result must be copied to be stored.
123 */
124 void (*callback)(const struct caravan_result *result, void *data);
126};
127
128
131 const struct unit *caravan);
132bool caravan_parameter_is_legal(const struct caravan_parameter *parameter);
133void caravan_parameter_log_real(const struct caravan_parameter *parameter,
134 enum log_level level, const char *file,
135 const char *function, int line);
136#define caravan_parameter_log(parameter, loglevel) \
137 if (log_do_output_for_level(loglevel)) { \
138 caravan_parameter_log_real(parameter, loglevel, __FILE__, \
139 __FUNCTION__, __FC_LINE__); \
140 }
141
142void caravan_result_init_zero(struct caravan_result *result);
143int caravan_result_compare(const struct caravan_result *a,
144 const struct caravan_result *b);
145
147 const struct unit *caravan,
148 const struct caravan_parameter *parameter,
149 struct caravan_result *result, bool omniscient);
150
151#ifdef __cplusplus
152}
153#endif /* __cplusplus */
154
155#endif /* FC__CARAVAN_H */
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)
Definition caravan.c:682
bool caravan_parameter_is_legal(const struct caravan_parameter *parameter)
Definition caravan.c:72
void caravan_result_init_zero(struct caravan_result *result)
Definition caravan.c:144
int caravan_result_compare(const struct caravan_result *a, const struct caravan_result *b)
Definition caravan.c:183
foreign_trade_limit
Definition caravan.h:29
@ FTL_ALLIED
Definition caravan.h:31
@ FTL_NATIONAL_ONLY
Definition caravan.h:30
@ FTL_NONWAR
Definition caravan.h:33
@ FTL_PEACEFUL
Definition caravan.h:32
void caravan_parameter_log_real(const struct caravan_parameter *parameter, enum log_level level, const char *file, const char *function, int line)
Definition caravan.c:115
void caravan_parameter_init_default(struct caravan_parameter *parameter)
Definition caravan.c:36
void caravan_parameter_init_from_unit(struct caravan_parameter *parameter, const struct unit *caravan)
Definition caravan.c:53
char * incite_cost
Definition comments.c:76
log_level
Definition log.h:29
struct setting_list * level[OLEVELS_NUM]
Definition settings.c:190
bool consider_trade
Definition caravan.h:86
bool consider_windfall
Definition caravan.h:85
enum foreign_trade_limit allow_foreign_trade
Definition caravan.h:99
bool consider_wonders
Definition caravan.h:87
bool ignore_transit_time
Definition caravan.h:108
double discount
Definition caravan.h:77
bool account_for_broken_routes
Definition caravan.h:93
void * callback_data
Definition caravan.h:125
const struct city * src
Definition caravan.h:52
const struct city * dest
Definition caravan.h:53
int arrival_time
Definition caravan.h:54
bool help_wonder
Definition caravan.h:57
bool required_boat
Definition caravan.h:58
double value
Definition caravan.h:56
Definition city.h:317
Definition unit.h:140