<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8" />
<script src="sample.js"></script>
<script src="jquery.js"></script>
<script src="baseball.js"></script>
<title>野球</title>
</head>
<body onload="sample()">
<p id="memo"></p>
</body>
</html>
var point_h, point_v;
function sample() {
var sub = new base();
sub.delta();
point_h = sub.point_h;
point_v = sub.point_v;
$("#memo").html(point_h+","+point_v);
}
class base{
out:number;
base:number[]=new Array();
point:number;
point_h:number;
point_v:number;
number_h:number;
number_v:number;
number_hit:number;
p_h:number[]=new Array();
p_v:number[]=new Array();
p:number[]=new Array();
delta():void{
this.point_h=0;
this.point_v=0;
this.number_h=9;
this.number_v=9;
var s:number;
for(s=1;s<10;s++){
this.p_h[s]=0.3;
this.p_v[s]=0.3;
}
var inn:number;
for(inn=1;inn<10;inn++){
this.number_hit=this.number_v;
for(s=1;s<10;s++){
this.p[s]=this.p_v[s];
}
this.game();
this.point_v=this.point_v+this.point;
this.number_v=this.number_hit;
for(s=1;s<10;s++){
this.p[s]=this.p_h[s];
}
this.number_hit=this.number_h;
this.game();
this.point_h=this.point_h+this.point;
this.number_h=this.number_hit;
}
}
game():void{
this.out=0;
this.point=0;
var s:number;
for(s=1;s<4;s++){
this.base[s]=0;
}
while(this.out<3){
this.number_hit=this.number_hit+1;
if(this.number_hit>9)this.number_hit=1;
this.play();
}
}
play():void{
var h:number;
h=this.hit();
if(h<50)this.out=this.out+1;
if(h>50)this.step();
}
step():void{
if(this.base[3]>50)this.point=this.point+1;
if(this.base[3]>50)this.base[3]=0;
if(this.base[2]>50)this.base[3]=100;
if(this.base[2]>50)this.base[2]=0;
if(this.base[1]>50)this.base[2]=100;
this.base[1]=100;
}
hit():number{
var h:number;
h=0;
if(Math.random()<this.p[this.number_hit])h=100;
return h;
}
}
最終更新:2015年07月28日 15:06