mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 03:32:06 +00:00
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.
38 lines
1.0 KiB
Elixir
38 lines
1.0 KiB
Elixir
defmodule Mix.Tasks.Tablebase.Check do
|
|
use Mix.Task
|
|
|
|
@shortdoc "Verify the local Syzygy tablebases"
|
|
|
|
@moduledoc """
|
|
Verifies that the configured local Syzygy tablebases load.
|
|
|
|
TABLEBASE_PATH=/data/syzygy/3-4-5 mix tablebase.check
|
|
mix tablebase.check --path /data/syzygy/3-4-5
|
|
|
|
Exits non-zero when the path is unset, empty, or Fathom fails to initialise.
|
|
"""
|
|
@impl Mix.Task
|
|
def run(args) do
|
|
{opts, _rest, _invalid} = OptionParser.parse(args, strict: [path: :string])
|
|
|
|
path =
|
|
opts[:path] || System.get_env("TABLEBASE_PATH") ||
|
|
Chesstrainer.Endgames.Tablebase.Local.path()
|
|
|
|
if is_nil(path) do
|
|
Mix.raise("set TABLEBASE_PATH or pass --path")
|
|
end
|
|
|
|
case Chesstrainer.Endgames.Tablebase.Fathom.init(Path.expand(path)) do
|
|
{:ok, 0} ->
|
|
Mix.raise("no tablebase files found in #{path}")
|
|
|
|
{:ok, largest} ->
|
|
Mix.shell().info("local tablebases at #{path}: largest=#{largest}")
|
|
|
|
{:error, reason} ->
|
|
Mix.raise("failed to initialise Fathom: #{inspect(reason)}")
|
|
end
|
|
end
|
|
end
|