back to branching point

This commit is contained in:
Sander Land committed 2020-12-05 16:44:39 +01:00
1 parent 4d3c134e49
commit a02697c783
6 files changed
+27 -16

No files matched your search

+3 -2
View File
@@ -179,10 +179,11 @@ In addition to shortcuts mentioned above and those shown in the main menu:
* **[p]**: Pass
* **[b]**: Pause/Resume timer
* **[arrow left]** or **[z]**: Undo move. Hold alt for 10 moves at a time, or ctrl to skip to the start.
* **[arrow right]** or **[x]**: Redo move. Hold alt for 10 moves at a time, or ctrl to skip to the start.
* **[arrow right]** or **[x]**: Redo move. Hold alt for 10 moves at a time, or ctrl to skip to the end.
* **[arrow up/down]** Switch branch, as would be expected from the move tree.
* **[n]** As in clicking the red arrow, go to one move before the next mistake (orange or worse) by a human player.
* **[home/end]** Go to the beginning/end of the game.
* **[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.
* **[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.
+1
View File
@@ -499,6 +499,7 @@ class KaTrainGui(Screen, KaTrainBase):
"i": ("insert-mode",),
"p": ("play", None),
"n": ("next-mistake",),
"b": ("undo", "branch"),
"down": ("switch-branch", 1),
"up": ("switch-branch", -1),
"f5": ("timer-popup",),
-1
View File
@@ -112,7 +112,6 @@ class KataGoEngine:
self.terminate_query(query_id)
self.queries = {}
def restart(self):
self.queries = {}
self.shutdown(finish=False)
+11 -4
View File
@@ -259,10 +259,15 @@ class Game:
self.current_node = cn.parent
self._calculate_groups()
return
break_on_branch = False
if n_times == "branch":
n_times = 9999
break_on_branch = True
for _ in range(n_times):
if not cn.is_root:
cn = cn.parent
if break_on_branch and len(cn.children) > 1:
break
self.set_current_node(cn)
def redo(self, n_times=1, stop_on_mistake=None):
@@ -420,13 +425,13 @@ class Game:
x1, x2, y1, y2 = region_of_interest
xmin, xmax = min(x1, x2), max(x1, x2)
ymin, ymax = min(y1, y2), max(y1, y2)
if not (xmin==xmax and ymin==ymax):
szx, szy = self.board_size
if not (xmin == xmax and ymin == ymax) and not (xmax - xmin + 1 >= szx and ymax - ymin + 1 >= szy):
self.region_of_interest = [xmin, xmax, ymin, ymax]
else:
self.region_of_interest = None
self.katrain.controls.set_status("", OUTPUT_INFO)
def analyze_extra(self, mode, **kwargs):
stones = {s.coords for s in self.stones}
cn = self.current_node
@@ -443,7 +448,9 @@ class Game:
visits = cn.analysis_visits_requested + engine.config["max_visits"]
self.katrain.controls.set_status(i18n._("extra analysis").format(visits=visits), STATUS_ANALYSIS)
self.katrain.controls.set_status(i18n._("extra analysis").format(visits=visits), STATUS_ANALYSIS)
cn.analyze(engine, visits=visits, priority=-1_000, region_of_interest=self.region_of_interest, time_limit=False)
cn.analyze(
engine, visits=visits, priority=-1_000, region_of_interest=self.region_of_interest, time_limit=False
)
return
if mode == "game":
nodes = self.root.nodes_in_tree
+6 -8
View File
@@ -462,12 +462,11 @@ class BadukPanWidget(Widget):
Color(*LIGHTER_BACKGROUND_COLOR)
Line(
rectangle=(
self.gridpos_x[xmin] - self.grid_size/6,
self.gridpos_y[ymin] - self.grid_size/6,
(xmax - xmin + 1/3) * self.grid_size,
(ymax - ymin + 1/3) * self.grid_size,
self.gridpos_x[xmin] - self.grid_size / 3,
self.gridpos_y[ymin] - self.grid_size / 3,
(xmax - xmin + 2 / 3) * self.grid_size,
(ymax - ymin + 2 / 3) * self.grid_size,
),
dash_length=10,dash_offset=10,
width=width,
)
@@ -627,7 +626,7 @@ class BadukPanWidget(Widget):
if self.selecting_region_of_interest and len(self.region_of_interest) == 4:
x1, x2, y1, y2 = self.region_of_interest
self.draw_roi_box([min(x1, x2), max(x1, x2), min(y1, y2), max(y1, y2)],width=2)
self.draw_roi_box([min(x1, x2), max(x1, x2), min(y1, y2), max(y1, y2)], width=dp(2))
else:
# hover next move ghost stone
if self.ghost_stone:
@@ -641,8 +640,7 @@ class BadukPanWidget(Widget):
self.draw_pv(pv, node, up_to_move)
if self.katrain.game.region_of_interest:
self.draw_roi_box(self.katrain.game.region_of_interest, width=1) # dashed
self.draw_roi_box(self.katrain.game.region_of_interest, width=dp(1.25))
def animate_pv(self, _dt):
if self.animating_pv:
+6 -1
View File
@@ -92,7 +92,12 @@ class ControlsPanel(BoxLayout):
def set_status(self, msg, status_type, at_node=None, check_level=True):
at_node = at_node or self.katrain and self.katrain.game and self.katrain.game.current_node
if at_node != self.status_state[2] or not check_level or int(status_type) >= int(self.status_state[1]) or msg == "":
if (
at_node != self.status_state[2]
or not check_level
or int(status_type) >= int(self.status_state[1])
or msg == ""
):
if self.status_state != (msg, status_type, at_node): # prevent loop if error in update eval
Clock.schedule_once(self.update_evaluation, 0)
self.status_state = (msg, status_type, at_node)