Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

AILogic.h

00001 
00002 //      Copyright (C) 2004 Dylan Blair
00003 //
00004 //      email: dblair@alumni.cs.utexas.edu
00005 //
00006 //      This library is free software; you can redistribute it and/or
00007 //      modify it under the terms of the GNU Lesser General Public
00008 //      License as published by the Free Software Foundation; either
00009 //      version 2.1 of the License, or (at your option) any later version.
00010 //
00011 //      This library is distributed in the hope that it will be useful,
00012 //      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 //      Lesser General Public License for more details.
00015 //
00016 //      You should have received a copy of the GNU Lesser General Public
00017 //      License along with this library; if not, write to the Free Software
00018 //      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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

Generated on Sun Apr 11 05:05:56 2004 for FSM_API by doxygen 1.3.6