INNER CODE UNIT · TypeScript

move

josefjadrny/js-chess-engine · src/index.ts:81

        const move = legalMoves.find(m => m.from === fromIndex && m.to === toIndex);

        if (!move) {
            throw new Error(`Invalid move from ${fromNorm} to ${toNorm}`);
        }

        // Record move in history
        const historyEntry: HistoryEntry = { [fromNorm]: toNorm };
        this.history.push(historyEntry);

        // Apply the move
        applyMoveComplete(this.board, move);

        return boardToConfig(this.board);
    }

    /**
     * Get all legal moves, optionally filtered by from-square

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…