mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
Rewrite / update terms for TacticalAdvantage.
This commit is contained in:
parent
9ca991282a
commit
6463c33c26
@ -157,33 +157,23 @@ void FuzzyHelper::initTacticalAdvantage()
|
||||
val->addTerm(new fl::Ramp("LOW", 6.5, 3));
|
||||
val->addTerm(new fl::Triangle("MEDIUM", 5.5, 10.5));
|
||||
val->addTerm(new fl::Ramp("HIGH", 8.5, 16));
|
||||
val->setRange(3.0, 16.0);
|
||||
val->setRange(0, 25);
|
||||
}
|
||||
|
||||
ta.castleWalls = new fl::InputVariable("CastleWalls");
|
||||
engine.addInputVariable(ta.castleWalls);
|
||||
{
|
||||
fl::Rectangle* none = new fl::Rectangle("NONE",
|
||||
CGTownInstance::NONE - 5.0 * fl::fuzzylite::macheps(),
|
||||
CGTownInstance::NONE + 5.0 * fl::fuzzylite::macheps());
|
||||
fl::Rectangle* none = new fl::Rectangle("NONE", CGTownInstance::NONE, CGTownInstance::NONE + (CGTownInstance::FORT - CGTownInstance::NONE) * 0.5f);
|
||||
ta.castleWalls->addTerm(none);
|
||||
|
||||
fl::scalar a = CGTownInstance::FORT, d = 2.5;
|
||||
fl::scalar b = a + (d - a) * 1.0 / 5.0;
|
||||
fl::scalar c = a + (d - a) * 4.0 / 5.0;
|
||||
fl::Trapezoid* medium = new fl::Trapezoid("MEDIUM", a, b, c, d);
|
||||
fl::Trapezoid* medium = new fl::Trapezoid("MEDIUM", (CGTownInstance::FORT - CGTownInstance::NONE) * 0.5f, CGTownInstance::FORT,
|
||||
CGTownInstance::CITADEL, CGTownInstance::CITADEL + (CGTownInstance::CASTLE - CGTownInstance::CITADEL) * 0.5f);
|
||||
ta.castleWalls->addTerm(medium);
|
||||
|
||||
fl::Ramp* high = new fl::Ramp("HIGH", CGTownInstance::CITADEL - 0.1, CGTownInstance::CASTLE);
|
||||
ta.castleWalls->addTerm(high);
|
||||
|
||||
ta.castleWalls->setRange(
|
||||
std::min({none->getStart(),none->getEnd(),
|
||||
medium->getVertexA(), medium->getVertexD(),
|
||||
high->getStart(), high->getEnd()}),
|
||||
std::max({none->getStart(),none->getEnd(),
|
||||
medium->getVertexA(), medium->getVertexD(),
|
||||
high->getStart(), high->getEnd()}));
|
||||
ta.castleWalls->setRange(CGTownInstance::NONE, CGTownInstance::CASTLE);
|
||||
}
|
||||
|
||||
|
||||
@ -191,17 +181,11 @@ void FuzzyHelper::initTacticalAdvantage()
|
||||
ta.bankPresent = new fl::InputVariable("Bank");
|
||||
engine.addInputVariable(ta.bankPresent);
|
||||
{
|
||||
fl::Rectangle* termFalse = new fl::Rectangle("FALSE", 0.0 - 5.0 * fl::fuzzylite::macheps(),
|
||||
0.0 + 5.0 * fl::fuzzylite::macheps());
|
||||
fl::Rectangle* termFalse = new fl::Rectangle("FALSE", 0.0, 0.5f);
|
||||
ta.bankPresent->addTerm(termFalse);
|
||||
fl::Rectangle* termTrue = new fl::Rectangle("TRUE", 1.0 - 5.0 * fl::fuzzylite::macheps(),
|
||||
0.0 + 5.0 * fl::fuzzylite::macheps());
|
||||
fl::Rectangle* termTrue = new fl::Rectangle("TRUE", 0.5f, 1);
|
||||
ta.bankPresent->addTerm(termTrue);
|
||||
ta.bankPresent->setRange(
|
||||
std::min({termFalse->getStart(),termFalse->getEnd(),
|
||||
termTrue->getStart(), termTrue->getEnd()}),
|
||||
std::max({termFalse->getStart(),termFalse->getEnd(),
|
||||
termTrue->getStart(), termTrue->getEnd()}));
|
||||
ta.bankPresent->setRange(0, 1);
|
||||
}
|
||||
|
||||
ta.threat = new fl::OutputVariable("Threat");
|
||||
@ -254,17 +238,14 @@ ui64 FuzzyHelper::estimateBankDanger (const CBank * bank)
|
||||
bank1->setVertexA(info->maxGuards().totalStrength * 0.5f);
|
||||
bank1->setVertexC(info->maxGuards().totalStrength * 1.5f);
|
||||
|
||||
fl::scalar min = std::min(
|
||||
{bank0->getVertexA(), bank0->getVertexC(),
|
||||
bank1->getVertexA(), bank1->getVertexC()});
|
||||
fl::scalar max = std::max(
|
||||
{bank0->getVertexA(), bank0->getVertexC(),
|
||||
bank1->getVertexA(), bank1->getVertexC()});
|
||||
|
||||
if (fl::Op::isLt(min, bankDanger->getMinimum())){
|
||||
fl::scalar min = std::min({bank0->getVertexA(), bank0->getVertexC(), bank1->getVertexA(), bank1->getVertexC()});
|
||||
fl::scalar max = std::max({bank0->getVertexA(), bank0->getVertexC(), bank1->getVertexA(), bank1->getVertexC()});
|
||||
if (fl::Op::isLt(min, bankDanger->getMinimum()))
|
||||
{
|
||||
bankDanger->setMinimum(min);
|
||||
}
|
||||
if (fl::Op::isGt(max, bankDanger->getMaximum())){
|
||||
if (fl::Op::isGt(max, bankDanger->getMaximum()))
|
||||
{
|
||||
bankDanger->setMaximum(max);
|
||||
}
|
||||
}
|
||||
@ -394,7 +375,6 @@ void FuzzyHelper::initVisitTile()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
vt.strengthRatio = new fl::InputVariable("strengthRatio"); //hero must be strong enough to defeat guards
|
||||
vt.heroStrength = new fl::InputVariable("heroStrength"); //we want to use weakest possible hero
|
||||
vt.turnDistance = new fl::InputVariable("turnDistance"); //we want to use hero who is near
|
||||
@ -412,13 +392,13 @@ void FuzzyHelper::initVisitTile()
|
||||
|
||||
vt.strengthRatio->addTerm(new fl::Ramp("LOW", SAFE_ATTACK_CONSTANT, 0));
|
||||
vt.strengthRatio->addTerm(new fl::Ramp("HIGH", SAFE_ATTACK_CONSTANT, SAFE_ATTACK_CONSTANT * 3));
|
||||
vt.strengthRatio->setRange(0,SAFE_ATTACK_CONSTANT * 3 );
|
||||
vt.strengthRatio->setRange(0, SAFE_ATTACK_CONSTANT * 3 );
|
||||
|
||||
//strength compared to our main hero
|
||||
vt.heroStrength->addTerm(new fl::Ramp("LOW", 0.2, 0));
|
||||
vt.heroStrength->addTerm(new fl::Triangle("MEDIUM", 0.2, 0.8));
|
||||
vt.heroStrength->addTerm(new fl::Ramp("HIGH", 0.5, 1));
|
||||
vt.heroStrength->setRange(0.0,1.0);
|
||||
vt.heroStrength->setRange(0.0, 1.0);
|
||||
|
||||
vt.turnDistance->addTerm(new fl::Ramp("SMALL", 0.5, 0));
|
||||
vt.turnDistance->addTerm(new fl::Triangle("MEDIUM", 0.1, 0.8));
|
||||
|
Loading…
Reference in New Issue
Block a user