Add local tablebase path config, fetch and check tasks (#31)

Read the local Syzygy directory from TABLEBASE_PATH so a dev machine and a VPS can point at their own copies. Add mix tablebase.fetch (downloads the 3/4/5 WDL+DTZ set, resumable) and mix tablebase.check (verifies it loads), plus a boot log reporting whether local tablebases are ready and the largest piece count.

Covers the codeable part of #31; installing on the VPS and setting TABLEBASE_PATH there remains a manual step.
This commit is contained in:
2026-11-03 14:26:30 +01:00
parent cb35351f8c
commit f37242ed29
7 changed files with 230 additions and 10 deletions
@@ -15,13 +15,13 @@ defmodule Chesstrainer.Endgames.Tablebase.Backend.Fathom do
alias Chesstrainer.Endgames.Tablebase
alias Chesstrainer.Endgames.Tablebase.Backend.Lichess
alias Chesstrainer.Endgames.Tablebase.Fathom, as: Nif
alias Chesstrainer.Endgames.Tablebase.Local
alias Chesstrainer.Endgames.Tablebase.Move
alias Chesstrainer.Endgames.Tablebase.San
@impl true
def probe(fen) do
with {:ok, path} <- tablebase_path(),
{:ok, _largest} <- Nif.init(path),
with {:ok, _largest} <- Local.check(),
{:ok, {root, moves}} <- Nif.probe(fen) do
case root do
:failed -> fallback(fen)
@@ -32,13 +32,6 @@ defmodule Chesstrainer.Endgames.Tablebase.Backend.Fathom do
end
end
defp tablebase_path do
case Application.get_env(:chesstrainer, :tablebase_path) do
path when is_binary(path) and path != "" -> {:ok, path}
_ -> :error
end
end
defp fallback(fen) do
(Application.get_env(:chesstrainer, :tablebase_fallback) || Lichess).probe(fen)
end