Home | nevrax.com |
|
fuzzytype.cppGo to the documentation of this file.00001 00007 /* Copyright, 2000 Nevrax Ltd. 00008 * 00009 * This file is part of NEVRAX NEL. 00010 * NEVRAX NEL is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2, or (at your option) 00013 * any later version. 00014 00015 * NEVRAX NEL is distributed in the hope that it will be useful, but 00016 * WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * General Public License for more details. 00019 00020 * You should have received a copy of the GNU General Public License 00021 * along with NEVRAX NEL; see the file COPYING. If not, write to the 00022 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 00023 * MA 02111-1307, USA. 00024 */ 00025 00026 #include "nel/ai/fuzzy/fuzzytype.h" 00027 00028 namespace NLAIFUZZY 00029 { 00030 using namespace NLAILOGIC; 00031 00032 const NLAIC::IBasicType *FuzzyType::clone() const 00033 { 00034 NLAIC::IBasicInterface *m = new FuzzyType(*this); 00035 return m; 00036 } 00037 00038 const NLAIC::IBasicType *FuzzyType::newInstance() const 00039 { 00040 return clone(); 00041 } 00042 00043 void FuzzyType::save(NLMISC::IStream &os) 00044 { 00045 IBaseBoolType::save(os); 00046 double v = _Value; 00047 os.serial( v ); 00048 v = _Threshold; 00049 os.serial( v ); 00050 } 00051 00052 void FuzzyType::load(NLMISC::IStream &is) 00053 { 00054 IBaseBoolType::load(is); 00055 is.serial(_Value); 00056 is.serial(_Threshold); 00057 } 00058 00059 void FuzzyType::getDebugString(std::string &text) const 00060 { 00061 text += NLAIC::stringGetBuild("FuzzyType<%d>",_Value); 00062 } 00063 00064 bool FuzzyType::isTrue() const 00065 { 00066 return ( _Value >= _Threshold ) ; 00067 } 00068 00069 float FuzzyType::truthValue() const 00070 { 00071 return _Value; 00072 } 00073 00074 const NLAIAGENT::IVarName * FuzzyType::getName() const 00075 { 00076 return NULL; 00077 } 00078 00079 void FuzzyType::setName(const NLAIAGENT::IVarName &n) 00080 { 00081 } 00082 00083 const NLAIAGENT::IObjectIA::CProcessResult &FuzzyType::run() 00084 { 00085 return NLAIAGENT::IObjectIA::ProcessRun; 00086 } 00087 00088 bool FuzzyType::isEqual(const FuzzyType &a) const 00089 { 00090 return ( a._Value == _Value ); 00091 } 00092 00093 bool FuzzyType::isEqual(const NLAIAGENT::IBasicObjectIA &a) const 00094 { 00095 return ( ((FuzzyType &)a)._Value == _Value ); 00096 } 00097 00098 std::vector<IBaseVar *> *FuzzyType::getVars() 00099 { 00100 return new std::vector<IBaseVar *>; 00101 } 00102 00103 const NLAIC::CIdentType &FuzzyType::getType() const 00104 { 00105 return IdFuzzyType; 00106 } 00107 00108 NLAIAGENT::IObjetOp &FuzzyType::operator += (const NLAIAGENT::IObjetOp &a) 00109 { 00110 _Value += ((FuzzyType &)a)._Value; 00111 return ( *this ); 00112 } 00113 00114 NLAIAGENT::IObjetOp &FuzzyType::operator -= (const NLAIAGENT::IObjetOp &a) 00115 { 00116 _Value -= ((FuzzyType &)a)._Value; 00117 return ( *this ); 00118 } 00119 00120 NLAIAGENT::IObjetOp &FuzzyType::operator *= (const NLAIAGENT::IObjetOp &a) 00121 { 00122 _Value *= ((FuzzyType &)a)._Value; 00123 return ( *this ); 00124 } 00125 00126 NLAIAGENT::IObjetOp *FuzzyType::operator < (NLAIAGENT::IObjetOp &a) const 00127 { 00128 return new CBoolType( _Value < ((FuzzyType &)a)._Value ); 00129 } 00130 00131 NLAIAGENT::IObjetOp *FuzzyType::operator > (NLAIAGENT::IObjetOp &a) const 00132 { 00133 return new CBoolType( _Value > ((FuzzyType &)a)._Value ); 00134 } 00135 00136 NLAIAGENT::IObjetOp *FuzzyType::operator <= (NLAIAGENT::IObjetOp &a) const 00137 { 00138 return new CBoolType( _Value <= ((FuzzyType &)a)._Value ); 00139 } 00140 00141 NLAIAGENT::IObjetOp *FuzzyType::operator >= (NLAIAGENT::IObjetOp &a) const 00142 { 00143 return new CBoolType( _Value >= ((FuzzyType &)a)._Value ); 00144 } 00145 00146 NLAIAGENT::IObjetOp *FuzzyType::operator ! () const 00147 { 00148 return new CBoolType( !_Value ); 00149 } 00150 00151 NLAIAGENT::IObjetOp *FuzzyType::operator != (NLAIAGENT::IObjetOp &a) const 00152 { 00153 return new CBoolType( _Value != ((FuzzyType &)a)._Value ); 00154 } 00155 00156 NLAIAGENT::IObjetOp *FuzzyType::operator == (NLAIAGENT::IObjetOp &a) const 00157 { 00158 return new CBoolType( _Value == ((FuzzyType &)a)._Value ); 00159 } 00160 00161 } |