28 #include "eng3d/entity.hpp"
60 return glm::max<float>(rand() % 100, 1.f) / 100.f;
66 unit_battle_weight = 1.f + 1.f * this->
get_rand();
67 unit_exist_weight = 1.f + 1.f * this->
get_rand();
68 coastal_weight = 1.f + 1.f * this->
get_rand();
69 reconquer_weight = 1.f + 1.f * this->
get_rand();
70 erratic = 1.f + 1.f * this->
get_rand();
71 strength_threshold = 1.f * this->
get_rand();
72 override_threshold = 1.f * this->
get_rand();
73 conqueror_weight = 1.f * this->
get_rand();
97 for(
const auto& other : world.nations) {
98 if(&other != &nation) {
99 const auto& relation = world.
get_relation(nation, other);
100 if(relation.has_landpass())
107 const auto& relation = world.
get_relation(nation, other);
114 for(
const auto& other : world.nations)
115 if(&other != &nation)
124 const auto& province = world.provinces[province_id];
125 auto draw_in_force = 1.f;
129 for(
const auto unit_id : unit_ids) {
131 const auto& unit_owner = world.nations[unit.owner_id];
136 if(province.is_coastal)
138 if(!world.terrain_types[province.terrain_type_id].is_water_body) {
140 if(province.owner_id == nation && province.controller_id != nation)
149 const auto& province = world.provinces[province_id];
150 for(
const auto neighbour_id : province.neighbour_ids)
157 const auto* highest_risk = &start;
159 const auto& neighbour = world.provinces[neighbour_id];
164 if(neighbour.controller_id != unit.
owner_id) {
166 if(relation.has_landpass())
167 highest_risk = &neighbour;
169 highest_risk = &neighbour;
173 return *highest_risk;
177 extern std::vector<AIManager>
ai_man;
std::vector< AIManager > ai_man
std::vector< ProvinceId > g_water_provinces
std::vector< ProvinceId > controlled_provinces
A single province, which is used to simulate economy in a "bulk-tiles" way instead of doing economica...
std::vector< ProvinceId > neighbour_ids
Roughly a batallion, consisting of approximately 500 soldiers each.
Eng3D::Freelist< Unit > units
std::vector< UnitId > get_province_units(ProvinceId province_id) const
Nation::Relation & get_relation(NationId a, NationId b)
void recalc_weights()
Reshuffle weights of the AI.
void calc_nation_risk(const World &world, const Nation &nation)
void calc_province_risk(const World &world, const Nation &nation)
size_t last_constrolled_cnt
std::vector< float > potential_risk
void calc_weights(const Nation &nation)
Recalculate weights iff losing territory.
float get_nation_risk(const World &world, const Nation &nation, const Nation &other)
const Province & get_highest_priority_province(const World &world, const Province &start, const Unit &unit)
void collect_eval_provinces(const World &world, const Nation &nation)
std::vector< float > nations_risk_factor
std::vector< ProvinceId > eval_provinces