Пример #1
0
        IEnumerable <FigureMove> NextKnightMove_Steps()
        {
            ColorType other = figureCoord.figure.GetColor().Swap();

            int[,] KnightSteps =
            {
                { -1, -2 }, { +1, -2 },
                { -2, -1 }, { +2, -1 },
                { -2, +1 }, { +2, +1 },
                { -1, +2 }, { +1, +2 }
            };
            FigureMove figureMove = new FigureMove(figureCoord);

            for (int j = 0; j < 8; j++)
            {
                if (figureCoord.coord.Shift(KnightSteps[j, 0],
                                            KnightSteps[j, 1],
                                            out figureMove.to))
                {
                    if (board.IsEmpty(figureMove.to))
                    {
                        yield return(figureMove);
                    }
                    else if (board.IsColor(figureMove.to, other))
                    {
                        yield return(figureMove);
                    }
                }
            }
        }
Пример #2
0
        IEnumerable <FigureMove> NextKingMove_Steps()
        {
            FigureMove figureMove = new FigureMove(figureCoord);
            ColorType  otherColor = figureCoord.figure.GetColor().Swap();

            int[,] KingSteps =
            {
                { -1, -1 }, { -1,  0 }, { -1, +1 },
                {  0, -1 }, {  0, +1 },
                { +1, -1 }, { +1,  0 }, { +1, +1 }
            };
            for (int j = 0; j < 8; j++)
            {
                if (figureCoord.coord.Shift(KingSteps[j, 0],
                                            KingSteps[j, 1],
                                            out figureMove.to))
                {
                    if (board.IsEmpty(figureMove.to))
                    {
                        yield return(figureMove);
                    }
                    else if (board.IsColor(figureMove.to, otherColor))
                    {
                        yield return(figureMove);
                    }
                }
            }
        }
Пример #3
0
        // ed
        IEnumerable <FigureMove> NextPawnMove_Fight()
        {
            Coord to;

            if (x > 0)
            {
                to = new Coord(x - 1, y + up);
                if (board.IsColor(to, fightColor))
                {
                    yield return(new FigureMove(figureCoord, to));
                }
            }
            if (x < 7)
            {
                to = new Coord(x + 1, y + up);
                if (board.IsColor(to, fightColor))
                {
                    yield return(new FigureMove(figureCoord, to));
                }
            }
        }