Skip to content

nTh0rn/chess-engine

Repository files navigation

Terconari Chess Engine

("Attempt thrice"→Latin→"Ter conari")

A built-from-scratch lichess-bot compatible chess engine made in C++

Table of Contents
  1. About
  2. Getting started
  3. Usage
  4. License
  5. Contact

About

Terconari is a built-from-scratch chess-bot/chess-engine made in C++ with a GUI built ontop of openFrameworks, compatible with lichess-bot, and often live and playable at lichess.org/Terconari.

Technical Specifications

  • Lichess-style GUI for local-only BotvBot, PlayervBot (premove functionality), or PlayervPlayer usage
  • GUI-free UCI mode for compatibility with lichess-bot
  • Opening book functionality
    • Default opening book has 244,117 games up to 16 plys deep, see Usage→Opening Book for more details
  • Make/Unmake legal move verification
    • Legal move generation tested against Stockfish's perft results across tens-of-millions of positions
  • Evaluation via material/positional information
  • Negated Mini-Max with Alpha Beta Pruning
    • Non-pawn captures are always calculated an additional depth
  • Time-dependant Iterative Deepening
    • Attempts a depth of 6 plys
    • Escapes after (timeLeft/50)+increment seconds
  • Null Move Pruning
    • Does not run in positions that are in-check, have <= 4 legal moves, or have <= 6 total non-pawn pieces

An in-depth technical article about this project is coming soon to my website, nthorn.com

(back to top)

Getting started

Prerequisites

  1. Visit openFrameworks and download the Windows→Visual Studio version.
  2. Extract the downloaded zip to a directory of your choice.

Installation

  1. Clone/download the repository within your openFrameworks installation directory, apps/myApps/
    cd apps/myApps
    git clone https://github.com/nTh0rn/chess-engine.git
  2. Launch Chess Engine.sln and confirm any refactoring prompts.

(back to top)

Usage

A starting screen GUI that allows for the modification of these settings is coming soon.

  1. Customize time control and gamemode by modifying class members within /src/ofApp.h.
    1.1. int gamemode values: 0 = Bot(w) v Bot(b), 1 = Player(w) v Bot(b), 2 = Bot(w) v Player(b), 3 = Player(w) v Player(b), 4 = UCI Mode (For lichess-bot).
    1.2. int timeSec The amount of time in seconds either side has.
    1.3. int increment The amount of increment in seconds either side has.
  2. Enable/disable debug messages by modifying bool showDebugMessages within /include/Chess.h.
  3. Run in Release mode without the local debugger for significant performance increase over Debug mode.

Opening Book

By default, Terconari comes with an opening book containing 244,115 games up to 16 plys deep obtained from PGNMentor and stripped of duplicates.

Custom opening books compatible with Terconari can be made using opening-book-PGN-to-UCI. Whichever opening book is to be used must be renamed to book.txt and placed within /bin/data/openingbooks/. See the function openingBookMove() within /lib/Chess.cpp if Terconari is unable to find its opening book.

Lichess Bot

After compiling, the contents of /bin/ can easily be moved to the /engines/ folder of lichess-bot per its documentation.

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Nikolas Thornton - nthorn.com - contact@nthorn.com

(back to top)

About

A built-from-scratch chess engine made in C++.

Topics

Resources

License

Stars

Watchers

Forks

Languages