previous mistake
This commit is contained in:
1 parent
03e93568c7
commit
170a74bcea
5 files changed
+31
-16
No files matched your search
@@ -189,7 +189,8 @@ In addition to shortcuts mentioned above and those shown in the main menu:
|
||||
* **[Ctrl-delete]** Delete current node.
|
||||
* **[c]** Collapse/Uncollapse the branch from the current node to the previous branching point.
|
||||
* **[b]** Go back to the previous branching point.
|
||||
* **[n]** As in clicking the red arrow, go to one move before the next mistake (orange or worse) by a human player.
|
||||
* **[n]** As in clicking the forward red arrow, go to one move before the next mistake (orange or worse) by a human player.
|
||||
* **[Shift-n]** As in clicking the backward red arrow, go to one move before the previous mistake.
|
||||
* **[scroll up]**: Undo move. Only works when hovering the cursor over the board.
|
||||
* **[scroll down]**: Redo move. Only works when hovering the cursor over the board.
|
||||
* **[click on a move]**: See detailed statistics for a previous move, along with expected variation that was best instead of this move.
|
||||
|
||||
+9
-8
@@ -313,9 +313,9 @@ class KaTrainGui(Screen, KaTrainBase):
|
||||
self.board_gui.animating_pv = None
|
||||
self.game.redo(n_times)
|
||||
|
||||
def _do_next_mistake(self):
|
||||
def _do_find_mistake(self, fn="redo"):
|
||||
self.board_gui.animating_pv = None
|
||||
self.game.redo(999, stop_on_mistake=self.config("trainer/eval_thresholds")[-4])
|
||||
getattr(self.game, fn)(9999, stop_on_mistake=self.config("trainer/eval_thresholds")[-4])
|
||||
|
||||
def _do_cycle_children(self, *args):
|
||||
self.board_gui.animating_pv = None
|
||||
@@ -480,7 +480,7 @@ class KaTrainGui(Screen, KaTrainBase):
|
||||
self.engine, analyze_fast=False
|
||||
) # speed up result for looking at end of game
|
||||
self._do_new_game(move_tree=move_tree, analyze_fast=True)
|
||||
self("redo", 999)
|
||||
self("redo", 9999)
|
||||
self.log("Imported game from clipboard.", OUTPUT_INFO)
|
||||
|
||||
def on_touch_up(self, touch):
|
||||
@@ -514,7 +514,6 @@ class KaTrainGui(Screen, KaTrainBase):
|
||||
"i": ("insert-mode",),
|
||||
"p": ("play", None),
|
||||
"l": ("play-to-end",),
|
||||
"n": ("next-mistake",),
|
||||
"b": ("undo", "branch"),
|
||||
"down": ("switch-branch", 1),
|
||||
"up": ("switch-branch", -1),
|
||||
@@ -561,15 +560,17 @@ class KaTrainGui(Screen, KaTrainBase):
|
||||
elif keycode[1] in ["`", "~", "f12"]:
|
||||
self.zen = (self.zen + 1) % 3
|
||||
elif keycode[1] in ["left", "z"]:
|
||||
self("undo", 1 + shift_pressed * 9 + ctrl_pressed * 999)
|
||||
self("undo", 1 + shift_pressed * 9 + ctrl_pressed * 9999)
|
||||
elif keycode[1] in ["right", "x"]:
|
||||
self("redo", 1 + shift_pressed * 9 + ctrl_pressed * 999)
|
||||
self("redo", 1 + shift_pressed * 9 + ctrl_pressed * 9999)
|
||||
elif keycode[1] == "home":
|
||||
self("undo", 999)
|
||||
self("undo", 9999)
|
||||
elif keycode[1] == "end":
|
||||
self("redo", 999)
|
||||
self("redo", 9999)
|
||||
elif keycode[1] == "pageup":
|
||||
self.controls.move_tree.make_selected_node_main_branch()
|
||||
elif keycode[1] == "n":
|
||||
self("find-mistake", "undo" if shift_pressed else "redo")
|
||||
elif keycode[1] == "delete" and ctrl_pressed:
|
||||
self.controls.move_tree.delete_selected_node()
|
||||
elif keycode[1] == "c" and not ctrl_pressed:
|
||||
|
||||
+11
-3
@@ -257,10 +257,10 @@ class Game:
|
||||
self.current_node = node
|
||||
self._calculate_groups()
|
||||
|
||||
def undo(self, n_times=1):
|
||||
def undo(self, n_times=1, stop_on_mistake=None):
|
||||
# allow undo/delete only in insert mode
|
||||
cn = self.current_node # avoid race conditions
|
||||
if self.insert_mode:
|
||||
if self.insert_mode: # in insert mode, undo = delete
|
||||
if n_times == 1 and cn not in self.insert_after.nodes_from_root:
|
||||
cn.parent.children = [c for c in cn.parent.children if c != cn]
|
||||
self.current_node = cn.parent
|
||||
@@ -270,7 +270,15 @@ class Game:
|
||||
if n_times == "branch":
|
||||
n_times = 9999
|
||||
break_on_branch = True
|
||||
for _ in range(n_times):
|
||||
for move in range(n_times):
|
||||
if (
|
||||
stop_on_mistake is not None
|
||||
and cn.points_lost is not None
|
||||
and cn.points_lost >= stop_on_mistake
|
||||
and self.katrain.players_info[cn.player].player_type != PLAYER_AI
|
||||
):
|
||||
self.set_current_node(cn.parent)
|
||||
return
|
||||
if cn.shortcut_from:
|
||||
cn = cn.shortcut_from
|
||||
elif not cn.is_root:
|
||||
|
||||
+8
-4
@@ -186,9 +186,13 @@
|
||||
pos_hint: {'center_x': 0.5,'center_y':0.5}
|
||||
Label:
|
||||
size_hint: 0.075, 0.5
|
||||
NavIconButton:
|
||||
icon: 'Previous-Mistake.png'
|
||||
color: Theme.MISTAKE_BUTTON_COLOR
|
||||
on_press: root.katrain('find-mistake','undo')
|
||||
NavIconButton:
|
||||
icon: 'Previous-End.png'
|
||||
on_press: root.katrain('undo',999)
|
||||
on_press: root.katrain('undo',9999)
|
||||
NavIconButton:
|
||||
icon: 'Previous-5.png'
|
||||
on_press: root.katrain('undo',10)
|
||||
@@ -218,11 +222,11 @@
|
||||
on_press: root.katrain('redo',10)
|
||||
NavIconButton:
|
||||
icon: 'Next-End.png'
|
||||
on_press: root.katrain('redo',999)
|
||||
on_press: root.katrain('redo',9999)
|
||||
NavIconButton:
|
||||
icon: 'Next-Mistake.png'
|
||||
color: [0.79,0.06,0.06,1]
|
||||
on_press: root.katrain('next-mistake')
|
||||
color: Theme.MISTAKE_BUTTON_COLOR
|
||||
on_press: root.katrain('find-mistake','redo')
|
||||
ClickableLabel:
|
||||
pos_hint: {'center_x': 0.85,'center_y':0.5}
|
||||
size_hint: None, 1
|
||||
|
||||
@@ -46,6 +46,7 @@ class Theme:
|
||||
MENU_ITEM_SHORTCUT_COLOR = LIGHT_GREY
|
||||
PLAY_ANALYZE_TAB_COLOR = YELLOW
|
||||
INPUT_FONT_COLOR = WHITE
|
||||
MISTAKE_BUTTON_COLOR = [0.79, 0.06, 0.06, 1]
|
||||
|
||||
# gui spacing
|
||||
CP_SPACING = 6
|
||||
|
||||
Reference in new issue
Block a user