Chess Engine

Play

A chess engine that runs entirely in your browser. You play White; drag a piece to move. Nothing is sent anywhere, and the search runs on your own machine.

Even Your turn.
WhiteBlack

Captured

Nothing captured yet.

Settings

Move history

No moves yet.

How it works

Everything happens in this page: there is no server, no API call and no stored game. The engine is a classical search over the game tree, the same design as the first chess programs, with three parts.

Search

The engine looks ahead a fixed number of half-moves and assumes both sides play their best line (minimax). Alpha-beta pruning discards branches that cannot change the outcome, which cuts the number of positions examined by a large factor without changing the result. Depth 3 usually takes a second or two; depth 4 can take much longer in open positions, where there are more legal moves to consider.

Evaluation

At the leaves of the search, a position is scored in centipawns from White's point of view: material first, at the usual values of 1, 3, 3.2, 5 and 9 pawns, then a small bonus for occupying or attacking the four central squares, a bonus for pawns still sitting in front of a castled king, and a large score for mate. Everything the engine understands about chess is in that function, which is why it plays reasonable material chess but no real strategy.

Opening book

For the first few moves, the engine can follow a short book of standard openings instead of searching. When the moves played so far match the start of a book line, it plays the next move of that line, choosing at random when several lines match. Turning the book off makes the engine think from move one, which is slower and often stranger.

House rules

Colours
You play White and move first. The engine plays Black.
Special moves
Castling and en passant are allowed. A pawn reaching the last rank always promotes to a queen.
Draws
Threefold repetition, the fifty-move rule, stalemate and insufficient material all end the game.
No undo
Once a move is released it is final. Start again with New game.
Waiting
The search blocks the page while it runs. If your browser offers to stop the script, wait instead.