As the title says, given a valid chess move in algebraic notation, produce the string describing the move.
Example:
fxg8=Q+ -> Pawn takes g8 promotes to Queen check
Bb7# -> Bishop to b7 mate
Here is a list of all the keywords and their respective notation
R -> Rook x -> takes
N -> Knight + -> check
B -> Bishop # -> mate
Q -> Queen = -> promotes to
K -> King 0-0 -> short castle
0-0-0 -> long castle
Note: Long and short castle can be represented with either number 0
or letter O
uppercase. You can choose any you'd like.
From wiki: Both algebraic notation and descriptive notation indicate kingside castling as 0-0 and queenside castling as 0-0-0 (using the digit zero). Portable Game Notation and some publications use O-O for kingside castling and O-O-O for queenside castling (using the letter O) instead
Piece moves format follows {Piece name} to {square}
Moves without a piece are consider pawn moves. Example:
g4 -> Pawn to g4
Nh7 -> Knight to h7
For ambiguous moves, input will specify both departure rank and file. Example:
Rh8b8 -> Rook h8 to b8
Qb3e6 -> Queen b3 to e6
Input
String with a valid chess move in algebraic notation
Output
String describing the move (Upper case or Lower case is ok)
Test Cases
fxg8=Q+ -> Pawn takes g8 promotes to Queen check
Bb7# -> Bishop to b7 mate
0-0 -> short castle
0-0+ -> short castle check
0-0-0# -> long castle mate
Rxg8 -> Rook takes g8
fxe6 -> Pawn takes e6
Ra8g8 -> Rook a8 to g8
Nb3# -> Knight to b3 mate
a8=B -> Pawn to a8 promotes to Bishop
Ra8xg8 -> Rook a8 takes g8
:
for capture, e.g.,f:g8=Q
, and often with pawn captures, if it's unambiguous, just the two files are given:fg=Q
. \$\endgroup\$Ra8xg8 -> Rook a8 takes g8
(?) \$\endgroup\$f
? I don't see it in the list of keywords? Is it a pawn? \$\endgroup\$