私は、Droolsを推論マシンとして使用してロボットを作成するためのクラス割り当てを持っています。しかし、私の規則の大部分は、クラスのために発射しないので、奇妙な動作をしますが、スーパークラスのために発射します。このような何か:Robocode Robot with Drools Expert
私のルール:
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
と私は事実としてインスタンスを挿入するのRobocodeのシミュレーターによって呼び出されRobotonikkuのrun()メソッド内
public class Robotonikku extends TeamRobot
を期待通り:
ksession.insert(this)
ルール1と3は発生するはずですが、ルール2と3はf欲しい。なぜそれがインスタンスをRobotonikkuではなくTeamRobotとして認識するのですか?
ありがとうございます。
ローディングコード:
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();
同じことが原因である可能性があります。 Droolsから何かを取得してJavaの適切なクラスにキャストしようとすると、クラスローダーの動作はどうなるのですか?droolsとrobocodeは別のクラスローダーを使用できますか?:例外:java.lang.ClassCastException:drools_robocodeアクションをdrools_robocode.Actionにキャストできません。 –
ナレッジベースとセッションの作成方法を示すコードを含めてください。あなたが説明した基本クラスであなたのDRLを試したので、期待どおりに1つと3つの発砲をルールします。 – Perception
Hello Perceptionは、いくつかのマシンで動作します。私たちは、動作しているものが32ビットで、64ビットでないものを除いて、差分(同じdrools、jdk、jre、robocodeのバージョン番号)を知ることができませんでした。これが当てはまるとは思わない。 –