W.U. 8: Behaviour Trees

That screenshot right there means the fundamentals of my behaviour tree library is working.

As a side effect of me using unit tests, I made the code output a debug text of the whole tree when traversing.

This is all only the framework though. The next things to do are add more meaningful actions and conditions (like Retreat, Charge, Snipe, AmISurrounded, AmIDying, et al), and then make a visual editor for this.

Again, I’m storing the data in JSON format. Here’s an example:

{
    "__type": "BehaviourTree.Root, Assembly-CSharp",
    "Label": "Root",
    "Remarks": null,
    "InheritsFrom": null,
    "Children": [
        {
            "__type": "BehaviourTree.Selector, Assembly-CSharp",
            "Label": "Sel1",
            "Remarks": null,
            "Children": [
                {
                    "__type": "BehaviourTree.Sequence, Assembly-CSharp",
                    "Label": "Seq1",
                    "Remarks": null,
                    "Children": [
                        {
                            "__type": "TrueCondition, Assembly-CSharp",
                            "Label": "Scond1",
                            "Remarks": null,
                            "Children": null
                        },
                        {
                            "__type": "TrueAction, Assembly-CSharp",
                            "Label": "Sact1",
                            "Remarks": null,
                            "Children": null
                        }
                    ]
                },
                {
                    "__type": "BehaviourTree.Sequence, Assembly-CSharp",
                    "Label": "Seq2",
                    "Remarks": null,
                    "Children": [
                        {
                            "__type": "TrueCondition, Assembly-CSharp",
                            "Label": "Scond2",
                            "Remarks": null,
                            "Children": null
                        },
                        {
                            "__type": "TrueCondition, Assembly-CSharp",
                            "Label": "Scond3",
                            "Remarks": null,
                            "Children": null
                        },
                        {
                            "__type": "TrueAction, Assembly-CSharp",
                            "Label": "Sact2",
                            "Remarks": null,
                            "Children": null
                        }
                    ]
                }
            ]
        }
    ]
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s