E W
E W

Reputation: 61

Directing Turtles to Multiple Patches

I'm not sure if it is possible, but I want to direct turtles to any 1 patch belonging to a patch-set, since the food spans multiple patches. However, move-to and setxy both give me the error "move-to expected this input to be a turtle or a patch, but got a patch agent-set instead."

move-to (patch-set patch -41 -21 patch -40 -21 patch -39 -22 patch -40 -22 patch -41 -22 patch -42 -22 patch -42 -23 patch -41 -23 patch -40 -23 patch -39 -23 patch -41 -24 patch -40 -24)

Upvotes: 1

Views: 108

Answers (2)

JenB
JenB

Reputation: 17678

If you want to move a turtle to any patch in a patch set, then randomly select a patch from that patch set (using one-of) and move it to that patch. As Seth notes, the turtle can only be in one place at a time. For readability, I would suggest creating the patch set and selecting from it in separate lines, but that's not necessary. Something like:

let food-patches (patch-set patch -41 -21 patch -40 -21 patch -39 -22 patch -40 -22 patch -41 -22 patch -42 -22 patch -42 -23 patch -41 -23 patch -40 -23 patch -39 -23 patch -41 -24 patch -40 -24)
move-to one-of food-patches

Upvotes: 1

Seth Tisue
Seth Tisue

Reputation: 30453

At any given time, a turtle can only occupy a single location — some definite x coordinate and y coordinate.

A turtle may appear to take up space on the screen, put that's purely a visual effect, intended for human eyes. Logically, a turtle is a dimensionless point.

Upvotes: 1

Related Questions