<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
var base=new Array();
var out,home;
var point_v,point_h;
function sample(){
var timer;
var delay = 1000;
point_h=0;
point_v=0;
inn=1;
home="v";
out=0;
base[1]=0;
base[2]=0;
base[3]=0;
var loop = function () {
hit=Math.random();
if(hit>0.5)step();
if(hit<0.5)out=out+1;
if(out==3)fresh();
if(inn>9)game();
b="";
if(base[1]==1)b=b+"●";
if(base[1]==0)b=b+"○";
if(base[2]==1)b=b+"●";
if(base[2]==0)b=b+"○";
if(base[3]==1)b=b+"●";
if(base[3]==0)b=b+"○";
str=""+inn+"回表"+"("+out+")"+point_h+"*"+point_v+b;
if(home=="h")str=""+inn+"回裏"+"("+out+")"+point_h+"*"+point_v+b;
$("#memo").html(str);
clearTimeout(timer);
timer = setTimeout(loop, delay);
}
loop();
}
function fresh(){
out=0;
he=home;
if(he=="h")inn=inn+1;
if(he=="h")home="v";
if(he=="v")home="h";
base[1]=0;
base[2]=0;
base[3]=0;
base[3]=0;
}
function game(){
out=0;
home="v";
inn=1;
base[1]=0;
base[2]=0;
base[3]=0;
base[3]=0;
point_h=0;
point_v=0;
}
function step(){
p=0;
if(base[3]==1)p=1;
if(base[3]==1)base[3]=0;
if(base[2]==1)base[3]=1;
if(base[2]==1)base[2]=0;
if(base[1]==1)base[2]=1;
if(base[1]==1)base[1]=0;
base[1]=1;
if(home=="v")point_v=point_v+p;
if(home=="h")point_h=point_h+p;
}
</script>
最終更新:2018年06月04日 16:50