1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

NKAI: more fixes to defense and pandora

This commit is contained in:
Andrii Danylchenko 2023-03-13 19:58:44 +02:00
parent 519513e512
commit 88fb532d90
5 changed files with 11 additions and 7 deletions

View File

@ -70,7 +70,7 @@ void DangerHitMapAnalyzer::updateHitMap()
auto turn = path.turn();
auto & node = hitMap[pos.x][pos.y][pos.z];
if(tileDanger > node.maximumDanger.danger
if(tileDanger / (turn + 1) > node.maximumDanger.danger / (node.maximumDanger.turn + 1)
|| (tileDanger == node.maximumDanger.danger && node.maximumDanger.turn > turn))
{
node.maximumDanger.danger = tileDanger;

View File

@ -30,7 +30,7 @@ namespace NKAI
extern boost::thread_specific_ptr<CCallback> cb;
extern boost::thread_specific_ptr<AIGateway> ai;
const double TREAT_IGNORE_RATIO = 0.5;
const float TREAT_IGNORE_RATIO = 2;
using namespace Goals;
@ -133,7 +133,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
tasks.push_back(Goals::sptr(composition));
}
bool treatIsWeak = path.getHeroStrength() / treat.danger > TREAT_IGNORE_RATIO;
bool treatIsWeak = path.getHeroStrength() / (float)treat.danger > TREAT_IGNORE_RATIO;
bool needToSaveGrowth = treat.turn == 0 && dayOfWeek == 7;
if(treatIsWeak && !needToSaveGrowth)

View File

@ -130,8 +130,6 @@ ui64 FuzzyHelper::evaluateDanger(const CGObjectInstance * obj)
return danger;
}
case Obj::PANDORAS_BOX:
return 10000; //Who knows what awaits us there
case Obj::ARTIFACT:
case Obj::RESOURCE:
@ -148,6 +146,7 @@ ui64 FuzzyHelper::evaluateDanger(const CGObjectInstance * obj)
case Obj::CREATURE_GENERATOR4:
case Obj::MINE:
case Obj::ABANDONED_MINE:
case Obj::PANDORAS_BOX:
{
const CArmedInstance * a = dynamic_cast<const CArmedInstance *>(obj);
return a->getArmyStrength();

View File

@ -781,9 +781,11 @@ public:
if(garrisonHero && swapCommand.getLockingReason() == HeroLockedReason::DEFENCE)
{
auto defenderRole = evaluationContext.evaluator.ai->heroManager->getHeroRole(garrisonHero);
auto mpLeft = garrisonHero->movement / (float)garrisonHero->maxMovePoints(true);
evaluationContext.movementCost += garrisonHero->movement;
evaluationContext.movementCostByRole[defenderRole] += garrisonHero->movement;
evaluationContext.movementCost += mpLeft;
evaluationContext.movementCostByRole[defenderRole] += mpLeft;
evaluationContext.heroRole = defenderRole;
}
}
};

View File

@ -191,7 +191,10 @@ RuleBlock: gold reward
rule: if armyReward is LOW and heroRole is MAIN and danger is NONE and mainTurnDistance is LOWEST then Value is HIGH
rule: if skillReward is LOW and heroRole is MAIN and armyLoss is LOW then Value is BITHIGH
rule: if skillReward is MEDIUM and heroRole is MAIN and armyLoss is LOW and fear is not HIGH then Value is BITHIGH
rule: if skillReward is MEDIUM and heroRole is MAIN and rewardType is MIXED and armyLoss is LOW and fear is not HIGH then Value is HIGH with 0.5
rule: if skillReward is HIGH and heroRole is MAIN and armyLoss is LOW and fear is not HIGH then Value is HIGH
rule: if skillReward is MEDIUM and heroRole is SCOUT then Value is LOWEST
rule: if skillReward is HIGH and heroRole is SCOUT then Value is LOWEST
rule: if strategicalValue is LOW and heroRole is MAIN and armyLoss is LOW then Value is BITHIGH
rule: if strategicalValue is LOWEST and heroRole is MAIN and armyLoss is LOW then Value is LOW
rule: if strategicalValue is LOW and heroRole is SCOUT and armyLoss is LOW and fear is not HIGH then Value is HIGH with 0.5