• Visit Rebornbuddy
  • Behavior Tree Display

    Discussion in 'Archives' started by Stormchasing, Dec 11, 2011.

    1. Stormchasing

      Stormchasing Community Developer

      Joined:
      Jan 15, 2011
      Messages:
      4,029
      Likes Received:
      48
      Trophy Points:
      48
      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.
       
    2. exemplar

      exemplar New Member

      Joined:
      Mar 16, 2010
      Messages:
      167
      Likes Received:
      32
      Trophy Points:
      0
    3. highvoltz

      highvoltz Well-Known Member

      Joined:
      Mar 22, 2010
      Messages:
      1,729
      Likes Received:
      141
      Trophy Points:
      63
      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 compint 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(childcnt 1);
              }
          }
      }
       
      Last edited: Dec 11, 2011
    4. jim87

      jim87 New Member

      Joined:
      Aug 26, 2011
      Messages:
      445
      Likes Received:
      7
      Trophy Points:
      0
      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.
       
    5. solo1420

      solo1420 Member

      Joined:
      Oct 13, 2011
      Messages:
      307
      Likes Received:
      0
      Trophy Points:
      16
      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.
       
    6. Stormchasing

      Stormchasing Community Developer

      Joined:
      Jan 15, 2011
      Messages:
      4,029
      Likes Received:
      48
      Trophy Points:
      48
      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 :p 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
       
    7. Stormchasing

      Stormchasing Community Developer

      Joined:
      Jan 15, 2011
      Messages:
      4,029
      Likes Received:
      48
      Trophy Points:
      48
      okay ...
      now i have an output like that
      PHP:
      [20:38:49:115TreeSharp.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
       

    Share This Page