src/Engine/Utilities/ChessFormatter.cs
/// <summary>
/// Formats a chess move in the long algebraic notation.
/// https://en.wikipedia.org/wiki/Algebraic_notation_(chess)#Long_algebraic_notation.
/// </summary>
/// <param name="move">The move to format in long algebraic notation.</param>
/// <returns>A standard long algebraic representation of the move.</returns>
Formats a chess move in the long algebraic notation.
Formats a chess move in the long algebraic notation .
public static string MoveToLongAlgebraicNotation(Move move)
        {
            if (move.ShortCastle)
            {
                return "O-O";
            }
            if (move.LongCastle)
            {
                return "O-O-O";
            }
            return $"{PieceToString(move.PieceMoved, false, false)}" + 
                   $"{move.OriginalPosition}" + 
                   $"{(move.Capture ? "x" : "-")}" + 
                   $"{move.FinalPosition}" + 
                   $"{(move.PiecePromotedTo.HasValue ? $"={PieceToString(move.PiecePromotedTo.Value, false, false)}" : string.Empty)}"; 
        }
public static string MoveToLongAlgebraicNotation ( Move move ) { if ( move . ShortCastle ) { return " " ; } if ( move . LongCastle ) { return " " ; } return $" { PieceToString ( move . PieceMoved , false , false ) } " + $" { move . OriginalPosition } " + $" { ( move . Capture ? " " : " " ) } " + $" { move . FinalPosition } " + $" { ( move . PiecePromotedTo . HasValue ? $" = { PieceToString ( move . PiecePromotedTo . Value , false , false ) } " : string . Empty ) } " ; }
Formats a chess move in the long algebraic notation.
Formats a chess move in the long algebraic notation .
// Piece moved // Original position // Capture or move // Final position // Promotion disabiguation
A standard long algebraic representation of the move.
A standard long algebraic representation of the move .
move
Move
The move to format in long algebraic notation.
The move to format in long algebraic notation .