Przeglądaj źródła

Style, commend - requested

Tomasz Zieliński 3 lat temu
rodzic
commit
40585a66c0

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

@@ -299,7 +299,13 @@ float RewardEvaluator::getEnemyHeroStrategicalValue(const CGHeroInstance * enemy
 		vstd::amax(objectValue, getStrategicalValue(obj));
 	}
 
-	//AI should absolutely prioritize killing enemy heroes, even scouts
+	/*
+	  1. If an enemy hero can attack nearby object, it's not useful to capture the object on our own.
+	  Killing the hero is almost as important (0.9) as capturing the object itself.
+
+	  2. The formula quickly approaches 1.0 as hero level increases,
+	  but higher level always means higher value and the minimal value for level 1 hero is 0.5
+	*/
 	return std::min(1.0f, objectValue * 0.9f + (1.0f - (1.0f / (1 + enemy->level))));
 }
 

+ 1 - 4
server/CGameHandler.cpp

@@ -5583,10 +5583,7 @@ bool CGameHandler::isAllowedExchange(ObjectInstanceID id1, ObjectInstanceID id2)
 			auto topArmy = dialog->exchangingArmies.at(0);
 			auto bottomArmy = dialog->exchangingArmies.at(1);
 
-			if (topArmy == o1 && bottomArmy == o2)
-				return true;
-
-			if (bottomArmy == o1 && topArmy == o2)
+			if (topArmy == o1 && bottomArmy == o2 || bottomArmy == o1 && topArmy == o2)
 				return true;
 		}
 	}