Orbital-Web / Raphael

A chess GUI and a UCI chess engine coded in C++ and SFML.
MIT License
5 stars 1 forks source link
ai chess chess-engine chess-gui cpp sfml uci

Raphael

Both a UCI Chess Engine (Raphael) and a Chess GUI (to play against Raphael or to make Raphael play itself), coded in C++, using SFML and Disservin's Chess Library.

Raphael is a hobby project that is still a work in progress, but it will be updated as time goes by. It is nowhere near as competitive as some of the other chess engines out there, but it is strong enough to beat most humans with ease. Please scroll to the bottom to see a list of features currently implemented

Raphael is largely inspired by Sebastian Lague's Coding Adventure series on implementing a Chess Engine, and is a revisit/successor to a previous engine I coded in Python.

Note: v1.7 will be the last of the minor releases to Raphael. The next major release will be v2.0 using a custom NNUE evaluation function.

demo of Raphael

ELO

Estimated CCRL 40/2 ELO: 1865

To estimate Raphael's ELO, I paired it up against several other engines in a 10 rounds 40/2 gauntlet tournament inside of Arena, incrementally updating Raphael's ELO using the this calculator, which is based on the statistical model between win probability and ELO.

Raphaelv1.7 was matched against Sayuri (1838), Claudia (1908), and BeLL (1939), and the results were a WDL of 8-1-1 (+81), 4-1-5 (-1), and 3-2-5 (-12), respectively. Previously, the ELO of Raphaelv1.6 was estimated to be around 1797, thus the estimated ELO of Raphaelv1.7 is around 1865.

Note that this method of ELO estimation is very crude, as it only only compares against a few other engines with only 10 rounds. In the future, I will conduct a more thorough comparison (maybe once v2.0 is out).

Past ELOs

Version CCRL 40/2
1.71865
1.61797
1.51764


Getting started (Windows)

UCI Engine

Builds for Windows are available on the Releases page. To compile it on your own, run

g++ -c uci.cpp -Isrc -Ichess-library/src -ISFML-2.6.0/include -DSFML_STATIC
g++ -o Raphael uci.o -LSFML-2.6.0/lib -lsfml-graphics-s & del uci.o

GUI and Engine

Follow these steps to compile Raphael along with the GUI. This is recommended as you do not need an external UCI-compliant GUI to run Raphael.

  1. Clone the repository with

    git clone https://github.com/Orbital-Web/Raphael.git --recurse-submodules
  2. Download SFML-2.6.0 and add it to the root directory

  3. Copy openal32.dll from SFML-2.6.0/bin/ and add it to the root directory

  4. Compile and run main.exe with the following commands (optionally, compile with the -DMUTEEVAL flag to mute evaluations)

    g++ -c main.cpp -Isrc -Ichess-library/src -ISFML-2.6.0/include -DSFML_STATIC
    g++ -o main main.o -LSFML-2.6.0/lib -lsfml-graphics-s -lsfml-window-s -lsfml-audio-s -lsfml-system-s -lopengl32 -lfreetype -lwinmm -lgdi32 -lopenal32 -lflac -lvorbisenc -lvorbisfile -lvorbis -logg & del main.o
    main.exe human "Human" Raphael "Raphael" -s "game.pgn"
  5. See other features with main.exe -help

Note: the compilation process should be similar for other OS, though Raphael was built primarily for Windows, and thus the code has not been tested on other OS. Nonetheless, please refer to the official SFML documentation on how to download SFML for your OS

Features

Game Engine (GUI)

The game engine is a combination of GameEngine.hpp, GamePlayer.hpp, and HumanPlayer.hpp. It is a GUI-based chess game engine (not to be confused with a chess engine) which lets the user interactively play chess.

If using a human player, the user may annotate the board with arrows and select/play moves similarly to other chess GUIs. The user may also specify the number of rounds, different time controls, starting positions (with fens), and even swap out the players (e.g., with different versions of Raphael).

To use it, refer to the setup instructions above, and run the command main.exe -help in the command line.

Raphael (Engine)

Raphael is a UCI-compliant chess engine that comes with this project. To use it in other UCI-compliant softwares, compile uci.cpp using the instructions above. The UCI engine currently supports the following commands: uci, isready, ucinewgame, stop, quit, position, and go [wtime|btime|winc|binc|depth|nodes|movetime|infinite]. Pondering is not implemented yet. The engine contains the following features:

General

Evaluation

Move Ordering

Comparisons

Below is the result of each new version against v1.0 out of 400 matches (20 seconds each), starting from a different position (within a ±300 centipawn stockfish evaluation) and alternating between playing as white and black.

v1.0

v1.0 [177 / 34 / 189]

v1.1

v1.0 [245 / 39 / 116]

v1.2

v1.0 [253 / 34 / 113]

v1.3

v1.0 [301 / 23 / 76]

v1.4

v1.0 [333 / 25 / 42]

v1.5

v1.0 [344 / 23 / 33]

v1.6

v1.0 [355 / 27 / 18]

v1.7

v1.0 [374 / 20 / 6]

And below are the more detailed comparisons.

Player Wins Draws Losses Opponent
White Black Timeout White Black Timeout
v1.0 91 70 16 34 92 70 27 v1.0
v1.1 94 104 47 39 53 63 0 v1.0
v1.2 115 104 34 34 62 51 0 v1.0
v1.2 112 96 6 30 86 61 9 v1.1
v1.3 144 120 37 23 43 32 1 v1.0
v1.3 107 107 10 38 61 61 16 v1.2
v1.4 144 136 53 25 14 27 1 v1.0
v1.4 117 114 13 40 57 49 10 v1.3
v1.5 156 154 34 23 15 18 0 v1.0
v1.5 99 99 13 62 61 60 6 v1.4
v1.6 169 178 8 27 5 13 0 v1.0
v1.6 122 127 2 77 33 39 0 v1.5
v1.7 182 187 5 20 2 4 0 v1.0
v1.7 92 98 0 108 53 49 0 v1.6

Note: a timeout usually means that the game was relatively equal