triceo / drooms

Drools-based competition in a Snake-like game
3 stars 3 forks source link

CCEs when running from DroomsTournament #3

Open triceo opened 11 years ago

triceo commented 11 years ago

Pull request #2 seems to introduce strange CCEs when running DroomsTournament. What happens is:

(Where ReachableCollectible is a fact type declared in my DRL.)

The current facts of the matter are:

tomason commented 11 years ago

Could you paste the whole stack trace of exception you are getting so I can examine it?

If it is not too much to ask, could you paste the fact type declaration as well?

triceo commented 11 years ago

The stack trace:

2012-12-28 13:50:54,177 [main] WARN [org.drooms.impl.logic.CommandDistributor] - Player hungry, didn't reach a decision in time, STAY forced. java.util.concurrent.ExecutionException: Exception executing consequence for rule "From available collectibles, find those that can be reached in time" in org.drooms.strategy.hungry: java.lang.ClassCastException: org.drooms.strategy.hungry.ReachableCollectible cannot be cast to org.drooms.strategy.hungry.ReachableCollectible at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:262) ~[na:1.7.0_09-icedtea] at java.util.concurrent.FutureTask.get(FutureTask.java:119) ~[na:1.7.0_09-icedtea] at org.drooms.impl.logic.CommandDistributor.execute(CommandDistributor.java:193) ~[classes/:na] at org.drooms.impl.GameController.play(GameController.java:355) [classes/:na] at org.drooms.impl.DroomsGame.play(DroomsGame.java:99) [classes/:na] at org.drooms.impl.DroomsTournament.main(DroomsTournament.java:118) [classes/:na] org.drools.runtime.rule.ConsequenceException: Exception executing consequence for rule "From available collectibles, find those that can be reached in time" in org.drooms.strategy.hungry: java.lang.ClassCastException: org.drooms.strategy.hungry.ReachableCollectible cannot be cast to org.drooms.strategy.hungry.ReachableCollectible at org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drooms.impl.logic.DecisionMaker.decideNextMove(DecisionMaker.java:200) ~[classes/:na] at org.drooms.impl.logic.CommandDistributor$DecisionMakerUnit.call(CommandDistributor.java:59) ~[classes/:na] at org.drooms.impl.logic.CommandDistributor$DecisionMakerUnit.call(CommandDistributor.java:1) ~[classes/:na] at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) ~[na:1.7.0_09-icedtea] at java.util.concurrent.FutureTask.run(FutureTask.java:166) ~[na:1.7.0_09-icedtea] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) ~[na:1.7.0_09-icedtea] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) ~[na:1.7.0_09-icedtea] at java.lang.Thread.run(Thread.java:722) ~[na:1.7.0_09-icedtea] Caused by: java.lang.ClassCastException: org.drooms.strategy.hungry.ReachableCollectible cannot be cast to org.drooms.strategy.hungry.ReachableCollectible at ConditionEvaluator1bd97da9de4b4199b267fea99b988437.evaluate(Unknown Source) ~[na:na] at org.drools.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:200) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drools.rule.constraint.MvelConstraint.isAllowedCachedRight(MvelConstraint.java:184) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drools.common.SingleBetaConstraints.isAllowedCachedRight(SingleBetaConstraints.java:134) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drools.reteoo.NotNode.assertObject(NotNode.java:131) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:350) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drools.common.SimpleBeliefSystem.insert(SimpleBeliefSystem.java:38) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drools.common.TruthMaintenanceSystem.addLogicalDependency(TruthMaintenanceSystem.java:204) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drools.common.TruthMaintenanceSystem.addLogicalDependency(TruthMaintenanceSystem.java:176) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:231) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drools.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:245) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drools.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:210) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drools.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:205) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] at org.drooms.strategy.hungry.Rule_From_available_collectiblesfind_those_that_can_be_reached_in_time_0c8d41bc97ec409bb128b31c33b9dbb6.defaultConsequence(Rule_From_available_collectibles__find_those_that_can_be_reached_in_time_0c8d41bc97ec409bb128b31c33b9dbb6.java:7) ~[na:na] at org.drooms.strategy.hungry.Rule_From_available_collectiblesfind_those_that_can_be_reached_in_time_0c8d41bc97ec409bb128b31c33b9dbb6DefaultConsequenceInvokerGenerated.evaluate(Unknown Source) ~[na:na] at org.drooms.strategy.hungry.Rule_From_available_collectibles__find_those_that_can_be_reached_in_time_0c8d41bc97ec409bb128b31c33b9dbb6DefaultConsequenceInvoker.evaluate(Unknown Source) ~[na:na] at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287) ~[drools-core-5.5.0.Final.jar:5.5.0.Final] ... 13 common frames omitted

triceo commented 11 years ago

My declarations in the DRL:

global Logger logger; global PathTracker tracker;

declare AvailableMove x: int y: int move: Move end

declare CurrentPosition node: Node end

declare PresentCollectible node: Node collectible: Collectible end

declare AvailableCollectible node: Node collectible: Collectible path: List end

declare ReachableCollectible node: Node collectible: Collectible path: List end

declare TargettedCollectible node: Node collectible: Collectible path: List end

declare PlayerMoveEvent @role (event) end

declare CollectibleAdditionEvent @role (event) end

declare CollectibleRemovalEvent @role (event) end

declare entry-point rewardEvents @doc("A stream of reward events generated by the game") end

declare entry-point gameEvents @doc("A stream of non-reward events generated by the game") end

declare entry-point playerEvents @doc("A stream of events generated by players") end

triceo commented 11 years ago

And the rule mentioned in the exception:

rule "From available collectibles, find those that can be reached in time" salience 30 when CurrentTurn($turn: number) AvailableCollectible($n: node, $p: path, $c: collectible, $c.expires() == false || ($c.expires() == true && $c.expiresInTurn() > ($turn + $p.size()))) then insertLogical ( new ReachableCollectible($n, $c, $p) ); end

tomason commented 11 years ago

It is a problem with condition evaluation (not the rule that you mentioned). Problem is caused by Drools JIT optimization. I'm trying to find a way to disable it. For now, could you please try adding this line to Player.constructKnowleedgeBase() method:

kbconf.setOption(PermGenThresholdOption.get(0));

Please let me know if it helps. In the meantime, I'll keep digging.

triceo commented 11 years ago

It did work.