Chess - Programming - FEN (Forsyth-Edwards Notation)

FEN is a standard notation for describing a particular board position of a chess game.


The starting position:

rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1

NOTE: A FEN record contains six fields, separated by spaces.

The fields are:

  • Piece placement.
    • rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR: The Piece Placement.
    • /: The next rank.
    • Digits 1-8: The number of empty squares until the next piece on the rank.
  • Active color:
    • w means White moves next,
    • b means Black moves next.
  • Castling availability.
    • -: Neither side can castle.
    • K: White can castle kingside,
    • Q: White can castle queenside,
    • k: Black can castle kingside,
    • q: Black can castle queenside.
  • En passant target square in algebraic notation:
    • -: There is no en passant target square.
    • This is recorded regardless of whether there is a pawn in position to make an en passant capture.
  • Halfmove clock: The number of halfmoves since the last capture or pawn advance, used for the fifty-move rule.
  • Fullmove number: The number of the full move. It starts at 1, and is incremented after Blacks move.

Test Ambiguation

Test Castling

Test Castling Prevented

Test Castling

Test Discovered Check

Test Double Check

Test End Games

Test Enpassant capture gives check

Test Huge Number of Moves

Test Incorrect Positions

Test Long castling gives check

Test Move Generation

Test Pawn Shield

Test Perft

Test Positions

Test Promote out of check

Test Promotion gives check

Test Self Stalemate

Test Short castling gives check

Test Stalemate

Test Static Exchange

Test Underpromotion gives check


References

https://timkr.home.xs4all.nl/records/records.htm