アットウィキロゴ

hgghh

package koma3;
 
 
public class pro {
 
    String[] koma=new String[7];
  int[][] dx=new int[4][11];
      int[][] dy=new int[4][11];
  int[] number_dir=new int[4];
 
   int[] x=new int[7];
   int[] y=new int[7];
    String[] pos=new String[7];
 
   String mode;
 
   int[] point_koma=new int[7];
   int number_koma;
    int[] point_x=new int[7];
    int[] point_y=new int[7];
    int number_point;
 
    public static void main(String[] args) {
        pro t=new pro();
    }
    pro(){
 
             /**金の先手**/
 
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;        
 
 
        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]="後手";   
 
        mode="先手";
 
        select_koma();
 
        System.out.println(number_koma);
 
int sig=point_koma[1];
 
         System.out.println(sig); 
 
         select_dir(sig);
 
        System.out.println(number_point);
 
 
 
 
 
 
    }
    void select_koma(){
 
        int s,sx;
        sx=0;
        for(s=1;s<7;s++){
        if(pos[s].equals(mode))sx=sx+1;    
        if(pos[s].equals(mode))point_koma[sx]=s; 
        }
 
 
        number_koma=sx;
 
 
    }
 
 
    void select_dir(int sig){
 
        int s,sx;
        int k,h;
        k=0;
        if(koma[sig]=="王")k=3;
        h=0;
        if(koma[sig].equals("金"))h=h+1;
        if(pos[sig].equals("先手"))h=h+1;
        if(h==2)k=1;
        h=0;
        if(koma[sig].equals("金"))h=h+1;
        if(pos[sig].equals("後手"))h=h+1;
        if(h==2)k=2;
 
        sx=0;
 
 
        for(s=1;s<number_dir[k]+1;s++){ 
        int x1=x[sig]+dx[k][s];
        int y1=y[sig]+dy[k][s];
        int c=check(x1,y1);
        if(c<50)sx=sx+1;
        if(c<50)point_x[sx]=x1;
        if(c<50)point_y[sx]=y1;
        }
 
 
        number_point=sx;
 
 
    }
    int check(int x1,int y1){
 
        int s,ch;
        ch=0;
        for(s=1;s<7;s++){
        int h=0;    
        if(x[s]==x1)h=h+1;
        if(y[s]==y1)h=h+1;
        if(pos[s].equals(mode))h=h+1;
        if(h==3)ch=100;
        }
 
        if(x1>3)ch=100;
        if(y1>3)ch=100;
         if(x1<1)ch=100;
        if(y1<1)ch=100;
 
        return ch;
    }
 
 
}
 
最終更新:2017年10月25日 15:56