Edson Tirelli wrote:

    Geoffrey,

    I don't think you need multiple patterns for this specific use case:

rule "multipleQueensHorizontal"
when
     Queen($id : id, $y : y)
     Number( $multipleQueensHorizontal : intValue )
     from accumulate( $q : Queen(id > $id, y == $y), count($q) );
then
    // do something
end

This would result in the number of (higher id) queens which are at the same horizontal position for a certain queen.
But I need the sum of that for all queens.

For example for these rows:
AB_D_F
__C___
____E_
This would give me:
A: 3
B: 2
C: 0
D: 1
E: 0
F: 0
That's all correct, but I need the sum of that:
multipleQueensHorizontal: 6

After that I 'd like to use that for a sum of multipleQueensHorizontal, multipleQueensDiagonalUp and multipleQueensDiagonalDown (vertical is always 0 due to my moves and start position) which gives me the score (the only thing that I really need).

I could of course do a logicalAssert of a number per queen and then accumulate those, kinda what I did with the WorkaroundMultiplePatternAccumulate object.

But it looks like accumulate is improving my performance already, great work :) Or could it be because I am now using rules with assertLogical() instead of query's?


   Am I misunderstanding your use case?


   []s
   Edson

With kind regards,
Geoffrey De Smet


2007/7/28, Geoffrey De Smet <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>:

    I 'd like to get the number of queens which have the same y.

    I used to do this with a query:
        query "multipleQueensHorizontal"
            Queen($id : id, $y : y);
            Queen(id > $id, y == $y);
        end
    And then ask the size() of it.

    But now I should be able to do this with the accumulate function:
         $multipleQueensHorizontal : Integer()
         from accumulate(
             $q1 : Queen($id : id, $y : y);
             Queen(id > $id, y == $y);
           , count($q1)
         );

    However, I get a parsing error on it:
       Caused by: org.drools.rule.InvalidRulePackage: [31,37]: unknown:31:37
    Unexpected token ';'[33,6]: unknown:33:6 mismatched token:
    [EMAIL PROTECTED],814:814=',',<12>,33:6]; expecting type THEN

    Apparently the ; in of "$q1 : Queen($id : id, $y : y);" is inacceptable?

    --
    With kind regards,
    Geoffrey De Smet

    _______________________________________________
    rules-users mailing list
    [email protected] <mailto:[email protected]>
    https://lists.jboss.org/mailman/listinfo/rules-users
    <https://lists.jboss.org/mailman/listinfo/rules-users>




--
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  JBoss, a division of Red Hat @ www.jboss.com <http://www.jboss.com>


------------------------------------------------------------------------

_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to