mwg API
    Preparing search index...

    Function searchTourneyAsync

    • Chooses a move the way searchTourney does, but thinks on worker threads through threads.spawn, so a deep search does not drop the caller's frames. Each root move is a self-contained tourneyThink task over a structured-cloned bitboard, scored concurrently down a capped lane queue; the best child score from the opponent's view is the worst for us, so the root plays the move whose child scored lowest, with ties going to the earlier root move. rootScores exposes every candidate so games can choose near-best moves without repeating the search on the UI thread. An aborting signal rejects through threads.spawn and terminates the workers.

      Parameters

      Returns Promise<TourneyResult>

      import { searchTourneyAsync, startingBitboard } from '@datamoc/mwg/board';

      const result = await searchTourneyAsync(startingBitboard(), { depth: 2 });
      console.log(result.move !== null); // true - the opening position always has legal moves