I want to implement a complex branching logic Android business application to be used as a marketing questionaire tool with lots of questions and branching among them according to what the user responds. I'm confused whether to implement the dialog logic as a FSM or a behavior tree. Authors have used trees to implement state machines. For example in Artificial Intelligence for Games By Ian Millington et al, the author suggests using decision tree for a FSM. However, I think that a FSM can have closures, for example having a transition between "raise alarm" and "defend" will make it a graph rather than a tree. My first question is what is the difference between a tree and a state machine ? The second one is what will be a good implementation for my app, manage the high level of branching complexity?
-
9 years later. Looks to me like this is can be implemented by a behaviour tree for the dialog logic. – kimathie May 26 '20 at 15:52
-
I am looking for some examples of this in robotics and will update this thread. https://github.com/jiborobot/sample-code/blob/master/behaviors/02-parallel.bt https://www.behaviortree.dev/ An entire book has been written since I asked this during my PhD days: https://arxiv.org/abs/1709.00084 https://github.com/miccol/ROS-Behavior-Tree – iceman Jul 10 '20 at 00:22
-
@iceman What did you finally settle with? It seems BT is a bit different than Decision Trees (DT). While the DT graph can be translated into an equivalent BT graph, but this will introduce an extra complexity. See pages 42 and 43 in the book that you shared above [Behavior Trees in Robotics and AI: An Introduction](https://arxiv.org/pdf/1709.00084.pdf) for an example of DT -> BT graph translation. A library for Decision trees in Python or Java would be great. Extra bonus for a GUI to draw the decision tree and export the nodes/leaves into the library. – Haider Aug 04 '22 at 02:26
3 Answers
Behavior trees and Decision trees are two different things. Behavior trees are a goal oriented and reactive (suite more for simulating agents or smart entities decisions in a game like environment), and decision trees are a great tool for the specification (and storage) of decisions based on the utility of an action for a given state. Mainly, in first approach the execution is more state-full ( the execution is tied to the state you are in the tree) and in the later is more state-less (the whole tree is evaluated root to leaf in order to arrive to a conclusion).
That said, from your description it seems that what you are looking is for an expert system, rule based.

- 73
- 6
I think by definition, FSM have only one entry point, while behavior trees can have multiple inputs. A tree is a graph, but a graph is not a tree. A tree is an acyclic graph where leaves never have multiple parents. So in this regard, the tree is better suited for the FSM.
Anyways, I would imagine that this type of simulation is outside the scope of android api. Hence, I would be looking more at what kind of tools are available in Java. I once did a machine learning research project in Java. I ended up implementing a custom Tree data structure in order to facilitate multithreading.
I hope that helps!

- 3,500
- 1
- 24
- 25
FSM is a graph of states linked by transitions. for a complex fsm, it is difficult to extend due to complex transitions.
For behavior trees, each node is managed by its parent, the transition is in fact implicitly in the parent/child relationship, so it easier to extend an existing behavior tree.
you can refer to https://github.com/TencentOpen/behaviac for the source code and designer.

- 145
- 1
- 6