Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

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

Joined
Nov 18, 2013
Messages
120
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?
 
Last edited:
Engineer
Joined
Jul 28, 2013
Messages
2,776
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.
 
Joined
Nov 18, 2013
Messages
120
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.

Ah that makes a lot of sense. Didn't realize you could do that. thanks
 
Author of MaxiBots
Joined
Dec 3, 2013
Messages
6,774
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.
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.
 
Engineer
Joined
Jul 28, 2013
Messages
2,776
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.
You're right, nice catch. I over looked that.
 
Joined
Nov 18, 2013
Messages
120
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.

So given that, how do you handle it? Or do you just bear with the annoyance?
 
Author of MaxiBots
Joined
Dec 3, 2013
Messages
6,774
So given that, how do you handle it? Or do you just bear with the annoyance?
Bare with the annoyance, lol. It's either that or implement your own taskscript that returns when you want it to.
 
Joined
Nov 18, 2013
Messages
120
Bare with the annoyance, lol. It's either that or implement your own taskscript that returns when you want it to.

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:
class TaskConditions {
  public static boolean task1() {
    return !task2 && canChop && treeAvailable;
  }

  public static boolean task2() {
    return !task1 && canBank && inventoryIsFull;
  }

}

This could be implemented a better way, but the underlying idea remains.

Any downsides you see with that?
 
Author of MaxiBots
Joined
Dec 3, 2013
Messages
6,774
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:
class TaskConditions {
  public static boolean task1() {
    return !task2 && canChop && treeAvailable;
  }

  public static boolean task2() {
    return !task1 && canBank && inventoryIsFull;
  }

}

This could be implemented a better way, but the underlying idea remains.

Any downsides you see with that?
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
 
Engineer
Joined
Jul 28, 2013
Messages
2,776
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)
 
Last edited:
Author of MaxiBots
Joined
Dec 3, 2013
Messages
6,774
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)
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?
 
Engineer
Joined
Jul 28, 2013
Messages
2,776
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?
Assume the following task structure
1.
2.
a.
3.
4.
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.
 
Author of MaxiBots
Joined
Dec 3, 2013
Messages
6,774
Assume the following task structure
1.
2.
a.
3.
4.
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.
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
 
Top