by RodgerTheGreat · 9y ago · 0 comments
http://johnearnest.github.io/ok/ike/ike.html?gist=f974a638c4...
Source, for the curious:
p: 72 / players
s: p#100 / score
c: {(+/(!#x)=/:(+/t)?#x)-t:0<x} / change (per round)
b: {[c;p;y;x](p+0,2*y;;x#c)} / draw bar (color;pos;y;x)
g: {x'[!#y;_60*y%|/y]} / draw graph (bar;data)
tick: {{s+::c s}'!20} / iterate several steps/frame
draw: {g[b[3;10 10];s@<s],g[b[2;90 10];s]} / graph sorted, raw valueThe above program was implemented in iKe, a browser-based livecoding environment I built on top of my interpreter:
https://github.com/JohnEarnest/ok/tree/gh-pages/ike
The concision and flexibility of K is a huge boon for this kind of interactive development. I wrote my simulation in a few minutes, and most of that time was spent deciding how I wanted to draw my histograms.
If you have any more specific questions I'd be happy to try to answer them.