Public repository: timo / schach

Reader

Ein aufgeräumtes Schach-Programm für GNOME

feat(hints): square tags, arrow and ghost move for hint and threat

public

feat(hints): square tags, arrow and ghost move for hint and threat

Stage 1 frames the one square subtly; stage 2 drops frame and glow
for tags in a shared corner, an arrow under the pieces and the move
shown half transparent. On captures the victim shifts right and the
attacker left so both outlines stay readable (also in book preview).
Enter plays the hint move once both squares are shown.

Opening course: a piece-only hint counts half for repetition grading,
since recalling the target square shows partial recall.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Changesetc1ab5ff75ae785f994fbbdd147fd0b3a3d6896fa
Author (claimed)Timo Stolz <timo.stolz@nullachtvierzehn.de>,
Parents11fdf5078ebc
Children2023f76409ee 45f827567c35
Pushlog
by timo via ssh
by timo via ssh

modified README.md +3 −2

@@ -6,10 +6,11 @@ Schlichtes GNOME-Schachprogramm (Python,
66
   Im Dialog „Neue Partie“ auch mit Bedenkzeit (5, 10, 10+5, 15+10, 30 Minuten); die Uhr
77
   startet mit dem ersten Zug.
88
 - **Hinweis** (Taste `H`): Erster Druck lässt die Figur leuchten, zweiter Druck auch
9
-  das Zielfeld. Wer hilft, steht im Pfeil-Menü daneben: Maia 1500, 2000 (Standard) oder
9
+  das Zielfeld – mit Pfeil, Feldnamen und dem Zug halb durchsichtig; `Enter` spielt ihn dann.
10
+  Im Eröffnungskurs zählt ein Hinweis, der nur die Figur zeigt, halb. Wer hilft, steht im Pfeil-Menü daneben: Maia 1500, 2000 (Standard) oder
1011
   2500 – jeweils von Stockfish geprüft – oder Stockfish selbst.
1112
 - **Drohung** (Taste `B`, Schwert): umgekehrt zum Hinweis. Erster Druck zeigt das
12
-  bedrohte Feld (orange), zweiter die drohende Figur mit Pfeil. Die Drohung passt zum
13
+  bedrohte Feld (orange), zweiter die drohende Figur mit Pfeil und den Drohzug halb durchsichtig. Die Drohung passt zum
1314
   Gegner: Maia in seiner Stärke schlägt vor, was er sehen würde, Stockfish prüft nur, ob es
1415
   wirklich etwas gewinnt. Im Pfeil-Menü neben dem Schwert lässt sich auf „Stockfish“
1516
   (objektiv) umstellen.

modified schach/app.py +18 −1

@@ -50,7 +50,8 @@ AUTOSAVE_DELAY_MS = 800
5050
 SHORTCUTS = [
5151
     ("Partie", [
5252
         ("Neue Partie", "<Control>n"), ("Zug zurücknehmen", "<Control>z BackSpace"),
53
-        ("Hinweis", "h"), ("Drohung zeigen", "b"), ("Neues Rätsel", "r"),
53
+        ("Hinweis", "h"), ("Hinweiszug spielen (wenn beide Felder gezeigt)", "Return"),
54
+        ("Drohung zeigen", "b"), ("Neues Rätsel", "r"),
5455
     ]),
5556
     ("Ansicht", [
5657
         ("Brett drehen", "f"), ("Zugliste und Bewertung", "a"),
@@ -372,6 +373,7 @@ class Window(OnlineMixin, PuzzleMixin, O
372373
             ("new-game", self._new_game_dialog),
373374
             ("undo", self.undo),
374375
             ("hint", self.hint),
376
+            ("play-hint", self.play_hint),
375377
             ("threat", self.threat),
376378
             ("flip", self.flip),
377379
             ("export", self._export_dialog),
@@ -426,6 +428,7 @@ class Window(OnlineMixin, PuzzleMixin, O
426428
         app.set_accels_for_action("win.new-game", ["<Control>n"])
427429
         app.set_accels_for_action("win.undo", ["<Control>z"])
428430
         app.set_accels_for_action("win.hint", ["h"])
431
+        app.set_accels_for_action("win.play-hint", ["Return", "KP_Enter"])
429432
         app.set_accels_for_action("win.threat", ["b"])
430433
         app.set_accels_for_action("win.flip", ["f"])
431434
         app.set_accels_for_action("win.save-game", ["<Control>s"])
@@ -543,6 +546,7 @@ class Window(OnlineMixin, PuzzleMixin, O
543546
             v.selected = None
544547
             v.hint_from = v.hint_to = None
545548
             v.threat_from = v.threat_to = None
549
+            v.hint_preview = v.threat_preview = None
546550
             symbol = self.symbols.get(self.browse_ply)
547551
             v.badge = (shown.peek().to_square, symbol) if symbol and shown.move_stack else None
548552
             v.queue_draw()
@@ -561,6 +565,8 @@ class Window(OnlineMixin, PuzzleMixin, O
561565
         threat = self.threat_move if self._human_to_move() else None
562566
         v.threat_to = threat.to_square if threat and self.threat_level >= 1 else None
563567
         v.threat_from = threat.from_square if threat and self.threat_level >= 2 else None
568
+        v.hint_preview = self.hint_move if v.hint_to is not None else None
569
+        v.threat_preview = threat if v.threat_from is not None else None
564570
 
565571
         v.badge = None
566572
         v.turn_marker = self.board.turn if self.mode == "duo" and not self._over() else None
@@ -639,6 +645,10 @@ class Window(OnlineMixin, PuzzleMixin, O
639645
         self._action("duo-draw").set_enabled(self.mode == "duo" and not self._over())
640646
         self._action("duo-resign").set_enabled(self.mode == "duo" and not self._over())
641647
         self._action("hint").set_enabled(can_hint)
648
+        self._action("play-hint").set_enabled(
649
+            hints and self.hint_level >= 2 and self.hint_move is not None and self._human_to_move()
650
+            and not self._browsing()
651
+        )
642652
         self.hint_btn.set_tooltip_text(
643653
             "Hinweis (H) – das Rätsel zählt dann nicht als gelöst" if self.mode == "puzzle"
644654
             else "Kurszug zeigen (H)" if self.mode == "opening"
@@ -1015,6 +1025,8 @@ class Window(OnlineMixin, PuzzleMixin, O
10151025
             return
10161026
         if self.hint_level == 1:
10171027
             self.hint_level = 2
1028
+            if self.mode == "opening":
1029
+                self.course_stats["reveals"] += 1  # zweite Hälfte des Hinweises: auch das Zielfeld
10181030
             self._refresh()
10191031
             return
10201032
         if self.hint_level >= 2 or self.hint_pending:
@@ -1039,6 +1051,11 @@ class Window(OnlineMixin, PuzzleMixin, O
10391051
             self.hint_pending = True  # Vorausberechnung läuft noch; zeigt sich, sobald fertig
10401052
             self._refresh()
10411053
 
1054
+    def play_hint(self, *_):
1055
+        """Enter: den Hinweiszug spielen, sobald Figur und Zielfeld gezeigt werden."""
1056
+        if self.hint_level >= 2 and self.hint_move is not None and not self._browsing():
1057
+            self._play_human(self.hint_move)
1058
+
10421059
     # --- Bedrohung ---------------------------------------------------------
10431060
 
10441061
     def _threat_source(self):

modified schach/diagram.py +96 −39

@@ -157,6 +157,8 @@ class BoardPainter:
157157
         self.spotlight_via = None  # bei „Se5“ nach „Sf3“ im Text: Zwischenfeld, zwei Pfeile
158158
         self.shapes = ()  # Pfeile und Felder aus Kurskommentaren: ((von, nach, Farbe), …)
159159
         self.preview = None  # Zug, der halb durchsichtig gezeigt wird (Explorer: Maus über einer Zeile)
160
+        self.hint_preview = None  # Hinweiszug, sobald beide Felder gezeigt werden: ebenso halb durchsichtig
161
+        self.threat_preview = None  # Drohzug des Gegners, sobald beide Felder gezeigt werden
160162
         self.editing = False  # Stellung aufbauen: keine geschlagenen Figuren anzeigen
161163
         self.eval_bar = None  # Gewinnchance Weiß in Prozent: Balken links neben dem Brett
162164
         self._drag_sq = None
@@ -241,12 +243,16 @@ class BoardPainter:
241243
             king = self.board.king(self.board.turn)
242244
             if king is not None:
243245
                 self._glow(cr, king, sq, CHECK, 0.85)
244
-        for s in (self.hint_from, self.hint_to):
245
-            if s is not None:
246
-                self._mark(cr, s, sq, HINT)
247
-        for s in (self.threat_from, self.threat_to):
248
-            if s is not None:
249
-                self._mark(cr, s, sq, THREAT)
246
+        # Hinweis und Drohung, Stufe 1 (ein Feld): dezenter Rahmen, damit das Feld auffällt.
247
+        # Stufe 2 (beide Felder) ohne Rahmen – Feldnamen, Pfeil und halb durchsichtige Figur reichen.
248
+        for single, other, rgb in ((self.hint_from, self.hint_to, HINT), (self.threat_to, self.threat_from, THREAT)):
249
+            if single is not None and other is None:
250
+                self._frame(cr, single, sq, rgb)
251
+        # Pfeile von Hinweis und Drohung unter den Figuren: die halb durchsichtige Figur im Ziel bleibt klar
252
+        if self.hint_from is not None and self.hint_to is not None:
253
+            self._draw_arrow(cr, self.hint_from, self.hint_to, sq, HINT)
254
+        if self.threat_from is not None and self.threat_to is not None:
255
+            self._draw_arrow(cr, self.threat_from, self.threat_to, sq, THREAT)
250256
         if self.spotlight is not None and self.spotlight_from is not None:
251257
             self._glow(cr, self.spotlight_from, sq, SPOTLIGHT, 0.8)
252258
         elif self.spotlight is not None:
@@ -274,19 +280,22 @@ class BoardPainter:
274280
             self._draw_piece(cr, piece, x + off, y + off, sq * scale)
275281
             cr.pop_group_to_source()
276282
             cr.paint_with_alpha(1 - p)
277
-        ghosts = self._preview_ghosts()
283
+        ghosts, captured = self._preview_ghosts()
278284
         faded = {src for _p, src, _dst in ghosts}
285
+        nudge = sq * 0.14  # Schlagen: Opfer etwas nach rechts, Angreifer nach links – beide Umrisse bleiben lesbar
279286
         for square, piece in self.board.piece_map().items():
280287
             if (dragging and square == self._drag_sq) or square in hidden:
281288
                 continue
282289
             x, y = self._square_origin(square)
290
+            if square in captured:
291
+                x += nudge
283292
             if square in faded:
284293
                 self._draw_piece_alpha(cr, piece, x, y, sq, 0.35)
285294
             else:
286295
                 self._draw_piece(cr, piece, x, y, sq)
287296
         for piece, _src, dst in ghosts:
288297
             x, y = self._square_origin(dst)
289
-            self._draw_piece_alpha(cr, piece, x, y, sq, 0.6)
298
+            self._draw_piece_alpha(cr, piece, x - (nudge if dst in captured else 0), y, sq, 0.6)
290299
         if anim:
291300
             p = anim["progress"]
292301
             for piece, src, dst in anim["movers"]:
@@ -294,8 +303,6 @@ class BoardPainter:
294303
                 x1, y1 = self._square_origin(dst)
295304
                 self._draw_piece(cr, piece, x0 + (x1 - x0) * p, y0 + (y1 - y0) * p, sq)
296305
 
297
-        if self.threat_from is not None and self.threat_to is not None:
298
-            self._draw_arrow(cr, self.threat_from, self.threat_to, sq, THREAT)
299306
         if self.spotlight is not None:
300307
             hops = [s for s in (self.spotlight_from, self.spotlight_via) if s is not None] + [self.spotlight]
301308
             for a, b in zip(hops, hops[1:]):
@@ -311,6 +318,10 @@ class BoardPainter:
311318
                 self._square_tag(cr, hops[i], sq, SPOTLIGHT, hops[i - 1:i] + hops[i + 1:i + 2])
312319
             if len(hops) == 1:
313320
                 self._square_tag(cr, self.spotlight, sq, SPOTLIGHT)
321
+        for squares, rgb in (((self.hint_from, self.hint_to), HINT), ((self.threat_from, self.threat_to), THREAT)):
322
+            shown = [s for s in squares if s is not None]
323
+            if shown:
324
+                self._square_tags(cr, shown, sq, rgb)
314325
 
315326
         if self.strips:
316327
             if not self.editing:
@@ -342,16 +353,6 @@ class BoardPainter:
342353
                 s = sq * 1.1
343354
                 self._draw_piece(cr, piece, px - s / 2, py - s / 2, s)
344355
 
345
-    def _mark(self, cr, square, sq, rgb):
346
-        """Leuchtendes Feld mit Rahmen (Hinweis blau, Bedrohung orange)."""
347
-        self._glow(cr, square, sq, rgb, 0.9)
348
-        x, y = self._square_origin(square)
349
-        cr.set_source_rgba(*rgb, 0.95)
350
-        cr.set_line_width(max(sq * 0.05, 2))
351
-        inset = sq * 0.04
352
-        cr.rectangle(x + inset, y + inset, sq - 2 * inset, sq - 2 * inset)
353
-        cr.stroke()
354
-
355356
     def _square_tag(self, cr, square, sq, rgb, arrows=()):
356357
         """Zielfeld mit Namensschild („c4“): die Figur bleibt frei, der Name steht da.
357358
 
@@ -359,25 +360,59 @@ class BoardPainter:
359360
         Schneidet ein Pfeil dort, dann unten rechts, oben links, zuletzt unten links.
360361
         ``arrows``: Felder, zu denen oder von denen ein Pfeil an diesem Feld hängt.
361362
         """
363
+        free = self._tag_corners(cr, square, sq, arrows)
364
+        self._draw_tag(cr, square, sq, rgb, free[0] if free else 3)
365
+
366
+    def _square_tags(self, cr, squares, sq, rgb):
367
+        """Namensschilder für ein Feld oder ein Feldpaar mit Pfeil (Hinweis, Drohung).
368
+
369
+        Bei zwei Feldern sitzen beide Schilder möglichst in derselben Ecke – in der ersten,
370
+        die an keinem der beiden Felder den Pfeil schneidet; sonst wählt jedes Feld für sich.
371
+        """
372
+        pair = len(squares) == 2
373
+        free = [self._tag_corners(cr, s, sq, [o for o in squares if o != s] if pair else ()) for s in squares]
374
+        common = [c for c in free[0] if all(c in f for f in free[1:])]
375
+        for square, own in zip(squares, free):
376
+            corner = common[0] if common else own[0] if own else 3
377
+            self._draw_tag(cr, square, sq, rgb, corner)
378
+
379
+    def _tag_box(self, cr, square, sq, corner):
380
+        """(links, oben, Breite, Höhe, Text, Maße) des Schilds in Ecke ``corner`` (0 oben rechts … 3 unten links)."""
362381
         x, y = self._square_origin(square)
363382
         text = chess.square_name(square)
364383
         cr.save()
365384
         cr.select_font_face("Sans", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_BOLD)
366385
         cr.set_font_size(sq * 0.2)
367386
         ext = cr.text_extents(text)
368
-        pad = sq * 0.05
369
-        w, h = ext.width + 2 * pad, sq * 0.26
387
+        cr.restore()
388
+        w, h = ext.width + 2 * sq * 0.05, sq * 0.26
370389
         inset = sq * 0.04
371390
         corners = [(x + sq - w - inset, y + inset), (x + sq - w - inset, y + sq - h - inset),
372391
                    (x + inset, y + inset), (x + inset, y + sq - h - inset)]
392
+        left, top = corners[corner]
393
+        return left, top, w, h, text, ext
394
+
395
+    def _tag_corners(self, cr, square, sq, arrows=()):
396
+        """Ecken (0 oben rechts, 1 unten rechts, 2 oben links, 3 unten links), die kein Pfeil schneidet."""
397
+        x, y = self._square_origin(square)
373398
         shaft = []
374399
         for other in arrows:
375400
             fx, fy = self._square_origin(other)
376401
             shaft += [(x + sq / 2 + (fx - x) * t / 20, y + sq / 2 + (fy - y) * t / 20) for t in range(21)]
377402
         margin = sq * 0.06  # halber Schaft mit Rand
378
-        left, top = next(((cx, cy) for cx, cy in corners
379
-                          if not any(cx - margin < px < cx + w + margin and cy - margin < py < cy + h + margin
380
-                                     for px, py in shaft)), corners[-1])
403
+        free = []
404
+        for corner in range(4):
405
+            cx, cy, w, h, _text, _ext = self._tag_box(cr, square, sq, corner)
406
+            if not any(cx - margin < px < cx + w + margin and cy - margin < py < cy + h + margin for px, py in shaft):
407
+                free.append(corner)
408
+        return free
409
+
410
+    def _draw_tag(self, cr, square, sq, rgb, corner):
411
+        left, top, w, h, text, ext = self._tag_box(cr, square, sq, corner)
412
+        pad = sq * 0.05
413
+        cr.save()
414
+        cr.select_font_face("Sans", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_BOLD)
415
+        cr.set_font_size(sq * 0.2)
381416
         r = h * 0.3
382417
         cr.new_path()
383418
         cr.arc(left + w - r, top + r, r, -math.pi / 2, 0)
@@ -396,6 +431,16 @@ class BoardPainter:
396431
         cr.new_path()
397432
         cr.restore()
398433
 
434
+    def _frame(self, cr, square, sq, rgb):
435
+        """Dünner, halb durchsichtiger Rahmen innen am Feldrand."""
436
+        x, y = self._square_origin(square)
437
+        width = max(sq * 0.035, 1.5)
438
+        cr.new_path()
439
+        cr.set_source_rgba(*rgb, 0.7)
440
+        cr.set_line_width(width)
441
+        cr.rectangle(x + width / 2, y + width / 2, sq - width, sq - width)
442
+        cr.stroke()
443
+
399444
     def _ring(self, cr, square, sq, rgb):
400445
         """Markiertes Feld: Kreis wie bei Lichess."""
401446
         x, y = self._square_origin(square)
@@ -459,21 +504,33 @@ class BoardPainter:
459504
         cr.paint()
460505
         cr.restore()
461506
 
507
+    def _previews(self):
508
+        """[(Zug, Brett)], die halb durchsichtig gezeigt werden: Explorer-Zeile, Hinweis, Drohung."""
509
+        shown = [(m, self.board) for m in dict.fromkeys((self.preview, self.hint_preview)) if m is not None]
510
+        if self.threat_preview is not None:
511
+            probe = self.board.copy(stack=False)  # die Drohung spielt der Gegner, als wäre er am Zug
512
+            probe.push(chess.Move.null())
513
+            shown.append((self.threat_preview, probe))
514
+        return shown
515
+
462516
     def _preview_ghosts(self):
463
-        """[(Figur, von, nach)] für den Vorschau-Zug, bei Rochade mit Turm."""
464
-        move = self.preview
465
-        if move is None or move not in self.board.legal_moves:
466
-            return []
467
-        piece = self.board.piece_at(move.from_square)
468
-        if move.promotion:
469
-            piece = chess.Piece(move.promotion, piece.color)
470
-        ghosts = [(piece, move.from_square, move.to_square)]
471
-        if self.board.is_castling(move):
472
-            rank = chess.square_rank(move.from_square)
473
-            kingside = self.board.is_kingside_castling(move)
474
-            ghosts.append((chess.Piece(chess.ROOK, piece.color),
475
-                           chess.square(7 if kingside else 0, rank), chess.square(5 if kingside else 3, rank)))
476
-        return ghosts
517
+        """([(Figur, von, nach)], {Felder mit geschlagener Figur}) für die Vorschau-Züge, bei Rochade mit Turm."""
518
+        ghosts, captured = [], set()
519
+        for move, board in self._previews():
520
+            if move not in board.legal_moves:
521
+                continue
522
+            piece = board.piece_at(move.from_square)
523
+            if move.promotion:
524
+                piece = chess.Piece(move.promotion, piece.color)
525
+            ghosts.append((piece, move.from_square, move.to_square))
526
+            if board.is_castling(move):
527
+                rank = chess.square_rank(move.from_square)
528
+                kingside = board.is_kingside_castling(move)
529
+                ghosts.append((chess.Piece(chess.ROOK, piece.color),
530
+                               chess.square(7 if kingside else 0, rank), chess.square(5 if kingside else 3, rank)))
531
+            elif board.piece_at(move.to_square) is not None:  # en passant: Opfer steht daneben, nichts überlappt
532
+                captured.add(move.to_square)
533
+        return ghosts, captured
477534
 
478535
     def _draw_piece_alpha(self, cr, piece, x, y, size, alpha):
479536
         cr.push_group()

modified schach/repetition.py +15 −4

@@ -3,7 +3,7 @@
33
 Eine Linie ist ein Weg durch den Kurs vom Start bis zum Ende einer Variante.
44
 Fehlerfrei und ohne Hinweis gespielt, wächst der Abstand bis zur nächsten
55
 Wiederholung (1, 3, 7, 14 … Tage). Mit Fehler oder Hinweis ist sie sofort wieder
6
-fällig – kommt aber erst nach den anderen fälligen Linien dran.
6
+fällig (ein Hinweis, der nur die Figur zeigt, zählt halb) – kommt aber erst nach den anderen fälligen Linien dran.
77
 
88
 Reine Logik ohne GTK. Gespeichert wird als JSON, pro Kurs (Titel) und Linie
99
 (UCI-Züge, mit Leerzeichen getrennt).
@@ -205,11 +205,22 @@ def played_line(course, moves, target=No
205205
     return matches[0]
206206
 
207207
 
208
+def hint_weight(hints, reveals):
209
+    """Gewicht der Hinweise: nur die Figur zählt halb, Figur und Zielfeld ganz.
210
+
211
+    ``hints``: wie oft der Hinweis aufgerufen wurde, ``reveals``: wie oft davon auch das Zielfeld.
212
+    """
213
+    return (hints + reveals) / 2
214
+
215
+
208216
 def grade(errors, hints, blunders):
209
-    """Stufe wie bei Anki, aus dem Verlauf: kein Ausrutscher gut, einer schwer, mehr (oder ein Patzer) nochmal."""
210
-    if blunders or errors + hints >= 2:
217
+    """Stufe wie bei Anki, aus dem Verlauf: kein Ausrutscher gut, einer schwer, mehr (oder ein Patzer) nochmal.
218
+
219
+    ``hints`` darf halbe Hinweise enthalten (siehe ``hint_weight``): Hilfe gebraucht ist nie „gut“.
220
+    """
221
+    if blunders or errors + hints > 1:
211222
         return AGAIN
212
-    if errors + hints == 1:
223
+    if errors + hints > 0:
213224
         return HARD
214225
     return GOOD
215226
 

modified schach/training.py +12 −7

@@ -188,7 +188,7 @@ def square_at(label, x, y):
188188
 class OpeningMixin:
189189
     def _opening_init(self):
190190
         self.course = None
191
-        self.course_stats = {"errors": 0, "hints": 0, "blunders": 0}
191
+        self.course_stats = {"errors": 0, "hints": 0, "reveals": 0, "blunders": 0}
192192
         self.course_line = None  # (id, Züge): die Linie, die heute dran ist (Lernkarte)
193193
         self.course_recorded = False
194194
         self.opening_busy = False  # wartet auf Gegnerzug, Bewertung oder Zurücknahme
@@ -396,6 +396,7 @@ class OpeningMixin:
396396
         v.selected = None
397397
         v.badge = None
398398
         v.hint_from = v.hint_to = v.threat_from = v.threat_to = None
399
+        v.hint_preview = v.threat_preview = None
399400
         v.shapes = demo.steps[index][2]
400401
         v.queue_draw()
401402
         self._refresh_chrome()
@@ -502,7 +503,7 @@ class OpeningMixin:
502503
         self._leave_special()
503504
         self.mode = "opening"
504505
         self.course = course
505
-        self.course_stats = {"errors": 0, "hints": 0, "blunders": 0}
506
+        self.course_stats = {"errors": 0, "hints": 0, "reveals": 0, "blunders": 0}
506507
         self.course_line = progress().pick(course)
507508
         self.course_recorded = False
508509
         self.human = course.color
@@ -684,22 +685,26 @@ class OpeningMixin:
684685
 
685686
     def _opening_finished(self):
686687
         self.opening_busy = False
687
-        errors, hints = self.course_stats["errors"], self.course_stats["hints"]
688
+        errors, hints, reveals = (self.course_stats[k] for k in ("errors", "hints", "reveals"))
689
+        halves = hints - reveals  # Hinweise, bei denen nur die Figur gezeigt wurde
688690
         if errors == 0 and hints == 0:
689691
             summary = "Ziel erreicht – ohne Fehlversuch und ohne Hinweis!"
690692
         else:
691693
             parts = []
692694
             if errors:
693
-                parts.append(f"{errors} Fehlversuch" + ("e" if errors > 1 else ""))
694
-            if hints:
695
-                parts.append(f"{hints} Hinweis" + ("e" if hints > 1 else ""))
695
+                parts.append(f"{errors} Fehlversuch" + ("en" if errors > 1 else ""))
696
+            if reveals:
697
+                parts.append(f"{reveals} Hinweis" + ("en" if reveals > 1 else ""))
698
+            if halves:
699
+                parts.append(f"{halves} halben Hinweis" + ("en" if halves > 1 else ""))
696700
             summary = f"Ziel erreicht – mit {' und '.join(parts)}."
697701
         if not self.course_recorded and self.course is not None:
698702
             self.course_recorded = True  # nach Zurücknehmen und erneutem Ende nicht doppelt zählen
699703
             target = self.course_line[0] if self.course_line else None
700704
             line = repetition.played_line(self.course, self.board.move_stack, target)
701705
             if line is not None:
702
-                level = repetition.grade(errors, hints, self.course_stats["blunders"])
706
+                level = repetition.grade(errors, repetition.hint_weight(hints, reveals),
707
+                                         self.course_stats["blunders"])
703708
                 days = progress().record(self.course, line, level)
704709
                 summary = f"{summary} {repetition.next_text(days, level)}"
705710
         self.final_text = summary

modified tests/test_repetition.py +8 −0

@@ -132,6 +132,14 @@ class ProgressTest(unittest.TestCase):
132132
         self.assertEqual(repetition.grade(1, 1, 0), repetition.AGAIN)
133133
         self.assertEqual(repetition.grade(1, 0, 1), repetition.AGAIN)  # ein echter Patzer
134134
 
135
+    def test_piece_only_hint_counts_half(self):
136
+        half = repetition.hint_weight(1, 0)  # nur die Figur gezeigt
137
+        self.assertEqual(repetition.grade(0, half, 0), repetition.HARD)  # Hilfe gebraucht ist nie „gut“
138
+        self.assertEqual(repetition.grade(0, repetition.hint_weight(2, 0), 0), repetition.HARD)
139
+        self.assertEqual(repetition.grade(1, half, 0), repetition.AGAIN)
140
+        self.assertEqual(repetition.grade(0, repetition.hint_weight(1, 1), 0), repetition.HARD)
141
+        self.assertEqual(repetition.grade(0, repetition.hint_weight(2, 1), 0), repetition.AGAIN)
142
+
135143
     def test_hard_keeps_interval(self):
136144
         self.assertEqual(self.progress.record(self.course, self.main, repetition.HARD, at(0)), 1)  # neu: morgen
137145
         self.progress.record(self.course, self.main, repetition.GOOD, at(1))  # 3 Tage