1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-15 20:03:15 +02:00

Simplified target function comparison.

This commit is contained in:
Tomasz Zieliński
2023-04-10 17:59:59 +02:00
parent 164ecaea60
commit 809f6344ff

View File

@@ -445,15 +445,10 @@ void CZonePlacer::placeZones(CRandomGenerator * rand)
//check fitness function //check fitness function
bool improvement = false; bool improvement = false;
if (bestTotalDistance > 0 && bestTotalOverlap > 0) if ((totalDistance + 1) * (totalOverlap + 1) < (bestTotalDistance + 1) * (bestTotalOverlap + 1))
{ {
if (totalDistance * totalOverlap < bestTotalDistance * bestTotalOverlap) //multiplication is better for auto-scaling, but stops working if one factor is 0 //multiplication is better for auto-scaling, but stops working if one factor is 0
improvement = true; improvement = true;
}
else
{
if (totalDistance + totalOverlap < bestTotalDistance + bestTotalOverlap)
improvement = true;
} }
logGlobal->trace("Total distance between zones after this iteration: %2.4f, Total overlap: %2.4f, Improved: %s", totalDistance, totalOverlap , improvement); logGlobal->trace("Total distance between zones after this iteration: %2.4f, Total overlap: %2.4f, Improved: %s", totalDistance, totalOverlap , improvement);