I know that patches are sorted with the top left-most patch first and the bottom right-most patch last. My question is: if patches have an id patches-own[id] is it possible to sort patches by id. I don't want a list but an agenset?
Thanks
I know that patches are sorted with the top left-most patch first and the bottom right-most patch last. My question is: if patches have an id patches-own[id] is it possible to sort patches by id. I don't want a list but an agenset?
Thanks
Alas, as noted here
https://ccl.northwestern.edu/netlogo/docs/programming.html#agentsets
agentsets are always in random order. As you likely know, however, you can make an ordered list of patches by id and then loop or map through it. The sort-on primitive will do that. As an example,
patches-own [ id ]
to test
ask patches [set id random 10000] ; assign random ids to patches
let sorted-patches sort-on [id] patches
show sorted-patches
show map [[p] -> [id] of p] sorted-patches
end
gives you a sorted list of the patch ids.
Charles