#11: endgames can carry multiple themes (endgame tags) chosen from a searchable, autocompleting picker with inline creation. Tags are staged in the form and saved atomically, so they work on both New and Edit. Tag names are trimmed and case-insensitively unique per category. Admin Show and Index display themes, and the seeds ship a starter vocabulary. The theme picker has its own form: LiveView requires phx-change inputs to live inside a form, and a separate theme form keeps Enter from submitting the endgame form.
2.0 KiB
Chesstrainer
An endgame trainer: the user plays a stored endgame position against tablebase-optimal defence and is graded on every move.
Core model
Endgame: A stored chess position (FEN) plus metadata — side to move, result, rating, tags — that can be played as a puzzle. Avoid: Position, puzzle
Puzzle: A playable challenge derived from an endgame: play the winning (or drawing) side correctly against tablebase-optimal defence. Avoid: Endgame (the stored record), exercise
Attempt: One playthrough of a puzzle by a user, ending solved or failed. Avoid: Run, session, game
Theme: A label describing an endgame's technique or goal, such as "mate in 2", "Lucena" or "opposition"; an endgame can carry several. Avoid: Tag, label, category
Play
Winning side: The side that can force a win from the position; the side the user plays in win-type endgames.
Drawing side: In draw endgames, the side that must hold the draw; the side the user plays. Avoid: Defender
Optimal move: The tablebase's best move for the side to move (sharpest win / hardest defence).
Winning move: A move that keeps the win (the opponent is still lost). Passes. Avoid: Good move, accurate move
Losing move: A move that throws away the result (the position becomes drawn or lost). Fails the puzzle. Avoid: Blunder, mistake
Conversion: The decisive zeroing move — a promotion — that ends a conversion-type puzzle.
Cutoff: The terminal condition short of mate at which a puzzle counts as solved: promotion (still winning) for conversion puzzles, mate otherwise.
Infrastructure
Tablebase: A database of precomputed optimal outcomes for every position with at most seven pieces, queried via the lichess API and cached.
Cooldown: Rate-limit state entered after a 429 from the lichess tablebase API, during which the trainer blocks play.
Cache sweep: The periodic halving of LFU cache frequencies (weekly) that lets rarely-used entries age out.