Reputation: 35
For example, I would like to get the coordinates of the first patch above, below, to the left and right of the patch the turtle is currently on, as well as the value of a variable for each of those patches, such as plabel or pcolor. Essentially I would like to use this information so that then the agent can make a decision as to which patch to move to.
I think neighbors4 might be how to do this but I'm not quite sure of the code needed. For accessing variable values, I have been trying
let LabelsOfPatches neighbors4 [plabel]
or
let ColorOfPatches neighbors4 [pcolor]
But I get an error saying a command was expected in between the square brackets.
Upvotes: 1
Views: 472
Reputation: 4168
A one-liner that does the same thing would be
let NeighborList [(list pxcor pycor pcolor plabel)] of neighbors4
It can be run by either a turtle or a patch. of
is great for making lists of values drawn from another agent or agentset.
Upvotes: 2
Reputation: 35
I have seemingly done what I wanted by using
let NeighbourList []
ask neighbors4 [set ValuesOfInterest (list (pxcor) (pycor) (pcolor) (plabel))
set NeighbourList lput ValuesOfInterest NeighbourList
]
Upvotes: 0