Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


FSM AI examples


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 rpiller   Members   -  Reputation: 752

Like
0Likes
Like

Posted 27 January 2014 - 03:45 PM

Are there any code examples of a FSM for AI? I know it would be specific to whatever engine probably but I would love to see some code to get an idea on how to implement this for the engine I'm using. I've used FSM before for higher level states like (Logo, MainMenu, Options, Gameplay), but I've never used FSM for lower level stuff. It always seemed like getting access to required data from within states and between states was a challenge.



Sponsor:

#2 ApochPiQ   Moderators   -  Reputation: 17439

Like
0Likes
Like

Posted 27 January 2014 - 03:50 PM

The problems you cite are exactly why FSMs are not the favored approach for much of the game AI world. There are ways to mitigate this problem, such as hierarchical FSMs, blackboards, and so on, but generally there are much better architectures to choose from.



#3 rpiller   Members   -  Reputation: 752

Like
0Likes
Like

Posted 27 January 2014 - 03:53 PM

I've looked at the Behavior design before and it seemed nice, but it seemed like it would have the same data access issue. Any other that has some working code I could look at?



#4 rpiller   Members   -  Reputation: 752

Like
0Likes
Like

Posted 27 January 2014 - 04:50 PM

I find stuff like the following: https://github.com/headchant/bhtlua/blob/master/aibht.lua which is great, but the implementations are always so simple and basic and don't try to access any actual game data. Again, I realize this would be specific to the game, but I would just want to see how someone does it. For example, the 'makeThiefFlee' action would actually need a way to tell the thief to flee. So it needs some mechanism to do that. What thief? What if there are 5 loaded thiefs in the scene?

 

Looking at the below on the first sequence. If the/a thief is near the treasure (well what treasure object? this condition would need to know about this treasure object so it could do some calcs to see if a thief is near it. I could do a bounding box check and find entities inside it and see if they are thiefs but the idea that this can be attached to many guards means they need to know about the treasure they are guarding which means these functions need to know about it.

 

One would also think that if isThiefNearTreasure returned true that if would have access to the thief object and would then pass it to the makeThiefFlee action because that actions needs to know what thief to make flee. This still very much seems like it has data access issues. What are the common ways to expose all the needed data (and sometimes specific configurable data (like what treasure to guard in this case))?

 

local simpleBehaviour = Selector{
                            Sequence{
                                isThiefNearTreasure,
                                makeThiefFlee,
                            },
                            Sequence{
                                chooseCastle,
                                flyToCastle,
                                fightAndEatGuards,
                                packStuffAndGoHome
 
                            },
                            Sequence{
                                postPicturesOfTreasureOnFacebook
                            }
                        }





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS