アットウィキロゴ

うぃんx

package sh;
 
 
public class pro {
 
    String[] koma=new String[7];
    int[] x=new int[7];
     int[] y=new int[7];
  String[] pos=new String[7];
     int[][] dx=new int[4][11];
      int[][] dy=new int[4][11];
  int[] number_dir=new int[4];
 
int[] subx=new int[7];    
int subnumber;  
 
    public static void main(String[] args) {
        pro t=new pro();
    }
    pro(){
 
        koma[1]="王";
        koma[2]="金";
        koma[3]="金";
        koma[4]="王";
        koma[5]="金";
        koma[6]="金";
 
        x[1]=2;
        y[1]=3;
        x[2]=1;
        y[2]=3;
        x[3]=3;
        y[3]=3;
        x[4]=2;
        y[4]=1;
        x[5]=1;
        y[5]=1;
        x[6]=3;
        y[6]=1;
 
        pos[1]="先手";
        pos[2]="先手";
        pos[3]="先手";
        pos[4]="後手";
        pos[5]="後手";
        pos[6]="後手";   
 
 
 
  /**金の先手**/
 
dx[1][1]=1;
dy[1][1]=0;
dx[1][2]=-1;
dy[1][2]=0;
dx[1][3]=1;
dy[1][3]=1;
dx[1][4]=-1;
dy[1][4]=1;
dx[1][5]=0;
dy[1][5]=1; 
dx[1][6]=0;
dy[1][6]=-1; 
 
number_dir[1]=6;
 
  /**金の後手**/
 
dx[2][1]=1;
dy[2][1]=0;
dx[2][2]=-1;
dy[2][2]=0;
dx[2][3]=1;
dy[2][3]=-1;
dx[2][4]=-1;
dy[2][4]=-1;
dx[2][5]=0;
dy[2][5]=-1; 
dx[2][6]=0;
dy[2][6]=1; 
 
number_dir[2]=6; 
 
 /**王**/
 
dx[3][1]=1;
dy[3][1]=0;
dx[3][2]=-1;
dy[3][2]=0;
 
dx[3][3]=1;
dy[3][3]=-1;
dx[3][4]=-1;
dy[3][4]=-1;
dx[3][5]=0;
dy[3][5]=-1; 
 
dx[3][6]=-1;
dy[3][6]=1; 
dx[3][7]=0;
dy[3][7]=1;  
dx[3][8]=1;
dy[3][8]=1;
 
number_dir[3]=8;        
 
String mode="先手";
 
select(mode);
 
int p;
for(p=1;p<subnumber+1;p++){
int n;
int c=count(subx[p]);
for(n=1;n<c+1;n++){
int ch=check(mode,subx[p],n);   
System.out.println(ch);
}
}
 
 
    }
 int count(int s1){
 
     String k1=koma[s1];
 
  int c=0;
        if(k1.equals("王"))c=8;
        int h;
        h=0;
        if(k1.equals("金"))c=6;
 
 
     return c;
 
 
 }
 
void invade(String mode,int x1,int y1){
 
   int m,h;
   int ch=0;
   int sxs=0;
        for(m=1;m<7;m++){
        h=0;
        if(x[m]==x1)h=h+1;
        if(y[m]==y1)h=h+1;
        if(mode.equals(pos[m]))h=0;
        if(h==2)ch=100;
         if(h==2)sxs=m;
        }    
 
 
        if(ch>50){
        x[sxs]=0;
        y[sxs]=0;
        pos[sxs]=mode;    
        }
 
 
 
}
 
 
 int check(String m1,int s1,int d1){
 
        String k1=koma[s1];
 
 
        int z=0;
        if(k1.equals("王"))z=3;
        int h;
        h=0;
        if(k1.equals("金"))h=h+1;
        if(m1.equals("先手"))h=h+1;
        if(h==2)z=1;
        h=0;
        if(k1.equals("金"))h=h+1;
        if(m1.equals("後手"))h=h+1;
        if(h==2)z=2;
 
 
        int x1=x[s1]+dx[z][d1];
        int y1=y[s1]+dy[z][d1];
 
        int ch=0;
        if(x1>3)ch=100;
        if(y1>3)ch=100;
        if(x1<1)ch=100;
        if(y1<1)ch=100;
 
        int m;
        for(m=1;m<7;m++){
        h=0;
        if(x[m]==x1)h=h+1;
        if(y[m]==y1)h=h+1;
        if(m1.equals(pos[m]))h=h+1;
        if(h==3)ch=100;
        }
 
 
        return ch;
    }
 
 
 
void select(String m1){
 
    int s,sx;
    sx=0;
    for(s=1;s<7;s++){
    if(pos[s].equals(m1))sx=sx+1;    
    if(pos[s].equals(m1))subx[sx]=s;  
    }
 
    subnumber=sx;
 
}
 
void move(int s1,int x1,int y1){
 
 x[s1]=x1;
 y[s1]=y1;
 
 
 }
 
 
}
 
最終更新:2017年10月09日 03:48