3 ms·
I whipped up an interactive simulation of this effect in K: http://johnearnest.github.io/ok/ike/ike.html?gist=f974a638c484cbaa810bdf98c65c4951 http://johnearne
by RodgerTheGreat 9y ago
I whipped up an interactive simulation of this effect in K:
http://johnearnest.github.io/ok/ike/ike.html?gist=f974a638c484cbaa810bdf98c65c4951 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 value
- froggerplayer 9y agoI'm the author of the blog post OP points to. I'm impressed and intrigued what you've done here. Want to learn more about K.
- RodgerTheGreat 9y agoAs a brief summary, K is what's called a "vector-oriented" language; functional, very concise, naturally parallel. The canonical implementation(s) of K are commercial products sold by Kx Systems, and offer extremely high performance. I personally maintain an open-source clone implemented in JavaScript which is comparatively quite slow but is suitable for tinkering and prototyping. The 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 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.