59 int res, regen, recov;
65 if (lost_hp - recov <= 0) {
68 res = 1 + (lost_hp - recov) / (recov + regen);
92 struct tile *best = NULL;
115 }
else if (!best || regt < best_regt) {
151 log_debug(
"Don't want to attack %s, although we could",
164 struct tile *dst_tile)
166 struct unit *pdefender;
168 int balanced_cost, unit_cost, victim_cost = 0;
170 int unit_attack, victim_defense;
177#define PROB_MULTIPLIER 100
193 if (0 == victim_cost) {
220 profit =
kill_desire(victim_cost, unit_attack, unit_cost, victim_defense, 1)
225 profit, sortie_time, balanced_cost);
253 struct tile *best_tile = NULL;
284 if (new_best > best) {
287 log_debug(
"%s wants to attack tile (%d, %d)",
298 *path = best_tile ?
pf_map_path(pfm, best_tile) : NULL;
324 struct tile *best_tile = NULL;
326 struct unit *pvirtual = NULL;
327 adv_want best_worth = 0, target_worth;
331 bool refuel_start =
FALSE;
343 if (lost_hp > 0 && regen + recov > 0) {
345 punit->
moved ? lost_hp - recov : lost_hp - (regen + recov);
346 if (regen_turns_min <= 0) {
347 if (lost_hp - recov > 0) {
349 log_debug(
"Repairment of %s is almost finished, stays here",
357 regen_turns_min /= regen + recov;
358 regen_turns_min += 1;
364 > (unit_list_size(ptile->
units) - 1) << 1) {
365 if (lost_hp <= 0 || regen_turns_min <= 1) {
382 bool chg_for_regen =
FALSE;
396 if (regen_turns_min < regen_tn) {
397 log_debug(
"%s knows a better repair base than %d,%d",
400 }
else if (regen_turns_min > regen_tn) {
401 regen_turns_min = regen_tn;
404 chg_for_regen =
TRUE;
413 > unit_list_size(ptile->units) << 1) {
446 best_worth =
MAX(start_worth, 0);
452 if (target_worth > best_worth) {
454 best_worth = target_worth;
466 *path = best_tile ?
pf_map_path(pfm, best_tile) : NULL;
550 log_debug(
"%s will fly to (%i, %i) (%s) to fight there",
560 log_debug(
"%s cannot find anything to kill and is staying put",
584 bool allow_gold_upkeep)
586 bool want_something =
FALSE;
621 struct unit *virtual_unit =
623 pplayer, pcity, punittype,
627 if (profit > choice->
want) {
629 choice->
want = profit;
634 want_something =
TRUE;
645 return want_something;
static struct action * action_by_number(action_id act_id)
#define adv_choice_set_use(_choice, _use)
bool adv_follow_path(struct unit *punit, struct pf_path *path, struct tile *ptile)
static struct tile * find_nearest_airbase(struct unit *punit, struct pf_path **path)
static adv_want find_something_to_bomb(struct ai_type *ait, struct unit *punit, struct pf_path **path, struct tile **pptile)
void dai_manage_airunit(struct ai_type *ait, struct player *pplayer, struct unit *punit)
static int regen_turns(struct unit *punit, struct tile *ptile, int lost_hp)
bool dai_choose_attacker_air(struct ai_type *ait, struct player *pplayer, struct city *pcity, struct adv_choice *choice, bool allow_gold_upkeep)
static bool dai_should_we_air_attack_tile(struct ai_type *ait, struct unit *punit, struct tile *ptile)
static struct tile * dai_find_strategic_airbase(struct ai_type *ait, struct unit *punit, struct pf_path **path)
static adv_want dai_evaluate_tile_for_air_attack(struct unit *punit, struct tile *dst_tile)
const char * city_name_get(const struct city *pcity)
int city_production_unit_veteran_level(struct city *pcity, const struct unit_type *punittype)
bool can_city_build_unit_now(const struct civ_map *nmap, const struct city *pcity, const struct unit_type *punittype)
double unit_win_chance(const struct civ_map *nmap, const struct unit *attacker, const struct unit *defender, const struct action *paction)
struct unit * get_defender(const struct civ_map *nmap, const struct unit *attacker, const struct tile *ptile, const struct action *paction)
bool can_unit_attack_tile(const struct unit *punit, const struct action *paction, const struct tile *dest_tile)
static struct ai_city * def_ai_city_data(const struct city *pcity, struct ai_type *deftype)
static struct unit_ai * def_ai_unit_data(const struct unit *punit, struct ai_type *deftype)
adv_want kill_desire(adv_want benefit, int attack, int loss, int vuln, int victim_count)
int build_cost_balanced(const struct unit_type *punittype)
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 * punit
int get_unit_bonus(const struct unit *punit, enum effect_type effect_type)
struct unit * game_unit_by_number(int id)
struct city * game_city_by_number(int id)
bool has_handicap(const struct player *pplayer, enum handicap_type htype)
#define fc_assert_ret(condition)
#define log_debug(message,...)
bool same_pos(const struct tile *tile1, const struct tile *tile2)
bool map_is_known(const struct tile *ptile, const struct player *pplayer)
bool map_is_known_and_seen(const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
void pf_path_destroy(struct pf_path *path)
struct pf_map * pf_map_new(const struct pf_parameter *parameter)
struct pf_path * pf_map_path(struct pf_map *pfm, struct tile *ptile)
void pf_map_destroy(struct pf_map *pfm)
#define pf_map_move_costs_iterate_end
#define pf_map_move_costs_iterate(ARG_pfm, NAME_tile, NAME_cost, COND_from_start)
bool player_knows_techs_with_flag(const struct player *pplayer, enum tech_flag_id flag)
struct city * player_city_by_number(const struct player *pplayer, int city_id)
#define UNIT_LOG(loglevel, punit, msg,...)
struct unit_class::@85 adv
enum move_level land_move
enum unit_activity activity
struct city * tile_city(const struct tile *ptile)
const struct unit_type * utype
bool unit_type_is_losing_hp(const struct player *pplayer, const struct unit_type *punittype)
int hp_gain_coord(const struct unit *punit)
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
void unit_virtual_destroy(struct unit *punit)
void unit_tile_set(struct unit *punit, struct tile *ptile)
static bool is_enemy_unit_tile(const struct tile *ptile, const struct player *pplayer)
#define CHECK_UNIT(punit)
bool unit_activity_handling(struct unit *punit, enum unit_activity new_activity)
const struct unit_type * unit_type_get(const struct unit *punit)
int utype_upkeep_cost(const struct unit_type *ut, struct player *pplayer, Output_type_id otype)
const char * unit_rule_name(const struct unit *punit)
int unit_build_shield_cost_base(const struct unit *punit)
int utype_pays_mp_for_action_estimate(const struct civ_map *nmap, const struct action *paction, const struct unit_type *putype, const struct player *act_player, const struct tile *act_tile, const struct tile *tgt_tile)
const char * utype_rule_name(const struct unit_type *punittype)
bool unit_can_take_over(const struct unit *punit)
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
#define unit_type_iterate(_p)
#define unit_type_iterate_end