### Installing zlib using vcpkg on Windows Source: https://github.com/lightvector/katago/blob/master/Compiling.md This snippet shows how to install the zlib library on Windows using the vcpkg package manager. It outlines the steps to clone vcpkg, bootstrap it, and install zlib for the x64-windows triplet. ```powershell git clone https://github.com/microsoft/vcpkg.git cd .\vcpkg\ .\bootstrap-vcpkg.bat .\vcpkg.exe install zlib:x64-windows ``` -------------------------------- ### Configure CMake for KataGo Compilation Source: https://github.com/lightvector/katago/blob/master/Compiling.md These are example CMake configuration commands. Choose the appropriate backend (OPENCL, CUDA, TENSORRT, EIGEN) based on your hardware and desired performance. Ensure all required dependencies for the chosen backend are installed. ```bash cd KataGo/cpp cmake . -DUSE_BACKEND=OPENCL ``` ```bash cmake . -DUSE_BACKEND=CUDA ``` ```bash cmake . -DUSE_BACKEND=TENSORRT ``` ```bash cmake . -DUSE_BACKEND=EIGEN ``` -------------------------------- ### Install Libzip Source: https://github.com/lightvector/katago/blob/master/Compiling.md Install the libzip library, a required dependency for the build process. ```bash brew install libzip ``` -------------------------------- ### Install OpenSSL (for Distributed Training) Source: https://github.com/lightvector/katago/blob/master/Compiling.md Install OpenSSL if you plan to compile with support for contributing to public distributed training runs. ```bash brew install openssl ``` -------------------------------- ### Install Protobuf and Abseil Source: https://github.com/lightvector/katago/blob/master/Compiling.md Install protobuf and abseil libraries, which are dependencies for the Metal backend. ```bash brew install protobuf abseil ``` -------------------------------- ### Install Gperftools (Optional) Source: https://github.com/lightvector/katago/blob/master/Compiling.md Install Google perftools for TCMalloc, which can help manage memory fragmentation during self-play training with many threads. ```bash brew install gperftools ``` -------------------------------- ### Installing zlib and libzip dependencies with MSYS2 Source: https://github.com/lightvector/katago/blob/master/Compiling.md This shows how to install zlib and libzip dependencies for MinGW on Windows using the MSYS2 environment and pacman package manager. It also includes installation commands for xz, bzip2, and zstd. ```bash pacman -S mingw-w64-x86_64-libzip pacman -S mingw-w64-x86_64-xz pacman -S mingw-w64-x86_64-bzip2 pacman -S mingw-w64-x86_64-zstd ``` -------------------------------- ### Install CMake and Ninja Source: https://github.com/lightvector/katago/blob/master/Compiling.md Install CMake (version 3.18.2 or higher) and Ninja, which are required for the build process, especially for the Metal backend. ```bash brew install cmake ``` ```bash brew install ninja ``` -------------------------------- ### Start KataGo Selfplay Engine Source: https://github.com/lightvector/katago/blob/master/SelfplayTraining.md Launches the selfplay engine for generating training data. Ensure the output and models directories are on a shared filesystem. If models-dir is empty, it starts with random data generation. ```bash cpp/katago selfplay -output-dir $BASEDIR/selfplay -models-dir $BASEDIR/models -config cpp/configs/training/SELFPLAYCONFIG.cfg >> log.txt 2>&1 & disown ``` -------------------------------- ### Direct Position Setup Source: https://github.com/lightvector/katago/blob/master/docs/GTP_Extensions.md Allows direct specification of an initial board position using a sequence of color-vertex pairs. ```APIDOC ## POST /gtp/set_position ### Description Directly specify an initial board position as a sequence of color-vertex pairs, replacing the current board. This command does not imply any move history and should not be used for handicap games. ### Method POST ### Endpoint /gtp/set_position ### Parameters #### Request Body - **moves** (array of strings) - Required - A sequence of color-vertex pairs (e.g., "B", "Q16", "W", "D4"). An empty array clears the board. ### Request Example ```json { "command": "set_position B Q16 W D4" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates success. #### Response Example ```json { "status": "ok" } ``` ``` -------------------------------- ### Print KataGo Version Source: https://github.com/lightvector/katago/blob/master/README.md Simple command to display the installed version of the KataGo engine. ```bash ./katago version ``` -------------------------------- ### Search Tree Pruning Test Header Source: https://github.com/lightvector/katago/blob/master/cpp/tests/results/runOutputTests.txt Header for a test scenario focusing on pruning the search tree at the root node without symmetries. This setup is used to isolate and test pruning logic. ```text =================================================================== Testing pruning of search tree at root node, no symmetries, with avoid moves =================================================================== ``` -------------------------------- ### Configuring zlib and libzip paths for MinGW with CMake Source: https://github.com/lightvector/katago/blob/master/Compiling.md Example CMake configuration options for zlib and libzip when using MinGW on Windows. These paths should be adjusted based on your MSYS2 installation. ```cmake -DZLIB_INCLUDE_DIR="C:/msys64/mingw64/include" -DZLIB_LIBRARY="C:/msys64/mingw64/lib/libz.a" -DLIBZIP_INCLUDE_DIR_ZIP:PATH="C:/msys64/mingw64/include" -DLIBZIP_INCLUDE_DIR_ZIPCONF:PATH="C:/msys64/mingw64/include" -DLIBZIP_LIBRARY:FILEPATH="C:/msys64/mingw64/lib/libzip.dll.a" ``` -------------------------------- ### Run KataGo with Specific Paths Source: https://github.com/lightvector/katago/blob/master/README.md Example commands demonstrating how to specify different paths for the KataGo executable, model, and configuration file when integrating with a GUI. ```bash path/to/katago.exe gtp -model path/to/.bin.gz ``` ```bash path/to/katago.exe gtp -model path/to/.bin.gz -config path/to/gtp_custom.cfg ``` -------------------------------- ### Initialize Game State Variables Source: https://github.com/lightvector/katago/blob/master/cpp/tests/results/bookhtml/5A/68967FA95AC0019E9A08FF65DEA2C09E262864AB98C28B8614E3DC6ADF8F2299.html Initializes variables for game state, including next player, link information, and the current board configuration. This setup is typical for starting a game analysis. ```javascript const nextPla = 1; const pLink = '../CC/2A4B2282CC19AA3054FB86CA301A87405FD80ACF0E31F0F9989F10B18154627A.html'; const pSym = 2; const board = [1,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,]; const links = {}; const linkSyms = {}; ``` -------------------------------- ### Initialize Game State Variables Source: https://github.com/lightvector/katago/blob/master/cpp/tests/results/bookhtml/AF/02A8F886AF9908D438B02A0E06443CBB0631DB3E8D548DEBA51B3BF5FADEB88E.html Initializes variables for game state, including next player, link path, symbol count, board state, and link data structures. This setup is crucial for starting a game analysis. ```javascript const nextPla = 2; const pLink = '../A0/23A3B394A056CC98CAA720A4EFE26605E43170679500026C119E60ACC0A5E25D.html'; const pSym = 6; const board = [0,0,0,0,0,0,0,0,0,0,1,1,0,0,2,0,]; const links = {}; const linkSyms = {}; ``` -------------------------------- ### Initialize Game State Variables Source: https://github.com/lightvector/katago/blob/master/cpp/tests/results/bookhtml/1C/0DD58B411C0829D8036A6E048FE73BB7A9CC0CF82C071821A9F7D88E9D459E20.html Initializes variables for game state, including next player, link information, symbol mapping, board state, and move data. This setup is crucial for starting a game simulation or analysis. ```javascript const nextPla = 1; const pLink = '../96/0971EF5E9671A796679C44F5D33A7F2091A1B80BE1AC64D34EDF70D6F57F797E.html'; const pSym = 2; const board = [0,2,0,0,0,0,1,0,0,0,0,0,0,0,0,0,]; const links = {}; const linkSyms = {}; const moves = [{'xy':[[3,3],],'p':0.1996,'wl':-0.3875,'ssM':0.92,'wlRad':0.2086,'sRad':1.35,'v':80,'av':80,},{'xy':[[0,1],],'p':0.8662,'wl':-0.0539,'ssM':0.69,'wlRad':0.0284,'sRad':1.89,'v':155,'av':155,},{'xy':[[0,0],],'p':0.3014,'wl':0.1080,'ssM':0.53,'wlRad':0.0013,'sRad':0.42,'v':187,'av':187,},{'xy':[[1,2],],'p':0.9381,'wl':0.5469,'ssM':-0.27,'wlRad':0.0173,'sRad':1.07,'v':93,'av':93,},{'xy':[[0,2],],'p':0.7732,'wl':0.6860,'ssM':-0.06,'wlRad':0.0882,'sRad':0.70,'v':186,'av':186,},{'xy':[[2,3],],'p':0.4513,'wl':0.6108,'ssM':0.91,'wlRad':0.1642,'sRad':0.32,'v':98,'av':98,},{'move':'other','p':0.0084,'wl':-0.0589,'ssM':0.24,'wlRad':0.0209,'sRad':2.02,'v':15,'av':15,},]; ``` -------------------------------- ### Katago Initialization and GPU Info Source: https://github.com/lightvector/katago/blob/master/cpp/tests/results/runSearchTestsV8.txt These lines indicate the initialization process of Katago, including GPU detection and model loading. Useful for diagnosing setup issues. ```text : GPU 0 finishing, processed 55428 rows 55428 batches : Initializing neural net buffer to be size 19 * 19 allowing smaller boards : Cuda backend thread 0: Found GPU NVIDIA RTX A5000 memory 25425608704 compute capability major 8 minor 6 : Cuda backend thread 0: Model version 8 useFP16 = false useNHWC = false : Cuda backend thread 0: Model name: b6c96-s175395328-d26788732 ``` -------------------------------- ### Install Homebrew Source: https://github.com/lightvector/katago/blob/master/Compiling.md Install Homebrew, a package manager for MacOS, if you don't have it already. This is required for installing other dependencies. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` -------------------------------- ### Forwarding/Implementation Header Setup Source: https://github.com/lightvector/katago/blob/master/cpp/external/filesystem-1.5.8/README.md Include this in your main header files to forward filesystem operations. It conditionally includes std::filesystem if available and supported, otherwise falls back to ghc::filesystem. ```cpp #ifdef __APPLE__ #include // for deployment target to support pre-catalina targets without std::fs #endif #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L)) && defined(__has_include) #if __has_include() && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) #define GHC_USE_STD_FS #include namespace fs { using namespace std::filesystem; using ifstream = std::ifstream; using ofstream = std::ofstream; using fstream = std::fstream; } #endif #endif #ifndef GHC_USE_STD_FS #include namespace fs { using namespace ghc::filesystem; using ifstream = ghc::filesystem::ifstream; using ofstream = ghc::filesystem::ofstream; using fstream = ghc::filesystem::fstream; } #endif ``` -------------------------------- ### View Shuffle Help Source: https://github.com/lightvector/katago/blob/master/SelfplayTraining.md Provides information on how the window size is computed and other arguments for the `shuffle.py` script, useful for adjusting training data parameters. ```bash python ./shuffle.py -help ``` -------------------------------- ### Install Compilers Source: https://github.com/lightvector/katago/blob/master/Compiling.md Install AppleClang and Swift compilers using xcode-select. These are essential for compiling C++ code on MacOS. ```bash xcode-select --install ``` -------------------------------- ### View Training Help Source: https://github.com/lightvector/katago/blob/master/SelfplayTraining.md Displays all available command-line arguments for the `train.py` script, allowing for detailed customization of the training process. ```bash python/train.py --help ``` -------------------------------- ### Path Manipulation Example with Root Names Source: https://github.com/lightvector/katago/blob/master/cpp/external/filesystem-1.5.8/README.md Demonstrates handling of posix paths with root names (e.g., '//host/path') and ensures path equality after iterative appending, which matches standard behavior for non-host-leading paths. ```cpp fs::path p1 = "//host/foo/bar/file.txt"; fs::path p2; for (auto p : p1) p2 /= p; ASSERT(p1 == p2); ``` -------------------------------- ### Install GCC for MSYS2 MinGW Source: https://github.com/lightvector/katago/blob/master/Compiling.md Before configuring the project with MSYS2, install the GCC compiler using the pacman package manager. ```bash pacman -S mingw-w64-x86_64-gcc ``` -------------------------------- ### Run KataGo Match Engine Source: https://github.com/lightvector/katago/blob/master/README.md Start a high-performance match engine for playing bots against each other. This command requires a match configuration file and specifies output directories for logs and SGF files. ```bash ./katago match -config .cfg -log-file match.log -sgf-output-dir ```