pythonpython-chess

How can I change the notation in chess-python?


I am trying to change the notation of the moves, I mean the library returns for example g1f3 and I want to change to Nf3 (algebraic notation). I try this method but it doesn't work:

board.parse_san(move.move)

How can I do it? There is any method in the library?


Solution

  • https://python-chess.readthedocs.io/en/latest/core.html#chess.Board.san

    Here, you can see that given a board: chess.Board and a move: chess.Move, you can get the SAN representation of your move using board.san(move), returning a str.