For Horse,
you must difine Four variants in this class or in you programx_old,y_old, x_target,y_target
and you board declare as chessBoard[9][10]
in each bhessBoard, you should save the point of current chesstype. so if there is no chess on this cross, it will be Null.For horse,
the vaild move step isabs(x_old - x_target) = 1
  && abs(y_old - y_target) = 2
  && board[x_old][(y_old + y_target)/2] == NULL
||
abs(x_old - x_target) = 2
  && abs(y_old - y_target) = 1
  && board[x_old + x_target)/2][y_old] == NULL

解决方案 »

  1.   

    到这里看一看,也许会对你有用http://netcity3.web.hinet.net/userdata/zhengzmz/index.htm
      

  2.   

    http://netcity3.web.hinet.net/userdata/zhengzmz/index.htm
      

  3.   

    http://netcity3.web.hinet.net/userdata/zhengzmz/index.htm
      

  4.   

    /******************************************************************
    CanGo: 判断一步棋合不合法
    .......
    返回值: 合法返回TRUE,不合法返回FALSE
    ******************************************************************/
    BOOL  CanGo(int manmap[11][12],int man,const POINT &from,const POINT &to)
    {
    ......
    switch(ManToType[man])
    {
    ......
    case RED_M:
    case BLACK_M:
    //马走日:
    if(!((abs(to.x-from.x)==1&&abs(to.y-from.y)==2)||(abs(to.x-from.x)==2&&abs(to.y-from.y)==1)))return FALSE;

    //找马脚:
    if (to.x-from.x==2){i=from.x+1;j=from.y;}
    else if(from.x-to.x==2){i=from.x-1;j=from.y;}
    else if(to.y-from.y==2){i=from.x;j=from.y+1;}
    else if(from.y-to.y==2){i=from.x;j=from.y-1;}

    //绊马脚:
    if(manmap[i][j]!=32)return FALSE;
    break;
    default:
    break;
    }
    return TRUE;
    }