Sign in to follow this  
Wrathnut

simple platformer AI

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this