# Fuzzy Logic in Games

Michael Kelly (highrisk@shellx.best.com)
Mon, 15 Apr 1996 15:52:02 +0200

Help!

I've read "Fuzzy Logic in Games" by Larry O'Brien in the April/May issue
of Game Developer magazine. I've been searching the web looking in vain
and I'm now forced to seek assistance from news-land.

First, I'm assuming you've read the article. Makes it easier for me to

In Figure 2, where did the output fuzzy set diagram (the one at the
bottom of the figure) come from? The article hints that it was derived
from the top two input graphs, but I don't understand how.

In Figure 3... Suppose I assign a value for each box, based on the two
input values for distance and strength (e.g. the top-left corner box
would be 0.28 according to the example in the article). Boxes where one
or both input values are zero would be zero, of course. How do I decide
what action to take?

For instance, suppose the inputs are 20 for distance and 4 for relative
strength. According to Figure 2, this would give PX a value of about
0.3, NR a value of about 0.6, SU a value of 1.0, DO a value of 0.3, and
all others a value of 0.0. The table in Figure 3 would have the following
values:

EN CT PX NR FR
+---------+---------+---------+---------+---------+
DM |Surrender|Surrender| Retreat |Fall Back| Hold |
| 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
+---------+---------+---------+---------+---------+
OM | Retreat |Fall Back| Hold | Hold | Hold |
| 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
+---------+---------+---------+---------+---------+
EQ | Hold | Probe | Probe | Probe | Assault |
| 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
+---------+---------+---------+---------+---------+
SU | Probe | Probe | Probe | Assault | Overrun |
| 0.0 | 0.0 | 0.3 | 0.6 | 0.0 |
+---------+---------+---------+---------+---------+
DO | Assault | Assault | Assault | Overrun | Overrun |
| 0.0 | 0.0 | 0.3 | 0.3 | 0.0 |
+---------+---------+---------+---------+---------+

Where do I go from here? If the final result of all this computation is
to take one of the actions in the table, which action do I take? I have
four rules in the table that fired, right? Do I just go with the
highest value? What if all values were equal? In my example above, it
looks like Assault would be the best choice. I decided that in my head
at a glance by adding the values together (i.e. Probe = 0.3, Overrun = 0.3,
Assault = 0.3 + 0.6 = 0.9) and taking the largest number. But again, what
if those totals are all equal?

What if I want to use the results of the above table in another fuzzy
calculation? As I understand it, I would have to already have a fuzzy
set set up. I would fill in the triangles (or trapezoids) for each of
the results (one for Probe, one for Overrun, and what, two for Assault,
or take the largest Assault value, or add them together?) and find the
centroid of the resulting polygon. What if there are two resulting
polygons? Can that happen? In the process of setting up this set,
don't I have to assign a scale and min and max values for each of my
categories (Probe, Assault, etc.)? That sounds difficult. It seems
like there would have to be a logical relation between that scale and
the input values for the table above...?

I have other questions, I think (I'm brain-fried after reading this stuff
all day), but this should be enough to show that I'm totally clueless.
```--