mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 11:42:07 +00:00
Weight puzzle selection and stop repeats inside a session (#183)
Selection took a hard rating band (medium = user rating ± 100), removed everything attempted in the last 30 days, and drew uniformly from what was left. Because the bulk importer gives every endgame in a batch the same rating, the band held either the whole library or — once a user's rating drifted past it — only the endgames that user had already played. With `fresh` empty, the fallback re-drew from the same band ignoring recency, so recently played puzzles came straight back. An empty band used a deterministic nearest-match, alternating between the same two puzzles. Difficulty is now a bias rather than a filter: candidates are weighted by `exp(-|rating - target| / spread)` and drawn with an exponential race, so the whole library stays reachable and a thin region around the user's rating can never empty the pool. `easy` and `hard` keep one-sided guards so the labels stay honest. When every candidate is excluded, selection serves the least recently attempted endgame instead of a random recent one. Sessions now carry the ids they have served, which fixes the observed in-session repeat (only the current puzzle used to be excluded), and guest training gets the same treatment. The 30-day window is configurable as the repeat window and is now named in GLOSSARY.md, distinct from the rating window and from the tablebase cooldown. Difficulty copy is qualitative, since the band numbers no longer describe how selection works.
This commit is contained in:
@@ -170,6 +170,18 @@ defmodule ChesstrainerWeb.EndgameLive.TrainTest do
|
||||
assert Enum.any?(endgames, &(&1.id == second.id))
|
||||
end
|
||||
|
||||
test "does not serve the same puzzle twice in a session", %{conn: conn} do
|
||||
{view, [only]} = start_medium_session(conn, 1)
|
||||
|
||||
solve_current(view)
|
||||
view |> element("#next-puzzle-button") |> render_click()
|
||||
|
||||
assigns = :sys.get_state(view.pid).socket.assigns
|
||||
assert has_element?(view, "#pool-exhausted")
|
||||
assert assigns.endgame.id == only.id
|
||||
assert assigns.session.served_ids == [only.id]
|
||||
end
|
||||
|
||||
test "keeps next puzzle available while reviewing", %{conn: conn} do
|
||||
{view, endgames} = start_medium_session(conn, 2)
|
||||
first = :sys.get_state(view.pid).socket.assigns.endgame
|
||||
|
||||
Reference in New Issue
Block a user