2012-03-03 10:08:01 +00: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 11:26:03 +03:00
# pragma once
# include "fl/Headers.h"
# include "Goals.h"
2012-03-03 10:08:01 +00:00
class VCAI ;
2012-03-04 10:43:46 +00:00
class CArmedInstance ;
2014-06-22 13:39:40 +03:00
class CBank ;
2016-09-08 19:58:01 +03:00
struct SectorMap ;
2012-03-03 10:08:01 +00:00
2018-08-06 19:47:08 +02:00
class engineBase //subclasses create fuzzylite variables with "new" that are not freed - this is desired as fl::Engine wants to destroy these...
2014-12-19 10:52:41 +01:00
{
2018-08-05 20:59:04 +02:00
protected :
2014-12-19 10:52:41 +01:00
fl : : Engine engine ;
fl : : RuleBlock rules ;
2018-08-05 19:03:25 +02:00
virtual void configure ( ) ;
2018-04-07 15:44:14 +07:00
void addRule ( const std : : string & txt ) ;
2018-08-05 20:59:04 +02:00
public :
engineBase ( ) ;
2014-12-19 10:52:41 +01:00
} ;
2018-08-05 19:03:25 +02:00
class TacticalAdvantageEngine : public engineBase
2018-08-04 17:36:16 +02:00
{
public :
2018-08-05 19:03:25 +02:00
TacticalAdvantageEngine ( ) ;
2018-08-05 20:30:08 +02:00
float getTacticalAdvantage ( const CArmedInstance * we , const CArmedInstance * enemy ) ; //returns factor how many times enemy is stronger than us
private :
2018-08-06 19:38:39 +02:00
fl : : InputVariable * ourWalkers , * ourShooters , * ourFlyers , * enemyWalkers , * enemyShooters , * enemyFlyers ;
fl : : InputVariable * ourSpeed , * enemySpeed ;
fl : : InputVariable * bankPresent ;
fl : : InputVariable * castleWalls ;
fl : : OutputVariable * threat ;
2018-08-04 17:36:16 +02:00
} ;
2018-08-05 20:30:08 +02:00
class HeroMovementGoalEngineBase : public engineBase //in future - maybe derive from some (GoalEngineBase : public engineBase) class for handling non-movement goals with common utility for goal engines
2018-08-04 17:36:16 +02:00
{
public :
2018-08-04 18:58:50 +02:00
HeroMovementGoalEngineBase ( ) ;
2018-08-05 20:30:08 +02:00
virtual float evaluate ( Goals : : AbstractGoal & goal ) = 0 ;
protected :
void setSharedFuzzyVariables ( Goals : : AbstractGoal & goal ) ;
2018-08-06 19:38:39 +02:00
fl : : InputVariable * strengthRatio ;
fl : : InputVariable * heroStrength ;
fl : : InputVariable * turnDistance ;
fl : : InputVariable * missionImportance ;
fl : : OutputVariable * value ;
2018-08-05 19:03:25 +02:00
2018-08-05 20:30:08 +02:00
private :
2018-08-04 18:58:50 +02:00
float calculateTurnDistanceInputValue ( const CGHeroInstance * h , int3 tile ) const ;
2018-08-04 17:36:16 +02:00
} ;
2018-08-05 19:03:25 +02:00
class VisitTileEngine : public HeroMovementGoalEngineBase
2018-08-04 17:36:16 +02:00
{
public :
2018-08-05 19:03:25 +02:00
VisitTileEngine ( ) ;
float evaluate ( Goals : : AbstractGoal & goal ) override ;
2018-08-04 17:36:16 +02:00
} ;
2018-08-05 20:30:08 +02:00
class GetObjEngine : public HeroMovementGoalEngineBase
2018-08-04 17:36:16 +02:00
{
public :
2018-08-05 20:30:08 +02:00
GetObjEngine ( ) ;
float evaluate ( Goals : : AbstractGoal & goal ) override ;
protected :
2018-08-06 19:38:39 +02:00
fl : : InputVariable * objectValue ;
2018-08-04 17:36:16 +02:00
} ;
2012-03-03 10:08:01 +00:00
class FuzzyHelper
{
friend class VCAI ;
2018-08-05 20:59:04 +02:00
public :
2018-08-05 19:03:25 +02:00
TacticalAdvantageEngine tacticalAdvantageEngine ;
VisitTileEngine visitTileEngine ;
2018-08-05 20:30:08 +02:00
GetObjEngine getObjEngine ;
2018-07-27 02:28:12 +02:00
2018-04-07 15:44:14 +07:00
float evaluate ( Goals : : Explore & g ) ;
float evaluate ( Goals : : RecruitHero & g ) ;
float evaluate ( Goals : : VisitTile & g ) ;
2018-08-05 20:30:08 +02:00
float evaluate ( Goals : : GetObj & g ) ;
2018-04-07 15:44:14 +07:00
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 ) ;
2018-07-26 12:06:55 +02:00
float evaluate ( Goals : : BuyArmy & g ) ;
2018-04-07 15:44:14 +07:00
float evaluate ( Goals : : GatherArmy & g ) ;
float evaluate ( Goals : : ClearWayTo & g ) ;
float evaluate ( Goals : : Invalid & g ) ;
float evaluate ( Goals : : AbstractGoal & g ) ;
void setPriority ( Goals : : TSubgoal & g ) ;
2013-12-19 20:21:21 +00:00
2018-08-05 19:03:25 +02:00
ui64 estimateBankDanger ( const CBank * bank ) ; //TODO: move to another class?
2013-11-24 08:21:51 +00:00
2018-04-07 15:44:14 +07:00
Goals : : TSubgoal chooseSolution ( Goals : : TGoalVec vec ) ;
2015-12-29 05:43:33 +03:00
//std::shared_ptr<AbstractGoal> chooseSolution (std::vector<std::shared_ptr<AbstractGoal>> & vec);
2012-03-05 13:31:59 +00:00
} ;