アットウィキロゴ

sp

package spin;
 
 
public class pro {
 
      int[] c=new int[11];
     int[] y=new int[11];
    int[] dc=new int[11];
     int[] dy=new int[11];
     int s,th;
 
    public static void main(String[] args) {
       pro test=new pro();
    }
 
    pro(){
 
         th=100;
 
    for(s=1;s<11;s++){
    c[s]=40;
    y[s]=60;
    dc[s]=0;
    dy[s]=0;
    }
 
    int tr;
 
    for(tr=1;tr<10000;tr++){
 
    move();
 
    for(s=1;s<11;s++){
shuffle(s);
    }
 
    System.out.println(bud());
 
    }
 
 
 
    }
 
void shuffle(int s){
double p1,p2;
 
p1=Math.random();
 
p2=0.2;
if(met(s)>10)p2=0.8;
if(met(s)<3)p2=0.8;
 
if(p1<p2)change(s);
 
 
}
 
void change(int s){
int b1;
double w1,u1;
int point;
b1=bud();
u1=du(s);    
w1=wel();
 
point=0;
if(b1>0)point=point+1;
if(u1>w1)point=point+1;
 
System.out.println(u1+","+w1);
 
double p1,p2;
 
p1=Math.random();
 
p2=0.5;
if(point==2)p2=0.8;
if(point==1)p2=0.5;
if(point==0)p2=0.2;
 
int c;
c=0;
if(p1<p2)c=100;
 
if(c<50)play_a(s);
if(c>50)play_b(s);
 
}
 
void play_a(int s){
 
double p1,uc,uy,p2;    
 
System.out.println("A");
 
p1=Math.random();
 
uc=u(c[s]+1,y[s],th)-u(c[s],y[s],th);
uy=u(c[s],y[s]-1,th)-u(c[s],y[s],th);
 
p2=0.3;
if(uc>uy)p2=0.7;
 
if(p1<p2)dc[s]=1;
if(p1<p2)dy[s]=0;
if(p1>p2)dc[s]=0;
if(p1>p2)dy[s]=-1;
 
 
}
 
void play_b(int s){
double p1,uc,uy,p2;    
 
System.out.println("B");
 
p1=Math.random();
 
uc=u(c[s]+1,y[s],th)-u(c[s],y[s],th);
uy=u(c[s],y[s]-1,th)-u(c[s],y[s],th);
 
p2=0.3;
if(uc>uy)p2=0.7;
 
if(p1<p2)dc[s]=0;
if(p1<p2)dy[s]=1;
if(p1>p2)dc[s]=-1;
if(p1>p2)dy[s]=0;
 
 
}
 
double du(int s){
double uc,uy,du;
 
uc=u(c[s]+1,y[s],th)-u(c[s],y[s],th);
uy=u(c[s],y[s]-1,th)-u(c[s],y[s],th);
du=(uc+uy)/2;    
return du;
}
double wel(){    
int s;
double w1,uc,uy;
w1=0;
for(s=1;s<11;s++){
uc=u(c[s]+1,y[s],th)-u(c[s],y[s],th);
uy=u(c[s],y[s]-1,th)-u(c[s],y[s],th);
w1=w1+uc+uy;    
}
w1=w1/20;
return w1;    
}
 
int bud(){
int s,b1;
b1=0;
for(s=1;s<11;s++){
b1=b1+y[s]-c[s];    
}
return b1;
}
 
double u(int c1,int y1,int th1){
double delta,u1;
delta=0.01;
u1=Math.log(c1*delta)+Math.log(1-(double)y1/th1);
return u1;
}
 
double met(int s){
int sx;
double m1,minm;
minm=999;
for(sx=1;sx<11;sx++){    
m1=(c[s]-c[sx])*(c[s]-c[sx]);
m1=m1+(y[s]-y[sx])*(y[s]-y[sx]);
if(s==sx)m1=9999;
if(m1<minm)minm=m1;
}
return Math.sqrt(minm);
}
 
void move(){
 
    int s;
 
   for(s=1;s<11;s++){
    c[s]=c[s]+dc[s];
    y[s]=y[s]+dy[s];
    if(c[s]<1)c[s]=1;
    if(y[s]<0)y[s]=0;
    if(y[s]>th-1)y[s]=th-1;
    }
 
 
 
 
}
 
}
最終更新:2014年04月13日 15:07