Reputation: 449
I've been trying since yesterday to code the following: I have a world with 1 turtle in each patch (sprout command). I would like the turtle to check the 8 neighbors from the patch it is in. I did it like this: let neighWithVeg count neighbors of patch-here with [veg-value > 0.2]. But the error appears: WITH expected this input to be an agentset, but got a patch instead
Can someone help me?
patches-own [
veg-value
]
to setup
clear-all
reset-ticks
ask patches [
sprout 1
]
end
to go
ask turtles [
neighboring
]
end
to neighboring
let neighWithVeg count neighbors of patch-here of [veg-value > 0.2] ;; HERE THE ERROR
ifelse neighWithVeg = 0
[
move
]
[
move-to one-of neighbors of patch-here with [veg-value > 0.2]
]
end
Thanks in advance
Upvotes: 0
Views: 336
Reputation: 17678
For future questions, please only show the relevant code - probably the procedure with the error and the procedure that calls it. Also, NetLogo tells you which line generated the error.
I am guessing this is the line generating the error:
let neighWithVeg count neighbors of patch-here with [veg-value > 0.2]
You don't actually need of patch-here
because the code is taking the perspective of the relevant patch anyway. But if you did, then you need [ ] for of
, so it would be [neighbors] of patch-here
.
But I think what you want is:
let neighWithVeg count neighbors with [veg-value > 0.2]
Upvotes: 1