From 0ef10855555c7fd184509a657a1925d1e2da6acd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Tue, 6 Mar 2012 16:28:32 +0000 Subject: [PATCH] Changes around FuzzyLite library based on patch by q4a. http://forum.vcmi.eu/viewtopic.php?p=6592#6592 --- AI/FuzzyLite/FuzzyLite.vcxproj | 192 +++++++++++++++++++++++++++++++++ AI/FuzzyLite/defs.h | 23 ++++ AI/FuzzyLite/test.cpp | 36 +++++-- AI/VCAI/Fuzzy.cpp | 29 ----- AI/VCAI/Fuzzy.h | 22 ---- AI/VCAI/VCAI.vcxproj | 18 ++-- VCMI_VS10.sln | 8 ++ 7 files changed, 259 insertions(+), 69 deletions(-) create mode 100644 AI/FuzzyLite/FuzzyLite.vcxproj diff --git a/AI/FuzzyLite/FuzzyLite.vcxproj b/AI/FuzzyLite/FuzzyLite.vcxproj new file mode 100644 index 000000000..172d4f6b3 --- /dev/null +++ b/AI/FuzzyLite/FuzzyLite.vcxproj @@ -0,0 +1,192 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + RD + Win32 + + + RD + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {D15B34EC-A32C-4968-9B0B-66998B579364} + FuzzyLite + + + + StaticLibrary + true + MultiByte + + + DynamicLibrary + true + MultiByte + + + DynamicLibrary + false + true + MultiByte + + + DynamicLibrary + false + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + $(SolutionDir)\AI\ + $(IncludePath) + $(LibraryPath) + + + $(SolutionDir)\AI\ + $(IncludePath) + $(LibraryPath) + + + $(SolutionDir)$(Configuration)\bin\AI\ + $(IncludePath) + $(LibraryPath) + + + $(SolutionDir)$(Configuration)\bin\AI\ + $(IncludePath) + $(LibraryPath) + + + + Level3 + Disabled + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + + + true + %(AdditionalDependencies) + $(OutDir)..;%(AdditionalLibraryDirectories) + $(OutDir)FuzzyLite.dll + + + + + Level3 + Disabled + %(AdditionalIncludeDirectories) + + + true + %(AdditionalDependencies) + $(OutDir)..;%(AdditionalLibraryDirectories) + $(OutDir)FuzzyLite.dll + + + + + Level3 + MaxSpeed + true + true + %(AdditionalIncludeDirectories) + + + true + true + true + %(AdditionalDependencies) + $(OutDir)..;%(AdditionalLibraryDirectories) + $(OutDir)FuzzyLite.dll + + + + + Level3 + MaxSpeed + true + true + %(AdditionalIncludeDirectories) + + + true + true + true + %(AdditionalDependencies) + $(OutDir)..;%(AdditionalLibraryDirectories) + $(OutDir)FuzzyLite.dll + + + + + + \ No newline at end of file diff --git a/AI/FuzzyLite/defs.h b/AI/FuzzyLite/defs.h index f1c2516b2..68f2c7096 100644 --- a/AI/FuzzyLite/defs.h +++ b/AI/FuzzyLite/defs.h @@ -22,6 +22,29 @@ #ifndef FL_DEFS_H #define FL_DEFS_H +#ifndef NAN + static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff}; + #define NAN (*(const float *) __nan) +#endif + +#ifdef _MSC_VER + #ifndef INFINITY + union MSVC_FL + { + unsigned __int8 Bytes[4]; + float Value; + }; + static union MSVC_FL INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}}; + #define INFINITY (INFINITY_HACK.Value) + #endif + #define isnan(x) ((x) != (x)) + template bool isinf (T val) + { + return val == INFINITY || val == -INFINITY; + } + //#include //nees for S +#endif + #include #include #include diff --git a/AI/FuzzyLite/test.cpp b/AI/FuzzyLite/test.cpp index be3a266ad..5b7422215 100644 --- a/AI/FuzzyLite/test.cpp +++ b/AI/FuzzyLite/test.cpp @@ -232,24 +232,36 @@ namespace fl { } void Test::main(int args, char** argv) { - FL_LOG("Starting in 2 second"); - FL_LOG("Example: Simple Mamdani"); - FL_LOG("======================="); - sleep(2); - SimpleMamdani(); - FL_LOG("=======================\n"); + FL_LOG("Starting in 2 second"); + FL_LOG("Example: Simple Mamdani"); + FL_LOG("======================="); +#ifdef _MSC_VER + //Sleep(2); +#else + sleep(2); +#endif + SimpleMamdani(); + FL_LOG("=======================\n"); - FL_LOG("Starting in 2 second"); - FL_LOG("Example: Complex Mamdani"); - FL_LOG("========================"); - sleep(2); + FL_LOG("Starting in 2 second"); + FL_LOG("Example: Complex Mamdani"); + FL_LOG("========================"); +#ifdef _MSC_VER + //Sleep(2); +#else + sleep(2); +#endif ComplexMamdani(); FL_LOG("=======================\n"); FL_LOG("Starting in 2 second"); FL_LOG("Example: Simple Pendulum"); FL_LOG("========================"); +#ifdef _MSC_VER + //Sleep(2); +#else sleep(2); +#endif SimplePendulum(); FL_LOG("=======================\n"); @@ -257,7 +269,11 @@ namespace fl { FL_LOG("Starting in 2 second"); FL_LOG("Example: Simple Takagi-Sugeno"); FL_LOG("========================"); +#ifdef _MSC_VER + //Sleep(2); +#else sleep(2); +#endif SimpleTakagiSugeno(); FL_LOG("=======================\n"); diff --git a/AI/VCAI/Fuzzy.cpp b/AI/VCAI/Fuzzy.cpp index 6f6321512..a66446488 100644 --- a/AI/VCAI/Fuzzy.cpp +++ b/AI/VCAI/Fuzzy.cpp @@ -1,35 +1,6 @@ #include "StdInc.h" #include "Fuzzy.h" #include "../../lib/CObjectHandler.h" -#include "../FuzzyLite/AreaCentroidAlgorithm.cpp" -#include "../FuzzyLite/CompoundTerm.cpp" -#include "../FuzzyLite/DescriptiveAntecedent.cpp" -#include "../FuzzyLite/FuzzyEngine.cpp" -#include "../FuzzyLite/FuzzyAnd.cpp" -#include "../FuzzyLite/FuzzyOr.cpp" -#include "../FuzzyLite/InputLVar.cpp" -#include "../FuzzyLite/OutputLVar.cpp" -#include "../FuzzyLite/FuzzyAntecedent.cpp" -#include "../FuzzyLite/FuzzyConsequent.cpp" -#include "../FuzzyLite/FuzzyDefuzzifier.cpp" -#include "../FuzzyLite/FuzzyModulation.cpp" -#include "../FuzzyLite/FuzzyOperator.cpp" -#include "../FuzzyLite/FuzzyOperation.cpp" -#include "../FuzzyLite/FuzzyException.cpp" -#include "../FuzzyLite/FuzzyExceptions.cpp" -#include "../FuzzyLite/FuzzyRule.cpp" -#include "../FuzzyLite/HedgeSet.cpp" -#include "../FuzzyLite/Hedge.cpp" -#include "../FuzzyLite/SingletonTerm.cpp" -#include "../FuzzyLite/TrapezoidalTerm.cpp" -#include "../FuzzyLite/TriangularTerm.cpp" -#include "../FuzzyLite/LinguisticTerm.cpp" -#include "../FuzzyLite/LinguisticVariable.cpp" -#include "../FuzzyLite/RuleBlock.cpp" -#include "../FuzzyLite/ShoulderTerm.cpp" -#include "../FuzzyLite/StrOp.cpp" -#include "../FuzzyLite/MamdaniRule.cpp" -#include "../FuzzyLite/MamdaniConsequent.cpp" /* * Fuzzy.cpp, part of VCMI engine diff --git a/AI/VCAI/Fuzzy.h b/AI/VCAI/Fuzzy.h index 3da8e6f45..fa2f37128 100644 --- a/AI/VCAI/Fuzzy.h +++ b/AI/VCAI/Fuzzy.h @@ -1,20 +1,3 @@ -#ifndef NAN - static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff}; - #define NAN (*(const float *) __nan) -#endif - -#ifdef _MSC_VER - #ifndef INFINITY - union MSVC_FL - { - unsigned __int8 Bytes[4]; - float Value; - }; - static union MSVC_FL INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}}; - #define INFINITY (INFINITY_HACK.Value) - #endif -#endif - #include "../FuzzyLite/FuzzyLite.h" /* @@ -30,11 +13,6 @@ class VCAI; class CArmedInstance; -template bool isinf (T val) -{ - return val == INFINITY || val == -INFINITY; -} - class FuzzyHelper { friend class VCAI; diff --git a/AI/VCAI/VCAI.vcxproj b/AI/VCAI/VCAI.vcxproj index 64113a680..8ec1111f3 100644 --- a/AI/VCAI/VCAI.vcxproj +++ b/AI/VCAI/VCAI.vcxproj @@ -97,8 +97,8 @@ true - VCMI_lib.lib;%(AdditionalDependencies) - $(OutDir)..;%(AdditionalLibraryDirectories) + VCMI_lib.lib;FuzzyLite.lib;%(AdditionalDependencies) + $(OutDir)..;$(OutDir);%(AdditionalLibraryDirectories) $(OutDir)VCAI.dll @@ -114,8 +114,8 @@ true - VCMI_lib.lib;%(AdditionalDependencies) - $(OutDir)..;%(AdditionalLibraryDirectories) + VCMI_lib.lib;FuzzyLite.lib;%(AdditionalDependencies) + $(OutDir)..;$(OutDir);%(AdditionalLibraryDirectories) $(OutDir)VCAI.dll @@ -135,8 +135,8 @@ true true true - VCMI_lib.lib;%(AdditionalDependencies) - $(OutDir)..;%(AdditionalLibraryDirectories) + VCMI_lib.lib;FuzzyLite.lib;%(AdditionalDependencies) + $(OutDir)..;$(OutDir);%(AdditionalLibraryDirectories) $(OutDir)VCAI.dll @@ -156,12 +156,13 @@ true true true - VCMI_lib.lib;%(AdditionalDependencies) - $(OutDir)..;%(AdditionalLibraryDirectories) + VCMI_lib.lib;FuzzyLite.lib;%(AdditionalDependencies) + $(OutDir)..;$(OutDir);%(AdditionalLibraryDirectories) $(OutDir)StupidAI.dll + Create @@ -172,6 +173,7 @@ + diff --git a/VCMI_VS10.sln b/VCMI_VS10.sln index 7e150ae66..43311ffea 100644 --- a/VCMI_VS10.sln +++ b/VCMI_VS10.sln @@ -19,6 +19,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ERM", "Scripting\ERM\ERM.vc EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VCAI", "AI\VCAI\VCAI.vcxproj", "{276C3DB0-7A6B-4417-8E5C-322B08633AAC}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FuzzyLite", "AI\FuzzyLite\FuzzyLite.vcxproj", "{D15B34EC-A32C-4968-9B0B-66998B579364}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -73,6 +75,12 @@ Global {276C3DB0-7A6B-4417-8E5C-322B08633AAC}.RD|Win32.ActiveCfg = RD|Win32 {276C3DB0-7A6B-4417-8E5C-322B08633AAC}.RD|Win32.Build.0 = RD|Win32 {276C3DB0-7A6B-4417-8E5C-322B08633AAC}.RD|x64.ActiveCfg = RD|Win32 + {D15B34EC-A32C-4968-9B0B-66998B579364}.Debug|Win32.ActiveCfg = Debug|Win32 + {D15B34EC-A32C-4968-9B0B-66998B579364}.Debug|Win32.Build.0 = Debug|Win32 + {D15B34EC-A32C-4968-9B0B-66998B579364}.Debug|x64.ActiveCfg = Debug|Win32 + {D15B34EC-A32C-4968-9B0B-66998B579364}.RD|Win32.ActiveCfg = RD|Win32 + {D15B34EC-A32C-4968-9B0B-66998B579364}.RD|Win32.Build.0 = RD|Win32 + {D15B34EC-A32C-4968-9B0B-66998B579364}.RD|x64.ActiveCfg = RD|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE