Implementing a simple fuzzy logic system

For this example, we're going to use my good friend, Bob, the wizard. Bob lives in an RPG world, and he has some very powerful healing magic at his disposal. Bob has to decide when to cast this magic on himself based on his remaining health points (HPs).

In a binary system, Bob's decision-making process might look like this:

if(healthPoints <= 50)  
{ 
  CastHealingSpell(me); 
}

We see that Bob's health can be in one of two states—above 50, or not. Nothing wrong with that, but let's have a look at what the fuzzy version of this same scenario might look like, starting with determining Bob's health status:

A typical function representing fuzzy values

Before the panic sets in upon seeing charts and values ...

Get Unity 2017 Game AI Programming - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.