# AI fuzzy logic problem - how do make this into one value?

**URL:** <https://forum.kirupa.com/t/ai-fuzzy-logic-problem-how-do-make-this-into-one-value/292813>\
**Category:** programming\
**Created:** [July 19, 2009, 4:36pm UTC](https://forum.kirupa.com/t/ai-fuzzy-logic-problem-how-do-make-this-into-one-value/292813 "2009-07-19T16:36:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![questioner1](https://avatars.discourse-cdn.com/v4/letter/q/a88e57/32.png) [@questioner1](https://forum.kirupa.com/u/questioner1)\
**Post date:** [July 19, 2009, 4:36pm UTC](https://forum.kirupa.com/t/ai-fuzzy-logic-problem-how-do-make-this-into-one-value/292813/1 "2009-07-19T16:36:59Z")

</div>

I am using fuzzy logic to calculate the desirability of certain strategic spots in a game.  
I have 4 vars:

//in Actionscript 3.0  
var mNotStrategic:Number   
var mStrategic:Number   
var mVeryStrategic:Numbe  
var mUnbeatable:Number

//in C++:  
double mNotStrategic   
double mStrategic   
double mVeryStrategic  
double mUnbeatable

all these vars are ofcourse from 0 to 1.  
and I want to calculate the desirability:  
var mDesirable:Number

I want to use mDesirable in other fuzzy logic expressions.  
So i don’t want to defuzzify it. it has to be a number between 0 and 1.

How do i do this? I can’t take the avarage of the four strategic vars, because, obviously a high mNotStrategic should cause mDesirable to be low. but if i took tha avarage, then it being VERY not strategic, would also make it very desirable.

I also want to be able to change the weight of those vars. so that the difference between mStrategic and mVeryStrategic, matters less, than the difference between mNotStrategic and mStrategic.

I hope i’ve made sense.

Thanks in advance.

EDIT:  
these are the calculations. i dont know if you need them to answer my question. I’ll just post them to make sure.

var mWeak:Number = fuzzyReverseGrade (nrShips, 1, 2);  
var mStable:Number = fuzzyTriangle (nrShips, 1, 3, 5);  
var mStrong:Number = fuzzyTriangle (nrShips, 4, 6, 9);  
var mVeryStrong:Number = fuzzyGrade (nrShips, 7, 10);  
//above calculates the value of the amount of ships.

var mClose:Number = fuzzyReverseGrade (dist, , );  
var mNearby:Number = fuzzyTrapezoid (dist, , , , );  
var mFar:Number = fuzzyTrapezoid (dist, , , , );  
var mVeryFar:Number = fuzzyGrade (dist, , );  
//the above calculates the value of the distance from the player (i haven’t filled in the constants yet.)

var mNotStrategic:Number = OR(AND(mWeak,mClose), AND(mWeak,mNearby), AND(mVeryFar, OR(mWeak,mStable,notVery(mStrong))) );  
//above means that a place is not strategic if it is weak and close or weak and nearby or very far and (weak,stable or kind of strong)

var mStrategic:Number = OR(AND(mStable,mNearby), AND(mWeak,mFar), AND(mStrong,mFar), AND(very(mVeryStrong),mVeryFar) );  
//meaning the place is strategic if it’s stable and nearby or weak and far or strong and far or verystrong and very far  
var mVeryStrategic:Number = OR(AND(mStrong, OR(notVery(mClose), mNearby)), AND(mVeryStrong, OR(notVery(mNearby),vFar) );  
//etc.  
var mUnbeatable:Number = OR(AND(mVeryStrong,OR(mClose,very(mNearby))), AND(very(mVeryStrong), mNearby) );

Someone told me, that i might not need fuzzy logic. I wouldn’t know how i would have to do something like this without fuzzy logic. But I’m open to suggestions.
