Files
chess-endgame-trainer/native/fathom_nif/csrc/wrapper.c
T
owenrees e60c161a3a Add a Fathom Syzygy probe NIF (#29)
Vendor the MIT-licensed Fathom C source and compile it into a Rustler NIF (native/fathom_nif). The NIF exposes init/1 (point Fathom at a tablebase directory) and probe/1 (raw WDL/DTZ/move results for a FEN); probes are serialised because Fathom's root probe is not thread safe, and run as dirty NIFs.

Add KRvK/KQvK 3-piece WDL+DTZ fixtures and an integration test proving a known KRvK probe returns Win, DTZ 23 and 15 moves.
2026-11-03 13:41:54 +01:00

23 lines
795 B
C

/*
* Thin C shim over Fathom's inline API so Rust can call stable symbols.
*/
#include <stdbool.h>
#include <stdint.h>
#include "tbprobe.h"
bool fathom_init(const char *path) { return tb_init(path); }
void fathom_free(void) { tb_free(); }
unsigned fathom_largest(void) { return TB_LARGEST; }
unsigned fathom_probe_root(uint64_t white, uint64_t black, uint64_t kings,
uint64_t queens, uint64_t rooks, uint64_t bishops,
uint64_t knights, uint64_t pawns, unsigned rule50,
unsigned castling, unsigned ep, bool turn,
unsigned *results) {
return tb_probe_root(white, black, kings, queens, rooks, bishops, knights,
pawns, rule50, castling, ep, turn, results);
}