开发者

netlogo programing help on traffic simulation

I am trying to find if there is a turtle on patch-ahead n

whose speed - acceleration is <= 0. The code I came up with is:

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

but this gives an error that:

patch-ahead expects a number, instead got agent set.

How do I remedy this?

n is a number variable. I want to access the turtle's 'speed', which is a user defined turtle-own variable, at the nth patch from the calling turtle. The command 'with' doesn't work here. Please suggest an alternative to access the speed of the turtle at, say, the 3rd patch from the callin开发者_开发技巧g turtle.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜