Tricks of the Windows Game Programming Gurus:Making Silicon Think with Artificial Intelligence

All ITKnowledge Source Code Search Tips Advanced Search |

| Tricks of the Windows Game Programming Gurus by Andre LaMothe Sams, Macmillan Computer Publishing ISBN: 0672313618 Pub Date: 09/27/99

Search this book:

Previous | Table of Contents | Next

### Fuzzy Logic

Fuzzy logic is the last technology I’m going to cover and perhaps one of the most interesting. It has to do with making deductions about the fuzzy set theory. In other words, fuzzy logic is a method of analyzing sets of data such that the elements of the sets can have partial inclusion. Most people are used to crisp logic, where something is either included or not. For example, if I created the sets child and adult, I would fall into the adult category and my three-year-old nephew would be part of the child category. That’s crisp logic.

Fuzzy logic, on the other hand, allows objects to be contained within a set even if they aren’t totally in the set. For example, I might say that I’m 10% part of the child set and 100% part of the adult set. Similarly, my nephew might be 2% part of the adult set and 100% part of the child set. These are fuzzy values. Also, you’ll notice that they don’t have to add up to 100%—they can be more or less—because they don’t represent probabilities, but rather inclusion in different classes. However, the probabilities of an event or state in different classes still must add up to 1.0.

The cool thing about fuzzy logic is that it enables you to make decisions based on fuzzy or error-ridden data that are usually correct. You can’t do this with a crisp logic system: If you’re missing a variable or input, it won’t work. But a fuzzy logic system can still function well with missing variables, just like a human brain. I mean, how many decisions do you make each day that feel fuzzy to you? You don’t have all the facts, but you’re still fairly confident about the decisions.

That’s the two-cent tour of fuzzy logic. Its applications to AI in the areas of decision making, behavioral selections, and input/output filtering should be obvious. With that in mind, let’s take a look at the various ways fuzzy logic is implemented and used.

#### Normal Set Theory

A normal set is simply a collection of objects. To write a set, use a capital letter to represent it and then place the elements contained in it between braces, separated by commas. Sets can consist of anything: names, numbers, colors, whatever. Figure 12.35 illustrates a number of normal sets.

Figure 12.35 Some simple sets.

For example, set A = {3,4,5,20} and set B = {1,3,9}. There are many operations that you can perform on these sets:

Math Usually a slash (`/`) or prime (`'`) symbol means `NOT` or complement, invert, etc.

  Element of (ε)—When talking about a set, you might want to know if an object is contained within the set. This is called set inclusion. Hence, if you wrote “is 3 ε A,” or “is 3 an element of A,” that would be true. But “2 ε B” is not.
  Union ()—This operator takes all the objects that exist in both sets and adds them into a new set. If an object appears in both sets initially, it is only added to the new set once. As a result, A ε B = {1,3,4,5,9,20}.
  Intersection (∩)—This operator takes only the objects that the two sets have in common. Therefore, A ∩ B = {3}.
  Subset of (∴)—Sometimes you want to know if one set is wholly contained in another. This is called set inclusion or subset of. Therefore, {1,3} ∴ B, which reads “the set {1,3} is a subset of B.” However, A ⊄ B, which reads “A is not a subset of B.”

Okay, that’s a little set theory for you. Nothing complicated, just some terminology and symbols. Everyone works with set theory every day; they just don’t know it. The one thing I want you to get from this section is that normal sets are exact. It’s either a fruit or it’s not. Either 5 is in the set or it’s not. This is not the case with fuzzy theory.

#### Fuzzy Set Theory

The problem with computers is that they’re exact machines, yet we continually use them to solve inexact or fuzzy problems—or at least we try to. In the ’70s, computer scientists started applying a technique of mathematics called fuzzy logic, or uncertainty logic, to software programming and problem solving. The fuzzy logic that we’re talking about here is really the application of fuzzy set theory and its properties. Let’s take a look at the fuzzy set theory version of everything you just learned about with normal set theory.

With fuzzy set theory, you don’t focus so much on the objects in the set anymore; the objects are in the set, but you focus on the degree of membership a particular object has within a certain class. For example, let’s create a fuzzy class or category called Computer Special FX. Then take a few of your favorite movies (mine, at least) and estimate how much each of them fits in this fuzzy class. See Table 12.4.

Table 12.4 Degree of Membership for Computer Special FX class

Movie | Degree of Membership in Class
--- | ---

Antz | 100%
Forrest Gump | 20%
The Terminator | 75%
Aliens | 50%
The Matrix | 90%

Do you see how fuzzy all this is? Although The Matrix had some really killer computer-generated effects, the entire movie Antz was computer-generated, so I have to be fair. However, do you agree with all these percentages? Antz is totally computer-generated and is an hour and 20 minutes, and Forrest Gump has only five minutes total of computer-enhanced imagery. Is it fair to rate Gump at 20 percent? I don’t know. That’s why we’re using fuzzy logic.

Previous | Table of Contents | Next

Copyright © Macmillan Computer Publishing, Inc.

Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.