Fen

Fen is a string that represents the board state. This module provides a utilites to parse and generate fen strings.

INITIAL_FEN_POSITION

The initial FEN position of the chess game.

import { INITIAL_FEN_POSITION } from "chess-lite/fen";
// "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";

parseFen

Parse FEN string to FenState object.

import { type FenState } from "chess-lite/definitions";
import { parseFen } from "chess-lite/fen";
 
const fenState: FenState = parseFen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1");

generateFen

Generate FEN string from FenState object.

import { type FenState } from "chess-lite/definitions";
import { generateFen } from "chess-lite/fen";
 
const fenState: FenState = {...}; // Your FenState object (Refer to definitions)
const generatedFen = generateFen(fenState);

To learn more about FEN format, you can refer to Wikipedia.