Java 生成自动移动

Java 生成自动移动,java,Java,我正在尝试为足球运动员生成一个自动运动。尝试创建玩家拥有的8种可能的情况,但是当我执行它们时,玩家没有移动,我不知道我是说移动错误还是返回移动错误。以下是法庭的形象: package players; public class SuJugador implements Player { public int[] move(int[][] history, int player) { int [] Move= new int [2]; int x=h

我正在尝试为足球运动员生成一个自动运动。尝试创建玩家拥有的8种可能的情况,但是当我执行它们时,玩家没有移动,我不知道我是说移动错误还是返回移动错误。以下是法庭的形象:

package players;
public class SuJugador implements Player 
{
     public int[] move(int[][] history, int player) 
{
        int []  Move= new int [2];
        int x=history[history.length-1][0];
        int y=history[history.length-1][1];
            /*.
             * |---|---|---|
             * | 1 | 2 | 3 | 
             * |---|---|---|
             * |           |
             * |     4     |
             * |           |
             * |___________|
             * | 5 | 6 | 7 |
             * |---|---|---|
             */
        if (player == 0)
        {
            // CUANDO LLEGUE A LA CACHA DE ARRIBA
            if((x==4)&&(y==2))
            {
                Move=casos(1, history);
                if((validMove(Move,history)==true)&& 
  (limit(Move[0],Move[1])==true))
                {
                  return Move;
                }
            }
            if((x==5)&&(y==2))
            {
                Move=casos(2, history);
                if((validMove(Move,history)==true)&& 
  (limit(Move[0],Move[1])==true))
                {
                  return Move;
                }
            }
            if((x==6)&&(y==2))
            {
                Move=casos(3, history);
                if((validMove(Move,history)==true)&& 
   (limit(Move[0],Move[1])==true))
                {
                  return Move;
                }
            }
            //Medio Total
            if((x==5)&&(y==7))
            {
                Move=casos(1, history);
                if((validMove(Move,history)==true)&& 
   (limit(Move[0],Move[1])==true))
                {
                  return Move;
                }
            }
        }
        return null;
    }
}
public static int[] casos(int $id,int[][]history) 
{
    {
        int []  Move= new int [2];
        int x=history[history.length-1][0];
        int y=history[history.length-1][1];
        switch ($id)
    {
    case 1: x=history[history.length-1][0];
            y=history[history.length-1][1];                        
            Move[0]=x;
            Move[1]=y-1; 
            break;

    case 2: x=history[history.length-1][0];
            y=history[history.length-1][1];                        
            Move[0]=x+1;
            Move[1]=y-1; 
            break;

    case 3: x=history[history.length-1][0];
            y=history[history.length-1][1];                        
            Move[0]=x-1;
            Move[1]=y-1; 
            break;

    case 4: x=history[history.length-1][0];
            y=history[history.length-1][1];                        
            Move[0]=x;
            Move[1]=y+1; 
            break;


    case 5: x=history[history.length-1][0];
            y=history[history.length-1][1];                        
            Move[0]=x+1;
            Move[1]=y; 
            break;

    case 6: x=history[history.length-1][0];
            y=history[history.length-1][1];                        
            Move[0]=x-1;
            Move[1]=y; 
            break;

    case 7: x=history[history.length-1][0];
            y=history[history.length-1][1];                        
            Move[0]=x+1;
            Move[1]=y+1; 
            break;

    case 8: x=history[history.length-1][0];
            y=history[history.length-1][1];                        
            Move[0]=x-1;
            Move[1]=y+1; 
            break;

    }
    }
return null;
}
public static boolean limit (int x, int y) 
{
       if ((x>=1)&&(x<=9)&&(y>=2)&&(y<=12)) 
       {
           return true;
       }           
       if (((y==1)||(y==13))&&(x==4)||(x==5)||(x==6))
       {
           return true;
       }
       return false;
}
public static boolean validMove(int []FutMov,int[][]history) 
{       
     if (history.length>1)
     {          
        boolean permitex=false;
        boolean permitey=false;
        int Posx=history[history.length-1][0];
        int Posy=history[history.length-1][1];

        for (int i=0;i<history.length-1;i++)
        {

            if (history[i][0]== Posx)
            {
                if (history[i+1][0]== FutMov[0]) 
                {
                    permitex =false;
                }
                else 
                {
                    permitex= true;
                }
            }
            if (history[i][1]==Posy)
            {
                if (history[i+1][1]== FutMov[1]) 
                {
                    permitey=false;
                }
                else 
                {
                    permitey= true;
                }
            }
        }
        return (permitey||permitex);    
     } 
     return false;
}
}
package播放器;
公共级SuJugador实现玩家
{
公共int[]移动(int[][]历史,int播放器)
{
int[]移动=新int[2];
int x=历史[history.length-1][0];
int y=历史[history.length-1][1];
/*.
* |---|---|---|
* | 1 | 2 | 3 | 
* |---|---|---|
* |           |
* |     4     |
* |           |
* |___________|
* | 5 | 6 | 7 |
* |---|---|---|
*/
如果(玩家==0)
{
//阿里巴咖啡馆
如果((x==4)和&(y==2))
{
移动=casos(1,历史);
如果((有效移动(移动,历史)=真)和
(限制(移动[0],移动[1])==真)
{
回击动作;
}
}
如果((x==5)和&(y==2))
{
移动=casos(2,历史);
如果((有效移动(移动,历史)=真)和
(限制(移动[0],移动[1])==真)
{
回击动作;
}
}
如果((x==6)和&(y==2))
{
移动=casos(3,历史);
如果((有效移动(移动,历史)=真)和
(限制(移动[0],移动[1])==真)
{
回击动作;
}
}
//中总计
如果((x==5)和&(y==7))
{
移动=casos(1,历史);
如果((有效移动(移动,历史)=真)和
(限制(移动[0],移动[1])==真)
{
回击动作;
}
}
}
返回null;
}
}
公共静态int[]casos(int$id,int[]history)
{
{
int[]移动=新int[2];
int x=历史[history.length-1][0];
int y=历史[history.length-1][1];
交换机($id)
{
案例1:x=历史[历史.长度-1][0];
y=历史[历史长度-1][1];
移动[0]=x;
Move[1]=y-1;
打破
案例2:x=历史[历史.长度-1][0];
y=历史[历史长度-1][1];
移动[0]=x+1;
Move[1]=y-1;
打破
案例3:x=历史[历史.长度-1][0];
y=历史[历史长度-1][1];
移动[0]=x-1;
Move[1]=y-1;
打破
案例4:x=历史[历史.长度-1][0];
y=历史[历史长度-1][1];
移动[0]=x;
移动[1]=y+1;
打破
案例5:x=历史[历史.长度-1][0];
y=历史[历史长度-1][1];
移动[0]=x+1;
移动[1]=y;
打破
案例6:x=历史[历史.长度-1][0];
y=历史[历史长度-1][1];
移动[0]=x-1;
移动[1]=y;
打破
案例7:x=历史[历史.长度-1][0];
y=历史[历史长度-1][1];
移动[0]=x+1;
移动[1]=y+1;
打破
案例8:x=历史[历史.长度-1][0];
y=历史[历史长度-1][1];
移动[0]=x-1;
移动[1]=y+1;
打破
}
}
返回null;
}
公共静态布尔限制(整数x,整数y)
{
如果((x>=1)&&(x=2)&&(y1)
{          
布尔permitex=false;
布尔许可=假;
int Posx=历史[history.length-1][0];
int Posy=history[history.length-1][1];
对于(int i=0;i
我不知道我是说动作不对还是说动作不对

显然,您忘记从
casos()
函数返回移动,该函数只返回null;