public static bool checkmove(simap map, Move move)//检查步数是否合法
        {
            chesstype my_item_type = map.Matrix[move.froX, move.froY].item.type;
            chesstype target_type  = map.Matrix[move.desX, move.desY].item.type;

            if (map.Matrix[move.froX, move.froY].flip != 0)//选中区域不为不为背面的状态。
            {
                if ((Math.Abs(move.desY - move.froY) <= 1 && Math.Abs(move.desX - move.froX) == 0) ||
                    (Math.Abs(move.desY - move.froY) == 0 && Math.Abs(move.desX - move.froX) <= 1)) //只能移动一格
                {
                    if (map.Matrix[move.desX, move.desY].item.type == chesstype.blank)              //移动棋子
                    {
                        return(true);
                    }
                    else if (my_item_type > target_type)//我的棋子rank更小则返回错误除非为卒和将
                    {
                        if (my_item_type == chesstype.zu && target_type == chesstype.jiang)
                        {
                            return(true);
                        }
                        return(false);
                    }
                    else if (my_item_type == chesstype.jiang && target_type == chesstype.zu)//将不能吃卒
                    {
                        return(false);
                    }
                    else if (my_item_type == chesstype.pao && target_type == chesstype.zu)
                    {
                        return(false);
                    }
                    else if (my_item_type == chesstype.pao && target_type == chesstype.pao)
                    {
                        return(false);
                    }
                    return(true);
                }
                else if (my_item_type == chesstype.pao)
                {
                    if (judge_pao(map, move) == true)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Пример #2
0
        public static int point_Evaluate(simap map, Move move)
        {
            int       point       = -1;
            chesstype target_type = map.Matrix[move.desX, move.desY].item.type;

            switch (target_type)
            {
            case chesstype.jiang:
                point = 10;
                break;

            case chesstype.shi:
                point = 7;
                break;

            case chesstype.xiang:
                point = 5;
                break;

            case chesstype.che:
                point = 4;
                break;

            case chesstype.ma:
                point = 3;
                break;

            case chesstype.zu:
                point = 2;
                break;

            case chesstype.pao:
                point = 6;
                break;

            case chesstype.blank:    //移动
                point = 0;
                break;
            }
            return(point);
        }