mwg API
    Preparing search index...

    Function makeMove

    • Plays a move, mutating the position, and returns what unmakeMove needs to take it back. Special moves are read off the position rather than flagged on the move: a pawn onto the en passant square captures the pawn behind it, a king stepping two squares swings its rook, a pawn stride of sixteen leaves a square behind it.

      Parameters

      Returns BitboardUndo

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

      const board = startingBitboard();
      const move = bitboardMoves(board)[0];
      const undo = makeMove(board, move);
      console.log(board.turn); // 'black' - the move is played
      unmakeMove(board, move, undo);