Followers 0

# Is fuzzy logic much use in programming game AI?

## 7 posts in this topic

I've read a bit about fuzzy logic in the past few days and it's pretty darn hard to get your head around but i'm getting the hang of it now. And I'm already from a heavy math background at that. But I read an article earlier (here) which uses methods that has similar functionality to fuzzy logic, but seems a lot easier. Is there anything that fuzzy logic can handle which other methods cannot? I am wondering if it's worth studying it in depth (because there's an option to study it for my final year at university) or whether it's redundant in the game programming world, or is it simply criticized because it's hard for people to get their head around it compared to other similar methods out there?

Edited by Zukias
0

##### Share on other sites

Thanks for replies, I'm not sure about studying it in depth now. Even if fuzzy logic is slightly better, it'll take much longer to implement.

0

##### Share on other sites

Tell the truth, I'd be hard pressed to say what is and what is not fuzzy logic according to a true definition.

Fuzzy logic has quite a clear definition, just like many other areas of AI. Picking weighted random numbers is nothing to do with fuzzy logic and isn't an approximation of it in any sense. In fact there is no randomness involved at all in fuzzy logic. It's not about imprecise or varying outputs, but about being able to specify inputs as continuous ranges or function curves which all contribute some amount towards the output.

Zukias, to answer your question - it's not a technique commonly used in game development, at least in part because it's not always clear to see what effect the inputs will have on the outputs. It's not really hard to understand compared to other AI tools - in fact, I think it's one of the simpler ones, at least if you read about rather than assuming there's randomness involved.
1

##### Share on other sites
Looking at the example on wikipedia, this type of logic is actually extremely common in computer graphics.

For example, say we want to assign textures to different parts of a terrain, with grass on flat areas, rock on slopes, and snow on flat areas that are at a high altitude.
Using boolean logic, you'd write something like:
sloped = true/false
highAltitude = true/false
if( !sloped )
set texture to grass
if( sloped )
set texture to rock
if( highAltitude && !sloped )
set texture to snow
However, this produces hard edges between the textures. To get some soft blending in the areas where these values transition from true to false, we can translate that logic over to it's 'fuzzy' version:
sloped = 0..1
highAltitude = 0..1
texture = RGB[0,0,0]
texture = linerInterpolate( texture, grass, 1-sloped )
texture = linerInterpolate( texture, rock,    sloped )
texture = linerInterpolate( texture, snow, min(1-sloped, highAltitude) )
0

##### Share on other sites
Yeah, that has similar numerical outcomes to fuzzy logic. But it hard-codes a lot of important aspects of fuzzy logic that are normally open to variation, such as the choice of rules, the shape of each of the functions for each fuzzy rule or 'set', and the way that membership of each fuzzy set is 'defuzzified' into a final value. Normally you'd want to have much more detailed control over what parts of the 0..1 range each of the 3 rules would apply to, and you wouldn't combine the results sequentially like that.

Usually you use fuzzy logic for behaviour rather than just selecting deterministic output values, because the main strength of the method is to allow a designer to supply fairly imprecise rules that apply to the input and get outputs that vary continuously but which are not too divorced from the input rules. The idea then is that the designers can easily tweak those inputs to get the sort of outputs they want, which is great for control systems where the desired values at certain points are known but points in between are not necessarily specified. The interesting part of fuzzy logic is really the form of the input rather than of the output.
0

##### Share on other sites

Tell the truth, I'd be hard pressed to say what is and what is not fuzzy logic according to a true definition.

Logic which is 100% defined by mathematical constraints is not fuzzy.
Logic which is 75% to 99% defined by mathematical constraints is not very fuzzy.
Logic which is 'a little bit' to 75% defined by mathematical constraints is moderately fuzzy.
Logic which is defined entirely by conceptual constraints is very fuzzy indeed. Edited by Khatharr
0

## Create an account

Register a new account