0

What are suggested coding snippets to add pieces to pure algebraic notation (this would change g1f3 to Nf3) when using the chess.js and chessboard.js (javascript) interface. Stockfish uses this type of raw notation and I would like to change it.

Answers such as the ones from the link below are not helpful. for example: the computer knows the names of the pieces.

Changing UCI output to include piece names

  • 1
    You just need to use the JS library to keep a board state. Or use FEN to work out the pieces. My answer in the link is correct. Please note asking for JS code without some serious attempt is off topic here. – SmallChess May 20 '18 at 15:26
0

Sorry I don’t know any JavaScript but here is the basic code (in pseudo code) for the problem:

SELECT CASE Board(Move(1),Move(2))
CASE “N”
      Move <== “N” + Move(3) + Move(4)
CASE “P”
      Move <== Move(3) + Move(4)
CASE “K”
      Move <==“K” +  Move(3) + Move(4)
CASE “R”
      Move <==“R” +  Move(3) + Move(4)
CASE “Q”
      Move <==“Q” +  Move(3) + Move(4)
CASE “B”
      Move <==“B” +  Move(3) + Move(4)
END SELECT

This is assuming there is a 2D array holding the board named “Board” and a string “Move” holding the move about to be played.

Hope this has helped.

Not the answer you're looking for? Browse other questions tagged or ask your own question.