Advertisement

simple platformer AI

Started by August 13, 2011 01:33 AM
1 comment, last by Wrathnut 13 years, 3 months ago
Hi,

I have been working on a simple 2d platformer. But recently was thinking about switching out the way I am currently doing AI to using the state pattern as a FSM so I can clean up my code and maybe make it more readable. I am currently just using if..then logic and it is pretty ugly and I envision it getting uglier as I add more enemies with more functionality. Currently my enemy class has a pure virtual function UpateAnimation() and UpdateAI(). Each enemy implementing their own method.

So I am looking for some suggestions on different approaches. I have been toying with the idea of coupling the animation FSM and the AI FSM. I am envisioning something like the AI State will start an animation on entering the state. Thus not requiring an animation state machine. Is this common? Or is it more common to have a seperate FSM for animation and AI? I am a little worried class explosion having to do 2 FSM's for each enemy type(ground based patrols, flying enemies, stationary enemies, swimming enemies, etc..) for the animation and AI. It seems like that would only be exchanging one complexity for another and I am not sure that many classes would be worth it.

Any suggestions would be greatly appreciated. I'd like to get a few ideas rolling around before I forge ahead and possibly realize I took the wrong path.

-Andy
Remember that a state in an FSM is not a decision modeler. Often, you will want to decouple the decision modeling from the state itself. That allows you to more tightly join the states to the animations (which is where they should be). Then, you can use a separate process (e.g. behavior tree, etc.) to determine what state you should be in at any moment.

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!"

Advertisement
Dave,

Thanks for the response. I have been reading through several of the books listed on the recommended section but haven't stumbled across behavior trees. After googling them I have to say they sound like an excellent way to make the whole framework more extensible. Thank you for pointing me in that direction.

This topic is closed to new replies.

Advertisement