[rules-users] Drools 6.0.0 activation-group + salience bug or feature?
Jan Šťastný
newohybat at gmail.com
Wed May 7 02:59:49 EDT 2014
Thanks for answer,
well I thought that the activation-group and salience applies only on
the rules with the same LHS, I mean exact match by equality. But there
it cancels different ones. Nevermind.
The game doesn't exist (yet). It is for my diploma thesis coordinated by
Red Hat. I have to implement game logic of civilization-like game.
As for my project, I started blog a while ago, but lately I'm busy
writing my diploma thesis, so I haven't updated it for a while. Here it
is: http://civilization-mmo.blogspot.com/ . Also you can visit my github
account where again there are some projects concerning the game, but
current version is to be added in short time. Hopefully by 26 may it
shall be updated.
Jan
Dne 7.5.2014 01:49, Mark Proctor napsal(a):
> That’s what an activation-group does. The first rule (with the highest salience) fires, the others are cancelled.
>
> Out of interest, what’s the game? Something online we can look at? I have an interest in games development for Drools, and have been slowly adding examples. Space invaders was my latest one:
> https://www.youtube.com/watch?v=wORlAZoxttA
> https://github.com/droolsjbpm/drools/tree/master/drools-examples/src/main/java/org/drools/games/invaders
>
> Mark
> On 6 May 2014, at 23:12, Jan Šťastný <newohybat at gmail.com> wrote:
>
>> Hi,
>> I came across in my view strange behaviour of rules defined with
>> activation-group and salience. I use this combination to set the
>> priority of exclusively fired rules "Democracy City Tiles Production"
>> and "Basic City Tiles Production".
>> Their definitions:
>> rule "Democracy City Tiles Production"
>> dialect "mvel"
>> ruleflow-group "manageProductions"
>> activation-group "cityProduction"
>> salience 5
>> when
>> PlayerDTO($owner:id, government=="democracy")
>> $city:CityDTO(
>> owner==$owner
>> ,$cityId:id
>> ,$managedTiles:managedTiles
>> )
>> accumulate(
>> TileDTO (
>> id memberOf $managedTiles
>> ,$foodProd:foodProduction
>> ,$resourcesProd:resourcesProduction
>> ,$tradeProd:tradeProduction
>> )
>> @watch(foodProduction,resourcesProduction,tradeProduction)
>> ,$sumFood : sum($foodProd)
>> ,$sumResources : sum($resourcesProd)
>> ,$sumTrade :
>> sum(($tradeProd<1)?$tradeProd:($tradeProd+1))
>> )
>> UpdateCityProduction(cityId==$cityId)
>> then
>> modify($city){
>> setFoodProduction($sumFood)
>> ,setResourcesProduction($sumResources)
>> ,setTradeProduction($sumTrade)
>> }
>> end
>>
>> and
>>
>> rule "Basic City Tiles Production"
>> dialect "mvel"
>> ruleflow-group "manageProductions"
>> activation-group "cityProduction"
>> when
>> PlayerDTO($owner:id)
>> $city:CityDTO(
>> owner==$owner
>> ,$cityId:id
>> ,$managedTiles:managedTiles
>> )
>> accumulate(
>> TileDTO (
>> id memberOf $managedTiles
>> ,$foodProd:foodProduction
>> ,$resourcesProd:resourcesProduction
>> ,$tradeProd:tradeProduction
>> )
>> @watch(foodProduction,resourcesProduction,tradeProduction)
>> ,$sumFood : sum($foodProd)
>> ,$sumResources : sum($resourcesProd)
>> ,$sumTrade : sum($tradeProd)
>> )
>> UpdateCityProduction(cityId==$cityId)
>> then
>> modify($city){
>> setFoodProduction($sumFood)
>> ,setResourcesProduction($sumResources)
>> ,setTradeProduction($sumTrade)
>> }
>> end
>>
>> But problem occurs when two CityDTO objects are in the session. I would
>> like to fire one rule for each CityDTO, but the activation-group cancels
>> all the activations after first is fired. So only one activation in
>> place of two fires. Here is the log:
>>
>> ==>[BeforeActivationFiredEvent: getActivation()=[[ Democracy City Tiles
>> Production active=false ] [ [fact
>> 0:12:36803987:36803987:12:DEFAULT:NON_TRAIT:UpdateCityProduction(
>> cityId=5 )]
>> [fact
>> 0:16:2083264739:2083264739:16:null:NON_TRAIT:[Ljava.lang.Object;@7c2c18e3]
>> [fact 0:11:792938926:966:11:DEFAULT:NON_TRAIT:CityDTO [id=5,
>> name=marefy, cityCentre=null, owner=1, improvements=[],
>> currentImprovement=null, enabledImprovements=[], homeUnits=[],
>> currentUnit=null, enabledUnitTypes=[], tradeRoutes=[], managedTiles=[1,
>> 2], size=5, weLoveDay=false, disorder=false, foodProduction=0,
>> foodConsumption=0, foodSurplus=0, foodStock=0, resourcesProduction=0,
>> resourcesConsumption=0, resourcesSurplus=null, tradeProduction=0,
>> corruption=0, luxuriesAmount=0, luxuriesSpent=0, taxesAmount=0,
>> researchAmount=0, peopleHappy=2, peopleUnhappy=1, peopleContent=1,
>> peopleEntertainers=0, peopleTaxmen=1, peopleScientists=0,
>> pollutionChance=0, improvementsUpkeep=0, unitsSupport=0]]
>> [fact 0:9:1762763035:99463566:9:DEFAULT:NON_TRAIT:PlayerDTO [id=1,
>> name=honza, government=democracy, enabledGovernments=null,
>> currentAdvance=null, advances=null, enabledAdvances=null, treasury=0,
>> research=0, researchSpent=null, turnsAvailable=null, luxuriesRatio=0,
>> taxesRatio=0, researchRatio=0]] ] ],
>> getKnowledgeRuntime()=org.drools.core.impl.StatefulKnowledgeSessionImpl at 6a5b07f2]
>> ==>[ActivationCancelledEvent: getCause()=CLEAR, getActivation()=[[ Basic
>> City Tiles Production active=false ] [ [fact
>> 0:15:807492131:807492131:15:null:NON_TRAIT:[Ljava.lang.Object;@30215a23]
>> [fact 0:11:792938926:966:11:DEFAULT:NON_TRAIT:CityDTO [id=5,
>> name=marefy, cityCentre=null, owner=1, improvements=[],
>> currentImprovement=null, enabledImprovements=[], homeUnits=[],
>> currentUnit=null, enabledUnitTypes=[], tradeRoutes=[], managedTiles=[1,
>> 2], size=5, weLoveDay=false, disorder=false, foodProduction=0,
>> foodConsumption=0, foodSurplus=0, foodStock=0, resourcesProduction=0,
>> resourcesConsumption=0, resourcesSurplus=null, tradeProduction=0,
>> corruption=0, luxuriesAmount=0, luxuriesSpent=0, taxesAmount=0,
>> researchAmount=0, peopleHappy=2, peopleUnhappy=1, peopleContent=1,
>> peopleEntertainers=0, peopleTaxmen=1, peopleScientists=0,
>> pollutionChance=0, improvementsUpkeep=0, unitsSupport=0]]
>> [fact 0:12:36803987:36803987:12:DEFAULT:NON_TRAIT:UpdateCityProduction(
>> cityId=5 )] ] ],
>> getKnowledgeRuntime()=org.drools.core.impl.StatefulKnowledgeSessionImpl at 6a5b07f2]
>> ==>[ActivationCancelledEvent: getCause()=CLEAR, getActivation()=[[ Basic
>> City Tiles Production active=false ] [ [fact
>> 0:23:833001332:833001332:23:null:NON_TRAIT:[Ljava.lang.Object;@31a69774]
>> [fact 0:18:1816369501:968:18:DEFAULT:NON_TRAIT:CityDTO [id=7, name=Brno,
>> cityCentre=null, owner=1, improvements=[], currentImprovement=null,
>> enabledImprovements=[], homeUnits=[], currentUnit=null,
>> enabledUnitTypes=[], tradeRoutes=[], managedTiles=[3, 4], size=1,
>> weLoveDay=false, disorder=false, foodProduction=0, foodConsumption=0,
>> foodSurplus=0, foodStock=0, resourcesProduction=0,
>> resourcesConsumption=0, resourcesSurplus=null, tradeProduction=0,
>> corruption=0, luxuriesAmount=0, luxuriesSpent=0, taxesAmount=0,
>> researchAmount=0, peopleHappy=0, peopleUnhappy=0, peopleContent=1,
>> peopleEntertainers=0, peopleTaxmen=0, peopleScientists=0,
>> pollutionChance=0, improvementsUpkeep=0, unitsSupport=0]]
>> [fact
>> 0:20:1314789527:1314789527:20:DEFAULT:NON_TRAIT:UpdateCityProduction(
>> cityId=7 )] ] ],
>> getKnowledgeRuntime()=org.drools.core.impl.StatefulKnowledgeSessionImpl at 6a5b07f2]
>> ==>[ActivationCancelledEvent: getCause()=CLEAR, getActivation()=[[
>> Democracy City Tiles Production active=false ] [ [fact
>> 0:20:1314789527:1314789527:20:DEFAULT:NON_TRAIT:UpdateCityProduction(
>> cityId=7 )]
>> [fact
>> 0:19:1857434733:1857434733:19:null:NON_TRAIT:[Ljava.lang.Object;@6eb6346d]
>> [fact 0:18:1816369501:968:18:DEFAULT:NON_TRAIT:CityDTO [id=7, name=Brno,
>> cityCentre=null, owner=1, improvements=[], currentImprovement=null,
>> enabledImprovements=[], homeUnits=[], currentUnit=null,
>> enabledUnitTypes=[], tradeRoutes=[], managedTiles=[3, 4], size=1,
>> weLoveDay=false, disorder=false, foodProduction=0, foodConsumption=0,
>> foodSurplus=0, foodStock=0, resourcesProduction=0,
>> resourcesConsumption=0, resourcesSurplus=null, tradeProduction=0,
>> corruption=0, luxuriesAmount=0, luxuriesSpent=0, taxesAmount=0,
>> researchAmount=0, peopleHappy=0, peopleUnhappy=0, peopleContent=1,
>> peopleEntertainers=0, peopleTaxmen=0, peopleScientists=0,
>> pollutionChance=0, improvementsUpkeep=0, unitsSupport=0]]
>> [fact 0:9:1762763035:99463566:9:DEFAULT:NON_TRAIT:PlayerDTO [id=1,
>> name=honza, government=democracy, enabledGovernments=null,
>> currentAdvance=null, advances=null, enabledAdvances=null, treasury=0,
>> research=0, researchSpent=null, turnsAvailable=null, luxuriesRatio=0,
>> taxesRatio=0, researchRatio=0]] ] ],
>> getKnowledgeRuntime()=org.drools.core.impl.StatefulKnowledgeSessionImpl at 6a5b07f2]
>>
>>
>> Is it a bug?
>> Thanks
>> Jan
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
More information about the rules-users
mailing list