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

No credit card required

Now all we have to do is clip the relevant member sets of the consequent to
the maximum of those values (ORing them together). This procedure and
the resulting set is shown in Figure 10.29.
Using the
MaxAv defuzzification method on this set results in a crisp
value of 57.16, a very similar result to that received from the traditional
fuzzy logic inference procedure.
Implementation
One fantastic aspect of this method is that no changes have to be made to
the fuzzy logic classes to implement it. You only have to rewrite the rules
to conform to the Combs logic. Bonus!
Ü
NOTE If you are curious about the logic behind the Combs method, I recom
-
mend you examine his paper. He gives a very detailed proof of the logic behind
the method, which is well worth reading when you have a few minutes to spare.
Summing Up
You should now have a firm understanding of the theory behind fuzzy
logic, but you’ll need to get some practical experience under your belt
before you recognize just how powerful and flexible it is. With this in mind
I strongly suggest you try your hand at some of the following tasks (they
start easy and become increasingly complex).
Practice Makes Perfect
1. Delve into the Raven code and increase the number of sets used in the
fuzzy linguistic variables to five. This means you will have to com
-
pletely redefine the FLVs and the accompanying rules for each
weapon (or for just one of the weapons if you are feeling lazy J).
2. If you completed task 1 successfully you will have ended up with 25
rules. Your second challenge is to reduce the number of rules to 10 by
converting them to the Combs method.
3. As it stands, the bot aiming logic is weak. Adding random noise to the
aiming is okay but it’s not very realistic. With random noise a bot will
still occasionally make very stupid and obvious aiming errors. For
instance, on occasions when a lot of noise is added, a bot might miss a
shot that a human player — no matter how poor — would never miss.
Alternatively, when very little is added a bot will from time to time
make shots that no mortal player could ever make. (Don’t you just
hate it when that happens!)
Fuzzy Logic | 455
Summing Up
The bot aiming can be made a lot more realistic by using fuzzy
logic to calculate the deviation of each shot from perfect based upon
variables like distance to target, relative lateral velocity, and how long
the opponent has been visible. (Other considerations might be size,
visibility, and profile — standing up, crouching, face on, side on, etc.
— but these aren’t relevant to Raven.) Use the skills you’ve learned in
this chapter to implement fuzzy rules for accomplishing this.
456 | Chapter 10
Summing Up

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

No credit card required