### Stockfish 'go' command example Source: https://github.com/official-stockfish/stockfish/wiki/UCI-&-Commands Basic usage of the 'go' command to start a search. The output shows search information and the best move found. ```uci > go depth 7 info depth 7 seldepth 5 multipv 1 score mate -2 nodes 36 nps 6000 hashfull 0 tbhits 0 time 2 pv g7g8 h6g5 g8h7 f6h6 bestmove g7g8 ponder h6g5 ``` -------------------------------- ### Basic Bench Command Usage Example Source: https://github.com/official-stockfish/stockfish/wiki/UCI-&-Commands A basic example of using the bench command within the UCI interface. It sets the starting position and runs a benchmark with specified parameters. ```uci > position startpos > bench 16 1 1 current depth ``` -------------------------------- ### Install Build Tools on Ubuntu Source: https://github.com/official-stockfish/stockfish/wiki/Developers Installs essential build tools and Git on Ubuntu systems. This is a prerequisite for compiling Stockfish. ```bash sudo apt install build-essential git ``` -------------------------------- ### Install Build Tools on Debian/Ubuntu Source: https://github.com/official-stockfish/stockfish/wiki/Compiling-from-source Installs essential build tools including git, wget, curl, and optionally expect for running the test suite. ```bash sudo apt update && sudo apt install build-essential git wget curl expect ``` -------------------------------- ### Example UCI Interaction Flow Source: https://github.com/official-stockfish/stockfish/wiki/UCI-&-Commands Demonstrates a typical interaction flow: starting a new game, checking engine readiness, setting a position, and initiating a search. This sequence ensures proper state management and synchronization. ```uci > ucinewgame > isready readyok > position startpos > go depth 1 info string NNUE evaluation using nn-ad9b42354671.nnue enabled info depth 1 seldepth 1 multipv 1 score cp 18 nodes 20 nps 10000 hashfull 0 tbhits 0 time 2 pv e2e4 bestmove e2e4 > ucinewgame > isready readyok > position fen r2q1rk1/p2bbppp/Q7/2p1P2P/8/2p1B3/PPP2P1P/2KR3R w - - 0 17 ``` -------------------------------- ### Update Packages and Install Build Tools Source: https://github.com/official-stockfish/stockfish/wiki/Compiling-from-source Installs necessary tools like git, build-essential, clang, make, and wget for compiling the source code. ```bash pkg update pkg install git build-essential clang make wget ``` -------------------------------- ### Stockfish Position and Go Command Source: https://github.com/official-stockfish/stockfish/wiki/UCI-&-Commands This example demonstrates setting a specific chess position and then initiating a 'go ponder' command with a time limit. ```text > position startpos moves e2e4 e7e5 g1f3 b8c6 f1c4 > go ponder movetime 1000 ``` -------------------------------- ### Install Packages for Clang/LLVM Build Source: https://github.com/official-stockfish/stockfish/wiki/Compiling-from-source Installs necessary packages including make and Clang for building Stockfish on Windows using MSYS2 MinGW Clang environment. ```bash pacman -S --noconfirm --needed make mingw-w64-clang-x86_64-clang ``` -------------------------------- ### Install clang-format on Ubuntu Source: https://github.com/official-stockfish/stockfish/wiki/Developers Installs clang-format version 20 on Ubuntu systems using apt. This tool is used for code formatting. ```bash sudo apt install clang-format-20 ``` -------------------------------- ### Install GCC Packages for MSYS2 Source: https://github.com/official-stockfish/stockfish/wiki/Compiling-from-source Install the make utility and the GCC compiler for either 64-bit or 32-bit Windows systems within the MSYS2 environment. ```bash # For 64-bit pacman -S --noconfirm --needed make mingw-w64-x86_64-gcc # For 32-bit # pacman -S --noconfirm --needed make mingw-w64-i686-gcc ``` -------------------------------- ### Install Build Tools on MSYS2 Source: https://github.com/official-stockfish/stockfish/wiki/Compiling-from-source Installs necessary development tools for cross-compiling on Windows using MSYS2. ```bash pacman -S --needed base-devel git wget curl expect ``` -------------------------------- ### Install MSYS2 with WinGet Source: https://github.com/official-stockfish/stockfish/wiki/Compiling-from-source Use WinGet, Microsoft's command-line package manager, to install MSYS2 on Windows. ```powershell winget install MSYS2.MSYS2 ``` -------------------------------- ### Automated Stockfish Build Script (64-bit Windows) Source: https://github.com/official-stockfish/stockfish/wiki/Compiling-from-source A bash script to automate downloading Stockfish source, installing dependencies, building the executable, and cleaning up. Designed for 64-bit Windows using GCC. ```bash #!/bin/bash # makefish.sh set -euo pipefail # install missing packages pacman -S --noconfirm --needed unzip make mingw-w64-x86_64-gcc branch='master' github_user='official-stockfish' # download the Stockfish source code wget -O ${branch}.zip https://github.com/${github_user}/Stockfish/archive/refs/heads/${branch}.zip unzip -o ${branch}.zip pushd Stockfish-${branch}/src # remove old nets file_nnue=$(grep 'define.*EvalFileDefaultName' evaluate.h | grep -Ewo 'nn-[a-z0-9]{12}.nnue') shopt -s nullglob for f in *.nnue; do [[ "$f" != "$file_nnue" ]] && rm -f -- "$f" done shopt -u nullglob # build the fastest Stockfish executable for the CPU read -r arch_cpu _ < <(../scripts/get_native_properties.sh) make -j profile-build COMP=mingw make strip COMP=mingw mv stockfish.exe ../../stockfish_${arch_cpu}.exe make clean COMP=mingw popd ``` -------------------------------- ### Get Compiler and Build Information (`compiler`) Source: https://github.com/official-stockfish/stockfish/wiki/UCI-&-Commands The `compiler` command displays details about the compiler and build environment used to create the Stockfish binary. It includes the compiler version, compilation flags, and the expansion of the `__VERSION__` macro. ```text > compiler Compiled by g++ (GNUC) 13.1.0 on MinGW64 Compilation settings include: 64bit AVX2 SSE41 SSSE3 SSE2 POPCNT __VERSION__ macro expands to: 13.1.0 ``` -------------------------------- ### Automated Stockfish Build Script (32-bit Windows) Source: https://github.com/official-stockfish/stockfish/wiki/Compiling-from-source A bash script to automate downloading Stockfish source, installing dependencies, building the executable, and cleaning up. Designed for 32-bit Windows using GCC. ```bash #!/bin/bash # makefish.sh set -euo pipefail # install missing packages pacman -S --noconfirm --needed unzip make mingw-w64-i686-gcc branch='master' github_user='official-stockfish' ``` -------------------------------- ### Compile Stockfish with Makefile Source: https://github.com/official-stockfish/stockfish/blob/master/README.md Compile Stockfish on Unix-like systems using the provided Makefile. Run 'make help' for a list of targets. This example uses a profile build suitable for most Intel and AMD chips. ```bash cd src make -j profile-build ``` -------------------------------- ### Automated Download and Build Script with Clang/LLVM Source: https://github.com/official-stockfish/stockfish/wiki/Compiling-from-source A bash script to automate downloading Stockfish source, installing Clang dependencies, and building the executable. It also cleans up old neural network files. ```bash #!/bin/bash # makefish.sh set -euo pipefail # install missing packages pacman -S --noconfirm --needed unzip make mingw-w64-clang-x86_64-clang branch='master' github_user='official-stockfish' # download the Stockfish source code wget -O ${branch}.zip https://github.com/${github_user}/Stockfish/archive/refs/heads/${branch}.zip unzip -o ${branch}.zip pushd Stockfish-${branch}/src # remove old nets file_nnue=$(grep 'define.*EvalFileDefaultName' evaluate.h | grep -Ewo 'nn-[a-z0-9]{12}.nnue') shopt -s nullglob for f in *.nnue; do [[ "$f" != "$file_nnue" ]] && rm -f -- "$f" done shopt -u nullglob # build the fastest Stockfish executable for the CPU read -r arch_cpu _ < <(../scripts/get_native_properties.sh) make -j profile-build COMP=clang make strip COMP=clang mv stockfish.exe ../../stockfish_${arch_cpu}.exe make clean COMP=clang popd ``` -------------------------------- ### Build Stockfish with Clang/LLVM on Windows Source: https://github.com/official-stockfish/stockfish/wiki/Compiling-from-source Compiles the Stockfish executable using Clang/LLVM. Assumes necessary packages are installed and the user is in the MSYS2 MinGW Clang x64 shell. ```bash make -j profile-build COMP=clang ``` -------------------------------- ### Ponder Hit Example Source: https://github.com/official-stockfish/stockfish/wiki/UCI-&-Commands Demonstrates the 'ponderhit' scenario where the user plays the move the engine was pondering. The engine switches from pondering to normal search. ```text > setoption name Ponder value true > position startpos moves e2e4 > go movetime 1000 info string NNUE evaluation using nn-52471d67216a.nnue enabled info depth 1 seldepth 1 multipv 1 score cp -13 nodes 22 nps 22000 hashfull 0 tbhits 0 time 1 pv e7e5 info depth 2 seldepth 2 multipv 1 score cp -11 nodes 71 nps 71000 hashfull 0 tbhits 0 time 1 pv e7e6 info depth 3 seldepth 2 multipv 1 score cp -11 nodes 189 nps 94500 hashfull 0 tbhits 0 time 2 pv e7e6 info depth 4 seldepth 2 multipv 1 score cp -11 nodes 248 nps 124000 hashfull 0 tbhits 0 time 2 pv e7e6 info depth 5 seldepth 5 multipv 1 score cp -37 nodes 1383 nps 345750 hashfull 1 tbhits 0 time 4 pv d7d5 e4d5 d8d5 info depth 6 seldepth 5 multipv 1 score cp -30 nodes 2545 nps 318125 hashfull 1 tbhits 0 time 8 pv c7c5 g1f3 e7e6 info depth 7 seldepth 7 multipv 1 score cp -30 nodes 4201 nps 350083 hashfull 2 tbhits 0 time 12 pv c7c5 g1f3 e7e6 d2d4 c5d4 f3d4 info depth 8 seldepth 10 multipv 1 score cp -43 nodes 10574 nps 377642 hashfull 4 tbhits 0 time 28 pv c7c5 g1f3 e7e6 d2d4 c5d4 f1e2 info depth 9 seldepth 11 multipv 1 score cp -35 nodes 16924 nps 360085 hashfull 6 tbhits 0 time 47 pv e7e5 g1f3 b8c6 d2d4 e5d4 f3d4 g8f6 info depth 10 seldepth 13 multipv 1 score cp -41 nodes 34866 nps 325850 hashfull 12 tbhits 0 time 107 pv e7e5 g1f3 b8c6 f1b5 g8f6 b1c3 f8c5 e1g1 d7d6 d2d4 e5d4 f3d4 info depth 11 seldepth 14 multipv 1 score cp -38 nodes 43562 nps 325089 hashfull 15 tbhits 0 time 134 pv e7e6 d2d4 d7d5 b1c3 g8f6 c1g5 d5e4 c3e4 info depth 12 seldepth 16 multipv 1 score cp -41 nodes 56507 nps 326630 hashfull 23 tbhits 0 time 173 pv e7e6 d2d4 d7d5 b1c3 f8b4 g1e2 d5e4 a2a3 b4c3 e2c3 info depth 13 seldepth 15 multipv 1 score cp -32 nodes 73728 nps 323368 hashfull 28 tbhits 0 time 228 pv e7e6 d2d4 d7d5 b1c3 g8f6 e4e5 f6d7 f2f4 c7c5 c3e2 c5d4 e2d4 info depth 14 seldepth 17 multipv 1 score cp -31 nodes 90766 nps 318477 hashfull 37 tbhits 0 time 285 pv e7e6 d2d4 d7d5 b1c3 g8f6 e4e5 f6d7 f2f4 c7c5 c3e2 b8c6 g1f3 f8e7 c2c3 e8g8 info depth 15 seldepth 17 multipv 1 score cp -35 nodes 193951 nps 317432 hashfull 76 tbhits 0 time 611 pv e7e5 g1f3 b8c6 f1c4 g8f6 d2d3 f8e7 b1c3 d7d6 h2h3 e8g8 info depth 16 seldepth 17 multipv 1 score cp -23 nodes 255750 nps 322916 hashfull 98 tbhits 0 time 792 pv e7e5 g1f3 b8c6 f1c4 g8f6 b1c3 f8c5 d2d3 h7h6 c1e3 c5e3 f2e3 d7d6 c4b3 info depth 17 seldepth 20 multipv 1 score cp -27 upperbound nodes 323628 nps 322338 hashfull 132 tbhits 0 time 1004 pv e7e5 g1f3 bestmove e7e5 ponder g1f3 ``` ```text > position startpos moves e2e4 e7e5 g1f3 > go ponder movetime 1000 info string NNUE evaluation using nn-52471d67216a.nnue enabled info depth 1 seldepth 1 multipv 1 score cp -30 nodes 47 nps 23500 hashfull 0 tbhits 0 time 2 pv g8f6 d2d4 info depth 2 seldepth 2 multipv 1 score cp -30 nodes 86 nps 43000 hashfull 0 tbhits 0 time 2 pv g8f6 d2d4 info depth 3 seldepth 4 multipv 1 score cp -30 nodes 144 nps 72000 hashfull 0 tbhits 0 time 2 pv g8f6 d2d4 e5d4 e4e5 info depth 4 seldepth 5 multipv 1 score cp -30 nodes 189 nps 94500 hashfull 0 tbhits 0 time 2 pv g8f6 d2d4 e5d4 e4e5 f6e4 info depth 5 seldepth 6 multipv 1 score cp -29 nodes 252 nps 126000 hashfull 0 tbhits 0 time 2 pv g8f6 d2d4 e5d4 e4e5 f6e4 d1d4 info depth 6 seldepth 7 multipv 1 score cp -29 nodes 355 nps 177500 hashfull 0 tbhits 0 time 2 pv g8f6 d2d4 e5d4 e4e5 f6e4 d1d4 d7d5 e5d6 info depth 7 seldepth 8 multipv 1 score cp -29 nodes 591 nps 295500 hashfull 0 tbhits 0 time 2 pv g8f6 d2d4 e5d4 e4e5 f6e4 d1d4 d7d5 e5d6 info depth 8 seldepth 11 multipv 1 score cp -29 nodes 1676 nps 279333 hashfull 0 tbhits 0 time 6 pv g8f6 d2d4 e5d4 e4e5 f6e4 d1d4 d7d5 e5d6 info depth 9 seldepth 10 multipv 1 score cp -29 nodes 2414 nps 301750 hashfull 0 tbhits 0 time 8 pv g8f6 d2d4 e5d4 e4e5 f6e4 d1d4 d7d5 e5d6 e4d6 info depth 10 seldepth 12 multipv 1 score cp -26 nodes 5045 nps 296764 hashfull 1 tbhits 0 time 17 pv g8f6 d2d4 e5d4 e4e5 f6e4 d1d4 d7d5 e5d6 e4d6 c1g5 b8c6 info depth 11 seldepth 12 multipv 1 score cp -26 nodes 8612 nps 277806 hashfull 2 tbhits 0 time 31 pv g8f6 d2d4 e5d4 e4e5 f6e4 d1d4 d7d5 e5d6 e4d6 d4c3 d8e7 f1e2 info depth 12 seldepth 17 multipv 1 score cp -34 nodes 18839 nps 303854 hashfull 6 tbhits 0 time 62 pv g8f6 d2d4 f6e4 f1d3 d7d5 f3e5 f8d6 b1d2 e4d2 c1d2 b8c6 d1h5 g7g6 e5c6 b7c6 h5e2 d8e7 info depth 13 seldepth 19 multipv 1 score cp -36 nodes 59966 nps 310704 hashfull 25 tbhits 0 time 193 pv b8c6 f1c4 g8f6 d2d3 f8e7 e1g1 e8g8 f1e1 d7d6 a2a4 c8e6 ``` -------------------------------- ### Set Up Chess Position Source: https://github.com/official-stockfish/stockfish/wiki/UCI-&-Commands Use 'position' to set up a chess board. 'startpos' initializes from the standard starting position. 'fen' allows setting up from a Forsyth-Edwards Notation string. 'moves' specifies a sequence of moves to play from the current position. ```uci > position startpos ``` ```uci > position startpos moves e2e4 e7e5 g1f3 b8c6 f1b5 ``` ```uci > position fen 8/1B6/8/5p2/8/8/5Qrq/1K1R2bk w - - 0 1 ``` ```uci > position fen 8/3P3k/n2K3p/2p3n1/1b4N1/2p1p1P1/8/3B4 w - - 0 1 moves g4f6 h7g7 f6h5 g7g6 d1c2 ``` -------------------------------- ### Build Stockfish with Custom MinGW-w64 on Windows Source: https://github.com/official-stockfish/stockfish/wiki/Compiling-from-source This bash script downloads, configures, and builds Stockfish using a custom MinGW-w64 toolchain. It detects CPU architecture for optimized builds and handles path setup. ```bash #!/bin/bash # makefish.sh # set PATH to use GCC 8.1.0 if [ -d "/mingw64-810/bin" ] ; then PATH="/mingw64-810/bin:${PATH}" else echo "folder error" exit 1 fi branch='master' github_user='official-stockfish' # download the Stockfish source code wget -O ${branch}.zip https://github.com/${github_user}/Stockfish/archive/refs/heads/${branch}.zip unzip ${branch}.zip cd Stockfish-${branch}/src # find the CPU architecture # CPU without popcnt and bmi2 instructions (e.g. older than Intel Sandy Bridge) arch_cpu=x86-64 # CPU with bmi2 instruction (e.g. Intel Haswell or newer) if [ "$(g++ -Q -march=native --help=target | grep mbmi2 | grep enabled)" ] ; then # CPU AMD zen if [ "$(g++ -Q -march=native --help=target | grep march | grep 'znver[12]')" ] ; then arch_cpu=x86-64-avx2 else arch_cpu=x86-64-bmi2 fi # CPU with popcnt instruction (e.g. Intel Sandy Bridge) elif [ "$(g++ -Q -march=native --help=target | grep mpopcnt | grep enabled)" ] ; then arch_cpu=x86-64-sse41-popcnt fi # build the Stockfish executable make profile-build ARCH=${arch_cpu} COMP=mingw make strip mv stockfish.exe ../../stockfish_${arch_cpu}.exe make clean cd ``` -------------------------------- ### Display Help Information (`help`) Source: https://github.com/official-stockfish/stockfish/wiki/UCI-&-Commands The `help` command provides version information, a description of Stockfish as a UCI chess engine, and a link to its GitHub repository for more details. ```text help ``` -------------------------------- ### Install Xcode Command Line Tools on macOS Source: https://github.com/official-stockfish/stockfish/wiki/Developers Installs the necessary Xcode command line tools on macOS. This command is sufficient for development without installing the full Xcode IDE. ```bash sudo xcode-select --install ``` -------------------------------- ### Linux Stockfish Compilation Steps Source: https://github.com/official-stockfish/stockfish/wiki/Compiling-from-source Navigate to the src directory and run 'make help' to view available options. Then, compile Stockfish using 'make -j profile-build'. ```bash cd src make help make -j profile-build ``` -------------------------------- ### Install clang-format on macOS Source: https://github.com/official-stockfish/stockfish/wiki/Developers Installs clang-format version 20 on macOS using Homebrew. This tool is used for code formatting. ```bash brew install clang-format@20 ``` -------------------------------- ### Cross-Compile Stockfish with Zig on Ubuntu Source: https://github.com/official-stockfish/stockfish/wiki/Compiling-from-source This script demonstrates how to set up a build environment on Ubuntu and cross-compile Stockfish for ARMv8 and ARMv7 architectures targeting Linux or Android using Zig and QEMU for testing. ```bash # Use a clean Ubuntu to cross compile # a static build for armv8 and armv7 on Linux/Android # one time configuration sudo apt update && sudo apt install -y make git sudo snap install zig --classic --edge sudo apt install -y qemu-user # armv8 static build with musl libc git clone https://github.com/official-stockfish/Stockfish.git cd Stockfish/src make -j build ARCH=armv8 COMP=clang CXX="zig c++ -target aarch64-linux-musl" # test: qemu's magic at work qemu-aarch64 stockfish compiler qemu-aarch64 stockfish bench # armv7 static build with musl libc make clean make -j build ARCH=armv7 COMP=clang CXX="zig c++ -target arm-linux-musleabihf" # test: qemu's magic at work qemu-arm stockfish compiler qemu-arm stockfish bench ``` -------------------------------- ### Synchronize with Engine Source: https://github.com/official-stockfish/stockfish/wiki/UCI-&-Commands Use 'isready' to ensure the engine has completed its initialization or any lengthy operations. The engine responds with 'readyok' when it is ready. This is crucial for synchronization after commands like 'ucinewgame' or when loading resources. ```uci > isready readyok ``` -------------------------------- ### Stockfish 'go' with MultiPV enabled Source: https://github.com/official-stockfish/stockfish/wiki/UCI-&-Commands Demonstrates using the 'go' command with MultiPV set to 2 to find multiple principal variations. This is useful for analyzing complex positions. ```uci > setoption name MultiPV value 2 > position startpos > go depth 5 info depth 1 seldepth 1 multipv 1 score cp 18 nodes 39 nps 19500 hashfull 0 tbhits 0 time 2 pv e2e4 info depth 1 seldepth 1 multipv 2 score cp 12 nodes 39 nps 19500 hashfull 0 tbhits 0 time 2 pv g1f3 info depth 2 seldepth 2 multipv 1 score cp 43 nodes 113 nps 56500 hashfull 0 tbhits 0 time 2 pv g1f3 info depth 2 seldepth 2 multipv 2 score cp 18 nodes 113 nps 56500 hashfull 0 tbhits 0 time 2 pv e2e4 info depth 3 seldepth 3 multipv 1 score cp 75 nodes 169 nps 56333 hashfull 0 tbhits 0 time 3 pv d2d4 c7c6 b1d2 info depth 3 seldepth 2 multipv 2 score cp 43 nodes 169 nps 56333 hashfull 0 tbhits 0 time 3 pv g1f3 info depth 4 seldepth 4 multipv 1 score cp 75 nodes 326 nps 108666 hashfull 0 tbhits 0 time 3 pv d2d4 c7c6 b1d2 info depth 4 seldepth 3 multipv 2 score cp 47 nodes 326 nps 108666 hashfull 0 tbhits 0 time 3 pv b1c3 e7e5 e2e4 c7c6 info depth 5 seldepth 4 multipv 1 score cp 30 nodes 933 nps 233250 hashfull 0 tbhits 0 time 4 pv e2e4 g8f6 info depth 5 seldepth 5 multipv 2 score cp 12 nodes 933 nps 233250 hashfull 0 tbhits 0 time 4 pv b1c3 e7e5 e2e4 c7c6 bestmove e2e4 ponder g8f6 ``` -------------------------------- ### Update MSYS2 Core Packages Source: https://github.com/official-stockfish/stockfish/wiki/Compiling-from-source After installing MSYS2 with the official installer, update the core packages using pacman. Close the shell when finished. ```bash pacman -Syuu ``` -------------------------------- ### Install Xcode Command-Line Tools on macOS Source: https://github.com/official-stockfish/stockfish/wiki/Compiling-from-source Installs the necessary command-line developer tools for Xcode on macOS. This is a prerequisite for compiling software using Clang or GCC. ```bash sudo xcode-select --install ``` -------------------------------- ### Install GCC 10 via MacPorts on macOS Source: https://github.com/official-stockfish/stockfish/wiki/Compiling-from-source Installs the GCC 10 compiler package using the MacPorts package manager. This is required for older macOS versions that do not support C++17 with the default Clang. ```bash sudo port install gcc10 ``` -------------------------------- ### Start New Game Source: https://github.com/official-stockfish/stockfish/wiki/UCI-&-Commands Send 'ucinewgame' before starting a new game to clear engine's internal state, such as hash tables and search history. Always follow with 'isready' to ensure the engine has finished its internal reset. ```uci > ucinewgame > isready ``` ```uci > ucinewgame > isready ``` -------------------------------- ### Download Neural Network Source: https://github.com/official-stockfish/stockfish/wiki/Compiling-from-source Prepares the neural network for embedding into the Stockfish binary. ```bash make net ``` -------------------------------- ### Cross-Compile Stockfish for Windows on Ubuntu Source: https://github.com/official-stockfish/stockfish/wiki/Compiling-from-source A bash script to set up the environment, download Stockfish, and cross-compile Windows executables on Ubuntu, including PGO builds. ```bash #!/bin/bash # functions to build Stockfish _build_sf () { make build ARCH=x86-64$1 COMP=mingw -j make strip COMP=mingw mv stockfish.exe ../../stockfish-x64${1}.exe make clean COMP=mingw } _build_sf_pgo () { make profile-build ARCH=x86-64$1 COMP=mingw PGOBENCH="wine ./stockfish.exe bench" -j make strip COMP=mingw mv stockfish.exe ../../stockfish-x64${1}-pgo.exe make clean COMP=mingw } # full-upgrade and install required packages sudo apt update && sudo apt full-upgrade -y && sudo apt autoremove -y && sudo apt clean sudo apt install -y \ make \ mingw-w64 \ git \ wine64 \ binutils # clone Stockfish source code git clone --single-branch --branch master https://github.com/official-stockfish/Stockfish.git cd Stockfish/src # build Stockfish executables # to speedup the building process you can keep only the section fitting your CPU architecture # build the binary for CPUs without popcnt and bmi2 instructions (e.g. older than Intel Sandy Bridge) _build_sf_pgo # build the binary for CPU with popcnt instruction (e.g. Intel Sandy Bridge) if [ "$(x86_64-w64-mingw32-c++-posix -Q -march=native --help=target | grep mpopcnt | grep enabled)" ] ; then _build_sf_pgo -sse41-popcnt else _build_sf -sse41-popcnt fi # build the binary for CPU with bmi2 instruction (e.g. Intel Haswell or newer) if [ "$(x86_64-w64-mingw32-c++-posix -Q -march=native --help=target | grep mbmi2 | grep enabled)" ] ; then _build_sf_pgo -bmi2 else _build_sf -bmi2 fi ``` -------------------------------- ### Compile Stockfish on Android with Termux Source: https://github.com/official-stockfish/stockfish/wiki/Compiling-from-source This command initiates the build process for Stockfish within the Termux environment on Android. It assumes Termux is installed and configured. ```bash pkg update && pkg upgrade pkg install make clang git git clone https://github.com/official-stockfish/Stockfish.git cd Stockfish make build ``` -------------------------------- ### Stockfish Compilation with Specific Compiler Versions Source: https://github.com/official-stockfish/stockfish/wiki/Compiling-from-source Build Stockfish using a specific compiler and C++ compiler, for example, GCC and G++ version 14.0. ```bash make -j build COMP=gcc COMPCXX=g++-14.0 ``` -------------------------------- ### Infinite search mode Source: https://github.com/official-stockfish/stockfish/wiki/UCI-&-Commands The `infinite` parameter for the `go` command starts a search that continues indefinitely until a `stop` command is issued. The engine will not exit the search on its own. ```uci infinite ``` -------------------------------- ### General Stockfish Compilation Command Source: https://github.com/official-stockfish/stockfish/wiki/Compiling-from-source Use this command to build Stockfish. Specify the target, architecture, and compiler as needed. Run 'make help' for a list of available options. ```bash make target [ARCH=arch] [COMP=compiler] [COMPCXX=cxx] ``` -------------------------------- ### Format Code with clang-format Source: https://github.com/official-stockfish/stockfish/blob/master/CONTRIBUTING.md Format your C++ code changes to adhere to Stockfish's coding style using clang-format. Ensure you have clang-format version 20 installed. ```bash make format ``` -------------------------------- ### Set Engine Option Example Source: https://github.com/official-stockfish/stockfish/wiki/UCI-&-Commands Use `setoption` to change internal engine parameters. For 'button' type options, no value is required. This command is sent when the engine is waiting. ```plaintext > setoption name Threads value 6 ``` ```plaintext > setoption name SyzygyPath value C:\Chess\tb\tb345;C:\Chess\tb\wdl6;C:\Chess\tb\wdl7 ``` ```plaintext > setoption name UCI_ShowWDL value true ``` ```plaintext > setoption name Clear Hash ```