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
|
|
|
|
*
|
|
|
|
*/
|
2017-07-13 10:26:03 +02:00
|
|
|
#pragma once
|
|
|
|
#include "fl/Headers.h"
|
|
|
|
#include "Goals.h"
|
2012-03-03 13:08:01 +03:00
|
|
|
|
|
|
|
class VCAI;
|
2012-03-04 13:43:46 +03:00
|
|
|
class CArmedInstance;
|
2014-06-22 13:39:40 +03:00
|
|
|
class CBank;
|
2016-09-08 18:58:01 +02:00
|
|
|
struct 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;
|
2017-07-15 00:15:08 +02:00
|
|
|
fl::InputVariable * estimatedReward;
|
2014-10-25 16:51:53 +03:00
|
|
|
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-10-26 17:38:17 +02:00
|
|
|
|
2015-08-31 08:25:33 +02:00
|
|
|
|
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);
|
2015-12-29 04:43:33 +02:00
|
|
|
//std::shared_ptr<AbstractGoal> chooseSolution (std::vector<std::shared_ptr<AbstractGoal>> & vec);
|
2012-03-05 16:31:59 +03:00
|
|
|
};
|