user399466
user399466

Reputation: 117

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 calling turtle.

Upvotes: 0

Views: 888

Answers (1)

Jose M Vidal
Jose M Vidal

Reputation: 9142

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.

Upvotes: 1

Related Questions