views:

16

answers:

2

while running the following code

if any? (turtles-on patch-ahead q) [ some commands ]

where q is a number variable

there is a run time error saying: turtles-on expected the input to be agent or agent set but got nothing.

what can be wrong.

+1  A: 

It could be that there is no patch-ahead q because the turtle is at the edge of world, facing towards the outside, and your would does not wrap around. The turtle has reached the end of the world and is facing the abyss.

Try setting the world so that it wraps around on both the x and y axis.

Jose M Vidal
A: 
 let p patch-ahead q
 if p != nobody and any? turtles-on p
   [ some commands ]

works, as does

 if can-move? q and any? turtles-on patch-ahead q
   [ some commands ]
Seth Tisue