Print

Print


Hi everyone,

is there a way to set a generic constraint for a GPNode at runtime?

Background:

I've a class called FactChecker.class. In this class there are many many boolean methods 
which compare textbased entites.

A method could look like:

public boolean comesAfter(Entity a, Entity b){

b comes after a? return true;
else return false;
}

So now I don't have only so easy methods, they could also be:

public boolean comesAfterInRange(Entity a, Entity b, int r){

b comes after a in range r? return true;
else return false;
}

And so on... Now I need a way to constrain a GPNode to the types a method needs. The methods 
are chosen randomly, so I don't know which classes a method will need. 

Up till now I'm checking only if all children-classes, match the order of classes 
needed for the method to invoke. If they're fine I'll let the node evaluate, otherwise
I skip the invoking, so basically the use of the method itself, what makes the tree useless but
for now I don't get any IllegalArgumentException anymore and that saves me some nerve (Can't
see this exception anymore...)

Is there a way to generate constraints at runtime so that I can check for the classes and don't
even let such nodes generate?

Greetings
Bojan