src/Engine/ChessEngine.cs
/// <summary>
/// Retrieves potential legal moves for a given piece.
/// </summary>
/// <param name="position">The position of the piece to move.</param>
/// <returns>All possible legal moves for the piece.</returns>
Retrieves potential legal moves for a given piece.
Retrieves potential legal moves for a given piece .
public IEnumerable<Move> GetLegalMoves(BoardPosition position)
        {
            var pieceToMove = Game.GetPiece(position);
            if (pieceToMove != null)
            {
                var possibleMoves = GetMoveOptions(pieceToMove).Where(IsLegal);
                foreach (var move in possibleMoves)
                {
                    CheckForAmbiguousMove(move);
                    CheckForCheck(move);
                    CheckForMate(move);
                    yield return move;
                }
            }
        }
public IEnumerable < Move > GetLegalMoves ( BoardPosition position ) { var pieceToMove = Game . GetPiece ( position ) ; if ( pieceToMove != null ) { var possibleMoves = GetMoveOptions ( pieceToMove ) . Where ( IsLegal ) ; foreach ( var move in possibleMoves ) { CheckForAmbiguousMove ( move ) ; CheckForCheck ( move ) ; CheckForMate ( move ) ; yield return move ; } } }
Retrieves potential legal moves for a given piece.
Retrieves potential legal moves for a given piece .
All possible legal moves for the piece.
All possible legal moves for the piece .
position
BoardPosition
The position of the piece to move.
The position of the piece to move .