mwg API
    Preparing search index...

    Function cloneChess

    • A deep copy, safe to mutate (via applyMove) without touching the original - what legalMoves uses to try a move and check it does not leave the mover in check.

      Parameters

      Returns ChessState

      import { startingChess, cloneChess } from '@datamoc/mw_games/board';

      const state = startingChess();
      const trial = cloneChess(state);
      console.log(trial !== state, trial.turn); // true 'white'