[rules-users] How to write a rule which only fires for a closest value?

velven velven83 at hotmail.com
Thu Dec 6 09:33:54 EST 2007


HI, i have a problem
using tileworld model, i'm supposed to write a rule which will cause the
agents to choose the tile in the agent's range which is closest to the
agent.

so a rough idea is

when

agent: Agent(x1:x, y1:y, r:range)

tile1: Tile(<tile's x to be between (x1+r) and (x1-r)> && <tile's y to be
between (y1+r and y1-r)>)

tile2: not Tile( < which is closer than the tile1 to agent> )

desperately need help,
alternatives tried::
i tried to use a query to return a list of tiles which is within the agent's
range then compared which one is closer and other similar implementation,
but this too slow for my simulation... 

I need one single good rule or efficient way of implementing the above rule 


then i tried to do multiple constraints too, say     x (> 30 && < 40) is ok
but 
                                                                  x (>
($x-$r) && < ($x+$r)) gives errors ,due to extra parenthesis? i dunno.. any
workarounds?

Thanks!


-- 
View this message in context: http://www.nabble.com/How-to-write-a-rule-which-only-fires-for-a-closest-value--tf4947931.html#a14166650
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list