mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 03:32:06 +00:00
Add a Backend behaviour, a Lichess implementation, and a Router that picks a backend by piece count: five or fewer to the local slot, six or seven to the remote slot, and eight or more short-circuited as not covered with no network call. Both slots point at Lichess for now; the local Syzygy backend replaces the local slot when it lands. Map :not_covered to the existing 'not covered by the tablebase' message.
18 lines
484 B
Elixir
18 lines
484 B
Elixir
defmodule Chesstrainer.Endgames.Tablebase.Backend do
|
|
@moduledoc """
|
|
A backend answers a tablebase probe for one position.
|
|
|
|
The router chooses a backend by piece count, so the play flow never depends on
|
|
which one answered. Every backend returns the same shape.
|
|
"""
|
|
|
|
alias Chesstrainer.Endgames.Tablebase
|
|
|
|
@type result ::
|
|
{:ok, Tablebase.t()}
|
|
| {:cooldown, non_neg_integer()}
|
|
| {:error, term()}
|
|
|
|
@callback probe(String.t()) :: result()
|
|
end
|