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 say开发者_如何转开发ing: turtles-on expected the input to be agent or agent set but got nothing.
what can be wrong.
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.
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 ]
精彩评论