GitHub

Lucerna

Chess engine · version 2.0

An original chess engine with a neural-network evaluation, written from scratch and trained on hundreds of millions of positions.

Lucerna 2.0— 2 —19… Qxa1+

Openings.

    Lucerna 2.0— 3 —20. Ke2

    In its light, a pawn casts the shadow of a king.

    Photo · Andrey Soldatov / Unsplash

    Lucerna is Latin for lamp. Every engine starts as a pawn. This one first taught itself, generation after generation, then learned from millions of games played by people and by Leela Chess Zero.

    Lucerna 2.0— 4 —20… Na6

    Search and evaluation.

    Photo · Edoardo Bortoli / Unsplash

    Evaluation. Lucerna judges a position with an efficiently updatable neural network (NNUE). 768 inputs per side feed a layer of 512 neurons, mirrored for both colours, with SCReLU activation and eight output buckets. It runs on AVX2 instructions and is updated move by move rather than recomputed.

    Search. A principal variation search with null-move pruning, late move reductions and internal iterative reductions decides which moves deserve a deeper look. Singular extensions, with double and negative extensions and multi-cut, spend extra effort on the one move that really matters.

    Everything else. Lazy SMP lets many threads share one transposition table. Lucerna speaks UCI, so it runs in Arena, Cute Chess, BanksiaGUI or En Croissant. Every change to the engine is kept only if it wins an SPRT match against the version before it.

    Lucerna 2.0— 5 —21. Nxg7+

    See how it thinks.

    01 / 05

    The position

    Lucerna receives the board from your chess program, piece by piece.

    02 / 05

    Bitboards

    Inside, the board becomes 12 sheets of 64 bits, one for each piece type and colour. Moves are generated with fast bit operations.

    03 / 05

    Neural network

    Each piece switches on its inputs. 512 neurons per side combine them through a squared, clipped activation, and one of 8 outputs gives the score.

    04 / 05

    Search

    A principal variation search looks millions of positions ahead each second. Pruning cuts lines that cannot matter, and singular extensions look deeper when one move is forced.

    05 / 05

    Best move

    The move that survives the search is played. The whole journey takes a fraction of a second.

    +6.70 · Nxh6
    0 positions per second
    Lucerna 2.0— 6 —21… Kd8

    Training data.

    The 1.0 network learned from three sources. Each square below is one sixty-fourth of the data.

    • 125MLucerna's own self-play, generations 7–11
    • 98.2MLeela Chess Zero training data (test80, ODbL)
    • 13.6MLichess Elite games, scored by Lucerna itself

    All code and every network are original. No Stockfish evaluations were used.

    Lucerna 2.0— 7 —22. Qf6+!!

    Download.

    Lucerna 2.0— 8 —22… Nxf6

    What's next.

    Lucerna 2.0— 9 —23. Be7#

    Thanks.

    Lucerna 1.0 learned from the open training data of Leela Chess Zero (ODbL), and from games in the Lichess database (CC0) and the Lichess Elite Database, which it scored itself. The clear code of Stash gave us many ideas. Cute Chess played every one of our test matches, and lichess-bot lets LucernaBot play online. The chess pieces are the Merida set by Armando Hernandez Marroquin (GPLv2+), from Lichess. Thank you.