<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 () {
r1=Math.random();
hit=0;
if(r1>0.7)hit=1;
if(r1>0.8)hit=2;
if(r1>0.9)hit=3;
if(r1>0.95)hit=4;
if(hit>0)step(hit);
if(r1<0.7)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(hit){
if(hit==1)one();
if(hit==2)two();
if(hit==3)three();
if(hit==4)four();
}
function one(){
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;
}
function two(){
p=0;
if(base[3]==1)p=p+1;
if(base[3]==1)base[3]=0;
if(base[2]==1)p=p+1;
if(base[2]==1)base[2]=0;
if(base[1]==1)base[3]=1;
if(base[1]==1)base[1]=0;
base[2]=1;
if(home=="v")point_v=point_v+p;
if(home=="h")point_h=point_h+p;
}
function three(){
p=0;
if(base[3]==1)p=p+1;
if(base[3]==1)base[3]=0;
if(base[2]==1)p=p+1;
if(base[2]==1)base[2]=0;
if(base[1]==1)p=p+1;
if(base[1]==1)base[1]=0;
base[3]=1;
if(home=="v")point_v=point_v+p;
if(home=="h")point_h=point_h+p;
}
function four(){
p=0;
if(base[3]==1)p=p+1;
if(base[3]==1)base[3]=0;
if(base[2]==1)p=p+1;
if(base[2]==1)base[2]=0;
if(base[1]==1)p=p+1;
if(base[1]==1)base[1]=0;
p=p+1;
if(home=="v")point_v=point_v+p;
if(home=="h")point_h=point_h+p;
}
</script>
最終更新:2018年06月05日 05:04