Пример #1
0
        private static bool CanForward(
            Color pawnColor,
            Board board,
            Square from, Square to)
        {
            // white: a1 -> a2; from.y - to.y == 1; from.x == to.x
            // black: a2 -> a1; from.y - to.y == -1; from.x == to.x
            var step = GetPawnStep(pawnColor);

            return
                (MoveProperty.DeltaX(from, to) == 0 &&
                 MoveProperty.DeltaY(from, to) == step &&
                 board[to].IsNone());
        }
Пример #2
0
        private static bool CanPush(
            Color pawnColor,
            Board board,
            Square from, Square to)
        {
            // white: a2 -> a4; from.y - to.y == 2; from.x == to.x
            // black: a7 -> a5; from.y - to.y == -2; from.x == to.x
            var row  = GetPawnStartRow(pawnColor);
            var step = GetPawnStep(pawnColor);

            return
                (row == from.Y &&
                 board[to].IsNone() &&
                 board[new Square(from.X, from.Y + step)].IsNone() &&
                 MoveProperty.DeltaX(from, to) == 0 &&
                 MoveProperty.DeltaY(from, to) == 2 * step);
        }