The JavaScript Chessboard

<<   < move back   move forward >   >>     move 1 of 1, white to move

reset   size:   clear the board   reset history   b/w   restore

board setup   Chess 960 - generate   read    


load FEN string:   

Did you ever wish you had a chessboard on your computer with pieces that you could move?
Now you do!

Drag the pieces to move them.  Go backward or forward by pressing “move back” or “move forward.”

The move history saves certain move sequences as one move.

• Move captured pieces off the board immediately after capture.

• Exchange the pawn for its replacement immediately after pawn promotion.

• To castle, move the king first, then the rook.

While a move sequence is in progress, it will be indicated after the move number.

The move history ignores non-moves and rearranging pieces off the board.  Use the “move back” function to undo erroneous moves.

Check “board setup” to stop recording history while setting up a board position.  Then use “reset history,” and “b/w” to change color, if needed.
(Remember to uncheck “board setup”!)

The extra pieces are for pawn promotion.

Moves are recorded as reversible algebraic notation in the text area on the left, and Forsyth–Edwards notation in the string below the controls:  the piece positions in rows, with numbers indicating blank spaces; which color to move; castling ability; en passant target, if any; half-moves since the last capture or pawn move; and the move number.

To play Chess960 (Fischer Random Chess), press “generate” to randomly set up a position.  Or, arrange the white pieces and press “read.”  The setup procedure:

• Place the bishops on different colors.

• Place the queen and knights anywhere.

• Place the king between the rooks.

The Forsyth–Edwards notation is modified in Chess960 to Shredder-FEN:  to resolve ambiguity, castling ability is indicated by the files of the rooks rather than “K” and “Q.”  Also, as in X-FEN, only “real” en passant targets, with an enemy pawn in position, are recorded.

• In Chess960, castling may require moving only the king, or moving it to the square occupied by the rook.  In these cases, begin the move sequence by moving the king to the spot off the board beside its target square.

You may use the “load FEN string” field to load a saved chess position.  The script error-checks the piece placement part of the string; and if present, the overall structure (but not all the details) of the rest.  Because there is no move history, the move count resets to 1.

Wikipedia on Forsyth–Edwards Notation:

A FEN record contains six fields.  The separator between fields is a space.  The fields are:

  1. Piece placement (from white’s perspective).  Each rank is described, starting with rank 8 and ending with rank 1; within each rank, the contents of each square are described from file “a” through file “h”.  Following the Standard Algebraic Notation (SAN), each piece is identified by a single letter taken from the standard English names (pawn = “P”, knight = “N”, bishop = “B”, rook = “R”, queen = “Q”, and king = “K”).  White pieces are designated using upper-case letters (“PNBRQK”) while black pieces use lowercase (“pnbrqk”).  Empty squares are noted using digits 1 through 8 (the number of empty squares), and “/” separates ranks.
  2. Active color.  “w” means White moves next, “b” means Black.
  3. Castling availability.  If neither side can castle, this is “-”.  Otherwise, this has one or more letters: “K” (White can castle kingside), “Q” (White can castle queenside), “k” (Black can castle kingside), and/or “q” (Black can castle queenside).
  4. En passant target square in algebraic notation.  If there’s no en passant target square, this is “-”.  If a pawn has just made a two-square move, this is the position “behind” the pawn.  This is recorded regardless of whether there is a pawn in position to make an en passant capture.
  5. Halfmove clock: This is the number of halfmoves since the last capture or pawn advance.  This is used to determine if a draw can be claimed under the fifty-move rule.
  6. Fullmove number: The number of the full move.  It starts at 1, and is incremented after Black’s move.

FEN is critical for recording games in chess variants such as Chess960 (also known as Fischer Random Chess), where the initial position is not necessarily the traditional initial position.  However, the FEN castling availability encoding (KQkq) is inadequate for positions in which there are two Rooks on the same side of the King on the back rank.  It is ambiguous which Rook is still available for castling without knowing their initial positions.

The solution implemented by chess engines like Shredder and Fritz_9 is to use the letters of the columns on which the rooks began the game.  This scheme is sometimes called Shredder-FEN.  For the traditional setup, Shredder-FEN would use AHah instead of KQkq.

The Chess960 Numbers Decoded

Castling in Chess960:  An appeal for simplicity by John Kipling Lewis

Don’t click here.