short algebraic notation to long algebraic notation
* Folkert van Heusden (14:45) schrieb:
When a chessengine or user enters a SAN move, do I need to know what moves
he is capable at that moment of doing? Or is it enough to know what pieces
are where on the board?
With SAN you always know:
- the type of the piece that moves
- the square the piece moves to
- if it captures another piece or not
- if it is a promotion and what kind
When you have more than one piece of the indicated type, SAN almost never
tells you which of the pieces is to move.
I found it easiest to generate a list of legal moves and check for the
one that satisfys all the constraints of the SAN string.
But of course you can walk through the pieces of the indicated type and
test if they cann legally move to the target square. But that needs
almost the same code as the move generator.
The best way might be to just generate legal moves that satisfy the
contraints. With bitboards that would look like:
"exd5" for white
generate_legal (type = WHITE_CAPTURING_PAWN,
from = pawns & white & BITBOARD_FILE(E),
to = black & BITBOARD_SQUARE(D5))
"Ng2" for black
generate_legal (type = KNIGHT,
from = knights & black
to = ~white & BITBOARD_SQUARE(G2))
"Q8xg2" for black
generate_legal (type = QUEEN
from = queens & black & BITBOARD_RANK(8),
to = white & BITBOARD_SQUARE(G2))
If the SAN is correct this will always produce exactly one move.
mfg, simon .... l
|