1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Request Tries In TreeBot

Discussion in 'Client & Site Suggestions' started by EzPzi, Mar 20, 2018.

?

Should this be implemented?

  1. Yes, definitely.

  2. Yes, with some changes.

  3. No, not at all.

  4. No, not useful enough.

Results are only viewable after voting.
  1. EzPzi

    Joined:
    Mar 16, 2018
    Messages:
    2
    Likes Received:
    1
    Current Treebot
    Each Branch is a validation of a single Boolean.
    - Validation is True -> Go to success child
    - Validation is False -> Got to failure child

    How can we improve upon this?

    Well, the main problem with using a BST is that each sub-child can only return a single leaf or a single
    branch on success or failure. It can never return multiple leaves and branches.This causes a lot of extra bloat-code that doesn't necessarily have to be there.

    Observe:

    Lets say there is a weapon in the bank. After searching the bank for the weapon, the current
    branch validation returns true and it executes the successTask. Now, you want to both withdraw AND equip it, but you know that once the weapon is in your inventory, the parent branch would validate to false and wouldn't execute another leafTask. This causes you to create an entirely new LeafTask class, AKA LeafWithdrawAndEquip, or at least share variables from child -> parent treeTasks.

    Solution

    A better way to do this would be to utilize the structure of a Trie by returning a LinkedList or
    Queue of TreeTasks on each success or failure.

    Then, each of these would be executed in the same order they were put in (FIFO). Anything in this
    Queue or LinkedList would be executed before restarting from the root of the tree.
    Code (Text):
    1.  
    2. // in the onLoop, there would be something like this, executing one LEAF per loop,
    3. // branches add items onto the queue.
    4. treetask = q.poll();
    5. while(treetask != null):
    6.     if leaf
    7.        leaf.execute
    8.        break? // only execute 1 task per onLoop?
    9.     else if branch
    10.         if branch.validate
    11.              add all branch.success() to queue
    12.         else
    13.             add all branch.failure to queue
    14.    treetask = q.poll();
    15.  

    Implementing Into the current API:

    The TrieBranchTask (or something similar) would act as said above and could be implemented alongside the already existing TreeBot API. No need to create an entirely diofferent bot type.

    Observe (using TrieBranchTask)
    Lets say there is a weapon in the bank. After searching the bank for the weapon, the current
    branch validation returns true and it executes the successTask. Now, you want to both withdraw AND equip it, but you know that once the weapon is in your inventory, the parent branch would validate to false and wouldn't execute another LeafTask.
    Now:
    new Queue
    addToQueue(LeafWithdraw(item))
    addToQueue(LeafEquip(item))
    return Queue

    EDIT:
    MUCH improved pseudo-code.
     
    #1 EzPzi, Mar 20, 2018
    Last edited: Mar 20, 2018
  2. Wet Rag

    Wet Rag easily triggered ✌

    Joined:
    Dec 31, 2015
    Messages:
    4,449
    Likes Received:
    1,692
    is this a joke
     
  3. Snufalufugus

    Joined:
    Aug 23, 2015
    Messages:
    1,961
    Likes Received:
    757
    Since you're looking for feedback
    • Treebot is already intimidating enough to a lot of new devs
    • You can always make a custom bot framework that accomplishes this
    • You CAN return to the same leaf just by making the validate in the branch leading to it an OR with logic to handle what you want to accomplish
     
  4. EzPzi

    Joined:
    Mar 16, 2018
    Messages:
    2
    Likes Received:
    1
    Thanks for the feedback!

    1) agreed, but we have really great tutorials here on RuneMate. Also this wouldn't be a completely new AbstractBot type, as the title suggests. It would be another Treetask like that of a BranchTask or LeafTask.

    2) I'll Most likely do this, but it would be nice to see implemented into the API because I think it is something other authors could use.

    3) I looked into using OR logic in the validate branch, but this seems a little messy to me, which is why i suggested using Tries. This way it is a simple 1 line statement in the successTask or failureTask methods instead of adding completely new variables into the program to expand the validation logic, making it more complex.

    At least with the way I am currently structuring my bots, Tries would be extremely useful. I am trying to keep as many branches as I can outside of my main bot class and am only instantiating branches in constructors of other branches.
     
  5. Derk

    Derk 12 year old normie

    Joined:
    Jan 8, 2015
    Messages:
    2,766
    Likes Received:
    1,339
    I don't quite understand what the usecase is of executing two success tasks at once. Your case about withdrawing and equipping a weapon doesn't really make sense because your argument is that it has to create new branches again to go to withdrawing. The classes however can be stored in variables and just use getters to pass them on as success or failure task. They won't be created over and over again.

    I could see how it would require more resources for going through validators again, but your withdrawing leaf would be somewhere else in the tree, hopefully with less bank querying and other nonsense which shouldn't burden your cpu so much.

    The queue system is basically taskbot as I read it. You throw a bunch of tasks in a queue and it'll execute the first one of which the validator returns true. Correct me if I'm wrong.
     
    awesome123man likes this.

Share This Page

Loading...