1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

Preparations for merge

No longer using FuzzyEngine just to create a log-message. It's now only used when isUseFuzzy is set.
Also:
Removed < operator and instead use already existing "canAfford"-Method.
This commit is contained in:
Xilmi
2024-09-05 16:22:25 +02:00
parent b32c9615ed
commit 23cd54c998
2 changed files with 29 additions and 40 deletions

View File

@@ -1328,6 +1328,8 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
double result = 0;
if (ai->settings->isUseFuzzy())
{
float fuzzyResult = 0;
try
{
@@ -1356,8 +1358,6 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
{
logAi->error("evaluate VisitTile: %s", fe.getWhat());
}
if (ai->settings->isUseFuzzy())
{
result = fuzzyResult;
}
else
@@ -1520,7 +1520,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
auto resourcesAvailable = evaluationContext.evaluator.ai->getFreeResources();
auto income = ai->buildAnalyzer->getDailyIncome();
score /= evaluationContext.buildingCost.marketValue();
if (resourcesAvailable < evaluationContext.buildingCost)
if (resourcesAvailable.canAfford(evaluationContext.buildingCost))
{
TResources needed = evaluationContext.buildingCost - resourcesAvailable;
needed.positive();

View File

@@ -189,17 +189,6 @@ public:
return this->container == rhs.container;
}
// WARNING: comparison operators are used for "can afford" relation: a <= b means that foreach i a[i] <= b[i]
// that doesn't work the other way: a > b doesn't mean that a cannot be afforded with b, it's still b can afford a
bool operator<(const ResourceSet &rhs)
{
for(int i = 0; i < size(); i++)
if (this->container.at(i) < rhs[i])
return true;
return false;
}
template <typename Handler> void serialize(Handler &h)
{
h & container;