G’day,
This is regarding mixing both Finite and Fuzzy State machines to obtain an over all Machine that can do either, both, and a little more.
The idea behind this is that a CombinedSM class is created whereby it only has one current state aptly named the “super state”. The “super state” can be have many “inner states” in between which correspond to fuzzy values in that “super state”.
Each inner state has a low range, and a high range in which it operates under. And the inner states can overlap in their ranges. The “inner states” will either be sorted using the HighRange or the LowRange (any difference?).
The low/high ranges will be recreated to give the same value but the total range will be from 0 - 2.
The power of this design shines in the input/output. You input an aggression value of that “super state”, that does this on the input:
public float fuzzyTransition(float input) {
// check to see if the input is more than 1.
// if it is, then make the input 1
if (input > 1) {
input = 1;
}
// calculate how far it is from the mean
float calculatedInput = input + fuzzyLogicEffectiveness;
if (calculatedInput > 1) {
calculatedInput = 1;
} else if (calculatedInput < -1) {
calculatedInput = -1;
}
float output = 0.5f - calculatedInput;
fuzzyLogicEffectiveness = 1.0f - (output/0.5f);
// and return it
return fuzzyLogicEffectiveness;
}
This gives the average distance away from the mean (0 - 1) the input is and this gives an output from 0 - 2.
Now this output is given back to the “super state” which returns three things:
- The output from the above method
- The “inner state” (or states, it any number of inner states overlap) at which that output resides in.
- The distance away from the mean of each “inner state” that output is (this number(s) ranges from -1 to 1)
Now for the big question, has anyone done anything like this?
Malohkan, this is very useful for your difficulty effects in gaming. Even more powerful than FuzzyStateMachines for your case because you are incoorporating finite states as well, e.g. Angry, Mad, Raging, and they all bleed into each other, so you can be mad and raging at the same time. Say you will increase the accuracy when your in mad and when your in raging, you increase the speed of fire. With this system, the transition is very smooth…Its all for you baby!
Thx, DP