Reputation: 43
any idea how I can make a reference to an earlier output in netlogo? e.g. I have a loop and would like its exit condition to be observing three same consecutive results (the ones that are shown in the command center) I'm not sure how to do this (i.e. how to make a reference to the value that appears in the command center, so that I can compare them)
here is my code:
let exit false
let i 0
while [ not exit ] [let x (random 6)
type x
set exit (???)
set i (i + 1)]
Upvotes: 1
Views: 49
Reputation: 9610
There are lots of ways to do this. Some more context about your underlying goals might help. But here's an example that is narrowly tailored to your question:
to test
let lst [-1 -2 -3]
while [1 < length remove-duplicates lst] [
let x (random 6)
type x
set lst lput x butfirst lst
]
end
Upvotes: 3