Advertisement

FSM with fuzzy controller?

Started by September 14, 2011 02:01 PM
18 comments, last by IADaveMark 13 years, 2 months ago
I had this idea for how an FSM might be traversed using a fuzzy system rather than discrete logic. The idea is that each state consists of two functions: an update function, and a scoring function. Following each update function, the data of the agent being controlled is input to the scoring function, and the state with the highest score is the next state in the sequence. This would be the top level behaviour in a subsumption like architecture.

Has this been done before? If so, what is it called? I looked into fuzzy state machines, but they seem to be something slightly different - what im talking about is using a fuzzy controller to traverse a finite state machine.
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!
What specific functionality would this provide? What need does it address?

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Advertisement
FSMs control a sequence with modal decisions for (one or more) transitions to subsequent states (including resuming with no transition).

Fuzzy logic could be used to calculate/decide if the requirements for a transition is met (or which is the best) but the transition is still discrete.
The decision is based on the locality of the current state (testing a set of transitions for that context).

What you describe might just be competing transitions within the parent state and yes fuzzy logic might be useful for more flexible decision calculation.
--------------------------------------------[size="1"]Ratings are Opinion, not Fact
One of the console games I worked on in the past had its combat AI decide between attacks, movement, etc using pretty much exactly what you're describing. It worked horribly. There were too many tuning variables in the state machine that the fuzzy selection code used to make decisions; it was nearly impossible to get it to actually be effective (we didn't have any kind of automated training for the tuning variables - they were all tweaked by the design team, who were not AI-savvy).

It also used a HUGE chunk of our CPU budget (this was back in PS2 and PSP days), so we had to limit the state-switch frequency down to where it was ALSO very unresponsive. Most of the CPU time was spent doing massive amounts of line-of-sight checks. Some was spent doing pathfinding. Quite a bit was spent evaluating the ridiculous amounts of tuning variables to see if a state should be continued/entered.

For the boss AI I worked on, I avoided using the fuzzy controller, tossed out as many tuning variables as I could, hardcoded a lot of behavior directly in C++, and got a much more satisfying boss fight out of it.

We didn't use a special name for the fuzzy system. It was just called the Enemy State Machine.
This kind of stuff is done all the time. Recently, the term seems to be a "utility-based system" -- which I believe I am unwittingly responsible for via my book. One obvious example of this is the implementation in the Sims games where a variety of "scores" are combined to create a single decision. I use that example because people can actually see it happening through the design of the game and UI. (e.g. My hunger bar is going up so finding something to eat is more of a priority.) Strategy games are another common example of this. The Civ games are another place where this sort of process is displayed to an extent in the UI. You can see the plusses and minuses that the other leader has for you and it explains why he will or won't ally with you.

Of course, there are plenty of other games in a wide variety of genres that do this. The key thing that I want to point out in your request, however, is that you need to conceptually separate "state" from "reasoner". A state is analogous to a behavior. A reasoner is a thought processes that selects a behavior. In a FSM, the reasoners are in each state. In other methods (a behavior tree for example), the reasoner is its own entity that selects a state based on its decisions.

Start with that line of thinking.

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

A bit of context might be good here.

What I want to do is implement a few different AI agents, for different types of enemy, in a vehicle combat game. I wanted to try something different to an FSM, because in the past I've had a lot of hassle programming and debugging FSM's. I want each agent to use a subsumption architecture; tasks which have a series of logical steps will have a traditional FSM, and the top layer would be a fuzzy controller which selects, based on what is happening, what the priorities are, from a list which is different for each entity.

Scanner bots need to spread out over an area, doing a more concentrated scan (i.e. more bots in that area) if a particularly suspicious event occurs; events are things like the appearance of tire tracks,"enemy" bullets appearing, and things blowing up. They also need to return to base occasionally to recharge.

Enemy tanks work in patrols; each patrol has a "boss" vehicle, and that vehicle can work from a traditional FSM because its main job is to follow a predetermined patrol path and occasionally order an en-masse attack if the player gets spotted.

Other vehicles in the patrol need to be a bit more subtle. They need to keep close to a formation relative to the boss vehicle, dodge projectiles, and attack the player.

Finally, if I get time, I want to add helicopters. These things work in bombing runs, responding to any alarmed scanners, and providing support to any patrol which is under attack.

I wanted the overall effect of all this to be that the world feels "alive" and the player must learn how each enemy behaves in order to defeat the level. FSM's feel clunky, and do stupid things like getting stuck in particular states, or having to go through several redundant states before they reach their desired state.
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!
Advertisement
Sounds like a utility-based architecture would indeed suit you well, as Dave already mentioned.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]


Sounds like a utility-based architecture would indeed suit you well, as Dave already mentioned.

Yep. It's all about defining the behavior through mathematics. I bet if you look around... look down really, you can find a book on the subject. cool.gif

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"


[quote name='ApochPiQ' timestamp='1316149130' post='4862317']
Sounds like a utility-based architecture would indeed suit you well, as Dave already mentioned.

Yep. It's all about defining the behavior through mathematics. I bet if you look around... look down really, you can find a book on the subject. cool.gif
[/quote]

Yeah... thanks, but I'm not going to do that. I don't need to define all the behavior through mathematics. I encountered formalism in university and I found it incredibly time consuming and unproductive to boil everything down to equations, especially for non deterministic systems or systems with emergent behavior.

What I want is an architecture, not a notation, which should have been made clear by my original post.

Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!
Utility is a meta-architecture. You use utility as a control factor to decide how to progress through a more traditional set of discrete states, where instead of explicitly modeling transitions in a directed graph (ala FSMs) you model transitions as implicit changes in the currently highest-scoring state. (Note that highest score isn't the same as highest utility factor; you may choose less immediately useful options as a means to introduce "flavor" to your AI, or as part of larger-scale planning operations - e.g. what is most opportune now might be best deferred by choosing something slightly less opportune that leads to a chain of better outcomes.)

Nobody's suggesting that you have to write your system down as a bunch of greek letters and weird symbols...

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

This topic is closed to new replies.

Advertisement