new game fix
This commit is contained in:
1 parent
86fc714a94
commit
a3815cb47a
21 files changed
+63
-30
No files matched your search
@@ -166,7 +166,9 @@ Keyboard shortcuts are shown with **[key]**.
|
||||
* **[s]**: Equalize visits: Re-evaluate all currently shown next moves with the same visits as the current top move. Useful to increase confidence in the suggestions with high uncertainty.
|
||||
* **[d]**: Analyze all moves: Evaluate all possible next moves. This can take a bit of time even though 'fast_visits' is used, but can be useful to see how many reasonable next moves are available.
|
||||
* **[f]**: Find alternatives: Increases analysis of current candidate moves to at least the 'fast visits' level, and request a new query that excludes all current candidate moves.
|
||||
* **[g]**: Find local responses: Searches within 5 spaces of the last move only.
|
||||
* **[g]**: Select area of interest: set an area and search only for moves in this box, including variations. Good for solving tsumegos.
|
||||
* **[i]**: Start insertion mode. Allows you to insert moves, to improve analysis when both players ignore an important exchange or life and death situation. Press again to stop inserting and copy the rest of the branch.
|
||||
* **[l]**: Play out the game until the end and add as a collapsed branch, to visualize the potential effect of mistakes. This is done in the background, and can be started at several nodes at once when comparing the results at different starting positions.
|
||||
* **[spacebar]**: Turn continuous analysis on/off. This will continuously improve analysis of the current position, similar to Lizzie's 'pondering', but only when there are no other queries going on.
|
||||
* **[enter]** AI move. Makes the AI move for the current player regardless of current player selection.
|
||||
|
||||
@@ -182,6 +184,9 @@ In addition to shortcuts mentioned above and those shown in the main menu:
|
||||
* **[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.
|
||||
* **[home/end]** Go to the beginning/end of the game.
|
||||
* **[pageup]** Make the currently selected node the main branch
|
||||
* **[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.
|
||||
* **[scroll up]**: Undo move. Only works when hovering the cursor over the board.
|
||||
|
||||
@@ -339,6 +339,7 @@ class KaTrainGui(Screen, KaTrainBase):
|
||||
).__self__
|
||||
self.new_game_popup.content.popup = self.new_game_popup
|
||||
self.new_game_popup.open()
|
||||
self.new_game_popup.content.update_from_current_game()
|
||||
|
||||
def _do_timer_popup(self):
|
||||
self.controls.timer.paused = True
|
||||
|
||||
@@ -535,18 +535,25 @@ class Game:
|
||||
def analyze_and_play_policy(node):
|
||||
nonlocal count, cn
|
||||
cand = node.candidate_moves
|
||||
if self.katrain.game is not self:
|
||||
return # a new game happened
|
||||
if cand:
|
||||
move = Move.from_gtp(cand[0]["move"], player=node.next_player)
|
||||
else:
|
||||
polmoves = node.policy_ranking
|
||||
move = polmoves[0][1] if polmoves else Move(None)
|
||||
|
||||
if move.is_pass:
|
||||
cn.add_shortcut(node)
|
||||
self.set_current_node(node)
|
||||
self.katrain.controls.set_status("", STATUS_INFO)
|
||||
return
|
||||
count += 1
|
||||
new_node = GameNode(parent=node, move=move)
|
||||
if node != cn:
|
||||
node.remove_shortcut()
|
||||
cn.add_shortcut(new_node)
|
||||
self.katrain.controls.move_tree.redraw_tree_trigger()
|
||||
|
||||
self.katrain.controls.set_status(i18n._("playtoend:status").format(num_moves=count), STATUS_INFO)
|
||||
|
||||
def set_analysis(result, _partial):
|
||||
|
||||
+5
-5
@@ -763,6 +763,11 @@
|
||||
icon: 'img/insert.png'
|
||||
shortcut: 'i'
|
||||
on_action: root.katrain("insert-mode")
|
||||
AnalysisMenuItem:
|
||||
text: i18n._("analysis:playtoend")
|
||||
icon: 'img/Finish.png'
|
||||
shortcut: 'l'
|
||||
on_action: root.katrain("play-to-end")
|
||||
AnalysisMenuItem:
|
||||
text: i18n._("analysis:game")
|
||||
icon: 'img/analysis.png'
|
||||
@@ -778,11 +783,6 @@
|
||||
icon: 'img/ai.png'
|
||||
shortcut: 'enter'
|
||||
on_action: root.katrain("ai-move")
|
||||
AnalysisMenuItem:
|
||||
text: i18n._("analysis:playtoend")
|
||||
icon: 'img/Finish.png'
|
||||
shortcut: 'l'
|
||||
on_action: root.katrain("play-to-end")
|
||||
|
||||
|
||||
<AnalysisControls>:
|
||||
|
||||
+26
-7
@@ -35,7 +35,6 @@ from katrain.core.lang import i18n, rank_label
|
||||
from katrain.core.utils import PATHS, find_package_resource
|
||||
from katrain.gui.kivyutils import BackgroundMixin, I18NSpinner
|
||||
from katrain.gui.style import DEFAULT_FONT, EVAL_COLORS
|
||||
from katrain.gui.widgets import RankGraph
|
||||
from katrain.gui.widgets.progress_loader import ProgressLoader
|
||||
|
||||
|
||||
@@ -249,14 +248,35 @@ class NewGamePopup(QuickConfigGui):
|
||||
self.player_setup.update_player_info(bw, info)
|
||||
|
||||
self.rules_spinner.value_refs = [name for abbr, name in katrain.engine.RULESETS_ABBR]
|
||||
Clock.schedule_once(self.update_from_current_game, 0.1)
|
||||
|
||||
def update_playerinfo(self):
|
||||
def normalized_rules(self):
|
||||
rules = self.katrain.game.root.get_property("RU", "japanese").strip().lower()
|
||||
for abbr, name in self.katrain.engine.RULESETS_ABBR:
|
||||
if abbr==rules or abbr==rules:
|
||||
return name
|
||||
|
||||
|
||||
def update_playerinfo(self,*args):
|
||||
for bw, player_setup in self.player_setup.players.items():
|
||||
name = self.player_name[bw].text
|
||||
if name:
|
||||
self.katrain.game.root.set_property("P" + bw, name)
|
||||
self.katrain.update_player(bw, **player_setup.player_type_dump)
|
||||
|
||||
def update_from_current_game(self):
|
||||
for bw in "BW":
|
||||
name = self.katrain.game.root.get_property("P" + bw, None)
|
||||
if name:
|
||||
self.player_name[bw].text = name
|
||||
komi = self.katrain.game.root.komi
|
||||
rules = self.normalized_rules()
|
||||
if komi is not None:
|
||||
self.km.text = str(komi)
|
||||
if rules is not None:
|
||||
self.rules_spinner.select_key(rules.strip())
|
||||
|
||||
|
||||
def update_config(self, save_to_file=True):
|
||||
super().update_config(save_to_file=save_to_file)
|
||||
self.katrain.log(f"New game settings: {self.katrain.config('game')}", OUTPUT_DEBUG)
|
||||
@@ -270,14 +290,13 @@ class NewGamePopup(QuickConfigGui):
|
||||
props = self.collect_properties(self)
|
||||
root = self.katrain.game.root
|
||||
changed = False
|
||||
for k, v in [("RU", props["game/rules"]), ("KM", props["game/komi"])]:
|
||||
current = root.get_property(k)
|
||||
if current != v:
|
||||
for k, currentval, newval in [("RU",self.normalized_rules(), props["game/rules"]), ("KM", root.komi, props["game/komi"])]:
|
||||
if currentval !=newval:
|
||||
changed = True
|
||||
self.katrain.log(
|
||||
f"Property {k} changed from {current} to {v}, triggering re-analysis of entire game.", OUTPUT_INFO
|
||||
f"Property {k} changed from {currentval} to {newval}, triggering re-analysis of entire game.", OUTPUT_INFO
|
||||
)
|
||||
self.katrain.game.root.set_property(k, v)
|
||||
self.katrain.game.root.set_property(k, newval)
|
||||
self.update_playerinfo()
|
||||
if changed:
|
||||
self.katrain.engine.on_new_game()
|
||||
|
||||
@@ -227,7 +227,7 @@ class MoveTree(ScrollView, BackgroundMixin):
|
||||
super().__init__(**kwargs)
|
||||
self.insert_node = None
|
||||
self.redraw_tree_trigger = Clock.create_trigger(
|
||||
lambda _dt: self.move_tree_canvas.draw_move_tree(self.current_node, self.insert_node)
|
||||
lambda _dt: self.move_tree_canvas.draw_move_tree(self.current_node, self.insert_node), 0.1
|
||||
)
|
||||
self.bind(current_node=self.redraw_tree_trigger, size=self.redraw_tree_trigger)
|
||||
|
||||
|
||||
Binary file not shown.
@@ -817,5 +817,5 @@ msgstr "Fast playout to game end"
|
||||
#. TODO - Status message
|
||||
msgid "playtoend:status"
|
||||
msgstr ""
|
||||
"Playing game to the end with policy strategy, please wait ... {num_moves} "
|
||||
"moves played."
|
||||
"Playing the game quickly to the end, please wait ... {num_moves} moved "
|
||||
"played.moves played."
|
||||
Binary file not shown.
@@ -11,7 +11,7 @@ msgid "menu:playersetup"
|
||||
msgstr "Player Setup"
|
||||
|
||||
msgid "menu:newgame"
|
||||
msgstr "New Game"
|
||||
msgstr "New Game/Change Rules"
|
||||
|
||||
msgid "menu:save"
|
||||
msgstr "Save Game"
|
||||
@@ -125,8 +125,8 @@ msgstr "Fast playout to game end"
|
||||
#. Status message
|
||||
msgid "playtoend:status"
|
||||
msgstr ""
|
||||
"Playing the game quickly to the end, please wait ... {num_moves} moved played."
|
||||
"moves played."
|
||||
"Playing the game quickly to the end, please wait ... {num_moves} moved "
|
||||
"played.moves played."
|
||||
|
||||
#. Keep improving current position analysis when there is nothing else to do
|
||||
msgid "analysis:continuous"
|
||||
|
||||
Binary file not shown.
@@ -824,5 +824,5 @@ msgstr "Fast playout to game end"
|
||||
#. TODO - Status message
|
||||
msgid "playtoend:status"
|
||||
msgstr ""
|
||||
"Playing game to the end with policy strategy, please wait ... {num_moves} "
|
||||
"moves played."
|
||||
"Playing the game quickly to the end, please wait ... {num_moves} moved "
|
||||
"played.moves played."
|
||||
Binary file not shown.
@@ -851,5 +851,5 @@ msgstr "Fast playout to game end"
|
||||
#. TODO - Status message
|
||||
msgid "playtoend:status"
|
||||
msgstr ""
|
||||
"Playing game to the end with policy strategy, please wait ... {num_moves} "
|
||||
"moves played."
|
||||
"Playing the game quickly to the end, please wait ... {num_moves} moved "
|
||||
"played.moves played."
|
||||
Binary file not shown.
@@ -808,5 +808,5 @@ msgstr "Fast playout to game end"
|
||||
#. TODO - Status message
|
||||
msgid "playtoend:status"
|
||||
msgstr ""
|
||||
"Playing game to the end with policy strategy, please wait ... {num_moves} "
|
||||
"moves played."
|
||||
"Playing the game quickly to the end, please wait ... {num_moves} moved "
|
||||
"played.moves played."
|
||||
Binary file not shown.
@@ -778,5 +778,5 @@ msgstr "Fast playout to game end"
|
||||
#. TODO - Status message
|
||||
msgid "playtoend:status"
|
||||
msgstr ""
|
||||
"Playing game to the end with policy strategy, please wait ... {num_moves} "
|
||||
"moves played."
|
||||
"Playing the game quickly to the end, please wait ... {num_moves} moved "
|
||||
"played.moves played."
|
||||
Binary file not shown.
@@ -814,5 +814,5 @@ msgstr "Fast playout to game end"
|
||||
#. TODO - Status message
|
||||
msgid "playtoend:status"
|
||||
msgstr ""
|
||||
"Playing game to the end with policy strategy, please wait ... {num_moves} "
|
||||
"moves played."
|
||||
"Playing the game quickly to the end, please wait ... {num_moves} moved "
|
||||
"played.moves played."
|
||||
@@ -375,6 +375,7 @@
|
||||
<NewGamePopup>:
|
||||
restart: restart
|
||||
rules_spinner: rules_spinner
|
||||
km: km
|
||||
player_setup: player_setup
|
||||
player_name: {"W": white_player_name, "B": black_player_name}
|
||||
PlayerSetupBlock:
|
||||
|
||||
Reference in new issue
Block a user