diff --git a/AI/GeniusAI/ExpertSystem.cpp b/AI/GeniusAI/ExpertSystem.cpp index 40403dcee..23d6420c1 100644 --- a/AI/GeniusAI/ExpertSystem.cpp +++ b/AI/GeniusAI/ExpertSystem.cpp @@ -1,5 +1,6 @@ #include "GeneralAI.h" #include "../../CCallback.h" +#include "ExpertSystem.h" /* * ExpertSystem.cpp, part of VCMI engine @@ -11,3 +12,15 @@ * */ +template void ExpertSystemShell::DataDrivenReasoning(runType type) +{ + switch (type) + { + case ANY_GOAL: //first produced decision ends reasoning + { + for (std::list::iterator it = factList.begin(); it != factList.end(); it++) + {}; + } + break; + } +} \ No newline at end of file diff --git a/AI/GeniusAI/ExpertSystem.h b/AI/GeniusAI/ExpertSystem.h index 2a532f7f8..a4207123d 100644 --- a/AI/GeniusAI/ExpertSystem.h +++ b/AI/GeniusAI/ExpertSystem.h @@ -1,6 +1,7 @@ #include "../vcmi/global.h" #include "../vcmi/CCallback.h" -#include "HeroBonus.h" +#include "../vcmi/lib/HeroBonus.h" +#include #include /* @@ -12,19 +13,33 @@ * Full text of license available in license.txt file, in main folder * */ +struct Bonus; +template class Rule; +typedef Rule BRule; template class ExpertSystemShell { + enum runType {ANY_GOAL, TRESHOLD, FULL}; private: ICallback* m_cb; protected: - template std::set knowledge; + std::set knowledge; + ui16 goalCounter; //count / evaluate achieved goals for runType public: - template std::set facts; + ExpertSystemShell(){goalCounter = 0;}; + std::list factList; template void getKnowledge(const t1 &a1){}; template void getNextRule(){}; template void returnGoals(const t2 &a2){}; + virtual void DataDrivenReasoning(runType type); +}; +template class Blackboard : public ExpertSystemShell +//handle Bonus info coming from different sections of the game +{ +public: + Blackboard(){this->goalCounter = 0;}; + std::vector experts; //modules responsible for different tasks }; template class condition @@ -36,34 +51,37 @@ public: conditionType conType; }; -template class Rule +template class Rule { -friend class ExpertSystemShell; +friend class ExpertSystemShell ; public: - fired; //if conditions of rule were met and it produces some output + bool fired; //if conditions of rule were met and it produces some output protected: - std::set conditions; + std::set conditions; + output decision; virtual void canBeFired(); //if this data makes any sense for rule virtual void fireRule(); public: - template bool matchesInput() //if condition and data match type - {return dynamic_cast(givenInput);}; + template bool matchesInput() //if condition and data match type + {return dynamic_cast(&givenInput);}; }; -template class Goal : public Rule +template class Goal : public Rule { +protected: + boost::function decision(); //do something with AI eventually public: - void fireTule(){}; + void fireRule(){}; }; -template class Weight : public Rule +template class Weight : public Rule { public: float value; //multiply input by value and return to output void fireTule(){}; }; -template class BonusSystemExpert : public ExpertSystemShell -{ +class BonusSystemExpert : public ExpertSystemShell +{ //TODO: less templates? enum effectType {POSITIVE=1, NEGATIVE=2, EXCLUDING=4, ENEMY=8, ALLY=16}; //what is the influencce of bonus and for who }; \ No newline at end of file