我应该通过php实现一个模糊函数。问题是它我不知道如何创建它我在网上寻找并且我没有找到任何东西。现在我会帮助你说我如何创建一个php模糊函数的拼写错误。每个功能都可以顺利进行。我将了解一般模型并让我了解如何为自己创建模糊函数。
答案 0 :(得分:0)
取决于你所谓的模糊函数,但是 基本上模糊逻辑转换为这种IF条件:
假设我们想为视频游戏怪物编写模糊逻辑规则。我们决定从两个变量开始:生命值(HP)和火力(FP)。我们可以从这开始:
HP/FP Very low HP Low HP Medium HP High HP Very high HP Very weak FP Retreat! Retreat! Defend Defend Attack Weak FP Retreat! Defend Defend Attack Attack Medium FP Retreat! Defend Attack Attack Full attack! High FP Retreat! Defend Attack Attack Full attack! Very high FP Defend Attack Attack Full attack! Full attack!
function fuzzy ($hp, $firepower)
{
if($hp == 'very low hp' && $firepower == 'very weak fp' ) return 'retreat';
if($hp == 'low hp' && $firepower == 'very weak fp' ) return 'retreat';
if($hp == 'high hp' && $firepower == 'very weak fp' ) return 'defend';
...
if($hp == 'high hp' && $firepower == 'very high fp' ) return 'full attack';
if($hp == 'very high hp' && $firepower == 'very high fp' ) return 'full attack';
}