MiniSweeper
A minesweeper in 512 735 bytes
<table border="" id="t"><script>s=15;b=[];f=[];n=[];v=[];H="";h=1;g=l=r=0;p=func
tion(a){if(!g){l&&(v[a]=1,b[a]&&(g=-1));r&&(f[a]=!f[a],g=1);for(m=1;m;){for(j=m=
0;j<s*s;j++)r&&b[j]==!f[j]&&(g=0),h&&(n[j]=0);for(j=0;j<s*s;j++){J=~~(j/s);I=j%s
;V="<br>";h&&(H+=(j%s?"":"<tr>")+"<td id=c"+j+" align=center style=width:25;heig
ht:25;background:#ddd onclick=l=1;p("+j+") oncontextmenu=r=1;p("+j+");return!1>"
+V,b[j]=0.1>Math.random());for(y=2;--y+2;)for(x=2;--x+2;)B=J+y,A=I+x,C=B*s+A,0<=
B&&0<=A&&B<s&&A<s&&(h&&b[j]&&n[C]++,h||!v[j]||n[j]||v[C]||b[C]||(m=v[C]=1));if(v
[j]||g)V=n[j]||V;b[j]&&g&&(V="💣");f[j]&&(V="⚑");!h&&(Z=this["c"+j],Z[z]=V,g||v[j
])&&(Z.style.background=0)}}g&&alert(~g?"😁":"☹");l=r=h=0}};p();t[z="innerHTML"]=
H</script> // 731
Demo:
- Left click to reveal a cell and see how many bombs are around.
- Don't click on bombs! Right click to set a flag where you believe there is a bomb.
- You win when all the bombs are flagged.