1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

- Implemented serialization of Goals. Loaded games work, at least.

- Attempts to add Subterranean Gates to SectorMap
- Extensive use of ClearWayTo goal.
This commit is contained in:
DjWarmonger
2014-02-20 20:18:49 +00:00
parent 8a9f2781c2
commit b0b0249524
6 changed files with 164 additions and 85 deletions

View File

@@ -480,6 +480,32 @@ float FuzzyHelper::evaluate (Goals::GatherArmy & g)
float army = g.hero->getArmyStrength();
return g.value / std::max(g.value - army, 1000.0f);
}
float FuzzyHelper::evaluate (Goals::ClearWayTo & g)
{
if (!g.hero.h)
throw cannotFulfillGoalException("ClearWayTo called without hero!");
SectorMap sm(g.hero);
int3 t = sm.firstTileToGet(g.hero, g.tile);
if (t.valid())
{
if (isSafeToVisit(g.hero, t))
{
g.setpriority(Goals::VisitTile(g.tile).sethero(g.hero).setisAbstract(g.isAbstract).accept(this));
}
else
{
g.setpriority (Goals::GatherArmy(evaluateDanger(t, g.hero.h)*SAFE_ATTACK_CONSTANT).
sethero(g.hero).setisAbstract(true).accept(this));
}
return g.priority;
}
else
return -1;
}
float FuzzyHelper::evaluate (Goals::BuildThis & g)
{
return 1;