Skip to content

mrtonbrian/BRITON

Repository files navigation

BRITON

A small chess engine I wrote in C++ and a (very) basic frontend. Note: the branch you are on is undergoing a major rewrite / restructuring of the code to use a bitboard board representation and more modern C++ style (instead of C in C++), and it is currently unfinished. Head over to the master branch to see high school me's attempt at writing code.

How The Frontend Interfaces With the Backend (Simply)

First, the user interacts with the chessboard.js board, which updates the chess.js game representation.

Then, after the user makes the initial move, the chessboard gets locked, so that the user cannot make moves on the board, and a POST request is sent to the /move path with the PGN of the current game and the time the user requested, which waits until the server returns the best move with the format:

{'move': <...>, 'from': <...>, 'to': <...>, 'eval': <...>}

Note: move is in the long algebraic notation, from and to are the move to and move from squares, and eval is the score that the chess engine scored the position as.

TODO: Add ability to select depth, rather than time

Finally, the game.js game representation and the chessboard.js board are updated, and the square highlights are made using the code:

game.move(data["move"], {
  sloppy: true
});
removeHighlights("white");
removeHighlights("black");
boardEl.find(".square-" + data["from"]).addClass("highlight-black");
boardEl.find(".square-" + data["to"]).addClass("highlight-black");
board.position(game.fen()); // update the board to the new position

How the engine works

The engine is a UCI engine that communicates with the Flask webapp engine package from python-chess.

Essentially, the engine uses an Alpha-Beta search with move ordering and quiescent search, a Principal Variation table, a combined 120 square array and bitboard data structure, and a material and Piece-Square table evaluation.

About

A small chess engine I wrote in C++

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published