mwg API
    Preparing search index...

    Function positionKey

    • The position half of FEN: placement, side to move, castling rights and en passant square, without either move clock. Two positions share a key exactly when the same moves are legal from both, which is what makes it the lookup key for an opening book (board/openings.ts builds and probes keys with this function on both sides, so the en passant square is taken as stored rather than re-derived).

      Parameters

      Returns string

      import { positionKey, startingChess } from '@datamoc/mwg/board';

      console.log(positionKey(startingChess()));
      // 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -'