// e2-e3 IEnumerable <FigureMove> NextPawnMove_Forward() { Coord to = new Coord(x, y + up); if (board.IsEmpty(to)) { yield return(new FigureMove(figureCoord, to)); } }
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); } } } }
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); } } } }