Skip to content

SaadSaid158/chess-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chess Engine

This chess engine is a compact chess engine written in Go with two front ends: a local browser UI and a UCI mode for chess GUIs. It uses a bitboard-based engine, iterative deepening alpha-beta search, and built-in perft support for engine validation.

Features

  • Go 1.21 project with no third-party runtime dependencies
  • Bitboard board representation with incremental make/unmake
  • UCI protocol support for external GUI integration
  • Built-in web UI served by the engine over HTTP

Project Layout

  • main.go selects web or uci mode
  • engine/ contains board logic, move generation, evaluation, search, and UCI handling
  • web/ contains the HTTP server and embedded single-page interface

Requirements

  • Go 1.21 or newer

Build

go build -o chessengine .

On Windows the output binary will be chessengine.exe.

Run

Start the browser UI on the default port:

go run . -mode web

Start the browser UI on a custom port:

go run . -mode web -port 9090

Then open http://localhost:8080 or your chosen port.

Start UCI mode:

go run . -mode uci

Build once, then run the binary:

./chessengine -mode web
./chessengine -mode uci

UCI Usage

Minimal manual session:

uci
isready
ucinewgame
position startpos
go depth 8
quit

Supported commands in the current implementation include:

  • uci
  • isready
  • ucinewgame
  • position startpos
  • position fen <fen> moves <...>
  • go depth <n>
  • go movetime <ms>
  • go wtime <ms> btime <ms> [winc <ms>] [binc <ms>] [movestogo <n>]
  • stop
  • perft <depth>
  • d
  • eval

Web UI

The web mode exposes:

  • GET / for the UI
  • GET /api/state for current board state
  • POST /api/move to play a move
  • POST /api/newgame to start a game with selected color and depth
  • POST /api/undo to undo the last full move pair
  • GET /api/legalmoves?square=<sq> for square-specific legal moves

The UI lets you:

  • play as White or Black
  • set engine depth from 1 to 20
  • view move list, evaluation, nodes, depth, and NPS
  • undo the last move pair and flip the board

License

This project is licensed under the MIT License. See LICENSE.

About

A compact chess engine written in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages