fix(analyse): explanation variations name the move they explain
public
fix(analyse): explanation variations name the move they explain A refutation can follow the game for a few moves and branch off later; it then stood under an opponent's move as 'Warum nicht?', as if it questioned that move. The name now carries the explained move, 'Warum nicht 14. Le6?', on every branch of the refutation; hint variations likewise read 'Hinweis 15. Sd6+' (the arrow label stays 'Hinweis'). Reported by the user. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| Changeset | 340f2d51619d9ca217ef7a32de15af4c9fa9fd25 |
|---|---|
| Author (claimed) | Timo Stolz <timo.stolz@nullachtvierzehn.de>, |
| Parents | badcb002fac2 |
| Children | 78d4a10ba1ae |
| Pushlog | by timo via ssh by timo via ssh |
modified roadmap/analysebrett.md +4 −2
| @@ -201,8 +201,10 @@ Was übrig bleibt, bestimmt die Pfeile an den Gabelungen und die Tiefe. | ||
| 201 | 201 | - Die dritte Hinweisstufe hängt die Erklärung an die Gegenwart. Spielt man den |
| 202 | 202 | Hinweiszug, wird ihr erster Zug zum gespielten Zug, der Rest bleibt Nebenvariante. |
| 203 | 203 | - Das Analysebrett pausiert eine Partie gegen Maia, wie heute schon die Vorführung. |
| 204 | - - In der Zugliste stehen sie als benannte Zweige („Bester Zug“, „Warum nicht?“, | |
| 205 | - „Hinweis“), zugeklappt, solange das Brett nicht in ihnen steht; löschen mit Entf. | |
| 204 | + - In der Zugliste stehen sie als benannte Zweige („Bester Zug“, „Warum nicht 14. Le6?“, | |
| 205 | + „Hinweis 15. Sd6+“), zugeklappt, solange das Brett nicht in ihnen steht; löschen mit | |
| 206 | + Entf. Der Name nennt den erklärten Zug, weil eine Widerlegung der Partie ein Stück folgen | |
| 207 | + und erst später abzweigen kann; dann steht sie unter einem Zug des Gegners. | |
| 206 | 208 | - Varianten an der Gegenwart (etwa der Hinweis, bevor man zieht) stehen im PGN im Header |
| 207 | 209 | `SchachDanach`, sonst würden sie zur Hauptlinie. |
| 208 | 210 | - Ganz am Anfang (noch kein Zug) und überall ohne Partiebaum bleibt es vorerst bei der |
modified schach/training.py +8 −4
| @@ -873,7 +873,7 @@ class OpeningMixin: | ||
| 873 | 873 | or sicht.allowed(self.mode, "explore", self._over()) |
| 874 | 874 | |
| 875 | 875 | WHY_NOT_BEST = "Bester Zug" # Name der Nebenvariante (PGN-Kommentar vor ihrem ersten Zug) |
| 876 | - WHY_NOT_REFUTATION = "Warum nicht?" | |
| 876 | + WHY_NOT_REFUTATION = "Warum nicht {}?" # mit dem erklärten Zug: „Warum nicht 14. Le6?“ | |
| 877 | 877 | |
| 878 | 878 | def _why_not_known(self, ply): |
| 879 | 879 | """Steht „Warum nicht?“ zu Halbzug ``ply`` schon im Partiebaum (Zweig „Bester Zug“ davor)?""" |
| @@ -884,14 +884,15 @@ class OpeningMixin: | ||
| 884 | 884 | """Analysebrett auf die Gabelung vor Halbzug ``ply``: Pfeile „Partie“ und „Bester Zug“.""" |
| 885 | 885 | self._analysis_open_node(self._game_node(ply - 1)) |
| 886 | 886 | |
| 887 | - HINT_NAME = "Hinweis" | |
| 887 | + HINT_NAME = "Hinweis" # Schild am Pfeil; vor der Variante mit dem Zug: „Hinweis 15. Sd6+“ | |
| 888 | 888 | |
| 889 | 889 | def _hint_variation(self, tree): |
| 890 | 890 | """Dritte Hinweisstufe im Partiebaum: die Erklärung (explain.explain_job, Wurzel = Gegenwart) |
| 891 | 891 | als Nebenvariante „Hinweis“ an die Gegenwart, das Brett auf den Hinweiszug. Spielt man ihn |
| 892 | 892 | danach, wird er zum gespielten Zug (_game_tree), der Rest bleibt Nebenvariante.""" |
| 893 | 893 | present = self._game_node(len(self.board.move_stack) - 1) |
| 894 | - found = explain.merge(self.game_tree, present, tree, tree.game.variations, self.HINT_NAME) | |
| 894 | + name = f"{self.HINT_NAME} {notation.label(present.board(), tree.first().move, self._notation())}" | |
| 895 | + found = explain.merge(self.game_tree, present, tree, tree.game.variations, name) | |
| 895 | 896 | first = found[tree.first()] |
| 896 | 897 | self.game_tree.info(first).setdefault("label", self.HINT_NAME) # Schild am Pfeil |
| 897 | 898 | self._schedule_autosave() |
| @@ -903,7 +904,10 @@ class OpeningMixin: | ||
| 903 | 904 | dahinter (wo der Gegner sie nicht ohnehin gespielt hat); dann auf die Gabelung.""" |
| 904 | 905 | fork, played = self._game_node(ply - 1), self._game_node(ply) |
| 905 | 906 | explain.merge(self.game_tree, fork, tree, tree.game.variations[1:], self.WHY_NOT_BEST) |
| 906 | - explain.merge(self.game_tree, played, tree, tree.first().variations, self.WHY_NOT_REFUTATION) | |
| 907 | + # Der Name nennt den erklärten Zug: Die Widerlegung kann der Partie ein Stück folgen und erst | |
| 908 | + # später abzweigen; dann steht sie unter einem Zug des Gegners und gehört doch zu diesem. | |
| 909 | + name = self.WHY_NOT_REFUTATION.format(notation.label(fork.board(), played.move, self._notation())) | |
| 910 | + explain.merge(self.game_tree, played, tree, tree.first().variations, name) | |
| 907 | 911 | self._schedule_autosave() |
| 908 | 912 | self._why_not_jump(ply) |
| 909 | 913 | |
modified tests/test_warum_variante.py +15 −3
| @@ -62,7 +62,18 @@ class WhyNotTest(unittest.TestCase): | ||
| 62 | 62 | win._why_not_variation(2, self.tree) |
| 63 | 63 | after = win._game_node(2) |
| 64 | 64 | self.assertEqual([(c.move, c.starting_comment) for c in after.variations], |
| 65 | - [(m("d7d6"), ""), (m("d8g5"), "Warum nicht?")]) | |
| 65 | + [(m("d7d6"), ""), (m("d8g5"), "Warum nicht 2. Ke2?")]) | |
| 66 | + | |
| 67 | + def test_widerlegung_die_der_partie_folgt_traegt_den_erklaerten_zug(self): | |
| 68 | + """Nutzerbericht 24.11.2026: Folgt die Widerlegung der Partie zwei Züge und zweigt erst dann | |
| 69 | + ab, steht sie unter einem Zug des Gegners. Ohne Zug im Namen sah „Warum nicht?“ dort aus, | |
| 70 | + als ginge es um den Zug des Gegners.""" | |
| 71 | + win = Window("e4", "e5", "Ke2", "d6", "d3", "Nc6") | |
| 72 | + tree = why_not(win.board, 2, m("g1f3"), refutation=[m("d7d6"), m("d2d3"), m("d8g5")]) | |
| 73 | + win._why_not_variation(2, tree) | |
| 74 | + deeper = win._game_node(4).variations # nach 3. d3: Partie 3… Sc6, Widerlegung 3… Dg5 | |
| 75 | + self.assertEqual([(c.move, c.starting_comment) for c in deeper], | |
| 76 | + [(m("b8c6"), ""), (m("d8g5"), "Warum nicht 2. Ke2?")]) | |
| 66 | 77 | |
| 67 | 78 | def test_twice_adds_nothing(self): |
| 68 | 79 | win = self.win |
| @@ -94,7 +105,8 @@ class HintTest(unittest.TestCase): | ||
| 94 | 105 | win._hint_variation(self.tree) |
| 95 | 106 | present = win._game_node(3) |
| 96 | 107 | hint = present.variations[0] |
| 97 | - self.assertEqual((hint.move, hint.starting_comment), (m("f1c4"), "Hinweis")) | |
| 108 | + self.assertEqual((hint.move, hint.starting_comment), (m("f1c4"), "Hinweis 3. Lc4")) | |
| 109 | + self.assertEqual(win.game_tree.label(hint), "Hinweis") # Schild am Pfeil bleibt kurz | |
| 98 | 110 | self.assertIs(win.demo["node"], hint) |
| 99 | 111 | self.assertEqual(zustand.violations(win), []) |
| 100 | 112 | |
| @@ -119,7 +131,7 @@ class HintTest(unittest.TestCase): | ||
| 119 | 131 | win._game_tree() |
| 120 | 132 | present = win._game_node(3) |
| 121 | 133 | self.assertEqual([c.move for c in present.variations], [m("f1b5"), m("f1c4")]) |
| 122 | - self.assertEqual(present.variations[1].starting_comment, "Hinweis") | |
| 134 | + self.assertEqual(present.variations[1].starting_comment, "Hinweis 3. Lc4") | |
| 123 | 135 | |
| 124 | 136 | |
| 125 | 137 | if __name__ == "__main__": |
modified tests/test_zustand_regression.py +4 −1
| @@ -16,7 +16,7 @@ import gi | ||
| 16 | 16 | gi.require_version("Gtk", "4.0") |
| 17 | 17 | gi.require_version("Adw", "1") |
| 18 | 18 | |
| 19 | -from schach import explain, zustand # noqa: E402 | |
| 19 | +from schach import explain, notation, zustand # noqa: E402 | |
| 20 | 20 | from schach.review import ReviewMixin # noqa: E402 |
| 21 | 21 | from schach.training import OpeningMixin # noqa: E402 |
| 22 | 22 | |
| @@ -88,6 +88,9 @@ class FakeWindow(OpeningMixin, ReviewMix | ||
| 88 | 88 | def _coach_show(self): |
| 89 | 89 | pass |
| 90 | 90 | |
| 91 | + def _notation(self): | |
| 92 | + return notation.DEFAULT | |
| 93 | + | |
| 91 | 94 | def _playback_controls(self): |
| 92 | 95 | pass |
| 93 | 96 | |