2012-07-01 02:48:40 +03:00
|
|
|
#pragma once
|
2014-09-02 16:29:28 +03:00
|
|
|
#include "fl/Headers.h"
|
2013-11-25 14:55:48 +03:00
|
|
|
#include "Goals.h"
|
2012-03-03 13:08:01 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Fuzzy.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
class VCAI;
|
2012-03-04 13:43:46 +03:00
|
|
|
class CArmedInstance;
|
2014-06-22 13:39:40 +03:00
|
|
|
class CBank;
|
2015-08-31 08:25:33 +02:00
|
|
|
class SectorMap;
|
2012-03-03 13:08:01 +03:00
|
|
|
|
2014-12-19 11:52:41 +02:00
|
|
|
class engineBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
fl::Engine engine;
|
|
|
|
fl::RuleBlock rules;
|
|
|
|
|
|
|
|
engineBase();
|
|
|
|
void configure();
|
|
|
|
void addRule(const std::string &txt);
|
|
|
|
};
|
|
|
|
|
2012-03-03 13:08:01 +03:00
|
|
|
class FuzzyHelper
|
|
|
|
{
|
|
|
|
friend class VCAI;
|
|
|
|
|
2014-12-19 11:52:41 +02:00
|
|
|
class TacticalAdvantage : public engineBase
|
2013-12-20 12:43:12 +03:00
|
|
|
{
|
|
|
|
public:
|
2014-10-25 16:51:53 +03:00
|
|
|
fl::InputVariable * ourWalkers, * ourShooters, * ourFlyers, * enemyWalkers, * enemyShooters, * enemyFlyers;
|
|
|
|
fl::InputVariable * ourSpeed, * enemySpeed;
|
|
|
|
fl::InputVariable * bankPresent;
|
|
|
|
fl::InputVariable * castleWalls;
|
|
|
|
fl::OutputVariable * threat;
|
2013-12-20 12:43:12 +03:00
|
|
|
~TacticalAdvantage();
|
|
|
|
} ta;
|
|
|
|
|
2014-12-19 11:52:41 +02:00
|
|
|
class EvalVisitTile : public engineBase
|
2013-12-20 12:43:12 +03:00
|
|
|
{
|
|
|
|
public:
|
2014-10-25 16:51:53 +03:00
|
|
|
fl::InputVariable * strengthRatio;
|
|
|
|
fl::InputVariable * heroStrength;
|
|
|
|
fl::InputVariable * turnDistance;
|
|
|
|
fl::InputVariable * missionImportance;
|
|
|
|
fl::OutputVariable * value;
|
2013-12-20 12:43:12 +03:00
|
|
|
fl::RuleBlock rules;
|
|
|
|
~EvalVisitTile();
|
|
|
|
} vt;
|
2012-03-03 13:08:01 +03:00
|
|
|
|
2015-08-31 08:25:33 +02:00
|
|
|
std::map <HeroPtr, SectorMap> cachedSectorMaps;
|
|
|
|
|
2012-03-03 13:08:01 +03:00
|
|
|
public:
|
2014-02-05 21:45:51 +03:00
|
|
|
enum RuleBlocks {BANK_DANGER, TACTICAL_ADVANTAGE, VISIT_TILE};
|
|
|
|
//blocks should be initialized in this order, which may be confusing :/
|
2012-03-04 13:43:46 +03:00
|
|
|
|
2012-03-03 13:08:01 +03:00
|
|
|
FuzzyHelper();
|
2012-03-04 13:43:46 +03:00
|
|
|
void initTacticalAdvantage();
|
2013-12-20 12:43:12 +03:00
|
|
|
void initVisitTile();
|
2012-03-04 13:43:46 +03:00
|
|
|
|
2013-12-19 23:21:21 +03:00
|
|
|
float evaluate (Goals::Explore & g);
|
|
|
|
float evaluate (Goals::RecruitHero & g);
|
|
|
|
float evaluate (Goals::VisitTile & g);
|
|
|
|
float evaluate (Goals::VisitHero & g);
|
|
|
|
float evaluate (Goals::BuildThis & g);
|
|
|
|
float evaluate (Goals::DigAtTile & g);
|
|
|
|
float evaluate (Goals::CollectRes & g);
|
|
|
|
float evaluate (Goals::Build & g);
|
2014-02-07 23:09:15 +03:00
|
|
|
float evaluate (Goals::GatherArmy & g);
|
2014-02-20 23:18:49 +03:00
|
|
|
float evaluate (Goals::ClearWayTo & g);
|
2013-12-19 23:21:21 +03:00
|
|
|
float evaluate (Goals::Invalid & g);
|
|
|
|
float evaluate (Goals::AbstractGoal & g);
|
2013-12-27 16:20:40 +03:00
|
|
|
void setPriority (Goals::TSubgoal & g);
|
2013-12-19 23:21:21 +03:00
|
|
|
|
2014-06-22 13:39:40 +03:00
|
|
|
ui64 estimateBankDanger (const CBank * bank);
|
2012-03-04 13:43:46 +03:00
|
|
|
float getTacticalAdvantage (const CArmedInstance *we, const CArmedInstance *enemy); //returns factor how many times enemy is stronger than us
|
2013-11-24 11:21:51 +03:00
|
|
|
|
2013-12-20 16:07:58 +03:00
|
|
|
Goals::TSubgoal chooseSolution (Goals::TGoalVec vec);
|
2013-11-24 11:21:51 +03:00
|
|
|
//shared_ptr<AbstractGoal> chooseSolution (std::vector<shared_ptr<AbstractGoal>> & vec);
|
2015-08-31 08:25:33 +02:00
|
|
|
|
|
|
|
//optimization - use one SM for every hero call
|
|
|
|
SectorMap& getCachedSectorMap (HeroPtr h);
|
2012-03-05 16:31:59 +03:00
|
|
|
};
|