00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef NL_FOOPERATOR_H
00027 #define NL_FOOPERATOR_H
00028
00029 #include "nel/ai/agent/agent.h"
00030 #include "nel/ai/logic/operator.h"
00031
00032 namespace NLAILOGIC
00033 {
00034 class IBaseVar;
00035 class IBaseBoolType;
00036 class IBaseAssert;
00037 class CFactPattern;
00038 class CVarSet;
00039 class CFact;
00040 class CValueSet;
00041
00042 class CFirstOrderOperator : public IBaseOperator {
00043 protected:
00044 std::vector<IBaseVar *> _Vars;
00045 std::vector< std::vector<sint32> > _PosVarsCond;
00046 std::vector< std::vector<sint32> > _PosVarsConc;
00047
00049 void compileFactPattern (CFactPattern *, std::vector<IBaseAssert *> &, std::vector<sint32> &);
00050
00052 sint32 CFirstOrderOperator::getVarPos(IBaseVar *var);
00053 void getPosListForward(sint32, sint32, std::vector<sint32> &);
00054 void getPosListBackward(sint32, sint32, std::vector<sint32> &);
00055 void getAssertPos(IBaseAssert *, std::vector<IBaseAssert *> &, std::vector<sint32> &);
00056 CValueSet *unifyBackward(std::list<CFact *> &);
00057 CValueSet *unifyForward(std::list<CFact *> &);
00058
00059
00060 CFact *buildFromVars(IBaseAssert *, std::vector<sint32> &, CValueSet *);
00061
00063 std::list<CValueSet *> *propagate(std::list<CValueSet *> &, CValueSet *, std::vector<sint32> &);
00064
00066 CValueSet *unifyLiaison( const CValueSet *, CValueSet *, std::vector<sint32> &);
00067
00068 public:
00069 CFirstOrderOperator();
00070 CFirstOrderOperator(const CFirstOrderOperator &);
00071 ~CFirstOrderOperator();
00072
00074 std::list<CFactPattern *> *forward(CFactPattern *);
00075
00077 std::list<CFactPattern *> *backward(CFactPattern *);
00078
00080 void addPrecondition(CFactPattern *);
00081
00083 void addPostcondition(CFactPattern *);
00084
00086 std::list<CFact *> *backward(std::list<CFact *> &);
00087
00089 std::list<CFact *> *forward(std::list<CFact *> &);
00090
00092 std::list<CFact *> *propagate(std::list<CFact *> &);
00093
00094 virtual const NLAIC::IBasicType *clone() const;
00095 virtual const NLAIC::IBasicType *newInstance() const;
00096 virtual void save(NLMISC::IStream &os);
00097 virtual void load(NLMISC::IStream &is);
00098 virtual void getDebugString(std::string &) const;
00099 virtual bool isEqual(const CFirstOrderOperator &a) const;
00100 virtual const NLAIAGENT::IObjectIA::CProcessResult &run();
00101 bool isEqual(const NLAIAGENT::IBasicObjectIA &a) const;
00102 const NLAIC::CIdentType &getType() const;
00103
00104 virtual bool operator==(CFirstOrderOperator *);
00105
00106 static const NLAIC::CIdentType IdCFirstOrderOperator;
00107
00108 std::list<CFact *> *test(std::list<CFact *> &);
00109
00111 virtual bool isTrue() const;
00112 virtual float truthValue() const;
00113 virtual bool isValid(CFactBase *);
00114
00115 virtual float priority() const;
00116 virtual void success();
00117 virtual void failure();
00118 virtual void success(IBaseOperator *);
00119 virtual void failure(IBaseOperator *);
00120 };
00121 }
00122 #endif