Public repository: timo / schach

Reader

Ein aufgeräumtes Schach-Programm für GNOME

chore(tools): treat arrows behind own pieces as review hints

public

chore(tools): treat arrows behind own pieces as review hints

Discovered attacks (Ld2 behind Sc3) and plans (De2 behind e3) look
like blocked arrows; list them for review instead of counting them.
Opponent blunders count only when neither the move nor the reply is
explained. Line-end threshold -0.8 (Scandinavian sits near -0.6).

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

modified tools/kurse_pruefen.py +19 −10

@@ -5,7 +5,7 @@ Meldet:
55
 - Kurszüge der lernenden Seite, die deutlich schlechter sind als Stockfishs bester Zug,
66
 - grobe Fehler der Gegenseite (manchmal Absicht – dann sollte es im Kommentar stehen),
77
 - Linienenden, an denen die lernende Seite schlechter steht,
8
-- Pfeile, deren Weg durch eine Figur versperrt ist,
8
+- Pfeile, deren Weg durch eine eigene Figur führt (zum Ansehen: Abzugsangriff, Plan oder Fehler),
99
 - und den Bewertungsverlauf jeder „Warum?“-Vorführung zum Gegenlesen.
1010
 
1111
 Bewertungen werden zwischengespeichert (~/.cache/schach/kurse_pruefen.json), ein zweiter
@@ -31,7 +31,7 @@ from schach import opening # noqa: E402
3131
 CACHE = os.path.expanduser("~/.cache/schach/kurse_pruefen.json")
3232
 LEARNER_LOSS = 70  # Centipawns: so viel schlechter als der beste Zug ist bei eigenen Kurszügen verdächtig
3333
 OPPONENT_LOSS = 200  # grober Fehler der Gegenseite
34
-LINE_END = -50  # Linienende: so schlecht darf es für die lernende Seite höchstens stehen
34
+LINE_END = -80  # Linienende: so schlecht darf es höchstens stehen (Skandinavisch steht von Haus aus um -0,6)
3535
 MATE = 10000
3636
 
3737
 
@@ -99,7 +99,10 @@ def path_of(board, node):
9999
 
100100
 
101101
 def blocked_arrows(board, node):
102
-    """Pfeile von Läufer/Turm/Dame/Bauer, deren Weg durch eine Figur versperrt ist."""
102
+    """Pfeile von Läufer/Turm/Dame/Bauer, deren Weg durch eine eigene Figur versperrt ist.
103
+
104
+    Gegnerische Figuren dazwischen sind erlaubt: So zeichnet man Fesselungen (Lc4 durch Sd5 auf Ke6).
105
+    """
103106
     problems = []
104107
     for arrow in node.arrows():
105108
         tail, head = arrow.tail, arrow.head
@@ -111,7 +114,8 @@ def blocked_arrows(board, node):
111114
         between = chess.SquareSet(chess.between(tail, head))
112115
         if not between and chess.square_distance(tail, head) > 1:
113116
             continue  # keine Linie (z. B. Plan-Pfeil) – nicht prüfbar
114
-        blockers = [chess.square_name(s) for s in between if board.piece_at(s)]
117
+        blockers = [chess.square_name(s) for s in between
118
+                    if board.piece_at(s) and board.piece_at(s).color == piece.color]
115119
         if blockers:
116120
             problems.append(f"{chess.square_name(tail)}→{chess.square_name(head)} versperrt auf {', '.join(blockers)}")
117121
     return problems
@@ -122,12 +126,12 @@ def check_course(path, ev):
122126
         game = chess.pgn.read_game(fh)
123127
     color = chess.BLACK if game.headers.get("SchachColor", "white").lower() == "black" else chess.WHITE
124128
     title = game.headers.get("Event", path)
125
-    findings, demos = [], []
129
+    findings, demos, arrows = [], [], []
126130
 
127131
     def walk(node, in_demo, demo_log):
128132
         board = node.board()
129133
         for problem in blocked_arrows(board, node):
130
-            findings.append(f"Pfeil: {path_of(board, node) or 'Start'}: {problem}")
134
+            arrows.append(f"{path_of(board, node) or 'Start'}: {problem}")
131135
         children = node.variations
132136
         if not children and not in_demo:
133137
             cp, _ = ev.score(board)
@@ -153,12 +157,14 @@ def check_course(path, ev):
153157
                 if mover == color and loss > LEARNER_LOSS and child.move.uci() != best:
154158
                     findings.append(f"Kurszug: {where} verliert {loss / 100:.2f} (besser {best_san}, danach {fmt(cp_after)})")
155159
                 elif mover != color and loss > OPPONENT_LOSS:
156
-                    note = opening.clean_comment(child.comment)[:60]
157
-                    findings.append(f"Gegnerfehler: {where} (−{loss / 100:.2f}; Kommentar: „{note}“)")
160
+                    # erklärt im eigenen Kommentar oder in der Antwort darauf? Dann ist es Absicht.
161
+                    replies = [opening.clean_comment(r.comment) for r in child.variations[:1]]
162
+                    if not opening.clean_comment(child.comment) and not any(replies):
163
+                        findings.append(f"Gegnerfehler ohne Erklärung: {where} (−{loss / 100:.2f})")
158164
             walk(child, demo, log)
159165
 
160166
     walk(game, False, None)
161
-    return title, findings, demos
167
+    return title, findings, demos, arrows
162168
 
163169
 
164170
 def main():
@@ -172,11 +178,14 @@ def main():
172178
     total = 0
173179
     try:
174180
         for path in paths:
175
-            title, findings, demos = check_course(path, ev)
181
+            title, findings, demos, arrows = check_course(path, ev)
176182
             total += len(findings)
177183
             print(f"\n=== {title} ({os.path.basename(path)}) – {len(findings)} Befund(e)")
178184
             for finding in findings:
179185
                 print("  •", finding)
186
+            for arrow in arrows:
187
+                # Abzugsangriff (Ld2 hinter Sc3) oder Plan (De2 hinter e3, vor e3–e4) – oder ein Fehler
188
+                print("  ? Pfeil hinter eigener Figur, bitte ansehen:", arrow)
180189
             for where, text, log in demos:
181190
                 print(f"  ▸ Vorführung nach {where}: „{text}“")
182191
                 print("      " + " ".join(log))