-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
save-matrix
should order rows by the corresponding turtles who
number
#151
Comments
So can whatever order the matrix is in be ouput too? So the columns/rows might be in a random order, but we'd know what that order is. Thanks, Thomas |
I'd like to make the rows order by I also posted a workaround there, but will put it here as well for convenience:
|
Thank you that's really useful. How would you get output of a turtle variable in the same order please? For instance, if I wanted to output the colour of each turtle so they came out in the same order as the adjacency matrix? Thank you, Thomas |
Editing what you did I came up with the following. I think it works.
|
Yup, that's about right. You could simplify like so:
|
Hi. I am having the same issue right now, and I tried what you did. But it doesnt work maybe due to netlogo version update? To be more specific, netlogo reply "nothing name ? has been defined." at the code "let source ?" and "let target ?". |
@hariWong Yeah, that's the old task syntax from before the anonymous procedure changes were done in version 6. Try this instead: to save-colors [ filename ]
file-open filename
foreach sort turtles [ [t] -> file-print [ color ] of t ]
file-close
end |
@LaCuneta Thank you so much. But actually I am having questions with the code below: to save-matrix [ filename ] Still, MANY thanks. |
Gotcha, okay, applying that same conversion process in the Transition Guide to that code we get: to save-matrix [ filename ]
if file-exists? filename [ file-delete filename ]
file-open filename
let turtle-list sort turtles
foreach turtle-list [ [source] ->
foreach turtle-list [ [target] ->
ifelse [ link-neighbor? target ] of source [
file-type "1 "
] [
file-type "0 "
]
]
file-print ""
]
file-close
end I didn't test that, but I think it's correct. |
@LaCuneta Thank you! It worked! Now that Here's some of my code:
Netlogo reported--OF expected input to be a link agentset or link but got NOBODY instead. |
@hariWong I think we're getting a little off-topic for this issue. I'd recommend posting your problem with the code you wrote to the NetLogo Users Group or StackOverflow with the |
@LaCuneta Oh right. Thank you! |
Currently, we're storing the
turtles
data structure which dictate the order in which the rows are generated in a set, so there is no guaranteed order.The text was updated successfully, but these errors were encountered: