ChessFromScratch

Projects Systems & Platforms Project

The opening position, drawn by the engine itself

Stack

Python, Game, Engine

Category

Systems & Platforms

Status

Open source

Source

Public repository

Chess From Scratch

Understand chess engines by writing one, no libraries.

You can use a chess library and never learn what it is doing. Castling rights, en passant, move legality under check — they are all handled for you, and all of the interesting difficulty is hidden.

Chess From Scratch is a complete chess engine built bottom-up — rules, board, moves, and an engine to think with — written without chess libraries to understand how engines really work.

So this one is written bottom-up with no chess libraries at all: board representation, the full legal-move rules, move generation, and a search that picks a move. The point was to understand engines by having to build one.

Three moves into a Ruy Lopez — the engine marks the square the bishop left and the one it landed on

The problem

Understand chess engines by writing one, no libraries.

Board & rules

Representation and full legal-move rules written from first principles.

A bishop on c4 selected: every legal move it has, worked out from the position rather than looked up

Move generation

Every legal move, generated rather than looked up.

Built with

Python · Game · Engine

The king on e1 with its legal moves, castling to g1 among them

The engine

A search that picks a move — no chess libraries anywhere.

Checkmate: the engine finds no legal reply for black and paints the king it has trapped
ReWearProduct & WebKeep scrolling for the next fileNext →