hi to all, did anyone know if it is possible to graphical display the Tree we've built? For example in a CC, if we think (or in this case i^^) that we'Ve got a issue with our tree, an infinite loop or something ... is there a way to display the Tree graphical ... or maybe in text like - root -- TreeOne --- LeafOfOne -- TreeTwo --- LeafOfTwo ---- LeafOfLeafOfTwo and so on? I tried with outputting the composites (debug print the names), but this does not return a tree, this gives me only a list of all composites loaded / used. But i can't see the root-Element with this.
I have a method called PrintComposite () That I use in PB for debugging purposes. It gets a snapshot of all composites and their status and it prints the output in a tree-like format. Below is a modified version that is more generic. Example usage: PrintComposite(TopLevelComposite,0); PHP: void PrintComposite(Composite comp, int cnt){ string name = comp.GetType().ToString(); Logging.Write("{0}{1} LastStatus:{2}", new string(' ', cnt * 4), name, comp.LastStatus); if (comp is GroupComposite) { foreach (Composite child in ((GroupComposite)comp).Children) { PrintComposite(child, cnt + 1); } }}
By the way you should NEVER ask for printing a behavior tree you've developed, as this is the pre-stage of writing it, not the post-stage. I'd suggest you to use Dia for such things, and only then implement the code.
The BT isn't developed by him though; He is just trying to implement some changes of his own until the author returns back to the forums.
That's right I've to know if there's something going wrong. In my opinion some of the builded trees are obsolete, some are redundant ... that'S what i try to fix atm. But i implemented a complete new tree which should run, but often it crashes HB completly, and i can't say at which point it is ... is it at building the trees (and if yes ... at which point) or ist on going trough a tree (and if yes...at which point) Thank you highvoltz, i'll try your method this looks like it's what i want and thank you exemplar but i know how my VS looks like^^, but the trees are very complex, where it is not enough to look only at 1 tree I've never got an UML or anything else of the CC^^ so i'm tired of painting these bymyself atm
okay ... now i have an output like that PHP: [20:38:49:115] TreeSharp.PrioritySelector LastStatus: [20:38:49:115] TreeSharp.Decorator LastStatus: [20:38:49:115] TreeSharp.Action LastStatus: [20:38:49:115] TreeSharp.Decorator LastStatus: [20:38:49:115] TreeSharp.Action LastStatus: [20:38:49:115] TreeSharp.Decorator LastStatus: [20:38:49:115] TreeSharp.Switch`1[System.String] LastStatus: [20:38:49:115] TreeSharp.PrioritySelector LastStatus: [20:38:49:115] TreeSharp.Decorator LastStatus: [20:38:49:115] TreeSharp.Action LastStatus: [20:38:49:115] TreeSharp.Decorator LastStatus: [20:38:49:115] TreeSharp.Action LastStatus: [20:38:49:115] TreeSharp.PrioritySelector LastStatus: [20:38:49:115] TreeSharp.Decorator LastStatus: [20:38:49:115] TreeSharp.Action LastStatus: [20:38:49:115] TreeSharp.PrioritySelector LastStatus: [20:38:49:115] TreeSharp.Action LastStatus: [20:38:49:115] TreeSharp.Decorator LastStatus: [20:38:49:115] TreeSharp.PrioritySelector LastStatus: in the final version it looks a little bit different, but that's not what i need It is helpfull for sure, but i really need the names of the composites, is there a way to get them? If not ... then okay, i've to clean up the complete code for redundancies and so on