O'Reilly logo

Programming Game AI by Example by Mat Buckland

Stay ahead with the world's most comprehensive technology and business learning platform.

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

Start Free Trial

No credit card required

Chapter 10
Fuzzy Logic
H
umans have the incredible ability to communicate skills simply and
accurately by using vague linguistic rules. For example, a TV chef
might instruct you how to make perfect cheese on toast like this:
1. Cut two slices of bread medium thick.
2. Turn the heat on the griddle on high.
3. Grill the slices on one side until golden brown.
4. Turn the slices over and add a generous helping of cheese.
5. Replace and grill until the top of the cheese is slightly brown.
6. Remove, sprinkle on a small amount of black pepper, and eat.
The words shown in bold are all vague linguistic terms, yet we would all
be confident of following these instructions to create a delicious snack.
Humans do this sort of thing all the time. It’s a transparent and natural pro-
cess for us to interpret instructions like this in a meaningful and accurate
way.
When designing the AI for computer games, wouldn’t it be great to be
able to communicate with a computer in a similar fashion — to quickly and
simply map expert knowledge from the human domain to the digital one?
If computers were able to understand vague linguistic terms then we could
sit down with an expert in the domain of interest (more often than not that
will be you), ask questions pertinent to the skill necessary to be successful
within that domain, and from the answers quickly create some linguistic
rules for the computer to interpret — just like the ones shown for making
toast.
Conventional logic is inadequate for processing such rules. As an exam
-
ple, imagine you are programming a golfing game and you’ve been given
the job of spending the day with Tiger Woods to determine some ground
rules for playing golf. At the end of the day your notepad is full of words
of wisdom such as these:
When putting: If the ball is far from the hole and the green is sloping
gently downward from left to right, then hit the ball firmly and at an
angle slightly to the left of the flag.
When putting: If the ball is very close to the hole, and the green
between the ball and hole is level, then hit the ball gently and directly
at the hole.
415

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

Start Free Trial

No credit card required