i have a class assignment to create a Robot using Drools as an inference machine. however, most of my rules act strange since they don't fire for the class but fire for it's superclass. Something like this:
my rules:
import the.manifested.Robotonikku;
import the.manifested.Strategy;
import the.manifested.Action;
import robocode.TeamRobot;
rule "One"
when
Robotonikku();
then
System.out.println("roboto is present");
end
rule "Two"
when
not Robotonikku();
then
System.out.println("roboto is not present");
end
rule "Three"
when
TeamRobot();
then
System.out.println("robot is present");
end
rule "Four"
when
not TeamRobot();
then
System.out.println("robot is not present");
end
and as expected
public class Robotonikku extends TeamRobot
inside the run() method of Robotonikku that is called by Robocode's simulator I insert the instance as a fact:
ksession.insert(this)
i would expect that rules One and Three should fire but rule Two and Three are fired. Why it recognizes the instance as a TeamRobot and not as Robotonikku?
thanks in advance.
loading code:
String ficheroReglas = System.getProperty("robot.reglas", RobotDrools.FICHERO_REGLAS);
kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(ficheroReglas, RobotDrools.class), ResourceType.DRL);
if (kbuilder.hasErrors()) {
System.err.println(kbuilder.getErrors().toString());
}
kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
ksession = kbase.newStatefulKnowledgeSession();