hyprfen-cpp is a C++ implementation of the Python package hyprfen. From its readme:
hyprfenstores standard chess FENs in about 64.9% fewer bits than raw FEN strings on a 100,000-position real-game sample from Lichess.It is a compact, reversible binary codec for standard chess positions. You give it a FEN string, it gives you bytes, and
decode_fen()returns the exact original FEN.
This C++ implementation tests for bit-equivalent output to the Python implementation. That means you can encode with hyprfen and decode with hyprfen-cpp or vice versa to get back the same FEN.
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
ctest --test-dir build --output-on-failure#include <hyprfen/hyprfen.hpp>
std::vector<std::uint8_t> blob = hyprfen::encode_fen(
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
);
std::string fen = hyprfen::decode_fen(blob);
hyprfen::EncodeStats stats = hyprfen::encoding_stats(fen);Installed-package flow:
find_package(hyprfen CONFIG REQUIRED)
target_link_libraries(your_target PRIVATE hyprfen::hyprfen)FetchContent flow:
include(FetchContent)
FetchContent_Declare(
hyprfen
GIT_REPOSITORY git@github.com:hyprchs/hyprfen-cpp.git
GIT_TAG main
)
FetchContent_MakeAvailable(hyprfen)
target_link_libraries(your_target PRIVATE hyprfen::hyprfen)