[Discussion] Best way to handle the ridiculous condition creep for TaskScript?

Discussion in 'Developer Support' started by Dibes, Jul 1, 2015.

  1. The more I think about it, the more ridiculous the amount of conditions to check increases as you add functionality/tasks to your bot. I am trying to think of a way to condense it or simply make it better. Initially the best way I can think to do it is simply to remove and add tasks based on a larger more broad set of conditions. What are your strategies to mitigate this?
    #1 Dibes, Jul 1, 2015
    Last edited: Jul 1, 2015
  2. TaskScript is a tree, so build a tree. Make it so that tasks that share a condition share a parent, and simply have the validate check in the parent. You don't actually need to include anything in the parents execute method unless you want to.
  3. Ah that makes a lot of sense. Didn't realize you could do that. thanks
  4. Only problem with that is if the parent returns true but all the children don't, it never moves to the next node in the parents level, because that parent had already returned true so the whole loop just starts over.
  5. You're right, nice catch. I over looked that.
  6. :) Maybe you should reconsider changing that ;)
  7. So given that, how do you handle it? Or do you just bear with the annoyance?
  8. Bare with the annoyance, lol. It's either that or implement your own taskscript that returns when you want it to.
  9. I'm considering having a simple constant class with methods for each task that state if !everyOtherTask and the conditional logic... that at least ensures that they will run independently.

    so Like:
    Code (Text):
    1. class TaskConditions {
    2.   public static boolean task1() {
    3.     return !task2 && canChop && treeAvailable;
    4.   }
    6.   public static boolean task2() {
    7.     return !task1 && canBank && inventoryIsFull;
    8.   }
    10. }
    This could be implemented a better way, but the underlying idea remains.

    Any downsides you see with that?
  10. I'd just write my own TaskScript that works exactly the same way except the root parent node will only return true if a leaf node returns true
  11. Would you guys be happy if I added an optional toggle that made it continue to iterate over top level tasks even after finding a branch it can execute?

    Edit: If so, can you guys think of a better name than setMultibranchExecution(boolean)
    #11 Cloud, Jul 1, 2015
    Last edited: Jul 1, 2015
  12. Do you mean continue to even if the branch never got executed all the way down to the leaf? Or will it continue only if the leaf node was reached?
  13. Assume the following task structure
    Currently if 2 validates successfully, a will be checked and possibly executed and then it'll go back to 1. What I'm proposing is that it'll continue on to 3 and 4 regardless of if a previous task executed.
  14. What i would want is if 2 is valid, check a, if a is valid, go back to 1. But if 2 is valid and a ISNT valid, continue on to 3 then 4

Share This Page