Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hyprfen-cpp

hyprfen-cpp is a C++ implementation of the Python package hyprfen. From its readme:

hyprfen stores 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.

Build

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
ctest --test-dir build --output-on-failure

Public API

#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);

Consumption

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)

About

Fast, compact, reversible binary encoding for standard chess FENs in C++.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages