var m=new Array();
var n=new Array();
var point=new Array();
function sample(){
tx=0;
for(s=1;s<5;s++){
for(sx=1;sx<14;sx++){
tx=tx+1;
m[tx]=s;
n[tx]=sx;
point[tx]=0;
}
}
for(s=1;s<13;s++){
s1=select();
point[s1]=1;
s2=select();
point[s2]=2;
s2=select();
point[s2]=3;
s2=select();
point[s2]=4;
}
shuffle(1);
shuffle(2);
shuffle(3);
shuffle(4);
v1=count();
$("#memo").html(v1);
var timer;
var delay = 1000;
var loop = function () {
get_card(1,2);
shuffle(1);
get_card(2,3);
shuffle(2);
get_card(3,4);
shuffle(3);
get_card(4,1);
shuffle(4);
v1=count();
$("#memo").html(v1);
clearTimeout(timer);
timer = setTimeout(loop, delay);
}
loop();
}
function select(){
var s,sx;
var a=new Array();
sx=0;
for(s=1;s<53;s++){
if(point[s]==0)sx=sx+1;
if(point[s]==0)a[sx]=s;
}
m1=sx*Math.random();
m2=Math.floor(m1)+1;
m3=a[m2];
return m3;
}
function count(){
var a=new Array();
sx=0;
for(s=1;s<53;s++){
if(point[s]==0)sx=sx+1;
if(point[s]==0)a[sx]=s;
}
return sx;
}
function get_card(n,m){
var a=new Array();
sx=0;
for(s=1;s<53;s++){
if(point[s]==m)sx=sx+1;
if(point[s]==m)a[sx]=s;
}
m1=sx*Math.random();
m2=Math.floor(m1)+1;
m3=a[m2];
point[m3]=n;
}
function shuffle(n){
var s,sx;
var a=new Array();
sx=0;
for(s=1;s<53;s++){
if(point[s]==n)sx=sx+1;
if(point[s]==n)a[sx]=s;
}
var k=sx;
for(s=1;s<k;s++){
for(sx=2;sx<k+1;sx++){
s1=a[s];
s2=a[sx];
n1=n[s1];
n2=n[s2];
h=0;
if(n1==n2)h=h+1;
if(point[s1]==n)h=h+1;
if(point[s2]==n)h=h+1;
if(h==3)point[s1]=0;
if(h==3)point[s2]=0;
}
}
}
最終更新:2016年09月15日 07:03