GitHub
Chess Engine banner

Chess Engine

  • TypeScript
  • Node.js
  • React
  • Vite
  • Worker Threads
  • REST APIs

Demo

Overview

A modern TypeScript chess engine that demonstrates high-quality evaluation, efficient search (alpha-beta pruning), and parallel move exploration using worker threads — built for learning, experimentation, and integration into web UIs or bots.

Highlights

  • Blazing search: Minimax with alpha-beta pruning and parallel search across worker threads.
  • Tunable evaluation: Piece-square tables, material, king safety, and tuned heuristic weights (tuned_values.csv).
  • Frontend-ready: Ships with a React + Vite UI to play against the engine and visualize its decisions.
  • Educational: Clear code structure in backend/src for stepping through the core algorithms.

Architecture

Structure

  • backend/ — engine logic: search, evaluation, and worker-thread orchestration.
  • frontend/ — React + Vite UI to play and visualize the engine's decisions.
  • tuned_values.csv — tunable parameters consumed by the evaluation function.

Search

  • Minimax with Alpha-Beta Pruning as the core search, cutting branches that cannot affect the result.
  • Worker Threads parallelize move exploration across CPU cores (see backend/src/searchBestMoveParallel.ts and worker.ts), so the root's candidate moves are searched concurrently rather than sequentially.

Evaluation

  • A configurable evaluation function (evaluate.ts) combining material, piece-square tables, king safety, and tuned heuristic weights.
  • Weights live in tuned_values.csv, so the engine's playing style can be adjusted without touching the search.

API

Search and evaluation are exposed over REST APIs consumed by the React frontend:

  • POST /api/evaluate → returns the evaluation score and features.
  • POST /api/search → returns the best move with its principal variation.

Gallery

Architecture
Architecture
Alpha-Beta Minimax
Alpha-Beta Minimax
Evaluation Function
Evaluation Function
Feature Set
Feature Set