Moe's code only checks for the X-distance (RELX command), but when you want to check in an actual round radius in all directions, try DISQ instead:
The CAOS Documentation wrote:
DISQ (float) other (agent)
Returns the square of the distance between the centre points of the target agent, and the other agent. It is quicker to compare this square against a squared constant directly, or if you need the actual distance use SQRT.
As it points out, it checks for squared values, instead of normal ones, such as values of 500 for example, you had to check for 250000.