Game Development Reference

In-Depth Information

Decision trees provide a simple and compact representation of complex

Boolean functions. Once constructed, a decision tree can also be decomposed

into a set of rules. The beauty of the decision tree is that the Boolean functions

are learned from a set of complex data that could take some time for a

programmer to deconstruct manually into rules. In addition, a decision tree

can be updated as the program runs to incorporate newly learned information

that may enhance the NPC's behavior.

5.8 Fuzzy Logic

Fuzzy logic provides a way to make a decision based on vague, ambiguous,

inaccurate, and incomplete information. For example, properties such as

temperature, height, and speed are often described with terms such as
too

hot
,
very tall
, or
really slow
, respectively. On a daily basis we use these terms

to make decisions with the unspoken agreement as to the interpretation of

such vague statements. If you order a hot coffee, for example, you and the

barista have an idea for a range of temperatures that are considered hot

(for coffee).

Computers, however, only understand exact values. When you set the

temperature on an oven to cook a pie you give it an exact temperatureâ€”

you can't tell it you want the pie just
hot
. There is, however, a type of

computational logic system that interprets vague terminology by managing

the underlying exactness of the computer. It is called fuzzy logic. It is based

on the concept that properties can be described on a sliding scale.

Fuzzy logic works by applying the theory of sets to describe the range

of values that exist in vague terminologies. Classical set theory from

mathematics provides a way of specifying whether some entity is a member

of a set or not. For example, given the temperatures
a
= 36 and
b
= 34 and the

set called
Hot
, which includes all numerical values greater than 35, we could

say that
a
is a member of the set
Hot
and
b
is not.

Classical set theory draws lines between categories to produce distinct

true and false answers; for example,
b = Hot
would equate to false. Fuzzy

logic blurs the borderlines between sets (or makes them fuzzy!). Instead

of a value being a member of a set, fuzzy set theory allows for a degree

of membership.

To illustrate this,
Figure 5.16
conceptualizes the difference between

classical and fuzzy setsâ€”the difference being that values in fuzzy sets

overlap. In this example, the lower ranges of warm values are also members

of the cold set. Values in fuzzy sets are given a
degree of membership
value

that allows them to be partially in one set and partially in another. For

example, the temperature value 34 could be 20% in the cold set and 80%

in the warm set.