mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 11:42:07 +00:00
Derive only-move, underpromotion and 50-move motif themes (#195)
Motifs describe the kind of problem, independent of the material family. One local tablebase probe returns the root WDL, the DTZ and every legal move with its own WDL, so each motif is proved without a search or a remote lookup. - only move: more than one legal move and exactly one preserves the 50-move-aware result, for wins and draws. - underpromotion: a preserving underpromotion exists while no preserving queen promotion does. - 50-move draw: cursed/blessed WDL, or a win whose DTZ exceeds the remaining halfmove budget. Motif links are recorded as derived and refreshed as a whole, scoped to the motif themes, so material, curated and community links survive. Loss endgames are skipped because only-move is undefined there. Stalemate is deferred: a stored endgame cannot itself be terminal, so it can only describe a line and needs a definition before it becomes a predicate. Release helpers run the derivation without starting the web application, so `bin/chesstrainer eval` works on the server. Closes #188
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
defmodule Mix.Tasks.Themes.DeriveMotifs do
|
||||
use Mix.Task
|
||||
|
||||
@shortdoc "Tags every endgame with its tablebase-proved motifs"
|
||||
|
||||
@moduledoc """
|
||||
Derives only-move, underpromotion and 50-move-draw motifs from the local
|
||||
Syzygy tablebase.
|
||||
|
||||
mix themes.derive_motifs
|
||||
|
||||
The pass never calls the remote tablebase. Positions the local files cannot
|
||||
answer are skipped and reported. Re-running is idempotent: only links to the
|
||||
motif themes are replaced, so material, curated and community links survive.
|
||||
"""
|
||||
|
||||
@impl Mix.Task
|
||||
def run(_args) do
|
||||
Mix.Task.run("app.start")
|
||||
|
||||
%{links: links, skipped: skipped, by_motif: by_motif, themes: themes} =
|
||||
Chesstrainer.Endgames.MotifThemes.derive()
|
||||
|
||||
Mix.shell().info(
|
||||
"Motif themes: #{themes} themes, #{links} link(s) written, #{skipped} endgame(s) skipped."
|
||||
)
|
||||
|
||||
for {motif, count} <- Enum.sort(by_motif) do
|
||||
Mix.shell().info(" #{motif}: #{count}")
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user