﻿ Game Development

Free JavaScript Editor     Ajax Editor ﻿

Main Page

### Fuzzy Representation and Conversions

Using fuzzy set theory, it's possible to define fuzzy values that are stored in single fuzzy variables. These fuzzy variables can be combined to create a more intuitive concept known as linguistic variables.

To initialize these fuzzy values from crisp numbers, the membership function is used. Converting from crisp to fuzzy is known as fuzzification, and the opposite is known as defuzzification.

#### Fuzzy Variables and Values

A fuzzy variable can be considered as a term, associated with a single float representing a fuzzy truth value. There is nothing complex about this intrinsically; it's just a symbol/number pair. For example, the variables shown in Table 30.1 might represent an enemy in a deathmatch.

##### Table 30.1. Collection of Fuzzy Variables, Each Assigned a Particular Value to Represent an Enemy

Term

Value

Healthy

0.9

Dangerous

0.3

Moving

0.0

These variables are conceptually independent from each other. To give each concept a more intuitive definition, fuzzy variables can be combined.

#### Linguistic Variables

Linguistic variables are a more sophisticated representation, and prove more humanlike. They harness the power of fuzzy logic to model real concepts without being limited to one fuzzy variable, or tied to the precision of crisp variables.

A linguistic variable is a high-level concept, such as health (see Table 30.2). However, instead of being associated with only one fuzzy variable, it corresponds to a collection of them—each a symbol/real number pair. Each symbol is known as a term; the group of fuzzy terms is known as the term set.

##### Table 30.2. A Linguistic Variable Representing the Concept of Allegiance

Term set

{enemy,neutral,friendly}

Values

[0.0, 0.4, 0.9]

These fuzzy variables are used in conjunction with each other to express the linguistic variable. Taken alone, they do not have the same meaning.

The linguistic variable is defined over base variables. The base variables correspond to the set of values over which the terms are defined. Base variables can correspond to continuous crisp values and fuzzy terms (see Figure 30.4).

##### Figure 30.4. The linguistic variable allegiance defined as a collection of membership functions defined over a single base variable (love).

The terms appear as fuzzy sets. Some terms have modifiers attached to them, others remain without modifiers; these are know as primary terms.

#### Fuzzification

Fuzzification is the process of creating a fuzzy variable from a crisp value. This is done by using fuzzy sets. The membership function defines the value of a fuzzy variable, as shown in Figure 30.5. The universe of discourse is in fact the range of the crisp value. Evaluating the membership function in terms of this crisp value results in the degree of membership.

##### Figure 30.5. Using the membership function to determine a fuzzy value in terms of a crisp value in the universe of discourse.

Naturally, the speed of the fuzzification depends entirely upon the efficiency of the membership function. For simple functions, it's faster to evaluate it dynamically with a native implementation. Using more complex membership functions may warrant the use of lookup tables to speed up the process.

#### Defuzzification

The process of defuzzification aims to do the exact opposite of fuzzification: convert a fuzzy value to a crisp value. This is relatively straightforward for atomic fuzzy values, but can get trickier for linguistic variables. The problem is to find a single crisp value for a concept expressed as a set of fuzzy values.

This process fundamentally involves the loss of information; only in the simplest case can the conversion process be lossless (although not all techniques exhibit this property). Each method will therefore have its own set of assumptions and flaws. It's also the case that different approaches to defuzzification are appropriate for certain types of problems (see Figure 30.6). There is no unique equation, because even humans defuzzify linguistic concepts in problem-dependent ways.

##### Figure 30.6. The fuzzy sets are used to determine the crisp value in terms of the fuzzy values.

There are two major approaches to defuzzification:

• Maximum approaches use the highest points in the membership function. The first of maxima approach essentially picks the crisp value corresponding to the highest point of all the membership functions. Average of maxima instead uses the average of all the crisp values. Sometimes, this average is weighted by the degree of membership.

• Centroid requires computing the area covered by the membership function. The crisp value can correspond to the center of gravity of the entire fuzzy set, or to the average of the center of each area. Such approaches are computationally intense, because they either rely on heavy analysis or mathematical knowledge of the integral of the membership function (to find the area).

When simple atomic sets are used as the fuzzy sets, the maximum approach works just fine. It's simple to implement, and faster by an order of magnitude. Indeed, we don't even need to compute the maxima, because we often know it (used to define the membership function). Centroid methods can be seen as more mathematically correct, but this seems out of place compared to the informal nature of fuzzy reasoning.

﻿

Ajax Editor     JavaScript Editor