セルオートマトンのルール30の音

言語:mathematica

ameba[max_] := Prepend[Table[0, {i, max - 1}], 1]

rule30[x_, y_, z_] := 
 If[x == 1, (1 - y) (1 - z), (1 - (1 - y) (1 - z))]

evolveat[list_, n_, max_] := (cell = list[[n]];
  If[n == 1, leftcell = list[[max]], leftcell = list[[n - 1]]];
  If[n == max, rightcell = list[[1]], rightcell = list[[n + 1]]];
  rule30[leftcell, cell, rightcell])

evolve[list_, max_] := (Table[evolveat[list, i, max], {i, 1, max}])

main[max_] := (imogai = NestList[evolve[#, max] &, ameba[max], max];
  ArrayPlot[imogai, PixelConstrained -> 1, Frame -> False] ListPlay[
    Flatten[imogai]])

f:id:mikuwaorenoyome:20170325190214p:plain

曲は直接貼れないので、下で聞いてください。
Rule30 by 鈴木淳 | 淳 鈴木 | Free Listening on SoundCloud