views:

35

answers:

1

i am trying to find if there is a turtle on patch ahead n whos speed - accelaration is <= 0. the code i came up with is:

if any? turtles on patch-ahead n with [speed <= (speed - aceleration)]

but this gives an error that patch-ahead expects a number, instead got agent set.

pleae help how can i do this.

n is a number variable. i want to excess the speed (speed is user defined variable of turtle) of the turtle at nth patch from the calling turtle. the command 'with' doesnt work here, please suggest any alternative to excess the speed of the turtle at, say, 3rd patch from the calling turtle.

+1  A: 

If you look at the patch-ahead documentation you will notice that it does require one argument: a number representing the distance to look ahead. You are using a patch 'n' instead of a number.

As per you comment, I think maybe you want turtles-on, and use parenthesis to make it clearer, as such:

if any? ((turtles-on patch-ahead n) with [speed <= (speed - aceleration)])

In the above I am assuming that n is a number: the distance you want to look ahead.

Jose M Vidal
n is a number variable. i want to excess the speed (speed is user defined variable of turtle) of the turtle at nth patch from the calling turtle. the command 'with' doesnt work here, please suggest any alternative to excess the speed of the turtle at, say, 3rd patch from the calling turtle.
I updated the answer. Note that its 'turtles-on' and not 'turtles on'.
Jose M Vidal
thanks a lot jmvidal really appreciated.