A player may have multiple characters and the rule should fire when any of its characters live longer than 2 minutes. that's why "characters" do not have a unique identification and there isn't any event representing a character birth.<div>
<br></div><div>Best Regards,</div><div>Kevin Zhao<br><br><div class="gmail_quote">2010/10/28 Wolfgang Laun <span dir="ltr"><<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
If EventB( index == 3 ) signifies that the "character" owned by player 3 has been killed: what is the event that this character has been born? Life is the time between birth and death; these two are well-defined (well, mostly) events, and they ought to be represented by clean-cut events in any application. Then it's no problem to write rules firing when a "character" lives longer or shorter than any time. Also, "characters" may have to have a unique identification beyond their player-owner.<br>
<br>If you are constantly shifting your specs, we won't be getting any closer to a solution, though.<div><div></div><div class="h5"><br><br>-W<br><br><br><div class="gmail_quote">2010/10/28 ΥΤΩ©Ω© <span dir="ltr"><<a href="mailto:kevin223@gmail.com" target="_blank">kevin223@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">To be honest, I don't quite understand the rules you wrote. Let me explain this a little bit with a real world scenario.<div>
Assume this is an on-line game that EventB indicates a 'kill' event that a player is losing its character who might be killed by some other player.</div>
<div>The property index points to the player who owns this character. What I'm looking for here is to find out when a player's character survives in 2 minutes. The number of players in a game is at least 2 but can be up to any number.</div>
<div><div></div><div>
<div><br></div><div>Best Regards,</div><div>Kevin Zhao<br><br><div class="gmail_quote">2010/10/28 Wolfgang Laun <span dir="ltr"><<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<br><br><div class="gmail_quote"><div>2010/10/28 ΥΤΩ©Ω© <span dir="ltr"><<a href="mailto:kevin223@gmail.com" target="_blank">kevin223@gmail.com</a>></span><br></div><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<div>Hello Wolfgang,</div><div><div><br></div>Index is just like the index in an array. the value can be any from 0 to the array length. <div>for the previous example, the length is 1 so index can be either 0 or 1. but in the real case, the length can be an arbitrary number.</div>
<div><br></div><div>another question, there are 2 rules here, do both of them have to be applied?</div></div></blockquote><div><br>One creates and inserts the PatternConsumer which blocks repeated usage of the pair of EventB facts that have been successfully paired. Otherwise a sequence EventB:0, EventB:1, EventB:2 would fire 2 times.<br>
<br>If the positive condition is more complex, e.g., you need *all* index values 0,...,L-1 within 2m, then other conditions will be required (and that's what I meant with "more precisesly"). If any pair a,b from [0..L-1] will do, then the modified version (!=) should be OK.<br>
<font color="#888888">
<br>-W<br><br> </font></div><div><div></div><div><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex"><div><br></div><div>Best Regards,</div>
<div>Kevin Zhao<br><br><div class="gmail_quote">
2010/10/28 Wolfgang Laun <span dir="ltr"><<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>></span><div><div></div><div><br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">Kindly state your requirements precisely.<br><br>Perhaps <br> not ( EventB ( index != $index,... )<br>
is what you need.<br>
-W<br><br><div class="gmail_quote">2010/10/28 ΥΤΩ©Ω© <span dir="ltr"><<a href="mailto:kevin223@gmail.com" target="_blank">kevin223@gmail.com</a>></span><div><div></div><div><br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">I haven't tested this rule, but what about the case that property index would have arbitrary number of possible values?<br>
<br><div class="gmail_quote">2010/10/27 Wolfgang Laun <span dir="ltr"><<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">Omitting the Entry Points:<br>
<br>
rule "B-0-1-not OK"<br>
when<br>
$b : EventB( $index: index )<br>
not ( PatternConsumer( id == "B01", events contains $b ) )<br>
not ( EventB( index == (1 - $index), this after[0s,2m] $b ) )<br>
then<br>
System.out.println( "B:" + $index + ", but no B:" + (1-$index) );<br>
end<br>
<br>
rule "B-0-1"<br>
when<br>
$b1 : EventB( $index: index )<br>
$b2 : EventB( index == (1 - $index), this after[0s,2m] $b1 )<br>
then<br>
insert( new PatternConsumer( "B01", $b1, $b2 ) );<br>
System.out.println( "B:" + $index + "+B:" + (1-$index) );<br>
end<br>
<br>
-W<br>
<br>
2010/10/27 ΥΤΩ©Ω© <<a href="mailto:kevin223@gmail.com" target="_blank">kevin223@gmail.com</a>>:<br>
<div><div></div><div>> Hello,<br>
> With the help from the community I managed to get my first rule working, and<br>
> I'm trying to write my second rule on my own but it just doesn't seem to<br>
> work correctly.<br>
> Here is the scenario, what I want is to identify a pattern that there's no<br>
> EventB coming in within 2 minutes with a particular index value.<br>
> For example, EventB would have a property named index and assume the value<br>
> of index would be either 0 or 1.<br>
> Before firing the rules, I would manually insert facts of possibleIndex with<br>
> value 0 and 1 into the workingMemory.<br>
> Within 2 minutes, if there only comes one EventB with index valued 0 then<br>
> the system should report no EventB coming in with index value 1 in last 2<br>
> minutes.<br>
> Vice versa, in the case of only coming one EventB with index valued 1 then<br>
> the system should report no EventB coming in with index value 0 in last 2<br>
> minutes.<br>
> If within 2 minutes, there comes 2 EventB with both value 0 and 1 then<br>
> nothing should report.<br>
> Here is what I wrote, but it doesn't seem to work correctly.<br>
> I used a timer to fire this rule every 10 seconds because I don't think the<br>
> rule would run automatically if I don't add that. (not too sure though)<br>
> rule "no B in 2 minutes"<br>
> timer (0 10s)<br>
> when<br>
> possibleIndex( $index : index ) from entry-point "Event stream"<br>
> $p : PatternConsumer ( name == 'no B' && index == $index )<br>
> not ( EventB( index == $index && this after[0ms,2m] $p) over window:time(2m)<br>
> from entry-point "Event stream" )<br>
> then<br>
> PatternConsumer pc = new PatternConsumer( "no B", $index );<br>
> insert(pc);<br>
> System.out.println("no B in 2 minutes " + $index);<br>
> end<br>
> Best Regards,<br>
> Kevin Zhao<br>
</div></div>> _______________________________________________<br>
> rules-users mailing list<br>
> <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
><br>
><br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div></div></div><br>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div></div></div><br></div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div></div></div><br>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br>
</div></div><br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br></div>