O'Reilly logo

Programming Game AI by Example by Mat Buckland

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Fuzzy Sets
Crisp sets are useful but problematic in many situations. For instance, let’s
examine the universe of discourse of all IQs, and let’s define sets for
Dumb, Average, and Clever like so:
Dumb = {70, 71, 72, … 89}
Average = {90, 91, 92, … 109}
Clever = {110, 111, 112, … 129}
A graphical way of showing these crisp sets is shown in Figure 10.3. Note
how the degree of membership of an element in any of the sets can be
either 1 or 0.
People’s intelligence can now be categorized by assigning them to one of
these sets based upon their IQ score. Clearly though, a person with an IQ of
109 is well above average intelligence and probably the majority of his
peers would categorize him as clever. He’s certainly much more intelligent
than a person who has a score of 92 even though both fall into the same
category. It’s also ridiculous to compare a person with an IQ of 79 and a
person of IQ 80 and come to the conclusion that one is dumb and the other
isn’t! This is where crisp sets fall down. Fuzzy sets allow elements to be
assigned to them to a matter of degree.
Defining Fuzzy Boundaries with Membership Functions
A fuzzy set is defined by a membership function. These functions can be
any arbitrary shape but are typically triangular or trapezoidal. Figure 10.4
shows a few examples of membership functions. Notice how they define a
gradual transition from regions completely outside the set to regions com
-
pletely within the set, thereby enabling a value to have partial membership
to a set. This is the essence of fuzzy logic.
Fuzzy Logic | 419
Fuzzy Sets
Figure 10.3
Figure 10.5 shows how the linguistic terms Dumb, Average, and Clever can
be represented as fuzzy sets comprised of triangular membership functions.
The dotted line shows how Brian, who has an IQ of 115, is a member of
two sets. His degree of membership in Clever is 0.75 and in Average is
0.25. This is consistent with how a human would reason about Brian’s
420 | Chapter 10
Fuzzy Sets
Figure 10.4. Some example membership functions. The singleton membership function
is not really fuzzy — it’s a special type of set that behaves like a discrete value. I’ve
included it here though because singletons are occasionally used in the creation of
fuzzy rules.
Figure 10.5. Dumb, Average, and Clever as fuzzy sets. The dotted line represents an
IQ of 115, and its points of intersection with the sets Clever and Average represent its
degree of membership in those sets.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required