mwg API
    Preparing search index...

    Function chooseMove

    • Chooses a move with a small negamax alpha-beta search.

      This is intentionally a rules engine, not a tournament engine: it searches legal positions, orders captures and promotions first, and evaluates material only. It has no opening book, transposition table, clock, or repetition scoring, which keeps it deterministic and small enough to run synchronously in a browser minigame.

      Parameters

      Returns ChessMove | null

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

      const state = startingChess();
      const move = chooseMove(state, { depth: 2 });
      if (move) applyMove(state, move); // the engine's own reply, played for it