80 const struct player *pplayer,
161 #define SAME_TER_SCORE 21
162 #define DIFF_TER_SCORE 81
163 #define KNOWN_SAME_TER_SCORE 0
164 #define KNOWN_DIFF_TER_SCORE 51
171 #define MAX_NEW_TILES 5
177 #define VISION_TILES 9
182 #define BEST_NORMAL_TILE \
183 (100 * MAX_NEW_TILES * DIFF_TER_SCORE \
184 + 100 * (VISION_TILES - MAX_NEW_TILES) * KNOWN_DIFF_TER_SCORE)
188 #define OWN_CITY_SCORE (BEST_NORMAL_TILE + 1)
193 #define HUT_SCORE (OWN_CITY_SCORE + 1)
195 #define BEST_POSSIBLE_SCORE (HUT_SCORE + BEST_NORMAL_TILE)
288 struct tile *best_tile =
nullptr;
295 #define DIST_FACTOR 0.6
312 parameter.omniscience =
false;
318 double log_desirable;
325 if (desirable <= 0) {
331 log_desirable = log(desirable);
355 if (log_desirable + move_cost * logDF
356 > log_most_desirable + best_MC * logDF) {
357 log_most_desirable = log_desirable;
363 max_dist = best_MC + (log_most_desirable - logBPS) / logDF;
367 if (move_cost > max_dist) {
377 if (best_tile !=
nullptr) {
382 if (
is_ai(pplayer)) {
418 #undef SAME_TER_SCORE
419 #undef DIFF_TER_SCORE
420 #undef KNOWN_SAME_TER_SCORE
421 #undef KNOWN_DIFF_TER_SCORE
422 #undef OWN_CITY_SCORE
bool adv_follow_path(struct unit *punit, const PFPath &path, struct tile *ptile)
Move a unit along a path without disturbing its activity, role or assigned destination Return FALSE i...
void adv_avoid_risks(struct pf_parameter *parameter, struct adv_risk_cost *risk_cost, struct unit *punit, const double fearfulness)
Set PF callbacks to favour paths that do not create tall stacks or cross dangerous tiles.
#define NORMAL_STACKING_FEARFULNESS
#define CALL_PLR_AI_FUNC(_func, _player,...)
#define SAME_TER_SCORE
Return a value indicating how desirable it is to explore the given tile.
static int explorer_desirable(struct tile *ptile, struct player *pplayer, struct unit *punit)
static enum tile_behavior explorer_tb(const struct tile *ptile, enum known_type k, const struct pf_parameter *param)
TB function used by explorer_goto().
enum unit_move_result manage_auto_explorer(struct unit *punit)
Handle eXplore mode of a unit (explorers are always in eXplore mode for AI) - explores unknown territ...
static bool explorer_goto(struct unit *punit, struct tile *ptile)
Constrained goto using player_may_explore().
#define KNOWN_DIFF_TER_SCORE
#define KNOWN_SAME_TER_SCORE
static int likely_native(struct tile *ptile, struct player *pplayer, struct unit_class *pclass)
Determine if a tile is likely to be native, given information that the player actually has.
#define BEST_POSSIBLE_SCORE
static bool player_may_explore(const struct tile *ptile, const struct player *pplayer, const struct unit_type *punittype)
Returns TRUE if a unit owned by the given player can safely "explore" the given tile.
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
bool has_handicap(const struct player *pplayer, enum handicap_type htype)
AI players may have handicaps - allowing them to cheat or preventing them from using certain algorith...
#define fc_assert_action(condition, action)
bool is_tiles_adjacent(const struct tile *tile0, const struct tile *tile1)
Are two tiles adjacent to each other.
bool same_pos(const struct tile *tile1, const struct tile *tile2)
Are (x1,y1) and (x2,y2) really the same when adjusted? This function might be necessary ALOT of place...
#define adjc_dir_iterate(nmap, center_tile, itr_tile, dir_itr)
#define circle_iterate(nmap, center_tile, sq_radius, tile_itr)
#define adjc_dir_iterate_end
#define circle_iterate_end
bool map_is_known(const struct tile *ptile, const struct player *pplayer)
Return whether the player knows the tile.
static bool is_native_tile_to_class(const struct unit_class *punitclass, const struct tile *ptile)
struct pf_map * pf_map_new(const struct pf_parameter *parameter)
Factory function to create a new map according to the parameter.
PFPath pf_map_path(struct pf_map *pfm, struct tile *ptile)
CHECK DOCS AFTER FULL CONVERSTION OF pf_path to class PFPath Tries to find the best path in the given...
void pf_map_destroy(struct pf_map *pfm)
After usage the map must be destroyed.
#define pf_map_move_costs_iterate_end
#define pf_map_move_costs_iterate(ARG_pfm, NAME_tile, NAME_cost, COND_from_start)
bool player_can_invade_tile(const struct player *pplayer, const struct tile *ptile)
Return TRUE iff the player can invade a particular tile (linked with borders and diplomatic states).
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players are allied.
static bool is_barbarian(const struct player *pplayer)
#define UNIT_LOG(_, punit, msg,...)
#define TIMING_LOG(timer, activity)
enum tile_behavior(* get_TB)(const struct tile *ptile, enum known_type known, const struct pf_parameter *param)
const struct player * owner
const struct unit_type * utype
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
struct unit * is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Is there an non-allied unit on this tile?
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
struct unit_class * unit_class_get(const struct unit *punit)
Returns unit class pointer for a unit.
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Return whether the unit has the given flag.
static bool utype_has_flag(const struct unit_type *punittype, int flag)