sergi martinez
sergi martinez

Reputation: 165

Global lists in NetLogo?

I'm implementing a model in which I need a global list to store some music notes during the execution. At the end of the execution, I would like to iterate over the list in order to listen all the musical phrase. I guess I need to use a global list but I don't know how to do it. Any suggestion? Thanks!

Upvotes: 1

Views: 907

Answers (1)

JenB
JenB

Reputation: 17678

Any global variable can be a number or a string or a list or an agentset or.... I'm not really sure what a 'music note' looks like in your implementation or how you are recording duration. But here's something to get you started that focuses on your specific question about global lists.

globals
[ melody
]

to setup
  clear-all
  set melody []
  reset-ticks
end

to go
  set melody lput one-of (list "A" "B" "C" "D" "E" "F" "G") melody
  print melody
  tick
end

Are you using the sound extension (see https://ccl.northwestern.edu/netlogo/docs/sound.html) to actually do notes?

Upvotes: 2

Related Questions