I am creating a list of boolean values that represent a set of patches with the following code, where "obstacle" is a boolean property of the patch that says whether or not it is an obstacle and "map-area" is a list of specific patches.
set cell-walls map [ p -> [ obstacle ] of p] map-area
Then I print cell-walls to a text file, and it will print [ true true false true ... ]. I need it to print [ 1 1 0 1 ... ] instead.
Maybe I can replace elements in the list, or create a new list by iterating over this one and adding a 1 or 0 for each element. I'm not sure how to accomplish this in Netlogo. Help is appreciated! :)
If you only ever have true or false values, you could probably get away with something like:
to boolean-to-numeric
let bool [ true false true ]
let bool2 map [ i -> ifelse-value ( i = true ) [ 1 ] [ 0 ] ] bool
print bool2
end
But do note that the above will report 0 for any values other than true, not just for false.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With