Pergunta

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.

Foi útil?

Solução

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';
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top