Monday, July 1, 2013

HTML5 game - decision tree

Most game entity, that you create for your HTML5 games needs our own intelligence. It has to decide what to do next. For example: walks, attacks, speaks, … In this post I show you how to make decision with decision tree.


Consider the following scenario:





This type of the presentation is easy to represent in the form of a tree:


It is better to convert each condition on a separate object. Then you can check the condition and return either a decision or another decision object.




Finally, you need to create the tree and let it make the decision:





Reference: