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;
|
std::map<const CGHeroInstance *, const CGTownInstance *> heroTownMap;
|
||||||
PathfinderSettings pathfinderSettings;
|
PathfinderSettings pathfinderSettings;
|
||||||
|
|
||||||
pathfinderSettings.mainTurnDistanceLimit = 3;
|
pathfinderSettings.mainTurnDistanceLimit = 5;
|
||||||
|
|
||||||
auto addTownHero = [&](const CGTownInstance * town)
|
auto addTownHero = [&](const CGTownInstance * town)
|
||||||
{
|
{
|
||||||
auto townHero = new CGHeroInstance();
|
auto townHero = new CGHeroInstance();
|
||||||
CRandomGenerator rng;
|
CRandomGenerator rng;
|
||||||
|
auto visitablePos = town->visitablePos();
|
||||||
|
|
||||||
townHero->pos = town->pos;
|
townHero->pos = visitablePos;
|
||||||
townHero->setOwner(ai->playerID); // lets avoid having multiple colors
|
townHero->setOwner(ai->playerID); // lets avoid having multiple colors
|
||||||
townHero->initHero(rng, static_cast<HeroTypeID>(0));
|
townHero->initHero(rng, static_cast<HeroTypeID>(0));
|
||||||
townHero->initObj(rng);
|
townHero->initObj(rng);
|
||||||
|
townHero->pos = townHero->convertFromVisitablePos(visitablePos);
|
||||||
|
|
||||||
heroTownMap[townHero] = town;
|
heroTownMap[townHero] = town;
|
||||||
townHeroes[townHero] = HeroRole::MAIN;
|
townHeroes[townHero] = HeroRole::MAIN;
|
||||||
|
@ -55,10 +55,6 @@ struct HitMapNode
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TileOwner
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
class DangerHitMapAnalyzer
|
class DangerHitMapAnalyzer
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -70,10 +70,10 @@ Goals::TGoalVec RecruitHeroBehavior::decompose() const
|
|||||||
|
|
||||||
for(auto obj : ai->nullkiller->objectClusterizer->getNearbyObjects())
|
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::TREASURE_CHEST
|
||||||
|| obj->ID == Obj::CAMPFIRE
|
|| obj->ID == Obj::CAMPFIRE
|
||||||
|| obj->ID == Obj::WATER_WHEEL
|
|| isWeeklyRevisitable(obj)
|
||||||
|| obj->ID ==Obj::ARTIFACT)
|
|| obj->ID ==Obj::ARTIFACT)
|
||||||
{
|
{
|
||||||
auto tile = obj->visitablePos();
|
auto tile = obj->visitablePos();
|
||||||
@ -84,7 +84,7 @@ Goals::TGoalVec RecruitHeroBehavior::decompose() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(treasureSourcesCount < 10)
|
if(treasureSourcesCount < 5)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(cb->getHeroesInfo().size() < cb->getTownsInfo().size() + 1
|
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 town = cb->getTown(target->id);
|
||||||
auto fortLevel = town->fortLevel();
|
auto fortLevel = town->fortLevel();
|
||||||
|
|
||||||
if(town->hasCapitol()) return booster * 2000;
|
if(town->hasCapitol())
|
||||||
|
return booster * 2000;
|
||||||
|
|
||||||
// probably well developed town will have city hall
|
// probably well developed town will have city hall
|
||||||
if(fortLevel == CGTownInstance::CASTLE) return booster * 750;
|
if(fortLevel == CGTownInstance::CASTLE) return booster * 750;
|
||||||
@ -497,14 +498,15 @@ float RewardEvaluator::getStrategicalValue(const CGObjectInstance * target) cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto fortLevel = town->fortLevel();
|
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)
|
if(fortLevel < CGTownInstance::CITADEL)
|
||||||
return booster * (town->hasFort() ? 0.6 : 0.4);
|
return booster * (town->hasFort() ? 1.0 : 0.8);
|
||||||
else
|
else
|
||||||
return booster * (fortLevel == CGTownInstance::CASTLE ? 0.9 : 0.8);
|
return booster * (fortLevel == CGTownInstance::CASTLE ? 1.4 : 1.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
case Obj::HERO:
|
case Obj::HERO:
|
||||||
@ -731,7 +733,7 @@ public:
|
|||||||
|
|
||||||
multiplier /= 1.0f + treat.turn / 5.0f;
|
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 ourSpeed = defendTown.hero->movementPointsLimit(true);
|
||||||
auto enemySpeed = treat.hero->movementPointsLimit(true);
|
auto enemySpeed = treat.hero->movementPointsLimit(true);
|
||||||
|
@ -18,8 +18,8 @@ namespace NKAI
|
|||||||
|
|
||||||
using namespace Goals;
|
using namespace Goals;
|
||||||
|
|
||||||
DefendTown::DefendTown(const CGTownInstance * town, const HitMapInfo & treat, const AIPath & defencePath, bool 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()), contrattack(isContrattack)
|
: CGoal(Goals::DEFEND_TOWN), treat(treat), defenceArmyStrength(defencePath.getHeroStrength()), turn(defencePath.turn()), counterattack(isCounterAttack)
|
||||||
{
|
{
|
||||||
settown(town);
|
settown(town);
|
||||||
sethero(defencePath.targetHero);
|
sethero(defencePath.targetHero);
|
||||||
|
@ -24,10 +24,10 @@ namespace Goals
|
|||||||
uint64_t defenceArmyStrength;
|
uint64_t defenceArmyStrength;
|
||||||
HitMapInfo treat;
|
HitMapInfo treat;
|
||||||
uint8_t turn;
|
uint8_t turn;
|
||||||
bool contrattack;
|
bool counterattack;
|
||||||
|
|
||||||
public:
|
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);
|
DefendTown(const CGTownInstance * town, const HitMapInfo & treat, const CGHeroInstance * defender);
|
||||||
|
|
||||||
virtual bool operator==(const DefendTown & other) const override;
|
virtual bool operator==(const DefendTown & other) const override;
|
||||||
@ -39,7 +39,7 @@ namespace Goals
|
|||||||
|
|
||||||
uint8_t getTurn() const { return turn; }
|
uint8_t getTurn() const { return turn; }
|
||||||
|
|
||||||
bool isContrAttack() { return contrattack; }
|
bool isCounterAttack() { return counterattack; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user