mwg API
    Preparing search index...

    Function unmakeMove

    • Takes back exactly what makeMove played: the mover returns, the taken piece (or the en passant pawn behind the landing square) is restored, and rights, en passant square, halfmove clock and king square come back from the undo.

      Parameters

      Returns void

      import { bitboardMoves, makeMove, startingBitboard, unmakeMove } from '@datamoc/mwg/board';

      const board = startingBitboard();
      const move = bitboardMoves(board)[0];
      const undo = makeMove(board, move);
      unmakeMove(board, move, undo);
      console.log(board.turn, bitboardMoves(board).length); // 'white' 20 - taken back whole