src/Engine/Models/ChessGame.cs
/// <summary>
/// Get the game state in PGN notation. https://en.wikipedia.org/wiki/Portable_Game_Notation, https://www.chessclub.com/help/PGN-spec.
/// </summary>
/// <returns>PGN notation description of the game state.</returns>
Get the game state in PGN notation.
Get the game state in PGN notation .
public string GetPGN()
        {
            var pgn = new StringBuilder();
            pgn.AppendLine($"[Event \"{Event ?? "-"}\"]");
            pgn.AppendLine($"[Site \"{Site ?? "-"}\"]");
            pgn.AppendLine($"[Round \"{Round ?? "-"}\"]");
            pgn.AppendLine($"[Date \"{StartDate.ToString("yyyy.MM.dd", CultureInfo.InvariantCulture) ?? "??"}\"]");
            pgn.AppendLine($"[White \"{WhitePlayer}\"]");
            pgn.AppendLine($"[Black \"{BlackPlayer}\"]");
            pgn.AppendLine($"[Result \"{ChessFormatter.ResultToString(Result)}\"]");
            if (!string.Equals(StartingFEN, InitialGameFEN, StringComparison.Ordinal))
            {
                pgn.AppendLine($"[FEN \"{StartingFEN}\"]");
            }
            pgn.AppendLine();
            pgn.Append(GetMoveList());
            pgn.AppendLine($" {ChessFormatter.ResultToString(Result)}");
            pgn.AppendLine();
            return pgn.ToString();
        }
public string GetPGN ( ) { var pgn = new StringBuilder ( ) ; pgn . AppendLine ( $" [Event  \" { Event ?? " " } \" ] " ) ; pgn . AppendLine ( $" [Site  \" { Site ?? " " } \" ] " ) ; pgn . AppendLine ( $" [Round  \" { Round ?? " " } \" ] " ) ; pgn . AppendLine ( $" [Date  \" { StartDate . ToString ( " " , CultureInfo . InvariantCulture ) ?? " " } \" ] " ) ; pgn . AppendLine ( $" [White  \" { WhitePlayer } \" ] " ) ; pgn . AppendLine ( $" [Black  \" { BlackPlayer } \" ] " ) ; pgn . AppendLine ( $" [Result  \" { ChessFormatter . ResultToString ( Result ) } \" ] " ) ; if ( ! string . Equals ( StartingFEN , InitialGameFEN , StringComparison . Ordinal ) ) { pgn . AppendLine ( $" [FEN  \" { StartingFEN } \" ] " ) ; } pgn . AppendLine ( ) ; pgn . Append ( GetMoveList ( ) ) ; pgn . AppendLine ( $" { ChessFormatter . ResultToString ( Result ) } " ) ; pgn . AppendLine ( ) ; return pgn . ToString ( ) ; }
Get the game state in PGN notation.
Get the game state in PGN notation .
PGN notation description of the game state.
PGN notation description of the game state .