Print FENs in shredder notation (instead of X-FEN) when in Chess960 mode in the mixed mode interface (bench 5736541)

This commit is contained in:
2026-01-08 11:33:12 +01:00
parent 8a8b8821b6
commit 75450e7355
2 changed files with 8 additions and 7 deletions

View File

@@ -74,7 +74,7 @@ proc clone*(pos: Position): Position =
for fieldA, fieldB in fields(pos, result):
fieldB = fieldA
proc toFEN*(self: Position): string {.gcsafe.}
proc toFEN*(self: Position, chess960: bool = false): string {.gcsafe.}
func inCheck*(self: Position): bool {.inline.} =
@@ -708,7 +708,7 @@ proc `$`*(self: Position): string =
result &= "\na b c d e f g h"
proc toFEN*(self: Position): string =
proc toFEN*(self: Position, chess960: bool = false): string =
var skip: int
# Piece placement data
for rank in Rank.all():
@@ -736,22 +736,22 @@ proc toFEN*(self: Position): string =
else:
let files: array[White..Black, pcs.File] = [self.kingSquare(White).file(), self.kingSquare(Black).file()]
if castleWhite.king != nullSquare():
if castleWhite.king == H1 and absDistance(files[White], castleWhite.king.file()) > 1:
if not chess960 and castleWhite.king == H1 and absDistance(files[White], castleWhite.king.file()) > 1:
result &= "K"
else:
result &= castleWhite.king.toUCI()[0].toUpperAscii()
if castleWhite.queen != nullSquare():
if castleWhite.queen == A1 and absDistance(files[White], castleWhite.queen.file()) > 1:
if not chess960 and castleWhite.queen == A1 and absDistance(files[White], castleWhite.queen.file()) > 1:
result &= "Q"
else:
result &= castleWhite.queen.toUCI()[0].toUpperAscii()
if castleBlack.king != nullSquare():
if castleBlack.king == H8 and absDistance(files[Black], castleBlack.king.file()) > 1:
if not chess960 and castleBlack.king == H8 and absDistance(files[Black], castleBlack.king.file()) > 1:
result &= "k"
else:
result &= castleBlack.king.toUCI()[0]
if castleBlack.queen != nullSquare():
if castleBlack.queen == A8 and absDistance(files[Black], castleBlack.queen.file()) > 1:
if not chess960 and castleBlack.queen == A8 and absDistance(files[Black], castleBlack.queen.file()) > 1:
result &= "q"
else:
result &= castleBlack.queen.toUCI()[0]

View File

@@ -1206,7 +1206,8 @@ proc startUCISession* =
stdout.styledWrite(useColor, fgGreen, "Raw eval: ", styleBright, fgWhite, $rawEval, resetStyle, fgGreen, " engine units\n")
stdout.styledWrite(useColor, fgRed, "Normalized eval: ", styleBright, fgWhite, $rawEval.normalizeScore(session.board.material()), resetStyle, fgMagenta, " cp\n")
of PrintFEN:
stdout.styledWrite(useColor, fgGreen, "FEN of the current position: ", styleBright, fgWhite, session.board.position.toFEN(), resetStyle, "\n")
let fen = session.board.position.toFEN(session.searcher.state.chess960.load())
stdout.styledWrite(useColor, fgGreen, "FEN of the current position: ", styleBright, fgWhite, fen, resetStyle, "\n")
of PrintASCII:
echo $session.board
of PrettyPrint: