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?
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!
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.
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.
精彩评论