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

Best result so far

This commit is contained in:
Tomasz Zieliński 2024-03-20 08:36:02 +01:00
parent 3e959f3ad9
commit 1546a221d1
2 changed files with 27 additions and 4 deletions

View File

@ -239,7 +239,8 @@ void Zone::fractalize()
//Squared
float minDistance = 9 * 9;
float freeDistance = pos.z ? (10 * 10) : 6 * 6;
//float freeDistance = pos.z ? (10 * 10) : 6 * 6;
float freeDistance = pos.z ? (10 * 10) : (9 * 9);
float spanFactor = (pos.z ? 0.3f : 0.45f); //Narrower passages in the Underground
float marginFactor = 1.0f;
@ -258,10 +259,22 @@ void Zone::fractalize()
}
else //Scale with treasure density
{
/*
if (treasureValue > 400)
{
// A quater at max density
// A quater at max density - means more free space
marginFactor = (0.25f + ((std::max(0, (600 - treasureValue))) / (600.f - 400)) * 0.75f);
}
*/
if (treasureValue > 250)
{
// A quater at max density - means more free space
marginFactor = (0.5f + ((std::max(0, (600 - treasureValue))) / (600.f - 250)) * 0.5f);
// Add more empty space to treasure zones
spanFactor *= (0.5f + ((std::max(0, (600 - treasureValue))) / (600.f - 250)) * 0.5f);
}
else if (treasureValue < 100)
{
@ -334,7 +347,7 @@ void Zone::fractalize()
}
Lock lock(areaMutex);
//cut straight paths towards the center. A* is too slow for that.
//Connect with free areas
auto areas = connectedAreas(clearedTiles, false);
for(auto & area : areas)
{

View File

@ -887,7 +887,10 @@ void TreasurePlacer::createTreasures(ObjectManager& manager)
}
//this is squared distance for optimization purposes
const float minDistance = std::max<float>((125.f / totalDensity), 1.0f);
//const float minDistance = std::max<float>((125.f / totalDensity), 1.0f);
//Integer dvision - round down
const float minDistance = std::max<float>((125 / totalDensity), 1.0f);
size_t emergencyLoopFinish = 0;
while(treasures.size() < count && emergencyLoopFinish < count)
@ -926,6 +929,9 @@ void TreasurePlacer::createTreasures(ObjectManager& manager)
}
}
const size_t numberToPlace = treasures.size();
size_t placedTreasures = 0;
for (auto& rmgObject : treasures)
{
const bool guarded = rmgObject.isGuarded();
@ -971,6 +977,8 @@ void TreasurePlacer::createTreasures(ObjectManager& manager)
if (path.valid())
{
placedTreasures++;
/*
//debug purposes
treasureArea.unite(rmgObject.getArea());
if (guarded)
@ -980,10 +988,12 @@ void TreasurePlacer::createTreasures(ObjectManager& manager)
auto areaToBlock = rmgObject.getAccessibleArea(true) - guardedArea;
treasureBlockArea.unite(areaToBlock);
}
*/
zone.connectPath(path);
manager.placeObject(rmgObject, guarded, true);
}
}
logGlobal->trace("Zone %d: Placed %d out of %d treasures with average value %f", zone.getId(), placedTreasures, numberToPlace,averageValue);
}
}