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>
| Changeset | 9e1a3e440b585a5ede3df555dc7894ecb0ff7044 |
|---|---|
| Author (claimed) | Timo Stolz <timo.stolz@nullachtvierzehn.de>, |
| Parents | 5c0f00182235 |
| Children | b41c03396c0a |
| Pushlog | by timo via ssh by timo via ssh |
modified tools/kurse_pruefen.py +19 −10
| @@ -5,7 +5,7 @@ Meldet: | ||
| 5 | 5 | - Kurszüge der lernenden Seite, die deutlich schlechter sind als Stockfishs bester Zug, |
| 6 | 6 | - grobe Fehler der Gegenseite (manchmal Absicht – dann sollte es im Kommentar stehen), |
| 7 | 7 | - 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), | |
| 9 | 9 | - und den Bewertungsverlauf jeder „Warum?“-Vorführung zum Gegenlesen. |
| 10 | 10 | |
| 11 | 11 | Bewertungen werden zwischengespeichert (~/.cache/schach/kurse_pruefen.json), ein zweiter |
| @@ -31,7 +31,7 @@ from schach import opening # noqa: E402 | ||
| 31 | 31 | CACHE = os.path.expanduser("~/.cache/schach/kurse_pruefen.json") |
| 32 | 32 | LEARNER_LOSS = 70 # Centipawns: so viel schlechter als der beste Zug ist bei eigenen Kurszügen verdächtig |
| 33 | 33 | 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) | |
| 35 | 35 | MATE = 10000 |
| 36 | 36 | |
| 37 | 37 | |
| @@ -99,7 +99,10 @@ def path_of(board, node): | ||
| 99 | 99 | |
| 100 | 100 | |
| 101 | 101 | 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 | + """ | |
| 103 | 106 | problems = [] |
| 104 | 107 | for arrow in node.arrows(): |
| 105 | 108 | tail, head = arrow.tail, arrow.head |
| @@ -111,7 +114,8 @@ def blocked_arrows(board, node): | ||
| 111 | 114 | between = chess.SquareSet(chess.between(tail, head)) |
| 112 | 115 | if not between and chess.square_distance(tail, head) > 1: |
| 113 | 116 | 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] | |
| 115 | 119 | if blockers: |
| 116 | 120 | problems.append(f"{chess.square_name(tail)}→{chess.square_name(head)} versperrt auf {', '.join(blockers)}") |
| 117 | 121 | return problems |
| @@ -122,12 +126,12 @@ def check_course(path, ev): | ||
| 122 | 126 | game = chess.pgn.read_game(fh) |
| 123 | 127 | color = chess.BLACK if game.headers.get("SchachColor", "white").lower() == "black" else chess.WHITE |
| 124 | 128 | title = game.headers.get("Event", path) |
| 125 | - findings, demos = [], [] | |
| 129 | + findings, demos, arrows = [], [], [] | |
| 126 | 130 | |
| 127 | 131 | def walk(node, in_demo, demo_log): |
| 128 | 132 | board = node.board() |
| 129 | 133 | 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}") | |
| 131 | 135 | children = node.variations |
| 132 | 136 | if not children and not in_demo: |
| 133 | 137 | cp, _ = ev.score(board) |
| @@ -153,12 +157,14 @@ def check_course(path, ev): | ||
| 153 | 157 | if mover == color and loss > LEARNER_LOSS and child.move.uci() != best: |
| 154 | 158 | findings.append(f"Kurszug: {where} verliert {loss / 100:.2f} (besser {best_san}, danach {fmt(cp_after)})") |
| 155 | 159 | 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})") | |
| 158 | 164 | walk(child, demo, log) |
| 159 | 165 | |
| 160 | 166 | walk(game, False, None) |
| 161 | - return title, findings, demos | |
| 167 | + return title, findings, demos, arrows | |
| 162 | 168 | |
| 163 | 169 | |
| 164 | 170 | def main(): |
| @@ -172,11 +178,14 @@ def main(): | ||
| 172 | 178 | total = 0 |
| 173 | 179 | try: |
| 174 | 180 | for path in paths: |
| 175 | - title, findings, demos = check_course(path, ev) | |
| 181 | + title, findings, demos, arrows = check_course(path, ev) | |
| 176 | 182 | total += len(findings) |
| 177 | 183 | print(f"\n=== {title} ({os.path.basename(path)}) – {len(findings)} Befund(e)") |
| 178 | 184 | for finding in findings: |
| 179 | 185 | 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) | |
| 180 | 189 | for where, text, log in demos: |
| 181 | 190 | print(f" ▸ Vorführung nach {where}: „{text}“") |
| 182 | 191 | print(" " + " ".join(log)) |