mwg API
    Preparing search index...

    Function applyMove

    • Plays a move, mutating the position. Refuses anything legalMoves would not list - a silent illegal move is how a minigame corrupts its own board.

      Parameters

      Returns void

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

      const state = startingChess();
      applyMove(state, { from: sq('e2'), to: sq('e4') });
      console.log(state.turn); // 'black'
      console.log(state.board[sq('e4')]); // { side: 'white', kind: 'pawn' }