[rules-users] How to write a rule which only fires for a closest value?
Mark Proctor
mproctor at codehaus.org
Sat Dec 8 07:06:25 EST 2007
velven wrote:
> 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?
>
if you need to do maths to manipulate fields you'll need to use a
returnRevalue field constraint or an inlineEval field constraint. The
first is if you only need to apply a function to the field/value on the
right of the operator, the eval is if you need to apply a function to
both sides.
> Thanks!
>
>
>
More information about the rules-users
mailing list