浏览代码

Road exploration

The non-cheating-AI on 100% and below is now smarter about exploration and will explore alongside roads with higher priority.
Xilmi 1 年之前
父节点
当前提交
d93c6211da
共有 2 个文件被更改,包括 18 次插入1 次删除
  1. 17 1
      AI/Nullkiller/Engine/PriorityEvaluator.cpp
  2. 1 0
      AI/Nullkiller/Engine/PriorityEvaluator.h

+ 17 - 1
AI/Nullkiller/Engine/PriorityEvaluator.cpp

@@ -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)

+ 1 - 0
AI/Nullkiller/Engine/PriorityEvaluator.h

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