Jump to content

April 2017 »

23 242526272829
- - - - -

My Study on Fuzzy Logic

fuzzy logic ai artificial intelligence
4: Adsense

So, someone recently (perhaps accidentally) introduced me to the term "fuzzy logic," and this is what I have been looking for! I am having a sort of hard time wrapping my head around how it works exactly, because I have only been using Boolean logic. However, since I am new to programming, I am not set in my ways, so I can retrain myself easier.

And I am very glad that I was introduced to this sooner than later. Right now I have been trying to implement fuzzy logic, but I quickly found myself reverting back to Boolean logic, or using some sort of probability. I just found the perfect documentation of fuzzy logic, and I am going to read this first. I will update my findings here, for anyone who might be interested.


Apr 19 2014 11:18 AM
I finally have some progress on getting to implementing this fuzzy logic. I had to find a formula for getting the degree of membership of a single value (non-fuzzy) easily.


on a scale of 10 to 100 where 10 is cold and 100 is hot:

55 degrees is given as degree .5 in the set.

That means it is halfway between the minimum temperature and the maximum temperature.

If the word "warm was given the range of 60 to 100 degrees, then the membeship of warm is given as:


This means that all values greater than .55 and less than 1 are considered warm.

In reality, I would use temperatures 75-85.
Apr 19 2014 01:05 PM

I finally have an implementation that can fuzzify a range of values from a minimum number to a maximum number as a string. For this example I used the Codea app on the iPad.

-- Fuzzy logic


--draw a horizontal line from minimum to maximum, and make the "value" a point on the line, lifted "degree" units up from te line.
--This will look like a triangle

function setup()
   x1 = x
   y1 = y
   x2 = x + value
   y2 = x2 

  function fuzzify(min,max,condition) 
       if value > min and value < max then
           return condition

function draw()
   membership = (value-min)/(max-min) 
   stroke(210, 255, 0, 255)


It also prints the value of the membership of the chosen value (not quite as a fuzzy member... yet.)

Apr 20 2014 09:52 AM

Okay, I am coming up with so many examples of how fuzzy logic can be used:

These prices are ridiculous!:

Today I was looking at the prices on a menu and I said to myself "These prices are getting ridiculous!"

What I was really saying is that "The prices are getting closer to my idea of a high price."

For a rich person, they might not be so ridiculous, but to me (a poor person), they are indeed ridiculous.

If I considred my idea of a ridiculous price for a burger to be 7 dollars, then is a burger that is 6.99 not ridiculous?

Instead, I would consider my idea of ridiculous to be in the range (5,8), with the epitamy of ridiculous being at 7. All else above 8 is still ridiculous, and not even worth mentioning. Or it might fall into another set "insanely ridiculous."

All numbers lower than the min might be classified a something else, same for all numbers above.

The couch is too close to the wall!

What this means is that the distance from the couch to the wall is less than a distance you presume to be "a good distance from the couch to the wall."

You are driving too fast!:

A range of values greater than 7 above the speed limit might be considered fast on a normal road, but on the highway, it depends on the flow of traffic, where even 10 above the speed limit would be considered a little slow.

That gun is dangerous!:

This means that the gun has the potential to decrease your health severely. If perfect health is 100% healthy, then perhaps a gun could do -85% to -100% damage to your health, whereas something that is not as dangerous would do perhaps -10%--20% to your health.

You cut the apple crookedly:

This means that the angle at which you cut the apple is not perpendicular to the surface you are cutting the apple on. But such a cut is impossible anyhow, so it really means that the angle at which you cut the apple is not "close to perpendicular" to the surface you are cutting the apple on. This angle could range from an offset of 90 plus or minus 5 degrees. (85,95).

Apr 27 2014 02:01 PM

I have found my first good use for fuzzy logic after looking at a few videos on Problem solving. A really good use for fuzzy logic is in Value Analysis. The following link is a very good video on value analysis, however, it's demonstration on how value is found is not a solid method. He uses words like "good" and "bad" and gives each word a value range, but he doesn't account for the degrees of "goodness" or "badness" which would present more accurate information. Anyhow, this is the video:


May 04 2014 07:09 PM

Hmm, looks like this form of logic is going to come in handy sooner than I thought. I am trying to do weather, and someone was using finite state machine and probability percentage to try to do it. In this case, fuzzy logic would be much better suited. 



Mar 26 2015 12:28 PM

So, I might have not had to discover the "fuzzy formula" on my own if I knew the keywords were Data Normalization and Standardization:



Note: GameDev.net moderates comments.