forked from JulesWang/Tetris.AI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
19 lines (19 loc) · 18.5 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<!DOCTYPE html>
<html><head><meta charset="utf-8"><script src="./lib/jquery.min.js"></script><script type="text/javascript">
(function(){var t,e,i,s,o,l,n,r,c,a,h,u,f,k,p,y,d,v,b,w,B,g,m,D,T,x,L;if(!window.requestAnimationFrame){window.requestAnimationFrame=function(){return window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}}()}g=function(t){var e,i,s,o,l,n;s=$.extend(true,[],t);for(e=l=1,n=s.length;l<n;e=l+=1){i=Math.floor(Math.random()*(e+1));o=s[e];s[e]=s[i];s[i]=o}return s};f=function(t,e){var i;while(e!==0){i=[e,t%e],t=i[0],e=i[1]}return t};D=function(t,e,i,s){if(t/e<i/s){s=e*i/t}else{i=t*s/e}return[i,s]};w=[];x=false;s=function(t){var e,i,s,o,l,n,r,c;o=0;for(i=l=0,r=t.length;l<r;i=l+=1){e=true;w[i]=false;for(s=n=0,c=t[i].length;n<c;s=n+=1){if(t[i][s]===null){e=false;break}}if(e){o+=1;w[i]=true}}return o};i=function(t){var e,i,s,o,l,n,r;e=0;for(s=l=0,r=t[0].length-1;l<r;s=l+=1){i=t.length-1;while(i>0&&(t[i][s]===null||w[i])){i--}for(o=n=0;n<i;o=n+=1){if(t[o][s]===null){e++}}}return e};o=function(t){var e,i,s,o,l,n;for(e=s=l=t.length-1;s>=0;e=s+=-1){for(i=o=0,n=t[e].length;o<n;i=o+=1){if(t[e][i]!==null){return e}}}return 0};r=function(t){var e,i,s,o,l,n,r,c,a,h;o=0;e=[];for(s=l=0,c=t[0].length;l<c;s=l+=1){i=t.length-1;while(i>=0&&t[i][s]===null){i--}e[s]=i}for(s=n=0,a=t[0].length-1;n<a;s=n+=1){o+=Math.abs(e[s]-e[s+1])}for(s=r=1,h=t[0].length-1;r<h;s=r+=1){if(e[s+1]-e[s]>=3&&e[s-1]-e[s]>=3){o+=10}}if(e[1]-e[0]>=3){o+=10}return o};l=function(t){var e,i,s,o;i=0;for(e=s=0,o=t.length;s<o;e=s+=1){if(t[e][t[0].length-1]!==null&&!w[e]){i+=1}}return i};n=function(t){var e,i,s,o,l;e=0;s=t[0].length-1;i=t.length-1;while(i>0&&(t[i][s]===null||w[i])){i--}for(o=l=0;l<i;o=l+=1){if(t[o][s]===null){e++}}return e};h=function(t){var c,a,h,f,k,p,y,d,v,b,w,B,g,m,D,T,x,L,P,S,C,q,F,A,R,H,K,U,$,_;S=u.state;h=u.state.display;F=t.block;a={};a.score=-1;B=8;b=-4;w=-20;D=-1;g=-1;m=-1;v=0;q=0;C=0;for(L=R=0;R<4;L=R+=1){for(y=H=0;H<10;y=H+=1){P=1e3;c=e.blocks.srs.blocks[F][L];A=y;f=t.h;while(S.tryActiveBlockPosition(A,f-1,c)){f-=1}if(f>=18){continue}v=o(h);q=r(h);for(p=K=0,$=c.length;K<$;p=K+=1){h[f-c[p][0]][A+c[p][1]]=e.blocks.srs.color[F]}C=r(h);P+=v*b;d=s(h);P+=d*(B+v/2);k=i(h);P+=k*w;T=l(h);P+=!!T*g;x=n(h);P+=x*m;P+=(C-q)*D;if(P>a.score){a.rot=L;a.x=y;a.holes=k;a.score=P;a.rm_holes=x}for(p=U=0,_=c.length;U<_;p=U+=1){h[f-c[p][0]][A+c[p][1]]=null}}}return a};t=function(){var t,e,i,s,l,n,r,c,a,f,k,y,d;if(!u){return}a=u.state;l=a.hold;t=a.activeBlock;s=t.block;c=o(u.state.display);if(t.block==="i"&&l!==t.block&&c<15){t.block=l;i=h(t);t.block=s;if(i.holes===0&&i.rm_holes===0){a.storeBlock();p();return}}if(t.block==="t"&&l!==t.block&&l!=="i"&&c<15){t.block=l;i=h(t);t.block=s;if(i.holes===0&&i.rm_holes===0){a.storeBlock();p();return}}e=h(t);if(l!==t.block&&(e.holes+e.rm_holes>0||c>15)){t.block=l;i=h(t);t.block=s;if(i.holes<e.holes||i.holes===e.holes&&i.rm_holes<e.rm_holes||i.holes===e.holes&&i.rm_holes===e.rm_holes&&i.score>e.score){a.storeBlock();p();return}}r=e.x-4;for(n=f=0,d=e.rot;f<d;n=f+=1){a.rotateRight()}if(r>0){for(n=k=0;k<r;n=k+=1){a.moveRight()}}else{for(n=y=r;y<0;n=y+=1){a.moveLeft()}}p();console.log(e.score);return a.doDrop()};p=function(){if(!c){return}setTimeout(t,v);if(v>10){return v-=50}};B={locale:true,debug:false,style:"srs"};e={_:false,blockTypes:"ijlotsz".split(""),blocks:{srs:{rotate:function(t){return[t[1],-t[0]]},derotate:function(t){return[-t[1],t[0]]},opposite:function(t){return[-t[0],-t[1]]},initials:{i:[[0,-1],[0,0],[0,1],[0,2]],j:[[-1,-1],[0,-1],[0,0],[0,1]],l:[[0,-1],[0,0],[0,1],[-1,1]],o:[[-1,0],[0,0],[-1,1],[0,1]],s:[[0,-1],[0,0],[-1,0],[-1,1]],t:[[-1,0],[0,-1],[0,0],[0,1]],z:[[-1,-1],[-1,0],[0,0],[0,1]]},kickTable:{right:{o:[[],[],[],[]],i:[[[-2,0],[1,0],[-2,-1],[1,2]],[[-1,0],[2,0],[-1,2],[2,-1]],[[2,0],[-1,0],[2,1],[-1,-2]],[[1,0],[-2,0],[1,-2],[-2,1]]],"default":[[[-1,0],[-1,1],[0,-2],[-1,-2]],[[1,0],[1,-1],[0,2],[1,2]],[[1,0],[1,1],[0,-2],[1,-2]],[[-1,0],[-1,-1],[0,2],[-1,2]]]},left:{o:[[],[],[],[]],i:[[[2,0],[-1,0],[2,1],[-1,-2]],[[1,0],[-2,0],[1,-2],[-2,1]],[[-2,0],[1,0],[-2,-1],[1,2]],[[-1,0],[2,0],[-1,2],[2,-1]]],"default":[[[1,0],[1,-1],[0,2],[1,2]],[[-1,0],[-1,1],[0,-2],[-1,2]],[[-1,0],[-1,-1],[0,2],[-1,2]],[[1,0],[1,1],[0,-2],[1,-2]]]}},offsets:{i:[[[0,0],[-1,0],[2,0],[-1,0],[2,0]],[[-1,0],[0,0],[0,0],[0,1],[0,-2]],[[-1,2],[1,1],[-2,1],[1,0],[-2,0]],[[0,1],[0,1],[0,1],[0,-1],[0,2]]],o:[[[0,0]],[[0,-1]],[[-1,-1]],[[-1,0]]],"default":[[[0,0],[0,0],[0,0],[0,0],[0,0]],[[0,0],[1,0],[1,-1],[0,2],[1,2]],[[0,0],[0,0],[0,0],[0,0],[0,0]],[[0,0],[-1,0],[-1,1],[0,2],[-1,2]]]},color:{i:"rgba(0,255,255,.9)",j:"rgba(0,0,255,.9)",l:"rgba(255,170,0,.9)",o:"rgba(255,255,0,.9)",s:"rgba(0,255,0,.9)",t:"rgba(153,0,255,.9)",z:"rgba(255,0,0,.9)"},blocks:{}}},images:{cache:{},links:{clown:"http://tweakers.net/ext/f/QiUS8Q3QxzG4yC76TOl0RSHI/full.jpg",nature:"http://www.finewallpaperss.com/wp-content/uploads/2012/09/green-nature-wallpaper1.jpg"},offline:{clown:"img/clown.jpg",nature:"img/green-nature-wallpaper.jpg"}}};y=function(){var t,i,s,o,l,n,r,c,a,h;if(e._){return}a=e.blockTypes;for(l=0,c=a.length;l<c;l+=1){t=a[l];o=e.blocks.srs.initials[t].slice(0);e.blocks.srs.blocks[t]=[];for(i=n=0;n<4;i=n+=1){e.blocks.srs.blocks[t][i]=$.extend(true,[],o);for(s=r=0,h=e.blocks.srs.initials[t].length;r<h;s=r+=1){o[s]=e.blocks.srs.rotate(o[s])}}}e._=true};T=function(){function t(){this.resetState(true)}t.prototype.resetState=function(t){var e,i,s,o,l;if(t==null){t=false}this.activeBlock={block:null,rotation:null,w:null,h:null};this.display=[];this.wall=0;this.lineOffsets=[];this.hold="i";this.holdDisabled=false;this.holdLock=false;this.queue=[];this.totalLines=0;this.totalBlocksDropped=0;this.linesSingle=0;this.linesDouble=0;this.linesTriple=0;this.linesQuadro=0;this.lastLineType=null;this.lastLineIsTSpin=false;this.combo=0;this.maxCombo=0;this.backToBackTetrisCombo=0;this.backToBackTSpin=0;if(t){this.settings=$["extend"](true,{},B)}this.rotationStyle="srs";for(e=s=0;s<24;e=++s){this.display[e]=[];for(i=o=0;o<10;i=++o){this.display[e][i]=null}}for(e=l=0;l<20;e=++l){this.lineOffsets[e]=0}this.fillQueue();this.nextBlock();if(this.counter){$("#results").append("<li>"+this.counter+"</li>")}this.counter=0};t.prototype.fillQueue=function(t){if(t==null){t=7}while(this.queue.length<t){this.queue=this.queue.concat(g(e.blockTypes))}};t.prototype.nextBlock=function(t,e){var i,s;if(t==null){t=1}if(e==null){e=7}for(i=s=0;s<t;i=s+=1){this.activeBlock.block=this.queue.shift();this.activeBlock.rotation=0;this.activeBlock.h=18;this.activeBlock.w=4;if(this.queue.length<e){this.fillQueue(e)}}this.counter++;$("#current").text("当前块数:"+this.counter)};t.prototype.tryActiveBlockPosition=function(t,e,i){var s,o,l;for(s=o=0,l=i.length;o<l;s=o+=1){if(e-i[s][0]<0||e-i[s][0]>=20){return false}if(t+i[s][1]<0||t+i[s][1]>=10){return false}if(this.display[e-i[s][0]][t+i[s][1]]!==null){return false}}return true};t.prototype.storeBlock=function(){var t;if(this.holdDisabled||this.holdLock){return}if(this.hold===null){this.hold=this.activeBlock.block;this.nextBlock()}else{t=[this.activeBlock.block,this.hold],this.hold=t[0],this.activeBlock.block=t[1];this.activeBlock.rotation=0;this.activeBlock.h=18;this.activeBlock.w=4}this.holdLock=true;this.updateDisplay()};t.prototype.moveLeft=function(){if(this.tryActiveBlockPosition(this.activeBlock.w-1,this.activeBlock.h,e.blocks.srs.blocks[this.activeBlock.block][this.activeBlock.rotation])){this.activeBlock.w-=1;this.updateDisplay()}};t.prototype.moveRight=function(){if(this.tryActiveBlockPosition(this.activeBlock.w+1,this.activeBlock.h,e.blocks.srs.blocks[this.activeBlock.block][this.activeBlock.rotation])){this.activeBlock.w+=1;this.updateDisplay()}};t.prototype.moveDown=function(){if(this.tryActiveBlockPosition(this.activeBlock.w,this.activeBlock.h-1,e.blocks.srs.blocks[this.activeBlock.block][this.activeBlock.rotation])){this.activeBlock.h-=1;this.updateDisplay()}else{this.lock()}};t.prototype.doDrop=function(){while(this.tryActiveBlockPosition(this.activeBlock.w,this.activeBlock.h-1,e.blocks.srs.blocks[this.activeBlock.block][this.activeBlock.rotation])){this.activeBlock.h-=1}this.lock()};t.prototype.rotateRight=function(){var t;t=(this.activeBlock.rotation+1)%4;if(this.tryActiveBlockPosition(this.activeBlock.w,this.activeBlock.h,e.blocks.srs.blocks[this.activeBlock.block][t])){this.activeBlock.rotation=t;this.updateDisplay()}};t.prototype.rotateLeft=function(){var t;t=(this.activeBlock.rotation+3)%4;if(this.tryActiveBlockPosition(this.activeBlock.w,this.activeBlock.h,e.blocks.srs.blocks[this.activeBlock.block][t])){this.activeBlock.rotation=t;this.updateDisplay()}};t.prototype.lock=function(){var t,i,s,o;this.holdLock=false;this.totalBlocksDropped+=1;t=e.blocks.srs.blocks[this.activeBlock.block][this.activeBlock.rotation];for(i=s=0,o=t.length;s<o;i=s+=1){this.display[this.activeBlock.h-t[i][0]][this.activeBlock.w+t[i][1]]=e.blocks.srs.color[this.activeBlock.block]}this.removeLines(this.activeBlock.type);this.nextBlock();if(!this.tryActiveBlockPosition(this.activeBlock.w,this.activeBlock.h,e.blocks.srs.blocks[this.activeBlock.block][this.activeBlock.rotation])){this.resetState()}this.updateDisplay()};t.prototype.removeLines=function(t){var e,i,s,o,l,n,r,c;o=0;for(i=l=0,r=this.display.length;l<r;i=l+=1){e=true;for(s=n=0,c=this.display[i].length;n<c;s=n+=1){this.display[i-o][s]=this.display[i][s];if(this.display[i][s]===null){e=false}}if(e){o+=1}}this.totalLines+=o;switch(o){case 1:this.linesSingle+=1;this.lastLineType="single";if(t==="t"){"test"}break;case 2:this.linesDouble+=1;this.lastLineType="double";if(t==="t"){"test"}break;case 3:this.linesTriple+=1;this.lastLineType="triple";if(t==="t"){"test"}break;case 4:if(this.lastLineType==="quadro"){this.backToBackTetrisCombo+=1}else{this.lastLineType="quadro"}this.linesQuadro+=1;this.lastLineIsTSpin=false}this.updateDisplay()};t.prototype.updateDisplay=function(){};t.prototype.gameOver=function(){};return t}();a=function(){function t(t,e,i,s,o,l){this.resetSettings();this.x=t;this.y=e;this.w=i;this.h=s;this.c=o;this.s=l;this.c.lineWidth=0}t.prototype.resetSettings=function(){this.options={defaultClearColor:"rgb(255, 255, 255)",defaultBlockColor:"rgba(0, 0, 0, .5)",defaultBgColor:"rgb(50, 50, 50)",defaultBlockBgColor:"rgba(255, 255, 255, .3)",defaultGridBgColor:"rgba(255, 255, 255, .5)",image:"clown",rows:20,cols:10,ghostBlock:true}};t.prototype.clearScreen=function(t){if(t==null){t=this.options.defaultClearColor}this.c.fillStyle=t;this.c.fillRect(this.x,this.y,this.w,this.h)};t.prototype.drawImageBackground=function(t,e,i,s,o){var l,n,r,c,a,h,u;if(o==null){o={}}r=24;n=i/r;l=s/r;a=n/2;c=k((h=o.image)!=null?h:this.options.image);this.c.beginPath();this.c.strokeStyle=this.c.fillStyle=(u=o.defaultBgColor)!=null?u:this.options.defaultBgColor;this.c.lineWidth=1;this.c.moveTo(t+n*2,e+l);this.c.arcTo(t+n*23,e+l,t+n*23,e+l*2,a);this.c.arcTo(t+n*23,e+l*23,t+n*22,e+l*23,a);this.c.arcTo(t+n,e+l*23,t+n,e+l*22,a);this.c.arcTo(t+n,e+l,t+n*2,e+l,a);this.c.closePath();this.c.clip();this.c.drawImage(c,t+n,e+l,i-n,s-l);this.c.restore();this.c.lineWidth=0};t.prototype.drawGameGrid=function(t,i,s,o,l){var n,r,c,a,h,u,f,k,p,y,d,v,b,w,B,g,m,D,T,x,L,P,S;if(l==null){l={}}d=(T=l.rows)!=null?T:this.options.rows;c=(x=l.cols)!=null?x:this.options.cols;a=(L=l.defaultBlockColor)!=null?L:this.options.defaultBlockColor;h=(P=l.defaultGridBgColor)!=null?P:this.options.defaultGridBgColor;n=o/d;r=s/c;this.c.fillStyle=h;this.c.fillRect(t,i,s,o);this.c.fillStyle=a;for(k=w=0;w<d;k=w+=1){for(p=B=0;B<c;p=B+=1){this.c.fillRect(t+r*p+1,i+n*k+1,r-2,n-2)}}f=this.s.activeBlock.h;while(this.s.tryActiveBlockPosition(this.s.activeBlock.w,f-1,e.blocks.srs.blocks[this.s.activeBlock.block][this.s.activeBlock.rotation])){f-=1}y=0;u=n;for(k=g=0;g<d;k=g+=1){y+=n+this.s.lineOffsets[k];if(y>o+.05){break}else if(y+n>o+.05){u=y+n-o}for(p=m=0;m<c;p=m+=1){if(this.s.display[k][p]!==null){this.c.fillStyle=this.s.display[k][p];this.c.fillRect(t+r*p+1,i+o-y+1,r-2,u-2)}}for(p=D=0,S=e.blocks.srs.blocks[this.s.activeBlock.block][this.s.activeBlock.rotation].length;D<S;p=D+=1){if(this.s.activeBlock.h-e.blocks.srs.blocks[this.s.activeBlock.block][this.s.activeBlock.rotation][p][0]===k){this.c.fillStyle=e.blocks.srs.color[this.s.activeBlock.block];this.c.fillRect(t+r*(e.blocks.srs.blocks[this.s.activeBlock.block][this.s.activeBlock.rotation][p][1]+this.s.activeBlock.w)+1,i+o-y+1,r-2,n-2)}else if(f-e.blocks.srs.blocks[this.s.activeBlock.block][this.s.activeBlock.rotation][p][0]===k&&this.options.ghostBlock){v=t+r*(e.blocks.srs.blocks[this.s.activeBlock.block][this.s.activeBlock.rotation][p][1]+this.s.activeBlock.w);b=i+o-y;this.c.lineWidth=2;this.c.strokeStyle=e.blocks.srs.color[this.s.activeBlock.block];this.c.beginPath();this.c.moveTo(v+1,b+1);this.c.lineTo(v+r-2,b+1);this.c.lineTo(v+r-2,b+n-2);this.c.lineTo(v+1,b+n-2);this.c.closePath();this.c.stroke();this.c.lineWdith=0}}}};t.prototype.drawBox=function(t,i,s,o,l,n){var r,c,a,h,u,f,k,p,y,d,v,b,w,B,g,m,D,T,x,L,P;if(n==null){n={}}h=(m=n.defaultBlockBgColor)!=null?m:this.options.defaultBlockBgColor;a=s/4;c=o/4;if(typeof l==="string"){r=(D=(T=n.blockColor)!=null?T:e.blocks.srs.color[l])!=null?D:this.options.defaultBlockColor;l=e.blocks.srs.blocks[l][0]}else{r=(x=n.blockColor)!=null?x:this.options.defaultBlockColor}this.c.fillStyle=h;this.c.fillRect(t,i,s,o);if(l===null){return}y=k=l[0][0];d=p=l[0][1];for(f=B=1,L=l.length;B<L;f=B+=1){if(l[f][0]<y){y=l[f][0]}else if(l[f][0]>k){k=l[f][0]}if(l[f][1]<d){d=l[f][1]}else if(l[f][1]>p){p=l[f][1]}}w=p-d+1;u=k-y+1;v=(4-w)/2*a;b=(4-u)/2*c;this.c.fillStyle=r;for(f=g=0,P=l.length;g<P;f=g+=1){this.c.fillRect(t+v+(l[f][1]-d)*a+1,i+b+(l[f][0]-y)*c+1,a-2,c-2)}};t.prototype.draw=function(){var t,e,i;i=(new Date).getDate();e=this.w/24;t=this.h/24;this.clearScreen("rgb(50,50,50)");this.drawGameGrid(this.x+e*7,this.y+t*2,e*10,t*20);this.drawBox(this.x+e*18,this.y+t*2,e*4,t*4,this.s.queue[0]);this.drawBox(this.x+e*18,this.y+t*7,e*4,t*4,this.s.queue[1]);this.drawBox(this.x+e*18,this.y+t*12,e*4,t*4,this.s.queue[2]);this.drawBox(this.x+e*18,this.y+t*17,e*4,t*4,this.s.queue[3]);this.drawBox(this.x+e*2,this.y+t*2,e*4,t*4,this.s.hold);if(B.debug){console.debug((new Date).getDate()-i+" ms spend drawing")}if(c){this.draw_words()}};t.prototype.draw_words=function(){this.c.fillStyle="#FFF";this.c.font="bold 13px Arial";return this.c.fillText("Believe me, you don't want to wait for the end of the game.",100,520)};return t}();b=function(){function t(t){var e=this;if(t==null){t=true}this.keys={keyUp:{},keyDown:{},keyPress:{}};this.keyDownFunction=function(t){return e.onKeyDown(t)};this.keyUpFunction=function(t){return e.onKeyUp(t)};this.keyPressFunction=function(t){return e.onKeyPress(t)};if(t){this.registerEventHandlers()}return}t.prototype.registerEventHandlers=function(){document.addEventListener("keydown",this.keyDownFunction,false);document.addEventListener("keyup",this.keyUpFunction,false);document.addEventListener("keypress",this.keyPressFunction,false)};t.prototype.unregisterEventHandlers=function(){document.removeEventListener("keydown",this.keyDownFunction,false);document.removeEventListener("keyup",this.keyUpFunction,false);document.removeEventListener("keypress",this.keyPressFunction,false)};t.prototype.registerKeyDown=function(t,e){this.keys.keyDown[t]=e};t.prototype.registerKeyUp=function(t,e){this.keys.keyUp[t]=e};t.prototype.registerKeyPress=function(t,e){this.keys.keyPress[t]=e};t.prototype.onKeyDown=function(t){var e;e=t.which;if(typeof this.keys.keyDown[e]==="function"){return this.keys.keyDown[e](t)}else if(typeof this.keys.keyDown["default"]==="function"){return this.keys.keyDown["default"]}};t.prototype.onKeyUp=function(t){var e;e=t.which;if(typeof this.keys.keyUp[e]==="function"){return this.keys.keyUp[e](t)}else if(typeof this.keys.keyUp["default"]==="function"){return this.keys.keyUp["default"]}};t.prototype.onKeyPress=function(t){var e;e=t.which;if(typeof this.keys.keyPress[e]==="function"){return this.keys.keyPress[e](t)}else if(typeof this.keys.keyPress["default"]==="function"){return this.keys.keyPress["default"]}};return t}();m=function(t,e,i,s){if(t/e<i/s){i=i-i%f(t,e);s=e*i/t}else{s=s-s%f(e,t);i=t*s/e}return[i,s]};k=function(t){return e.images.cache[t]||(e.images.cache[t]=new Image,e.images.cache[t].src=e.images[B.locale?"offline":"links"][t],e.images.cache[t])};L=function(){function t(t){var i=this;y();if(t==null){t="game"}this.c=document.getElementById(t).getContext("2d");this.state=new T;if(B.debug){this.cache=e}this.drawer=new a(0,0,this.c.canvas.width,this.c.canvas.height,this.c,this.state);this.keyHandler=new b;this.doDraw=false;this.state.updateDisplay=function(){if(i.doDraw===false){window.requestAnimationFrame(function(){i.doDraw=false;return i.drawer.draw()});i.doDraw=true}};this.keyHandler.registerKeyDown(37,function(t){i.state.moveLeft();t.preventDefault();return false});this.keyHandler.registerKeyDown(38,function(t){i.state.rotateRight();t.preventDefault();return false});this.keyHandler.registerKeyDown(39,function(t){i.state.moveRight();t.preventDefault();return false});this.keyHandler.registerKeyDown(40,function(t){i.state.moveDown();t.preventDefault();return false});this.keyHandler.registerKeyDown(32,function(t){i.state.doDrop();clearInterval(d);t.preventDefault();return false});this.keyHandler.registerKeyDown(16,function(t){i.state.storeBlock();t.preventDefault();return false});this.keyHandler.registerKeyDown(17,function(t){i.state.rotateLeft();t.preventDefault();return false});this.draw()}t.prototype.draw=function(){this.drawer.draw()};return t}();u=null;d=null;v=1010;c=false;$(document)["ready"](function(){u=new L;$("#human").attr("disabled",true);$("#human").click(function(){u.keyHandler.registerEventHandlers();v=1010;c=false;$("#human").attr("disabled",true);return $("#cpu").attr("disabled",false)});return $("#cpu").click(function(){d=setTimeout(t,10);u.keyHandler.unregisterEventHandlers();c=true;$("#human").attr("disabled",false);return $("#cpu").attr("disabled",true)})})}).call(this);
/*
//@ sourceMappingURL=output.min.js.map
*/ </script>
</head>
<body>
<canvas id="game" width="528" height="528" style="margin:auto; display:block;"></canvas>
<a href="https://github.com/JulesWang/Tetris.AI"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
<div style="margin:auto; display:block; width:528px; margin-top:10px">
<input type="button" id="cpu" value="交给电脑控制"></input>
<input type="button" id="human" value="交给玩家控制"></input>
<div style="display:inline">控制:↑ ↓ → ← 空格Alt, 暂存: Shift</div>
<div id="current" style="margin-top: 10px"></div>
<ul id="results"> </ul>
</div>
</body>
</html>