Created
September 30, 2023 13:29
-
-
Save moonblind/814e5283d73a7547b13c50c7a4208fee to your computer and use it in GitHub Desktop.
memory loss, for crow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- memory loss | |
| -- each crow can remember songs | |
| -- but some forget more than others | |
| -- | |
| -- in 1: v/8 sequence | |
| -- in 2: clock | |
| -- outs 1-4: shift register of memories | |
| s = sequins | |
| memory = {} | |
| loss = {} | |
| function init() | |
| input[2]{ mode = 'change', direction = 'rising' } | |
| for i = 1, 16 do | |
| for j = 1, 4 do | |
| table.insert(loss, i) | |
| end | |
| table.insert(memory, 0) | |
| end | |
| math.srandomseed(unique_id()) | |
| for j = (#loss/4), 2, -1 do | |
| for i = 4,1,-1 do | |
| local k = math.srandom(j) | |
| loss[i+4*j-4], loss[i+4*k-4] = loss[i+4*k-4], loss[i+4*j-4] | |
| end | |
| end | |
| loss = s(loss) | |
| end | |
| function remember() | |
| for n=1,4 do | |
| output[n].volts = memory[loss()] | |
| end | |
| end | |
| function forget() | |
| table.remove(memory) | |
| if ((unique_id() % 75 + 25)/100 > math.srandom()) then | |
| table.insert(memory, 1, input[1].volts) | |
| else | |
| table.insert(memory, 1, memory[1]) | |
| end | |
| end | |
| input[2].change = function() | |
| remember() | |
| forget() | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment