mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 03:32:06 +00:00
Add FEN.position_key/1 (board, side, castling and en-passant; clocks dropped) and have Tablebase.new/1 key cache reads and writes on it, so transpositions and clock-only differences share an entry. The Lichess category is a position property, so dropping the clocks is safe. Update the cache docs and tests, and give the play fixture's after_first/after_losing distinct positions since they previously differed only by the halfmove clock.
21 lines
542 B
Elixir
21 lines
542 B
Elixir
defmodule Chesstrainer.Endgames.Tablebase.Cache do
|
|
@moduledoc """
|
|
A cache of tablebases keyed by position.
|
|
|
|
The key is a FEN's position fields (see `Chesstrainer.FEN.position_key/1`), so
|
|
transpositions and clock-only differences share an entry.
|
|
"""
|
|
|
|
alias Chesstrainer.Cache
|
|
|
|
@table :tablebase
|
|
|
|
def put(key, tablebase), do: Cache.put(@table, key, tablebase)
|
|
|
|
def get(key), do: Cache.get(@table, key)
|
|
|
|
def delete(key), do: Cache.delete(@table, key)
|
|
def show, do: Cache.show(@table)
|
|
def size, do: Cache.size(@table)
|
|
end
|