1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Remember "best" placement at right moment.

This commit is contained in:
DjWarmonger 2014-12-22 21:47:19 +01:00
parent 067b56dda4
commit b52eeb2263

View File

@ -203,6 +203,14 @@ void CZonePlacer::placeZones(const CMapGenOptions * mapGenOptions, CRandomGenera
}
}
logGlobal->traceStream() << boost::format("Total distance between zones in this iteration: %2.2f, Worst distance/movement ratio: %3.2f") % totalDistance % maxRatio;
//save best solution before drastic jump
if (totalDistance < bestTotalDistance)
{
bestTotalDistance = totalDistance;
for (auto zone : zones)
bestSolution[zone.second] = zone.second->getCenter();
}
if (maxRatio > 100)
{
@ -231,14 +239,6 @@ void CZonePlacer::placeZones(const CMapGenOptions * mapGenOptions, CRandomGenera
logGlobal->traceStream() << boost::format("New distance %f") % targetZone->getCenter().dist2d(distantZone->getCenter());
}
//save best solution
if (totalDistance < bestTotalDistance)
{
bestTotalDistance = totalDistance;
for (auto zone : zones)
bestSolution[zone.second] = zone.second->getCenter();
}
zoneScale *= inflateModifier; //increase size of zones so they
}
for (auto zone : zones) //finalize zone positions