Game Development Reference
In-Depth Information
degree of membership equal to a linearly interpolated value between those cutoffs.
This value can be expressed as follows:
degree of membership = (inputValue - lowCutoff) / (highCutoff - lowCutoff)
This formula will give you the degree of membership in the close set. Subtract this
number from 1 to get the degree of membership in the far set.
There are other fuzzification methods, of course. You could apply a logarithmic curve
or Gaussian curve (aka bell curve). Nothing says that your degree of membership
values need to add up to 1, although it is typically best that they do. It makes the
math a bit easier, as you
'
ll see below.
Defuzzification is a bit trickier. There is rarely a direct mapping from the degree of
membership to a useful value. For example, if the player is behind cover by 0.6 and
exposed by 0.4, what is the correct behavior? We could just generate a random num-
ber and choose to throw the grenade 60% of the time. This works for extremely small
fuzzy sets, but what happens when we ' re trying to take into account multiple sets?
For example,
re using fuzzy logic to model the personality. The AI
belongs to the aggressive set by 0.4 and the cautious set by 0.6. If the AI is cautious
and the player is behind cover, toss a grenade. Is this AI cautious? Do we just ran-
domly decide if this AI is cautious for this particular decision?
One way of solving this problem is to use the highest degree of membership. In this
cause, the AI would be considered cautious because he belongs to that set more than
the opposing aggressive set. He would also consider the player to be within cover.
This is certainly simple, but it just masks the same problems we had in the first
place with the AI being too predictable.
If the result you
let
'
s say we
'
re looking for is a number, a blended approach becomes very useful.
How long the AI will take aim can be directly determined by its degree of member-
ship in the cautious set as well as its degree of membership in the behind cover set.
You could blend these two together, normalize the results, and then apply that as a
multiplier to the maximum time an AI will take to aim. This approach allows the AI
to easily take into account both its own cautious nature and how deep within cover
the player is.
For Boolean results, a cutoff is typically determined. If you belong to a set by more
than the cutoff value, the Boolean value is true . Otherwise, it is false .
The real power of fuzzy logic comes from being able to write logical sentences. You
use logical sentences every day, such as this one:
'
if (distance < 20 and health > 1) then Attack() end
Search WWH ::




Custom Search