使用 php 等语言创建模糊函数

发布于 2025-01-05 06:39:59 字数 128 浏览 0 评论 0原文

我应该通过 php 实现一个模糊函数。问题是我不知道如何创建它,我在网上查找但没有找到任何东西。现在我希望你能帮我告诉我如何创建 php 模糊函数的拼写错误。每个函数都能顺利进行。这对我来说将是理解一般模型,并使我了解如何为自己创建模糊函数。

I should implement a fuzzy function through php. the problem it is I haven't any idea how create it and I looked for in the web and I didn't found anything.Now I would your help to say me how I could create a typos of php fuzzy function. Every function could go well.It will be to understand for me the general model and make me an idea in how I create fuzzy function to myself.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ㄟ。诗瑗 2025-01-12 06:39:59

取决于你怎么称呼模糊函数,但是
模糊逻辑基本上可以转化为一组此类 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';
}

Depends on what do you call a fuzzy functions, but
Basically fuzzy logic translates into a set of IF conditions of this kind:

Let's suppose we want to write fuzzy logic rules for a video game monster. We decide to start with two variables: hit points (HP) and firepower (FP). We might start with this:

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';
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文