mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
NKAI: increase towns priority, buy heroes more often
This commit is contained in:
parent
ec0596f3dd
commit
ccfc6f5716
@ -148,17 +148,19 @@ void DangerHitMapAnalyzer::calculateTileOwners()
|
||||
std::map<const CGHeroInstance *, const CGTownInstance *> heroTownMap;
|
||||
PathfinderSettings pathfinderSettings;
|
||||
|
||||
pathfinderSettings.mainTurnDistanceLimit = 3;
|
||||
pathfinderSettings.mainTurnDistanceLimit = 5;
|
||||
|
||||
auto addTownHero = [&](const CGTownInstance * town)
|
||||
{
|
||||
auto townHero = new CGHeroInstance();
|
||||
CRandomGenerator rng;
|
||||
auto visitablePos = town->visitablePos();
|
||||
|
||||
townHero->pos = town->pos;
|
||||
townHero->pos = visitablePos;
|
||||
townHero->setOwner(ai->playerID); // lets avoid having multiple colors
|
||||
townHero->initHero(rng, static_cast<HeroTypeID>(0));
|
||||
townHero->initObj(rng);
|
||||
townHero->pos = townHero->convertFromVisitablePos(visitablePos);
|
||||
|
||||
heroTownMap[townHero] = town;
|
||||
townHeroes[townHero] = HeroRole::MAIN;
|
||||
|
@ -55,10 +55,6 @@ struct HitMapNode
|
||||
}
|
||||
};
|
||||
|
||||
struct TileOwner
|
||||
{
|
||||
};
|
||||
|
||||
class DangerHitMapAnalyzer
|
||||
{
|
||||
private:
|
||||
|
@ -70,10 +70,10 @@ Goals::TGoalVec RecruitHeroBehavior::decompose() const
|
||||
|
||||
for(auto obj : ai->nullkiller->objectClusterizer->getNearbyObjects())
|
||||
{
|
||||
if((obj->ID == Obj::RESOURCE && obj->subID == GameResID(EGameResID::GOLD))
|
||||
if((obj->ID == Obj::RESOURCE)
|
||||
|| obj->ID == Obj::TREASURE_CHEST
|
||||
|| obj->ID == Obj::CAMPFIRE
|
||||
|| obj->ID == Obj::WATER_WHEEL
|
||||
|| isWeeklyRevisitable(obj)
|
||||
|| obj->ID ==Obj::ARTIFACT)
|
||||
{
|
||||
auto tile = obj->visitablePos();
|
||||
@ -84,7 +84,7 @@ Goals::TGoalVec RecruitHeroBehavior::decompose() const
|
||||
}
|
||||
}
|
||||
|
||||
if(treasureSourcesCount < 10)
|
||||
if(treasureSourcesCount < 5)
|
||||
continue;
|
||||
|
||||
if(cb->getHeroesInfo().size() < cb->getTownsInfo().size() + 1
|
||||
|
@ -108,7 +108,8 @@ int32_t estimateTownIncome(CCallback * cb, const CGObjectInstance * target, cons
|
||||
auto town = cb->getTown(target->id);
|
||||
auto fortLevel = town->fortLevel();
|
||||
|
||||
if(town->hasCapitol()) return booster * 2000;
|
||||
if(town->hasCapitol())
|
||||
return booster * 2000;
|
||||
|
||||
// probably well developed town will have city hall
|
||||
if(fortLevel == CGTownInstance::CASTLE) return booster * 750;
|
||||
@ -497,14 +498,15 @@ float RewardEvaluator::getStrategicalValue(const CGObjectInstance * target) cons
|
||||
}
|
||||
|
||||
auto fortLevel = town->fortLevel();
|
||||
auto booster = isAnotherAi(town, *ai->cb) ? 0.3f : 0.7f;
|
||||
auto booster = isAnotherAi(town, *ai->cb) ? 0.4f : 1.0f;
|
||||
|
||||
if(town->hasCapitol()) return booster;
|
||||
if(town->hasCapitol())
|
||||
return booster * 1.5;
|
||||
|
||||
if(fortLevel < CGTownInstance::CITADEL)
|
||||
return booster * (town->hasFort() ? 0.6 : 0.4);
|
||||
return booster * (town->hasFort() ? 1.0 : 0.8);
|
||||
else
|
||||
return booster * (fortLevel == CGTownInstance::CASTLE ? 0.9 : 0.8);
|
||||
return booster * (fortLevel == CGTownInstance::CASTLE ? 1.4 : 1.2);
|
||||
}
|
||||
|
||||
case Obj::HERO:
|
||||
@ -731,7 +733,7 @@ public:
|
||||
|
||||
multiplier /= 1.0f + treat.turn / 5.0f;
|
||||
|
||||
if(defendTown.getTurn() > 0 && defendTown.isContrAttack())
|
||||
if(defendTown.getTurn() > 0 && defendTown.isCounterAttack())
|
||||
{
|
||||
auto ourSpeed = defendTown.hero->movementPointsLimit(true);
|
||||
auto enemySpeed = treat.hero->movementPointsLimit(true);
|
||||
|
@ -18,8 +18,8 @@ namespace NKAI
|
||||
|
||||
using namespace Goals;
|
||||
|
||||
DefendTown::DefendTown(const CGTownInstance * town, const HitMapInfo & treat, const AIPath & defencePath, bool isContrattack)
|
||||
: CGoal(Goals::DEFEND_TOWN), treat(treat), defenceArmyStrength(defencePath.getHeroStrength()), turn(defencePath.turn()), contrattack(isContrattack)
|
||||
DefendTown::DefendTown(const CGTownInstance * town, const HitMapInfo & treat, const AIPath & defencePath, bool isCounterAttack)
|
||||
: CGoal(Goals::DEFEND_TOWN), treat(treat), defenceArmyStrength(defencePath.getHeroStrength()), turn(defencePath.turn()), counterattack(isCounterAttack)
|
||||
{
|
||||
settown(town);
|
||||
sethero(defencePath.targetHero);
|
||||
|
@ -24,10 +24,10 @@ namespace Goals
|
||||
uint64_t defenceArmyStrength;
|
||||
HitMapInfo treat;
|
||||
uint8_t turn;
|
||||
bool contrattack;
|
||||
bool counterattack;
|
||||
|
||||
public:
|
||||
DefendTown(const CGTownInstance * town, const HitMapInfo & treat, const AIPath & defencePath, bool isContrattack = false);
|
||||
DefendTown(const CGTownInstance * town, const HitMapInfo & treat, const AIPath & defencePath, bool isCounterAttack = false);
|
||||
DefendTown(const CGTownInstance * town, const HitMapInfo & treat, const CGHeroInstance * defender);
|
||||
|
||||
virtual bool operator==(const DefendTown & other) const override;
|
||||
@ -39,7 +39,7 @@ namespace Goals
|
||||
|
||||
uint8_t getTurn() const { return turn; }
|
||||
|
||||
bool isContrAttack() { return contrattack; }
|
||||
bool isCounterAttack() { return counterattack; }
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user