Welcome!

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

Sign up now!

Request Make TreeBot treat null children properly

Java Warlord
Joined
Nov 17, 2014
Messages
4,906
TreeBot shouldn't throw an UnsupportedOperationException if a child of a branch is null, in trees of graph theory, not having a right or left subtree is legal too.
If failureTask() returns null as an example, it should be obvious that the respective branch simply has no failure task.
So if a child is null i would suppose it getting treated as an empty leaf instead.
 
bored
Joined
Feb 11, 2017
Messages
21
Because its a tree

Is there something I'm missing here? createRootBranch --> custom extension of RootBranch ... bot runs into empty leaf -> return your RootBranch to restart.

is there an issue with doing it that way (minus not having the delay)
 
Joined
Dec 10, 2014
Messages
3,255
By linking back to your root, you'll create a cycle, which you don't really want to do. I assume it was done the way it is to try to encourage authors to balance the tree rather than having one which is heavily weighted to a side.
 
Java Warlord
Joined
Nov 17, 2014
Messages
4,906
By linking back to your root, you'll create a cycle, which you don't really want to do. I assume it was done the way it is to try to encourage authors to balance the tree rather than having one which is heavily weighted to a side.
Got the point, but i suppose devs are just using an empty leaf task instead.
 
bored
Joined
Feb 11, 2017
Messages
21
Got the point, but i suppose devs are just using an empty leaf task instead.

Code:
LeafTask emptyLeaf = new LeafTask() {@Override public void execute() {});

Easiest way if you haven't already, instead of making new class.
 
Java Warlord
Joined
Nov 17, 2014
Messages
4,906
Code:
LeafTask emptyLeaf = new LeafTask() {@Override public void execute() {});

Easiest way if you haven't already, instead of making new class.
Yeah thank you i know how to make an empty LeafTask, but my point is using a leaftask that does nothing is pretty much equivalent to a null child, which should get represented as null. In a tree you wouldnt want any nodes with null as content, but rather let the node itself be null.
 
Joined
Dec 10, 2014
Messages
3,255
Yeah thank you i know how to make an empty LeafTask, but my point is using a leaftask that does nothing is pretty much equivalent to a null child, which should get represented as null. In a tree you wouldnt want any nodes with null as content, but rather let the node itself be null.
Tbh I'm torn each way, although I am leaning towards allowing null sub-nodes... @Party @Cloud opinions?
 
Client Developer
Joined
Oct 12, 2015
Messages
3,760
Tbh I'm torn each way, although I am leaning towards allowing null sub-nodes... @Party @Cloud opinions?

I'm the opposite, I wouldn't mind the idea but I'm definitely leaning in favour of restriction. In my opinion if you're going to have a branch with a null sub-node, that branch should be replaced by a leaf.
 
Top