Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


FSMs vs Behaviour trees in gameplay programming?


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
5 replies to this topic

#1 vexe   Members   -  Reputation: 117

Like
0Likes
Like

Posted 16 June 2014 - 12:02 AM

Hi all,

 

so I was just recently learning about Behavior trees and found them interesting so I decided to implement them. But what I don't understand is, are BTs a replacement for FSMs? in other words, can BTs do anything FSMs do?

 

I have asked the question here (no answers) with a concrete example that I would love to see how to represent it in a BT.

 

Your help is greatly appreciated, thanks!



Sponsor:

#2 phil_t   Crossbones+   -  Reputation: 3945

Like
0Likes
Like

Posted 16 June 2014 - 12:08 AM

My understanding is that BTs are a supserset of FSMs. Specifically, you could plug a FSM anywhere in a behavior tree (i.e. it's just a node in a behavior tree).



#3 vexe   Members   -  Reputation: 117

Like
0Likes
Like

Posted 16 June 2014 - 12:20 AM

Thanks for your fast reply. Yes I also read that you could plug a FSM in a BT, but I'm wondering if a FSM can be represented as a BT - More specifically, I'm wondering if the tiger statue puzzle i mentioned in my original question can be somehow a BT instead of an FSM, does it make sense? or a FSM is more suited for these types of things? (in my game I have much more similar triggers to that one I mentioned, they change state - you interact with them once, they do A, interact with them in a different way they do B, etc. so I'm wondering if using a BT is better here than an FSM...) Thank you.



#4 Ashaman73   Crossbones+   -  Reputation: 7793

Like
1Likes
Like

Posted 16 June 2014 - 01:08 AM

BTs are not really a superset of FSM, because a tree does not contain any cycles. I'm sure, that you can implement the same or atleast similar logic in both representations, but it will most likely get more complex in one of the two representations.

 

BTs are very flexible and easy to expand, therefor you can integrate other AI logic as special nodes, therefor adding FSMs should not be a problem. Both, BT and FSM, have kind of memory (path in BTs and state in FSM), but the follup interaction is strongly defined in FSM (state transitions) whereas a BT have the option of interrupting running actions and initiating new actions (priority nodes).

 

My rule of thumb is to use BTs where you have more script like behavior, eg the approximation of the AI of a human being and to use FSM where you have more rule/state based behavior. 



#5 Álvaro   Crossbones+   -  Reputation: 13645

Like
0Likes
Like

Posted 16 June 2014 - 06:56 AM

A BT can do anything a FSM can do, but you kind of have to cheat. You can set states in the world that can be queried by the BT.

 

The way I think of a BT, it's simply a boolean expression in a language like C, where you use operators && and || (with short-circuit evaluation) to combine calls to functions with no arguments that return bool. In that interpretation of BTs, you can write something like this:

 

(state_s1_is_set() && show_text() && set_state_s2())
||
(state_s2_is_set() && ...


#6 IADaveMark   Moderators   -  Reputation: 2509

Like
0Likes
Like

Posted 16 June 2014 - 08:58 AM

Please note... don't confuse an architecture with a reasoner. Theoretically, no matter what you use to make a decision, an agent ends up in a state. BTs simply lift the transition logic out of the states themselves and put them into a highly organized reasoner that operates independent of the state.


Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC

Professional consultant on game AI, mathematical modeling, simulation modeling
Co-advisor of the GDC AI Summit
Co-founder of the AI Game Programmers Guild
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!"




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