0 Favourites

# [Plugin] Fuzzy

• 15 posts
• Fuzzy

(Update: 2013/05/18)

This plugin need to understand what is fuzzy, sorry I could not explain too much.

"Fuzzy logic is a form of many-valued logic or probabilistic logic; it deals with reasoning that is approximate rather than fixed and exact."

Anyway, it is used in some AI cases.

Exampe, using fuzzy logic to simulate the behavior of fish.

• touch screen to put feed

Capx

Basic example of this sim-fish.

• Edit the value of each input parameter, then press "execute" to see the value of outputs.

Capx

The steps of using this fuzzy plugin are -

1. Define memberships. This plugin provide 3 kinds of levels (3,5,7).

2. Define fuzzy logic (rule). Put memberships for parameters of this action. For example,

• "-hp" = N(negative) membership of variable of "hp"
• "hp" = ZO(zero) membership of variable of "hp"
• "+hp" = P(Positive) membership of variable of "hp"

And expression:AND/OR/NOT for and/or/not logic.

<img src="http://i1081.photobucket.com/albums/j352/rexrainbow1/screen_zpsefa8bf92.png" border="0">

"-hp" : blue

"hp": green

"+hp" : red

3. Set input variables by "action:Set variable value"

4. Run rules by "action:Execute rules"

5. Then the grade of each rule could be picked by "expression:OutputGrade" , user could pick the rule with maximum degree by "expression:MaxOutput".

(In sim-fish example, I use "expression:MaxOutput" to be the command of the fish)

----

Dependency of sim-fish capx

[Plugin]

timeline

[Behavior]

timer

fps monitor

• Do you read minds? I was literally going to start working on a fish simulator today, and now a ton of the work is already started and functional. Thank you!

• damn!

• The plug-in Sounds great, but can you check the download links for the samples, they seem to be broken...

• hello, I'm back again...

I don't understand what the method "add rule" means... I know it's a logic, but I don't know the two parameters of it( Rule, Expression).

Such as this rule: Add rule "eat" <- Fuzzy.AND("stomach",Fuzzy.OR("hp","-hp"))

"eat" is a rule and "<- Fuzzy.AND("stomach",Fuzzy.OR("hp","-hp"))" is a expression.

Both Fuzzy.AND(...) and Fuzzy.OR(...) return a value, right? But who receives this value? Is it "eat"? Is "eat" a variable, too? ...

I'm completely confused...

• Fuzzy.AND(...) or Fuzzy.OR(...) will return a string (a rule) which is an expression about how to calculate the output variable (the rule name is also an output value).

In these expressions,

• an AND operation is to get the minimum value, an OR operation is to get the maximum value
• the expression "-hp"/"hp"/"+hp" is the degree (the value is 0~1) mapping from input value. The mapping rules is defined at "action:define membership" , shown as first post.
• oh!~I see..."eat" is both a rule name and a output value !!! THX!!! <img src="smileys/smiley12.gif" border="0" align="middle" />

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Update

• Wow.... I had some hard time understanding how it worked, mostly because I didn't know how to use fuzzy logic.

Great plugin !

EDIT :

oh!~I see..."eat" is both a rule name and a output value !!! THX!!! <img src="smileys/smiley12.gif" border="0" align="middle" />

The output values seems to be directly the fuzzy evaluation of the rules of the same name, with the parameters applied.

The only thing I don't understand now is how you mix multiple rules in 1 output. Do you sum the different output of the rules (could be logic as each rules correspond to P,Zo or N of a value, could be complementary), or ponderate each output value to calculate the final output ? Maybe the max of every rule ?

For example, if I take the "eat" rules :

• if the stomach is positive, always want to eat
• if the stomach is neutral, want to eat if hp is neutral or negative
• if the stomach is negative, want to eat only if hp is negative too

So in this case, if the stomach is 30% positive and 70% neutral, you should ponderate the result of the 2 first rules by their respective %, am I wrong ? (this question is more about checking I understand your plugin right)

Last thing, could we, in this same example, mix all 3 rules in a "Fuzzy.OR" statement ? Something like

OR(

"+Stomach",

AND("stomach",OR("hp","-hp")),

AND("-stomach","-hp")

)

(Just realised this last question is basicaly the same as the previous one...)

• I also try to understand this kind of logic (c'est malin !)

helps a lot.

• ``````OR(
"+Stomach",
AND("stomach",OR("hp","-hp")),
AND("-stomach","-hp")
)``````

is ok.

Actually, the OR operation is max , AND operation is min in this plugin.

To mix multiple rules in 1 output, it uses OR operation.

• Input a color at left-up textbox
• Then the grade of these 27 sample color will be shown at left side of each sample.
• I’m learning fuzzy logic and I found your plugin very interesting. I’m currently trying to work with it and understand it. I have a question to see if I’m getting it right.

Let’s suppose we have this Relationships between “100-point scale marks and fuzzy membership functions” in the URL bellow page 4.

I’m supposing we are going to use membership with 3 levels (In this case Excellent won’t be taken into consideration)

If I want to define the membership in construct 2 using your plugin, will it be like this:

Define membership “marks”: P to “0, 60, 65”, S to “60, 65, 75, 80”, G to “75, 80, 85, 90”