Reputation: 79
I'm struggling to work out how to tell my turtles to move forward 1 onto a vacant patch, once they have already been turned around in a procedure called "turn-turtle".
let ahead patch-ahead 1
let vacant-ahead ahead with [not any? turtles-here ] ;;this line needs fixing
if any? turtles
[turn-turtle if vacant-ahead [fd 1]]
It produces this error, which I understand, but can't work out how to fix.
WITH expected input to be an agentset but got the patch (patch 1 -2) instead.
error while solute 2 running WITH
called by procedure MOVE-TURTLE
called by procedure GO
called by Button 'go'
Just replying to some comments in a more readable fashion: Sorry I don't think I explained it very well, as I've just taken a tiny bit of my code out. Maybe this makes more sense.
to go
ask turtles
[move-turtle]
end
to move-turtle
turn-turtle
if (not any? turtles-on patch-ahead 1)
[fd 1]
end
So I just want this code to move the turtles that have been turned with "turn-turtle" to an empty patch ahead 1, preferably taking up the entire patch, like if they were "sprouted". Thanks!
Upvotes: 0
Views: 1011
Reputation: 9610
Sounds like you want to do something a bit different, if you really want ahead
to be a single patch. So perhaps
to move
ifelse (any? turtles-on patch-ahead 1) [
turn-turtle
][
fd 1
]
end
Upvotes: 1