const gameSpeed=40;let PS=500,FR=!0;const canvas=document.getElementById("canvas"),ctx=canvas.getContext("2d"),gap=2,gsX=window.innerWidth>window.innerHeight?96:window.innerWidth===window.innerHeight?81:51,gsY=window.innerWidth>window.innerHeight?51:window.innerWidth===window.innerHeight?81:96,minSizeToMove=9*gsY,csX=2*gsX+2*gsX,csY=2*gsY+2*gsY;canvas.width=csX,canvas.height=csY;let ratio=csXadjustColor(e,.2*Math.random()+.2));ccA.push(e)}const colInd=r(ccA.length),colArr=ccA[colInd],cl=colArr.length;document.title="Blockchain day #"+IND,window.addEventListener("resize",()=>{ratio=csXArray(gsX).fill(0)),cells=[];class Cell{constructor(e,t,s,l,n){this.x=e,this.y=t,this.destX=s,this.size=l,this.age=n,this.ageStep=0,this.spMod=.3*Math.random(),this.moving=!1,this.startX=e}}const cSz=canvas.width/gsX-2,sizeD={1:.3,2:.2,3:.1,4:.1,5:.08,6:.07,7:.06};let rPROB=1-sizeD[1]-sizeD[2]-sizeD[3]-sizeD[4]-sizeD[5]-sizeD[6];const exponent=-Math.log(1/333)/Math.log(gsY);for(let size=8;size<=gsY;size++){let t=rPROB*Math.pow(size,-exponent);sizeD[size]=t,rPROB-=t}function gRCS(){let e=r(333)/cl,t=0;for(let s=1;s0;)s--;if(s>0){let l=FR?t:gsX+Math.floor(r(cl))+2;cells.push(new Cell(l,e,t,s,FR?mAtX(t,gsX+Math.floor(5*r(cl-1))):Math.floor(2*Math.random()))),plC(t,e,s)}}FR=!1}let lAIT=0;function rCFG(e){for(let t=e.y;t!s.moving&&s.x===e&&s.y===t).forEach(t=>{mCell(t,e-1)})}function sCiR(e){let t=cells.filter(t=>!t.moving&&t.x>e.x&&t.y>=e.y&&t.y+t.sizet.size-e.size);return t.length>0&&(rCFG(t[0]),t[0].moving=!0,t[0].destX=e.x,plC(t[0].destX,t[0].y,t[0].size),!0)}function canMove(e){if(e.moving)return!1;for(let t=e.y;t0&&0!==grid[t][e.x-1])return!1;return!0}function draw(e){e.destX-e.x>=0?(e.moving=!1,e.x=e.destX):(e.moving=!0,e.x-=PS,e.x=gsX-2&&(ctx.fillStyle="rgba(255,255,255,0.9)"),ctx.fillRect(t+1,s+1,l,l),e.destX===e.x&&(e.startX=e.x)}let pass=0;function uADC(e){if(e-lAIT>=40){let t=!1;ctx.globalAlpha=.3,ctx.globalCompositeOperation="destination-out",ctx.fillRect(0,0,canvas.width,canvas.height),ctx.globalCompositeOperation="source-over",ctx.globalAlpha=1,cells.forEach(e=>{if(draw(e),e.ageStep++,1280===e.ageStep||e.size<=10&&e.ageStep===(e.size-1)*64+256||e.age===cl){if(e.age>cl&&!e.moving){pass+=e.size;let $=e;delC(e),t=sCiR($)}if(e.age++,e.ageStep=0,(e.age===cl-3||e.age===cl-2)&&1===e.size){let s=e;for(let l=s.x-1;l<=s.x+1;l++)for(let n=s.y-1;n<=s.y+1;n++)if(l>=0&&l=0&&n!e.moving&&e.x===l&&e.y===n&&e.size<=2)[0];o&&(o.age=s.age)}}}}),sSCiR(),pass>Math.min(cells.length-1,minSizeToMove)&&(fGr(),pass=0),PS=4,lAIT=e;}requestAnimationFrame(uADC)}function plC(e,t,s){for(let l=t;lgsY)return!1;for(let n=s;n=gsX-1?o