Skip to content

Instantly share code, notes, and snippets.

@TarVK
Created December 24, 2020 16:59
Show Gist options
  • Save TarVK/33be639b6c56dd9baf61952dbe8e7378 to your computer and use it in GitHub Desktop.
Save TarVK/33be639b6c56dd9baf61952dbe8e7378 to your computer and use it in GitHub Desktop.
Just some random script. The code is quite bad in an attempt to get it in this shape :P
m=" .,-~:;=!*#$@";u=Math;t=u.ceil;c=
(x,y,d)=>d>4?1:1<x&&x<=2&&1<y&&y<=2?
0:c( (x%1)*3, (y%1)*3, d+1)
;f=0 ;w=285;b =u.floor ;i=8
;j=16;while(!0){f+=.02;s=u.pow(3,f%1
)/3;p=new Array(t(w/j)).fill(false).
map((v)=>new Array(t(w/i)
).fill(.0)); for(x=0;x<w;
x++) {for (y=0 ;y<w
;y++ ){v= c((( x/w-
0.5)*s+0.5)* 3,(y/w)*s*3,
0);p[b(y/j)] [b(x/i)]+=v/
(i*j+1);}}e=m.length;process.stdout.
write(p.map(v=>"\033[F").join(""));o
=(p. map(r=>r .reduce( (c,v
)=>m [+b(v*e) ]+c,"")+ "\n"
).join(""));process.stdout.write(o)}
/**Stupid*code*by*Tar*van*Krieken**/
@TarVK
Copy link
Author

TarVK commented Dec 26, 2020

Also created GOL:

                w=40;h=40;m=Math
                ;s=setInterval;n
                =(x,y)=>[[-1,-1]
                ,[0,-1],[1,-1],[
                -1,0],[1,0],[-1,
                1],[0,1],[1,1]].
                reduce((t,[dx,dy
                                ])=>t+(c[(y+dy+h
                                )%h][(x+dx+w)%w]
                                ==1),0);s(()=>{c
                                =c.map((r,y)=>r.
                                map((v,x)=>{i=n(
                                x, y);return v==
                                1?i==3||i===2?1:
.99:i==3?1:v;}));},100);s(()=>{c=c.map(r=>r.map(
v=>v<1?m.max(v-0.01,0):1));t="\033[F".repeat(h)+
c.map(r=>r.map(v=>(v==1?`\x1b[38;2;255;255;255m`
:`\x1b[38;2;0;0;${m.floor(v*255)}m`)+"██").join(
"")+"\n").join("");process.stdout.write(t)},33);
c=new Array(h).fill(false).map((i)=>new Array(w)
.fill(10).map(()=>{return m.random()>0.9?1:0}));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment