- Author:
- cartuchogl
- Twitter:
- @
- GitHub:
- Facebook:
- Google+:
- +
- Reddit:
- /r/
- Pouet:
- Website:
- e-seanetwork.com
- Compo:
- classic
- Demo link:
- https://js1k.com/2010-first/demo/301
- Shortlink:
- https://js1k.com/301
- Blog post:
- please update here!
- Bytes:
- 1017
- Chars:
- 1017
- Submission
q=30;j=16;b=[];m=[];h=[];l=99;o=0;d=document;w='appendChild';function z(x,y){for(c=0;c<l;c++){if(m[c][0]==x&&m[c][1]==y)return 1}return 0}function e(x,y){n=0;if(z(x-1,y-1))n++;if(z(x,y-1))n++;if(z(x+1,y-1))n++;if(z(x+1,y))n++;if(z(x+1,y+1))n++;if(z(x,y+1))n++;if(z(x-1,y+1))n++;if(z(x-1,y))n++;return n}function u(x,y){if((x>=0)&&(x<q)&&(y>=0)&&(y<j)){if(h[y][x]==0){o++;h[y][x]=1;k=(e(x,y)+'');if(z(x,y)){k='*';r=1}else if(e(x,y)==0)k='.';b[y][x][w](d.createTextNode(k));if(k=='.'){u(x-1,y-1);u(x,y-1);u(x+1,y-1);u(x+1,y);u(x+1,y+1);u(x,y+1);u(x-1,y+1);u(x-1,y)}}}if((r!=1)&&(o==q*j-l))r=2;return r}function r(m){return Math.floor(Math.random()*m)}for(v=0;v<l;v++)m[v]=[r(q),r(j)];function c(x,y){p=d.createElement('p');d.body[w](p);p.setAttribute('style','position:absolute;top:'+(y*18)+'px;left:'+(x*18)+'px;width:16px;height:16px;border:1px solid #000');p.onclick=function(){s=u(x,y);if(s==1)alert('fail');if(s==2)alert('win')};return p}for(y=0;y<j;y++){b[y]=[];h[y]=[];for(x=0;x<q;x++){b[y][x]=c(x,y);h[y][x]=0}}
- Description
- minesweeper
- Base64 encoded
cT0zMDtqPTE2O2I9W107bT1bXTtoPVtdO2w9OTk7bz0wO2Q9ZG9jdW1lbnQ7dz0nYXBwZW5kQ2hpbGQnO2Z1bmN0aW9uIHooeCx5KXtmb3IoYz0wO2M8bDtjKyspe2lmKG1bY11bMF09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TIpYWxlcnQoJ3dpbicpfTtyZXR1cm4gcH1mb3IoeT0wO3k8ajt5Kyspe2JbeV09W107aFt5XT1bXTtmb3IoeD0wO3g8cTt4Kyspe2JbeV1beF09Yyh4LHkpO2hbeV1beF09MH19
- Original source
q=30;
j=16;
b=[];
m=[];
h=[];
l=99;
o=0;
d=document;
w='appendChild';
function z(x,y){
for(c=0;c<l;c++){
if(m[c][0]==x&&m[c][1]==y)
return 1
}
return 0
}
function e(x,y){
n=0;
if(z(x-1,y-1))n++;
if(z(x,y-1))n++;
if(z(x+1,y-1))n++;
if(z(x+1,y))n++;
if(z(x+1,y+1))n++;
if(z(x,y+1))n++;
if(z(x-1,y+1))n++;
if(z(x-1,y))n++;
return n
}
function u(x,y){
if((x>=0)&&(x<q)&&(y>=0)&&(y<j)){
if(h[y][x]==0){
o++;
h[y][x]=1;
k=(e(x,y)+'');
if(z(x,y)){
k='*';
r=1
} else if(e(x,y)==0)
k='.';
b[y][x][w](d.createTextNode(k));
if(k=='.'){
u(x-1,y-1);
u(x,y-1);
u(x+1,y-1);
u(x+1,y);
u(x+1,y+1);
u(x,y+1);
u(x-1,y+1);
u(x-1,y)
}
}
}
if((r!=1)&&(o==q*j-l))
r=2;
return r
}
function r(m){
return Math.floor(Math.random()*m)
}
for(v=0;v<l;v++)m[v]=[r(q),r(j)];
function c(x,y){
p=d.createElement('p');
d.body[w](p);
p.setAttribute('style',
'position:absolute;top:'+(y*18)+'px;left:'+(x*18)+
'px;width:16px;height:16px;border:1px solid #000');
p.onclick=function(){
s=u(x,y);
if(s==1)alert('fail');
if(s==2)alert('win')
};
return p
}
for(y=0;y<j;y++){
b[y]=[];
h[y]=[];
for(x=0;x<q;x++){
b[y][x]=c(x,y);
h[y][x]=0
}
}