mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 11:42:07 +00:00
Simplify the Tablebase struct to the fields the grader reads (#26)
Drop dtm/dtc from Tablebase and Tablebase.Move; the local Syzygy backend cannot produce them and nothing reads them. The Lichess parser now maps only category, checkmate and moves (with per-move category, dtz, san and uci), and the struct-shape tests follow.
This commit is contained in:
@@ -3,9 +3,9 @@ defmodule Chesstrainer.Endgames.Tablebase do
|
||||
All endgame tablebase related functions.
|
||||
|
||||
The cached value carries only what the trainer reads: `category`,
|
||||
`checkmate`, and `moves` drive play, while `dtm`/`dtc` are small distance
|
||||
hedges. Cursed-win/blessed-loss are normalised to `:draw` at parse time, so
|
||||
the raw `dtw`/`dtz`/`insufficient_material` fields are not kept here.
|
||||
`checkmate`, and `moves`. Cursed-win/blessed-loss are normalised to `:draw` at
|
||||
parse time, and distance fields (`dtm`/`dtc`/`dtw`) are not kept because the
|
||||
local Syzygy backend cannot produce them.
|
||||
"""
|
||||
|
||||
alias Chesstrainer.Endgames.Tablebase
|
||||
@@ -15,15 +15,11 @@ defmodule Chesstrainer.Endgames.Tablebase do
|
||||
@type t :: %__MODULE__{
|
||||
category: result,
|
||||
checkmate: boolean(),
|
||||
dtc: integer() | nil,
|
||||
dtm: integer() | nil,
|
||||
moves: [Tablebase.Move.t()]
|
||||
}
|
||||
|
||||
defstruct category: nil,
|
||||
checkmate: false,
|
||||
dtc: nil,
|
||||
dtm: nil,
|
||||
moves: nil
|
||||
|
||||
@doc """
|
||||
|
||||
@@ -3,25 +3,21 @@ defmodule Chesstrainer.Endgames.Tablebase.Move do
|
||||
Moves struct for the tablebase
|
||||
|
||||
Carries only the fields the trainer reads: `category` and `dtz` for grading,
|
||||
`san`/`uci` for display and matching, and `dtm`/`dtc` as small distance
|
||||
hedges. Terminal detection is structural (the next position's `checkmate` or
|
||||
its empty `moves`), so no per-move terminal flags are kept.
|
||||
and `san`/`uci` for display and matching. Terminal detection is structural
|
||||
(the next position's `checkmate` or its empty `moves`), so no per-move
|
||||
terminal flags are kept.
|
||||
"""
|
||||
|
||||
@type result :: :win | :draw | :loss | :unknown
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
category: result,
|
||||
dtc: integer() | nil,
|
||||
dtm: integer() | nil,
|
||||
dtz: integer() | nil,
|
||||
san: String.t() | nil,
|
||||
uci: String.t() | nil
|
||||
}
|
||||
|
||||
defstruct category: nil,
|
||||
dtc: nil,
|
||||
dtm: nil,
|
||||
dtz: nil,
|
||||
san: nil,
|
||||
uci: nil
|
||||
|
||||
@@ -43,8 +43,6 @@ defmodule Chesstrainer.Endgames.Tablebase.Parser do
|
||||
%Tablebase{
|
||||
category: Tablebase.normalize_category(map["category"]),
|
||||
checkmate: map["checkmate"],
|
||||
dtc: map["dtc"],
|
||||
dtm: map["dtm"],
|
||||
moves: Enum.map(map["moves"], &moves_from_map/1)
|
||||
}}
|
||||
end
|
||||
@@ -52,8 +50,6 @@ defmodule Chesstrainer.Endgames.Tablebase.Parser do
|
||||
defp moves_from_map(map) do
|
||||
%Tablebase.Move{
|
||||
category: Tablebase.normalize_category(map["category"]),
|
||||
dtc: map["dtc"],
|
||||
dtm: map["dtm"],
|
||||
dtz: map["dtz"],
|
||||
san: map["san"],
|
||||
uci: map["uci"]
|
||||
|
||||
Reference in New Issue
Block a user