package match;
import tool.*;
public class pro {
int[] point=new int[5001];
int[] r=new int[5001];
int[] matchx=new int[5001];
int[] matchy=new int[5001];
int[] rs=new int[5001];
int datanumber;
String[] data=new String[5000];
public static void main(String[] args) {
pro t=new pro();
}
pro(){
readfile sub2=new readfile();
sub2.makedata("data.csv","UTF-8");
data=sub2.data;
datanumber=sub2.datanumber;
int s;
for(s=1;s<datanumber;s++){
String[] x=data[s+1].split(",");
point[s]=num_int(x[2]);
}
int number=datanumber-1;
for(s=1;s<number+1;s++){
r[s]=(int)(point[s]/10)+1;
}
int k;
for(k=1;k<101;k++){
int[] ch=new int[1000];
for(s=1;s<number+1;s++){
ch[s]=100;
}
int tr;
for(tr=1;tr<number;tr++){
int s1;
int[] ch1=new int[1000];
int sx=0;
for(s=1;s<number+1;s++){
if(ch[s]>50)sx=sx+1;
if(ch[s]>50)ch1[sx]=s;
}
int de=sx;
int m1=(int)(de*Math.random())+1;
int fight=ch1[m1];
int[] ch2=new int[1000];
sx=0;
for(s1=1;s1<de+1;s1++){
int h=0;
if(ch1[s1]==fight)h=100;
if(h<60)sx=sx+1;
if(h<60)ch2[sx]=ch1[s1];
}
int m2=(int)((de-1)*Math.random())+1;
int def=ch2[m2];
int z=0;
if(point[def]>point[fight])z=100;
if(z<50)ch[def]=0;
if(z>50)ch[fight]=0;
if(z<50)matchx[tr]=fight;
if(z<50)matchy[tr]=def;
if(z>50)matchx[tr]=def;
if(z>50)matchy[tr]=fight;
}
for(s=1;s<number+1;s++){
int rr;
double minz=999999999;
int r2=1;
for(rr=1;rr<11;rr++){
double z=0;
for(tr=1;tr<number;tr++){
int s1=matchx[tr];
int s2=matchy[tr];
int p1=100*rr/(rr+r[s2]);
if(s==s1)z=z+(100-p1)*(100-p1);
if(s==s2)z=z+(p1-0)*(p1-0);
}
if(z<minz)r2=rr;
if(z<minz)minz=z;
}
rs[s]=r2;
}
for(s=1;s<number+1;s++){
if(rs[s]>r[s])r[s]=r[s]+1;
if(rs[s]<r[s])r[s]=r[s]-1;
}
}
for(s=1;s<number+1;s++){
System.out.println(point[s]+","+r[s]);
}
}
int num_int(String str){
int nx;
nx=0;
try{
nx=Integer.parseInt(str);
}catch (Exception e) {}
return nx;
}
}
最終更新:2017年08月24日 14:18