97 if (acity && punit->
id != 0
101 log_debug(
"Don't want to attack %s, although we could",
114 struct tile *dst_tile)
116 struct unit *pdefender;
118 int balanced_cost, unit_cost, victim_cost = 0;
120 int unit_attack, victim_defence;
125 #define PROB_MULTIPLIER 100
141 if (0 == victim_cost) {
170 kill_desire(victim_cost, unit_attack, unit_cost, victim_defence, 1)
175 sortie_time, balanced_cost);
176 log_debug(
"%s at (%d, %d) is a worthy target with profit %d",
179 log_debug(
"%s(%d, %d): %s at (%d, %d) is unworthy with profit %d",
203 struct tile *best_tile =
nullptr;
234 if (new_best > best) {
261 const struct unit *punit,
267 struct tile *best_tile =
nullptr;
269 struct unit *pvirtual =
nullptr;
270 int best_worth = 0, target_worth;
299 if (target_worth > best_worth) {
301 best_worth = target_worth;
349 if (punit->
activity == ACTIVITY_GOTO
372 if (punit->
fuel == 1) {
399 log_debug(
"%s will fly to (%i, %i) (%s) to fight there",
408 log_debug(
"%s cannot find anything to kill and is staying put",
431 bool allow_gold_upkeep)
433 bool want_something =
false;
462 if (!allow_gold_upkeep
475 pplayer, pcity, punittype,
480 if (profit > choice->
want) {
482 choice->
want = profit;
487 want_something =
true;
491 log_debug(
"%s doesn't want to build %s (want=%d)",
499 return want_something;
struct action * action_by_number(action_id act_id)
Return the action with the given id.
#define adv_choice_set_use(_choice, _use)
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...
static struct tile * find_nearest_airbase(const struct unit *punit, PFPath *path)
Looks for nearest airbase for punit reachable imediatly.
static int find_something_to_bomb(struct ai_type *ait, struct unit *punit, PFPath *path, struct tile **pptile)
Find something to bomb Air-units specific victim search Returns the want for the best target.
static struct tile * dai_find_strategic_airbase(struct ai_type *ait, const struct unit *punit, PFPath *path)
Iterates through reachable cities and appraises them as a possible base for air operations by (air)un...
void dai_manage_airunit(struct ai_type *ait, struct player *pplayer, struct unit *punit)
Trying to manage bombers and stuff.
bool dai_choose_attacker_air(struct ai_type *ait, struct player *pplayer, struct city *pcity, struct adv_choice *choice, bool allow_gold_upkeep)
Chooses the best available and usable air unit and records it in choice, if it's better than previous...
static bool dai_should_we_air_attack_tile(struct ai_type *ait, struct unit *punit, struct tile *ptile)
Very preliminary estimate for our intent to attack the tile (x, y).
static int dai_evaluate_tile_for_air_attack(struct unit *punit, struct tile *dst_tile)
Returns an estimate for the profit gained through attack.
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)
int build_cost_balanced(const struct unit_type *punittype)
In the words of Syela: "Using funky fprime variable instead of f in the denom, so that def=1 units ar...
int kill_desire(int benefit, int attack, int loss, int vuln, int victim_count)
Compute how much we want to kill certain victim we've chosen, counted in SHIELDs.
int city_production_unit_veteran_level(struct city *pcity, const struct unit_type *punittype)
How many veteran levels will created unit of this type get?
const char * city_name_get(const struct city *pcity)
Return the name of the city.
bool can_city_build_unit_now(const struct city *pcity, const struct unit_type *punittype)
Return whether given city can build given unit; returns FALSE if unit is obsolete.
struct unit * get_defender(const struct unit *attacker, const struct tile *ptile)
Finds the best defender on the tile, given an attacker.
double unit_win_chance(const struct unit *attacker, const struct unit *defender)
Returns a double in the range [0;1] indicating the attackers chance of winning.
bool can_unit_attack_tile(const struct unit *punit, const struct tile *dest_tile)
Is unit (1) diplomatically allowed to attack and (2) physically able to do so?
struct unit * game_unit_by_number(int id)
Find unit out of all units in game: now uses fast idex method, instead of looking through all units o...
struct city * game_city_by_number(int id)
Often used function to get a city pointer from a city ID.
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_ret(condition)
#define log_debug(message,...)
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...
bool map_is_known(const struct tile *ptile, const struct player *pplayer)
Return whether the player knows the tile.
bool map_is_known_and_seen(const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
Returns whether the layer 'vlayer' of the tile 'ptile' is known and seen by the player 'pplayer'.
bool is_unit_being_refueled(const struct unit *punit)
Is unit being refueled in its current position.
bool is_airunit_refuel_point(const struct tile *ptile, const struct player *pplayer, const struct unit *punit)
Can unit refuel on tile.
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_knows_techs_with_flag(const struct player *pplayer, enum tech_flag_id flag)
Returns TRUE iff the player knows at least one tech which has the given flag.
struct city * player_city_by_number(const struct player *pplayer, int city_id)
If the specified player owns the city with the specified id, return pointer to the city struct.
#define UNIT_LOG(_, punit, msg,...)
struct unit_class::@80 adv
enum move_level land_move
enum unit_activity activity
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
const struct unit_type * utype
bool unit_type_is_losing_hp(const struct player *pplayer, const struct unit_type *punittype)
Does unit lose hitpoints each turn?
void unit_virtual_destroy(struct unit *punit)
Free the memory used by virtual unit.
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Create a virtual unit skeleton.
void unit_tile_set(struct unit *punit, struct tile *ptile)
Set the tile location of the unit.
struct unit * is_enemy_unit_tile(const struct tile *ptile, const struct player *pplayer)
Is there an enemy unit on this tile? Returns the unit or nullptr if none.
#define CHECK_UNIT(punit)
bool unit_activity_handling(struct unit *punit, enum unit_activity new_activity)
Handle request for changing activity.
const char * unit_rule_name(const struct unit *punit)
Return the (untranslated) rule name of the unit.
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
int utype_upkeep_cost(const struct unit_type *ut, struct player *pplayer, Output_type_id otype)
Returns the upkeep of a unit of this type under the given government.
const char * utype_rule_name(const struct unit_type *punittype)
Return the (untranslated) rule name of the unit type.
bool utype_is_consumed_by_action_result(enum action_result result, const struct unit_type *utype)
Returns TRUE iff performing an action with the specified action result will consume an actor unit of ...
int unit_build_shield_cost_base(const struct unit *punit)
Returns the number of shields this unit represents.
bool unit_can_take_over(const struct unit *punit)
Return whether the unit can take over enemy cities.
int utype_pays_mp_for_action_estimate(const struct action *paction, const struct unit_type *putype, const struct player *act_player, const struct tile *act_tile, const struct tile *tgt_tile)
Returns an estimate of the amount of movement points successfully performing the specified action wil...
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Return TRUE iff units of the given type can do the specified generalized (ruleset defined) action ena...
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
#define utype_fuel(ptype)
#define unit_type_iterate(_p)
#define unit_type_iterate_end