This is a project made by Guillem Cabré. Its purpose is to learn how a Chess Engine works, using algorithmic experience and learning from other projects to gain expertise in computer science. The program features a simple GUI for users to interact with the game using the cursor.
The project is implemented in C++.
Before you begin, ensure you have met the following requirements:
- You have installed
g++ cmakeis installed- You have
libsdl2-dev,libsdl2-image-dev,libsdl2-mixer-devinstalled
If any of these are not installed, please refer to Installing Dependencies on Ubuntu/Debian.
To clone the repository, use the following command:
git clone https://github.com/Willyllem88/Chess-Engine.git
cd Chess-EngineTo install the necessary dependencies, run the following commands:
sudo apt-get update
sudo apt-get install g++ cmake libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev-
Build the project:
mkdir build cd build cmake .. make -
Executing the Program:
After compiling, the executable file is
engine, to see its options use--help../engine <options>
-
Cleaning the Build:
To clean the directory of object files and executables, use:
make clean
In order to clean the entire build, use:
make distclean
The executable file will be named
engine.
The options are specified using the -option format:
-hor--help: Displays a usage message.-b <Player | <engine_name>>or--black <Player | <engine_name>>: Specifies who will play with the black pieces.-w <Player | <engine_name>>or--white <Player | <engine_name>>: Specifies who will play with the white pieces.-cor--console-only: Runs the program without the GUI, allowing moves to be entered via the console.-t <seconds>or--timespan <seconds>: Sets the time span (in seconds) that the engine will take to make a move after its opponent. Can handle decimals.-f "<fen>"or--load-fen "<fen>": Loads a FEN (Forsyth-Edwards_Notation) position to the board. Visit FEN documentation. Important: The FEN string must be enclosed in quotes. If not specified, the initial board will be set to the default position.
The default values are --white Player, --black Player, and --timespan 2.
To run the program with a player as white and an engine named "EngineV1" as black, with a timespan of 2.5 seconds, and displaying it through the console, with an example FEN string, use:
./engine -w Player -b EngineV1 -t 2.5 -c -f "4k2r/6r1/8/8/8/8/3R4/R3K3 w Qk - 0 1"During the execution of the program, the user can enter the following commands:
uorundo: Undoes the last move. The user can undo multiple moves until the initial board is reached.<algebraic-move-notation>: if it's a valid move, it will perform it.
- FEN-Forsyth Edwards Notation
- Negamax algorithm
- Alpha Beta Pruning
- Transposition Table
- Iterative Deepening
- Bartek Spitza: The Fascinating Programming of a Chess Engine
- Sebastian Lague: Coding Adventure: Chess
