The situation is very simple: there are some turtles, producers, and others, choosers. Producers produce something with a certain objective-quality, choosers choose on the basis on perceived quality.
Choosers should be able to choose only from producers in Moore Neighbour, and can choose only one producer. Once chosen, they create a local for the chosen producer.
Here is what I have to begin with:
ask turtles with [group = "choosers"] [
let friends turtles-on neighbors
let x friends with-max [perceived-quality]
ask x [set chosen? (true) ]
]
Of course, with this code turtles choose all those with max perceived-quality (>1).
If I use max-one-of, there is an error, because not all the turtles have “friends”.
How can I do it?