package sh;
public class pro {
String[] koma=new String[7];
int[] pos=new int[7];
String[] hand=new String[7];
int[][] ban=new int[10][2];
String mode;
String[][] dic=new String[7][50000];
int[] number_dic=new int[10];
String[] hash_chx=new String[101];
int number;
String[][][] link=new String[7][50000][21];
int[][] number_link=new int[7][50000];
int[][] point=new int[7][65000];
int[][] pointx=new int[7][65000];
public static void main(String[] args) {
pro t=new pro();
}
pro(){
int s;
mode="先手";
koma[1]="王";
koma[2]="金";
koma[3]="金";
koma[4]="王";
koma[5]="金";
koma[6]="金";
pos[1]=2;
pos[2]=1;
pos[3]=3;
pos[4]=8;
pos[5]=7;
pos[6]=9;
hand[1]="先手";
hand[2]="先手";
hand[3]="先手";
hand[4]="後手";
hand[5]="後手";
hand[6]="後手";
int x1,y1;
int n=0;
for (y1=1;y1<4;y1++){
for (x1=1;x1<4;x1++){
n=n+1;
ban[n][0]=x1;
ban[n][1]=y1;
}}
String hhh=hash();
dic[1][1]=hhh;
number_dic[1]=1;
int tr,re;
for(tr=1;tr<6;tr++){
for(re=1;re<number_dic[tr]+1;re++){
decode(dic[tr][re]);
int ch=0;
if(mode.equals("先手"))ch=100;
if(mode.equals("後手"))ch=100;
game sub=new game();
sub.ban=ban;
sub.koma=koma;
sub.makedata(dic[tr][re]);
number=sub.number;
hash_chx=sub.hash_chx;
for(s=1;s<number+1;s++){
link[tr][re][s]=hash_chx[s];
}
number_link[tr][re]=number;
}
int c=0;
int sx;
for(s=1;s<number_dic[tr]+1;s++){
for(sx=1;sx<number_link[tr][s]+1;sx++){
c=c+1;
dic[tr+1][c]=link[tr][s][sx];
}
number_dic[tr+1]=c;
}
}
for(s=1;s<number_dic[6]+1;s++){
decode(dic[6][s]);
makepoint(mode,6,s);
}
int sig,sx;
for(sig=1;sig<6;sig++){
int t=6-sig;
int m;
for(m=1;m<number_dic[t]+1;m++){
decode(dic[t][m]);
int maxp=-999;
for(sx=1;sx<number_link[t][m]+1;sx++){
int p1=0;
int sxs=search(link[t][m][sx],t+1);
if(mode.equals("先手"))p1=point[t+1][sxs];
if(mode.equals("後手"))p1=pointx[t+1][sxs];
if (p1>maxp)maxp=p1;
}
if(mode.equals("先手"))point[t][m]=maxp;
if(mode.equals("先手"))pointx[t][m]=100-maxp;
if(mode.equals("後手"))pointx[t][m]=maxp;;
if(mode.equals("後手"))point[t][m]=100-maxp;;
if(mode.equals("先手勝利"))point[t][m]=100;
if(mode.equals("先手勝利"))pointx[t][m]=0;
if(mode.equals("後手勝利"))pointx[t][m]=100;
if(mode.equals("後手勝利"))point[t][m]=0;
}
}
for(s=1;s<number_dic[1]+1;s++){
System.out.println(pointx[1][s]);
}
}
int search(String x1,int m){
int s,sx;
sx=0;
for(s=1;s<number_dic[m];s++){
if(dic[m][s].equals(x1))sx=s;
}
return sx;
}
void makepoint(String mode,int t,int s){
point[t][s]=50;
pointx[t][s]=50;
if(mode.equals("後手勝利"))pointx[t][s]=100;
if(mode.equals("後手勝利"))point[t][s]=0;
}
String hash(){
String ha="";
if (mode.equals("先手"))ha=ha+"w";
if (mode.equals("後手"))ha=ha+"x";
if (mode.equals("先手勝利"))ha=ha+"y";
if (mode.equals("後手勝利"))ha=ha+"z";
int s;
for(s=1;s<7;s++){
if(hand[s].equals("先手"))ha=ha+"p";
if(hand[s].equals("後手"))ha=ha+"q";
}
String w1="a,b,c,d,e,f,g,h,i,j";
String[] ww=w1.split(",");
for(s=1;s<7;s++){
int sx=pos[s];
ha=ha+ww[sx];
}
return ha;
}
void decode(String hxp){
String m1=hxp.substring(0,1);
String[] h1=new String[7];
String[] p1=new String[7];
int s;
for(s=1;s<7;s++){
h1[s]=hxp.substring(s,s+1);
}
for(s=1;s<7;s++){
p1[s]=hxp.substring(s+6,s+7);
}
if(m1.equals("w"))mode="先手";
if(m1.equals("x"))mode="後手";
if(m1.equals("y"))mode="先手勝利";
if(m1.equals("z"))mode="後手勝利";
for(s=1;s<7;s++){
if(h1[s].equals("p"))hand[s]="先手";
if(h1[s].equals("q"))hand[s]="後手";
}
for(s=1;s<7;s++){
if(p1[s].equals("a"))pos[s]=0;
if(p1[s].equals("b"))pos[s]=1;
if(p1[s].equals("c"))pos[s]=2;
if(p1[s].equals("d"))pos[s]=3;
if(p1[s].equals("e"))pos[s]=4;
if(p1[s].equals("f"))pos[s]=5;
if(p1[s].equals("g"))pos[s]=6;
if(p1[s].equals("h"))pos[s]=7;
if(p1[s].equals("i"))pos[s]=8;
if(p1[s].equals("j"))pos[s]=9;
}
}
}
最終更新:2018年03月02日 10:37