アットウィキロゴ

energy

package th9;
 
 
public class pro {
 
    int[] y=new int[101];
int[] c=new int[101];
int[] th=new int[101];
    int s;
   double[] uc=new double[101];
    double[] uy=new double[101];
    double[] dc=new double[101];
    double[] dy=new double[101];
    int y1,c1,z;
int[] rank_uc=new int[101];
int[] rank_uy=new int[101];
  int[] rank_dc=new int[101];
   int[] rank_dy=new int[101];
 
 
    public static void main(String[] args) {
        pro test=new pro();
    }
   pro(){ 
 
 for(s=1;s<101;s++){
 th[s]=10*s;    
 c[s]=5*s;
 y[s]=5*s;
 }
 
 int tr,trs;
 
 for(tr=1;tr<10000;tr++){
 
step();
 
ranking();
 
ranking2();
 
for(trs=1;trs<11;trs++){
 
if(bud()>-1)move();
if(bud()<1)move2();
 
}
 
 
   }
 
for(s=1;s<101;s++){
 System.out.println(c[s]+","+y[s]);
}
 
 
 
   }
   void move(){
 
       int s;
       double p1,p2;
 
       for(s=1;s<101;s++){
       p1=0.05-0.00025*rank_uc[s];
       p2=Math.random();
       if(p2<p1)c[s]=c[s]+1;
       }
 
       for(s=1;s<101;s++){
       p1=0.05-0.00025*rank_uy[s];
       p2=Math.random();
       if(p2<p1)y[s]=y[s]-1;
       if(y[s]<0)y[s]=0;
       }
 
 
 
 
 
 
 
 
   }
   int bud(){
   int b1,s;
       b1=0;
       for(s=1;s<101;s++){
       b1=b1+y[s]-c[s];
       }
   return b1;
 
   }
 
    void move2(){
 
       int s;
       double p1,p2;
 
       for(s=1;s<101;s++){
       p1=0.05-0.00025*rank_dc[s];
       p2=Math.random();
       if(p2<p1)c[s]=c[s]-1;
       if(c[s]<1)c[s]=1;
       }
 
 
 
       for(s=1;s<101;s++){
       p1=0.05-0.00025*rank_dy[s];
       p2=Math.random();
       if(p2<p1)y[s]=y[s]+1;
       if(y[s]>th[s]-1)y[s]=th[s]-1;
       }
 
 
 
 
 
 
 
   }
 
double u(int c1,int y1,int th1){
double u1;
u1=Math.log(c1)+Math.log(1-(double)y1/th1);  
return u1;
}
 
void ranking2(){ 
int r,s,sx,h; 
int[] ch=new int[201];
 int[] rank=new int[201];
double maxu;
int t;
 
 double[] ux=new double[201];  
 
for(s=1;s<101;s++){ 
ux[s]=dc[s];
ux[s+100]=dy[s];
}   
 
for(r=1;r<201;r++){ 
sx=0; 
maxu=-999; 
for(s=1;s<201;s++){ 
h=0; 
if(ux[s]>maxu)h=h+1; 
if(ch[s]<50)h=h+1; 
if(h==2)maxu=ux[s]; 
if(h==2)sx=s; 
}
rank[sx]=r; 
ch[sx]=100; 
}
 
for(s=1;s<101;s++){ 
rank_dc[s]=rank[s];
rank_dy[s]=rank[s+100];
}
 
}
 
 void ranking(){ 
int r,s,sx,h; 
int[] ch=new int[201];
 int[] rank=new int[201];
double maxu;
int t;
 
 double[] ux=new double[201];  
 
for(s=1;s<101;s++){ 
ux[s]=uc[s];
ux[s+100]=uy[s];
}   
 
 
 
for(r=1;r<201;r++){ 
sx=0; 
maxu=-999; 
for(s=1;s<201;s++){ 
h=0; 
if(ux[s]>maxu)h=h+1; 
if(ch[s]<50)h=h+1; 
if(h==2)maxu=ux[s]; 
if(h==2)sx=s; 
}
rank[sx]=r; 
ch[sx]=100; 
}
 
for(s=1;s<101;s++){ 
rank_uc[s]=rank[s];
rank_uy[s]=rank[s+100];
}
 
}
 
void step(){
 
 
for(s=1;s<101;s++){    
uc[s]=u(c[s]+1,y[s],th[s])-u(c[s],y[s],th[s]);
}
 
for(s=1;s<101;s++){    
y1=y[s]-1;
z=0;
if(y1<0)z=100;
uy[s]=-999;
if(z<50)uy[s]=u(c[s],y1,th[s])-u(c[s],y[s],th[s]);
}
 
for(s=1;s<101;s++){    
y1=y[s]+1;
z=0;
if(y1>th[s]-1)z=100;
dy[s]=-999;
if(z<50)dy[s]=u(c[s],y1,th[s])-u(c[s],y[s],th[s]);
}
 
for(s=1;s<101;s++){    
c1=c[s]-1;
z=0;
if(c1<1)z=100;
dc[s]=-999;
if(z<50)dc[s]=u(c1,y[s],th[s])-u(c[s],y[s],th[s]);
}
 
 
 
 
 
 
 
 
}
}
最終更新:2014年03月26日 16:03