Hello,
I don't succeed in building a list from patch variables, see a reproducible example
globals [ABC LU IDlist]
patches-own [seed ID AT]
set ABC [ "A" "B" "C" "D" "E" "F" "G" "H" "I" ]
set LU ["apple" "pear" "citrus" "banana" "orange"]
ask patches [ set seed random 10 set ID one-of ABC set AT3 one-of LU
ifelse (ID = "A")
[ set pcolor orange] [set pcolor white]
]
set AT-data [["A" 65 81] ["B" 21 71] ["C" 54 18] ["D" 23 41] ["E" 85 27] ["F" 35 88] ["G" 29 4] ["H" 78 2] ["I" 99 60]]
ask patches [
let i 0
while [i < length AT-data] [
let current-inner-list item i AT-data
set IDlist [ ]
ifelse (ID = item 0 current-inner-list) [
set IDlist lput AT3 IDlist
;; this not working as expected
print IDlist
stop
]
[ set i i + 1]
]
]
The idea is to generate a IDlist for each item of AT-data where it is filled with the AT3 variable of all patches that share the same ID (as per AT-data list).
The idea is to create a temporary list, check something (not written here) and then move on to the next item of AT-data
That is why I "reinitiate" the IDlist.
The results is just a IDlist of length one, which should not be, as multiple patches share the same ID.
I have tried many things, including using foreach, or creating an initial list with the ID and then replace-item i + lput commands i for each ID.... but it looks like I'm missing something.
Many thanks, best
Sarah