Public repository: timo / schach

Reader

Ein aufgeräumtes Schach-Programm für GNOME

fix(training): grade a hint up to the target square as again

draft training obsolete

fix(training): grade a hint up to the target square as again

Second hint stage shows the whole move, so the answer was not
recalled. Piece-only hint stays hard. Applies to course moves and
puzzle reviews; puzzles count both stages like courses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Changeset38b6077112d0ee4cf848d84bfb45977b184a39f0
Author (claimed)Timo Stolz <timo.stolz@nullachtvierzehn.de>,
Parents6922aeec5d45
Children6767b4e6f8ee
Pushlog
by timo via ssh

modified roadmap/training.md +3 −3

@@ -130,8 +130,7 @@ wird gepflegt (6.3.3, letzter Commit 13.
130130
 | Ereignis | Fehlerpunkte |
131131
 | --- | --- |
132132
 | Hinweis Stufe 1 (Figur) | 0,5 |
133
-| Hinweis Stufe 2 (Zielfeld) | 1 |
134
-| Hinweis Stufe 3, Analysebrett oder „Lösung zeigen“ | sofort Nochmal |
133
+| Hinweis Stufe 2 (Zielfeld, also der ganze Zug), Analysebrett oder „Lösung zeigen“ | sofort Nochmal |
135134
 | falscher Zug, kleiner Verlust | 1 |
136135
 | Patzer (? oder ??), bei B der Partiezug noch einmal | sofort Nochmal |
137136
 | nur bei B: guter, aber nicht der beste Zug | 0 |
@@ -174,7 +173,8 @@ Lichess gemeldet, sonst stimmt die Wertu
174173
   zuerst. Erst wenn keins fällig ist, kommt ein neues von Lichess. Wiederholungen gehen
175174
   ohne Netz; die Kopfzeile sagt „Wiederholung · Rätsel 900“.
176175
 - Bewertung wie überall: fehlerfrei Gut, ein falscher Zug Schwer (für FSRS ein Vergessen),
177
-  mehr oder der Hinweis (er zeigt den Zug) Nochmal. Nochmal kommt heute erneut, aber nicht
176
+  der Hinweis bis zur Figur (Stufe 1) ebenfalls Schwer, mehr oder der Hinweis bis zum
177
+  Zielfeld (Stufe 2) Nochmal. Nochmal kommt heute erneut, aber nicht
178178
   direkt hintereinander. Ein übersprungenes Rätsel bleibt fällig.
179179
 
180180
 ## Kurse: nicht jedes Mal von vorn

modified schach/app.py +2 −0

@@ -1089,6 +1089,8 @@ class Window(OnlineMixin, PuzzleMixin, O
10891089
             self.hint_level = 2
10901090
             if self.mode == "opening":
10911091
                 self.course_stats["reveals"] += 1  # zweite Hälfte des Hinweises: auch das Zielfeld
1092
+            elif self.mode == "puzzle":
1093
+                self._puzzle_reveal()
10921094
             self._refresh()
10931095
             return
10941096
         if self.hint_level >= 2:

modified schach/puzzles.py +13 −5

@@ -70,7 +70,7 @@ class PuzzleMixin:
7070
             "id": info["id"], "rating": info.get("rating"), "themes": info.get("themes", []),
7171
             "solution": solution, "index": 0, "failed": False, "done": False,
7272
             "reported": False, "rating_diff": None,
73
-            "review": review, "errors": 0, "hints": 0, "recorded": False, "saved_days": None,
73
+            "review": review, "errors": 0, "hints": 0, "reveals": 0, "recorded": False, "saved_days": None,
7474
             "fen": board.fen(), "last": last.uci(), "started": time.monotonic(),
7575
         }
7676
         self._changed()
@@ -138,6 +138,11 @@ class PuzzleMixin:
138138
         self._puzzle_fail()
139139
         self.hint_move = p["solution"][p["index"]]
140140
 
141
+    def _puzzle_reveal(self):
142
+        """Zweite Stufe des Hinweises: auch das Zielfeld, also der ganze Zug."""
143
+        if self.puzzle is not None:
144
+            self.puzzle["reveals"] += 1
145
+
141146
     def _puzzle_fail(self):
142147
         p = self.puzzle
143148
         if not p["failed"]:
@@ -149,8 +154,9 @@ class PuzzleMixin:
149154
         p = self.puzzle
150155
         p["done"] = True
151156
         if p["review"]:
152
-            # Hinweis zeigt den Zug, das ist „Lösung zeigen“ – sofort Nochmal
153
-            grade = repetition.AGAIN if p["hints"] else repetition.grade(p["errors"], 0, 0)
157
+            # Hinweis Stufe 1 (Figur) wie ein halber Fehler, Stufe 2 (ganzer Zug) sofort Nochmal
158
+            hints = repetition.hint_weight(p["hints"], p["reveals"])
159
+            grade = repetition.grade(p["errors"], hints, 0, p["reveals"])
154160
             days = self._puzzle_record(grade)
155161
             lead = "Gelöst!" if grade == repetition.GOOD else "Geschafft."
156162
             if days is not None:
@@ -188,7 +194,8 @@ class PuzzleMixin:
188194
         info = {"id": p["id"], "fen": p["fen"], "last": p["last"],
189195
                 "solution": [move.uci() for move in p["solution"]],
190196
                 "rating": p["rating"], "themes": p["themes"]}
191
-        p["saved_days"] = progress.save_puzzle(info, errors=p["errors"], hints=p["hints"])
197
+        p["saved_days"] = progress.save_puzzle(info, errors=p["errors"],
198
+                                               hints=repetition.hint_weight(p["hints"], p["reveals"]))
192199
 
193200
     def _puzzle_record(self, grade):
194201
         p = self.puzzle
@@ -198,7 +205,8 @@ class PuzzleMixin:
198205
         p["recorded"] = True
199206
         self.puzzle_recent = p["id"]
200207
         duration = int((time.monotonic() - p["started"]) * 1000)
201
-        return progress.record_puzzle(p["id"], grade, errors=p["errors"], hints=p["hints"],
208
+        hints = repetition.hint_weight(p["hints"], p["reveals"])
209
+        return progress.record_puzzle(p["id"], grade, errors=p["errors"], hints=hints,
202210
                                       duration_ms=duration)
203211
 
204212
     def _puzzle_report(self, win):

modified schach/repetition.py +3 −2

@@ -487,12 +487,13 @@ def hint_weight(hints, reveals):
487487
     return (hints + reveals) / 2
488488
 
489489
 
490
-def grade(errors, hints, blunders):
490
+def grade(errors, hints, blunders, reveals=0):
491491
     """Stufe wie bei Anki, aus dem Verlauf: kein Ausrutscher gut, einer schwer, mehr (oder ein Patzer) nochmal.
492492
 
493493
     ``hints`` darf halbe Hinweise enthalten (siehe ``hint_weight``): Hilfe gebraucht ist nie „gut“.
494
+    ``reveals``: Hinweise bis Stufe 2 (Figur und Zielfeld, also der ganze Zug) – das ist Nochmal.
494495
     """
495
-    if blunders or errors + hints > 1:
496
+    if blunders or reveals or errors + hints > 1:
496497
         return AGAIN
497498
     if errors + hints > 0:
498499
         return HARD

modified schach/training.py +1 −1

@@ -993,7 +993,7 @@ class OpeningMixin:
993993
         base, self.decision = self.decision, None
994994
         delta = {k: self.course_stats[k] - base[k] for k in ("errors", "hints", "reveals", "blunders")}
995995
         hints = repetition.hint_weight(delta["hints"], delta["reveals"])
996
-        level = repetition.grade(delta["errors"], hints, delta["blunders"])
996
+        level = repetition.grade(delta["errors"], hints, delta["blunders"], delta["reveals"])
997997
         days = progress().record(self.course, before, level, errors=delta["errors"], hints=hints,
998998
                                  blunders=delta["blunders"])
999999
         self.course_records.append((level, days))

modified tests/test_puzzle_cards.py +18 −0

@@ -137,6 +137,24 @@ class PuzzleCardTest(unittest.TestCase):
137137
         window.start_puzzle()
138138
         self.background.assert_called_once()  # … aber erst nach einem neuen von Lichess
139139
 
140
+    def _review_with_hint(self, reveal):
141
+        self.progress.save_puzzle(PUZZLE, now=datetime.datetime.now() - datetime.timedelta(days=3))
142
+        window = FakeWindow()
143
+        window.start_puzzle()
144
+        window._puzzle_hint()  # Stufe 1: die Figur
145
+        if reveal:
146
+            window._puzzle_reveal()  # Stufe 2: auch das Zielfeld
147
+        window._puzzle_play(chess.Move.from_uci("h5f7"))
148
+        return window.final_text
149
+
150
+    def test_hint_showing_the_piece_is_hard(self):
151
+        self.assertIn("Fast. Dieses Rätsel kommt", self._review_with_hint(reveal=False))
152
+        self.assertEqual(self.progress.puzzles_due(), 0)  # nicht heute noch einmal
153
+
154
+    def test_hint_showing_the_move_is_again(self):
155
+        self.assertIn("Das Rätsel wiederholen wir gleich", self._review_with_hint(reveal=True))
156
+        self.assertEqual(self.progress.puzzles_due(), 1)
157
+
140158
 
141159
 class DuePuzzleTest(unittest.TestCase):
142160
     def test_most_overdue_first(self):

modified tests/test_repetition.py +1 −1

@@ -167,7 +167,7 @@ class ProgressTest(unittest.TestCase):
167167
         self.assertEqual(repetition.grade(0, half, 0), H)  # Hilfe gebraucht ist nie „gut“
168168
         self.assertEqual(repetition.grade(0, repetition.hint_weight(2, 0), 0), H)
169169
         self.assertEqual(repetition.grade(1, half, 0), A)
170
-        self.assertEqual(repetition.grade(0, repetition.hint_weight(1, 1), 0), H)
170
+        self.assertEqual(repetition.grade(0, repetition.hint_weight(1, 1), 0, reveals=1), A)  # ganzer Zug
171171
         self.assertEqual(repetition.grade(0, repetition.hint_weight(2, 1), 0), A)
172172
 
173173
     def test_hard_is_not_repeated_today(self):