Re: [rules-users] Drools 6.0.0 activation-group + salience bug or feature?

2014-05-07 Thread Jan Šťastný
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ý newohy...@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(($tradeProd1)?$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, 

[rules-users] Drools 6.0.0 activation-group + salience bug or feature?

2014-05-06 Thread Jan Šťastný
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(($tradeProd1)?$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@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 

Re: [rules-users] Drools 6.0.0 activation-group + salience bug or feature?

2014-05-06 Thread Mark Proctor
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ý newohy...@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(($tradeProd1)?$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@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,