00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020
00021 #pragma warning(disable:4786) //get rid of MSVC++ warning about long names for STL
00022
00023 #ifndef AILOGIC_H
00024 #define AILOGIC_H
00025
00026 #include "AIFSM.h"
00027 #include "AIKB.h"
00028
00029 extern AIKB global_kb;
00030
00035 class AILogic {
00036 struct AIRule {
00037 std::vector<AIPremise> theantecedents;
00038 std::vector<int> num_of_params_in_antecs_to_check;
00039 int consequentstateinput;
00040 std::vector<int> timesfound;
00041 std::vector<bool> accept_only_new_since_state_change;
00042 std::vector<float> secondsold;
00043 std::vector<AIPremise> consekbprems;
00044 std::vector<AIPremise> remkbprems;
00045 std::vector<bool> remall;
00046
00047 int serialize(std::ofstream& fout_) const;
00048 int assemble(std::ifstream& fin_);
00049 };
00050
00051 AI_LOGIC_IDS LOGICID;
00052 std::vector<AIRule> therules;
00053 int rulesmax;
00054 public:
00060 AILogic(AI_LOGIC_IDS LOGICID_, const int rulesmax_=-1);
00061
00065 AI_LOGIC_IDS getLOGICID() const { return LOGICID; }
00066
00079 bool createDerivationRule(std::vector<AIPremise> theantecedents_,
00080 std::vector<int> num_of_params_in_antecs_to_check_, int consequentstateinput_,
00081 std::vector<int> timesfound_=std::vector<int>(),
00082 std::vector<bool> accept_only_new_since_state_change_=std::vector<bool>(),
00083 std::vector<float> secondsold_=std::vector<float>(),
00084 std::vector<AIPremise> consekbprems_=std::vector<AIPremise>(),
00085 std::vector<AIPremise> remkbprems_=std::vector<AIPremise>(),
00086 std::vector<bool> remall_=std::vector<bool>());
00087
00096 bool performLogic(AIState*& state_, AIKB*& kb_, AIFSM*& fsm_, float& timestamp_, bool includeglobalkb_=false);
00097
00103 int serialize(std::ofstream& fout_) const;
00104
00110 int assemble(std::ifstream& fin_);
00111 };
00112
00116 namespace AIFileIO {
00123 template <>
00124 int serialize(std::ofstream& fout_, const std::vector<AILogic::AIRule>& ruleVector_);
00125
00132 template <>
00133 int assemble(std::ifstream& fin_, std::vector<AILogic::AIRule>& ruleVector_);
00134 }
00135
00136 #endif //AILOGIC_H