5

I saw this thread: Converting square notation to algebraic notation programmatically

Unfortunately, it's the reverse of what I need to do.

Given a FEN and an Algebraic move, I need to generate the coordinate notation of said move.

I realize that you need the position (FEN) in order to reverse engineer the starting position of the pawn/piece being moved.

I'm hoping there is some utility or library/function that does this. If not, a description/outline of the basic algorithm would be great too.

1 Answer 1

6

You can do this easily in python using the python-chess module and using the parse_san function of chess.Move.

Let's call the script algebTocoord.py:

import chess testfen = 'rnbqkb1r/pppppppp/5n2/8/3P4/8/PPP1PPPP/RNBQKBNR w KQkq - 1 2' board = chess.Board(testfen) algmove = 'Nf3' coordmove = str(board.parse_san(algmove)) print coordmove 

the printed output is:

'g1f3' 

This was tested using Python version 2.7.16 and the 0.22.1 version of python-chess.

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.