1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-17 01:32:21 +02:00

Road exploration

The non-cheating-AI on 100% and below is now smarter about exploration and will explore alongside roads with higher priority.
This commit is contained in:
Xilmi
2024-10-20 23:32:39 +02:00
parent 3a8a67407b
commit d93c6211da
2 changed files with 18 additions and 1 deletions

View File

@ -15,6 +15,8 @@
#include "../../../lib/mapObjectConstructors/CObjectClassesHandler.h"
#include "../../../lib/mapObjectConstructors/CBankInstanceConstructor.h"
#include "../../../lib/mapObjects/MapObjects.h"
#include "../../../lib/mapping/CMapDefines.h"
#include "../../../lib/RoadHandler.h"
#include "../../../lib/CCreatureHandler.h"
#include "../../../lib/VCMI_Lib.h"
#include "../../../lib/StartInfo.h"
@ -901,6 +903,8 @@ public:
break;
}
}
if(evaluationContext.evaluator.ai->cb->getTile(task->tile)->roadType && evaluationContext.evaluator.ai->cb->getTile(task->tile)->roadType->getId() != RoadId::NO_ROAD)
evaluationContext.explorePriority = 1;
if (evaluationContext.explorePriority == 0)
evaluationContext.explorePriority = 3;
}
@ -1408,7 +1412,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
return 0;
if (arriveNextWeek && evaluationContext.isEnemy)
return 0;
if (evaluationContext.conquestValue > 0 || evaluationContext.explorePriority == 1)
if (evaluationContext.conquestValue > 0)
score = 1000;
if (vstd::isAlmostZero(score) || (evaluationContext.enemyHeroDangerRatio > 1 && (evaluationContext.turn > 0 || evaluationContext.isExchange) && !ai->cb->getTownsInfo().empty()))
return 0;
@ -1419,6 +1423,18 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
score /= evaluationContext.movementCost;
break;
}
case PriorityTier::HIGH_PRIO_EXPLORE:
{
if (evaluationContext.enemyHeroDangerRatio > 1)
return 0;
if (evaluationContext.explorePriority != 1)
return 0;
score = 1000;
score *= evaluationContext.closestWayRatio;
if (evaluationContext.movementCost > 0)
score /= evaluationContext.movementCost;
break;
}
case PriorityTier::HUNTER_GATHER: //Collect guarded stuff
{
if (evaluationContext.enemyHeroDangerRatio > 1 && !evaluationContext.isDefend)

View File

@ -114,6 +114,7 @@ public:
INSTAKILL,
INSTADEFEND,
KILL,
HIGH_PRIO_EXPLORE,
HUNTER_GATHER,
LOW_PRIO_EXPLORE,
DEFEND