{"id":23120167,"url":"https://github.com/disservin/chess-library","last_synced_at":"2025-04-06T00:09:42.381Z","repository":{"id":45858390,"uuid":"482089592","full_name":"Disservin/chess-library","owner":"Disservin","description":"C++ chess library","archived":false,"fork":false,"pushed_at":"2024-10-24T17:51:29.000Z","size":3226,"stargazers_count":79,"open_issues_count":3,"forks_count":22,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-29T16:40:49.541Z","etag":null,"topics":["chess","cpp","library","single-header-library"],"latest_commit_sha":null,"homepage":"https://disservin.github.io/chess-library/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"OliveriQ/chess-library","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Disservin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-15T21:32:32.000Z","updated_at":"2024-10-28T10:14:54.000Z","dependencies_parsed_at":"2023-10-28T12:21:13.900Z","dependency_job_id":"8f275f2e-b26a-499f-b259-e1ea70a11c68","html_url":"https://github.com/Disservin/chess-library","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Disservin%2Fchess-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Disservin%2Fchess-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Disservin%2Fchess-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Disservin%2Fchess-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Disservin","download_url":"https://codeload.github.com/Disservin/chess-library/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247415967,"owners_count":20935387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chess","cpp","library","single-header-library"],"created_at":"2024-12-17T06:06:16.123Z","updated_at":"2025-04-06T00:09:42.365Z","avatar_url":"https://github.com/Disservin.png","language":"C++","readme":"# An extensive SHL Chess Library for C++\n\n[![Chess Library](https://github.com/Disservin/chess-library/actions/workflows/chess-library.yml/badge.svg)](https://github.com/Disservin/chess-library/actions/workflows/chess-library.yml)\n\n## [Documentation](https://disservin.github.io/chess-library)\n\n**chess-library** is a multi-purpose library for chess in C++17.\n\nIt can be used for any type of chess program, be it a chess engine, a chess GUI, or a chess data anaylsis tool.\n\n### Why this library?\n\n- **Fast**: This library is fast enough for pretty much any purpose in C++ and it is faster than most other chess libraries in C++.\n- **Documentation**: Easy to browse **documentation** at \u003chttps://disservin.github.io/chess-library\u003e\n- **Robust**: Unit Tests \u0026 it has been tested on millions of chess positions, while developing the C++ part of [Stockfish's Winrate Model](https://github.com/official-stockfish/WDL_model).\n- **PGN Support**: Parse basic PGN files.\n- **Namespace**: Everything is in the `chess::` namespace, so it won't pollute your namespace.\n- **Compact Board Representation in 24bytes**: The board state can be compressed into 24 bytes, using `PackedBoard` and `Board::Compact::encode`/`Board::Compact::decode`.\n\n\u003e [!NOTE]\n\u003e Users are advised to update to the latest version of the library, to fix possible SAN/LAN issues.\n\n### Usage\n\nThis is a single header library.\n\nYou only need to include `chess.hpp` header!\nAftewards you can access the chess logic over the `chess::` namespace.\n\n### Exceptions\n\nThis library might throw exceptions in some cases, for example when the input is invalid or things are not as expected.\nTo disable exceptions, define `CHESS_NO_EXCEPTIONS` before including the header.\n\n### Benchmarks\n\nTested on Ryzen 9 5950X.\n\n#### PGN Parser\n\nRan with `lichess_db_standard_rated_2017-03.pgn` on a Samsung 980 SSD.\n\n| Benchmark | Time    | Throughput    |\n| :---:   | :---: | :---: |\n| ./build/example | 28.927s   | 413.281 MB/s   |\n\n#### Perft\n\nWith movelist preallocation:\n\n| Category | Depth | Time (ms)  | NPS | FEN |\n|----------|-------|-----------|-----|-----|\n| **Standard Chess** | 7 | 8988 | 355534749 | `rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1` |\n| **Standard Chess** | 5 | 430 | 449398352 | `r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1` |\n| **Standard Chess** | 7 | 661 | 269839367 | `8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - - 0 1` |\n| **Standard Chess** | 6 | 1683 | 419266646 | `r3k2r/Pppp1ppp/1b3nbN/nP6/BBP1P3/q4N2/Pp1P2PP/R2Q1RK1 w kq - 0 1` |\n| **Standard Chess** | 5 | 210 | 426261582 | `rnbq1k1r/pp1Pbppp/2p5/8/2B5/8/PPP1NnPP/RNBQK2R w KQ - 1 8` |\n| **Standard Chess** | 5 | 377 | 434062304 | `r4rk1/1pp1qppp/p1np1n2/2b1p1B1/2B1P1b1/P1NP1N2/1PP1QPPP/R4RK1 w - - 0 1` |\n| **Chess960** | 6 | 358 | 331644356 | `rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w HAha - 0 1` |\n| **Chess960** | 6 | 710 | 269707784 | `1rqbkrbn/1ppppp1p/1n6/p1N3p1/8/2P4P/PP1PPPP1/1RQBKRBN w FBfb - 0 9`|\n| **Chess960** | 6 | 2434 | 379540629 | `rbbqn1kr/pp2p1pp/6n1/2pp1p2/2P4P/P7/BP1PPPP1/R1BQNNKR w HAha - 0 9` |\n| **Chess960** | 6 | 927 | 332492639 | `rqbbknr1/1ppp2pp/p5n1/4pp2/P7/1PP5/1Q1PPPPP/R1BBKNRN w GAga - 0 9` |\n| **Chess960** | 6 | 2165 | 402734901 | `4rrb1/1kp3b1/1p1p4/pP1Pn2p/5p2/1PR2P2/2P1NB1P/2KR1B2 w D - 0 21` |\n| **Chess960** | 6 | 6382 | 419555508 | `1rkr3b/1ppn3p/3pB1n1/6q1/R2P4/4N1P1/1P5P/2KRQ1B1 b Ddb - 0 14` |\n\n### Repositories using this library\n\n- Stockfish Winrate Model\n  \u003chttps://github.com/official-stockfish/WDL_model\u003e\n- CLI Tool for running chess engine matches\n  \u003chttps://github.com/Disservin/fast-chess\u003e\n- GUI-based Chess Player as well as a Chess Engine\n  \u003chttps://github.com/Orbital-Web/Raphael\u003e\n- UCI Chess Engine (\\~3.3k elo)\n  \u003chttps://github.com/rafid-dev/rice\u003e (old version)\n- Texel tuner for HCE engines\n  \u003chttps://github.com/GediminasMasaitis/texel-tuner\u003e\n\n### Development Setup\n\nThis project is using the meson build system. \u003chttps://mesonbuild.com/\u003e\n\n#### Setup\n\n```bash\nmeson setup build\n```\n\n#### Compilation\n\n```bash\nmeson compile -C build\n```\n\n#### Tests\n\n```bash\nmeson test -C build\n```\n\n#### Example\n\nDownload the [Lichess March 2017 database](https://database.lichess.org/standard/lichess_db_standard_rated_2017-03.pgn.zst).\nYou can decompress this with the following command: `unzstd -d lichess_db_standard_rated_2017-03.pgn.zst`\n\n```bash\ncd example\nmeson setup build\nmeson compile -C build\n\n./build/example ../lichess_db_standard_rated_2017-03.pgn\n```\n\n#### Comparison to other libraries\n\n[Benchmark implementation](./comparison/comparison.md) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdisservin%2Fchess-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdisservin%2Fchess-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdisservin%2Fchess-library/lists"}