Thanks for the answer!
Yep, in case of String types I could use 'matches' . But what if each player have also field:
int age
and instead of names I would like to compare age of players? How to cope with that?

As to the second idea - I think I can't just write the rule the exact way I did with "and" and "or" keywords. I believe it is impossible to nest "and"s and "or"s. Am I right? I also wasn't able to successfully write such a rule.

regards
John

On 11/8/06, gabriel quennesson <[EMAIL PROTECTED] > wrote:
I'm not sure this is the answer you expect but you could do the following :

when
    Player1 (name matches "Roy|Bob")
    Player2(name matches "Tom|Eric")
...
    Player11(name matches "Paulo|Ryan")
then
    doStuff();
end

In some trickier cases, you could use functions to perform other forms of matching.

Or you could just write the rule the exact way you did with "and" and "or" keywords, which is documented in Drools (I wasn't able to successfully write such a rule, though).

Regards,

Gabriel

John Cocktolstoy a écrit :
Hi,

I am new to Drools, I just read documentations and went through some examples.
I am wondering about the following example (I spiced it up with a story so it should not be boring :-) ):

Suppose I am a football manager and trying to use Drools to automate some processes.
I have 11 classes (these are going to be facts):
Player1, Player2, Player3, ..., Player11
One for each player of my team, each of class has one field:
String name
In run-time I will assert into working memory only one instance of each class as I would like to evaluate some rules over my current team.
Now I would like to create simple rule - I express it in pseudo-language:

when
  ((Player1.name == "Roy") or ( Player1.name == "Bob"))
and
  ((Player2.name == "Tom") or ( Player2.name == "Eric"))
and
  ...
and
  ((Player11.name == "Paulo") or (Player11.name == "Ryan"))
then
  do something

Could anyone show me how to express this rule using Drools without going into huge number of rules? As I understand from documentation each 'or' is creating two sub-rules. Isn't that limitation that makes Drools useless for football managers?

regards
John




Reply via email to