analysis alt fix, debug truncate
This commit is contained in:
1 parent
ffa75986f7
commit
409419f638
2 files changed
+25
-18
No files matched your search
+14
-14
@@ -11,7 +11,7 @@ from katrain.core.constants import (
|
|||||||
REPORT_DT,
|
REPORT_DT,
|
||||||
SGF_INTERNAL_COMMENTS_MARKER,
|
SGF_INTERNAL_COMMENTS_MARKER,
|
||||||
SGF_SEPARATOR_MARKER,
|
SGF_SEPARATOR_MARKER,
|
||||||
VERSION
|
VERSION,
|
||||||
)
|
)
|
||||||
from katrain.core.lang import i18n
|
from katrain.core.lang import i18n
|
||||||
from katrain.core.sgf_parser import Move, SGFNode
|
from katrain.core.sgf_parser import Move, SGFNode
|
||||||
@@ -182,11 +182,10 @@ class GameNode(SGFNode):
|
|||||||
region_of_interest=None,
|
region_of_interest=None,
|
||||||
report_every=REPORT_DT,
|
report_every=REPORT_DT,
|
||||||
):
|
):
|
||||||
additional_moves = bool(find_alternatives or region_of_interest)
|
|
||||||
engine.request_analysis(
|
engine.request_analysis(
|
||||||
self,
|
self,
|
||||||
callback=lambda result, partial_result: self.set_analysis(
|
callback=lambda result, partial_result: self.set_analysis(
|
||||||
result, refine_move, additional_moves, partial_result
|
result, refine_move, find_alternatives, region_of_interest, partial_result
|
||||||
),
|
),
|
||||||
priority=priority,
|
priority=priority,
|
||||||
visits=visits,
|
visits=visits,
|
||||||
@@ -216,6 +215,7 @@ class GameNode(SGFNode):
|
|||||||
analysis_json: Dict,
|
analysis_json: Dict,
|
||||||
refine_move: Optional[Move] = None,
|
refine_move: Optional[Move] = None,
|
||||||
additional_moves: bool = False,
|
additional_moves: bool = False,
|
||||||
|
region_of_interest=None,
|
||||||
partial_result: bool = False,
|
partial_result: bool = False,
|
||||||
):
|
):
|
||||||
if refine_move:
|
if refine_move:
|
||||||
@@ -224,25 +224,25 @@ class GameNode(SGFNode):
|
|||||||
{"pv": [refine_move.gtp()] + pvtail, **analysis_json["rootInfo"]}, refine_move.gtp()
|
{"pv": [refine_move.gtp()] + pvtail, **analysis_json["rootInfo"]}, refine_move.gtp()
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
if additional_moves:
|
if additional_moves: # additional moves: old order matters, ignore new order
|
||||||
for m in analysis_json["moveInfos"]:
|
for m in analysis_json["moveInfos"]:
|
||||||
del m["order"] # avoid changing order
|
del m["order"]
|
||||||
if refine_move is None and not additional_moves:
|
elif refine_move is None: # normal update: old moves to end, new order matters. also for region?
|
||||||
for move_dict in self.analysis["moves"].values():
|
for move_dict in self.analysis["moves"].values():
|
||||||
move_dict["order"] = 999 # old moves to end
|
move_dict["order"] = 999 # old moves to end
|
||||||
for move_analysis in analysis_json["moveInfos"]:
|
for move_analysis in analysis_json["moveInfos"]:
|
||||||
self.update_move_analysis(move_analysis, move_analysis["move"])
|
self.update_move_analysis(move_analysis, move_analysis["move"])
|
||||||
self.analysis["ownership"] = analysis_json.get("ownership")
|
self.analysis["ownership"] = analysis_json.get("ownership")
|
||||||
self.analysis["policy"] = analysis_json.get("policy")
|
self.analysis["policy"] = analysis_json.get("policy")
|
||||||
if not additional_moves:
|
if not additional_moves and not region_of_interest:
|
||||||
self.analysis["root"] = analysis_json["rootInfo"]
|
self.analysis["root"] = analysis_json["rootInfo"]
|
||||||
if self.parent and self.move:
|
if self.parent and self.move:
|
||||||
analysis_json["rootInfo"]["pv"] = [self.move.gtp()] + (
|
analysis_json["rootInfo"]["pv"] = [self.move.gtp()] + (
|
||||||
analysis_json["moveInfos"][0]["pv"] if analysis_json["moveInfos"] else []
|
analysis_json["moveInfos"][0]["pv"] if analysis_json["moveInfos"] else []
|
||||||
)
|
)
|
||||||
self.parent.update_move_analysis(
|
self.parent.update_move_analysis(
|
||||||
analysis_json["rootInfo"], self.move.gtp()
|
analysis_json["rootInfo"], self.move.gtp()
|
||||||
) # update analysis in parent for consistency
|
) # update analysis in parent for consistency
|
||||||
is_normal_query = refine_move is None and not additional_moves
|
is_normal_query = refine_move is None and not additional_moves
|
||||||
self.analysis["completed"] = self.analysis["completed"] or (is_normal_query and not partial_result)
|
self.analysis["completed"] = self.analysis["completed"] or (is_normal_query and not partial_result)
|
||||||
|
|
||||||
|
|||||||
+11
-4
@@ -31,7 +31,7 @@ from katrain.core.constants import (
|
|||||||
)
|
)
|
||||||
from katrain.core.game import Move
|
from katrain.core.game import Move
|
||||||
from katrain.core.lang import i18n
|
from katrain.core.lang import i18n
|
||||||
from katrain.core.utils import evaluation_class, format_visits, var_to_grid
|
from katrain.core.utils import evaluation_class, format_visits, var_to_grid, json_truncate_arrays
|
||||||
from katrain.gui.kivyutils import draw_circle, draw_text, cached_texture
|
from katrain.gui.kivyutils import draw_circle, draw_text, cached_texture
|
||||||
from katrain.gui.popups import I18NPopup, ReAnalyzeGamePopup
|
from katrain.gui.popups import I18NPopup, ReAnalyzeGamePopup
|
||||||
from katrain.gui.theme import Theme
|
from katrain.gui.theme import Theme
|
||||||
@@ -186,9 +186,16 @@ class BadukPanWidget(Widget):
|
|||||||
katrain.game.set_current_node(nodes_here[-1].parent)
|
katrain.game.set_current_node(nodes_here[-1].parent)
|
||||||
katrain.update_state()
|
katrain.update_state()
|
||||||
else: # load comments & pv
|
else: # load comments & pv
|
||||||
katrain.log(f"\nAnalysis:\n{nodes_here[-1].analysis}", OUTPUT_EXTRA_DEBUG)
|
katrain.log(
|
||||||
katrain.log(f"\nParent Analysis:\n{nodes_here[-1].parent.analysis}", OUTPUT_EXTRA_DEBUG)
|
f"\nAnalysis:\n{json_truncate_arrays(nodes_here[-1].analysis,lim=5)}", OUTPUT_EXTRA_DEBUG
|
||||||
katrain.log(f"\nRoot Stats:\n{nodes_here[-1].analysis['root']}", OUTPUT_DEBUG)
|
)
|
||||||
|
katrain.log(
|
||||||
|
f"\nParent Analysis:\n{json_truncate_arrays(nodes_here[-1].parent.analysis,lim=5)}",
|
||||||
|
OUTPUT_EXTRA_DEBUG,
|
||||||
|
)
|
||||||
|
katrain.log(
|
||||||
|
f"\nRoot Stats:\n{json_truncate_arrays(nodes_here[-1].analysis['root'],lim=5)}", OUTPUT_DEBUG
|
||||||
|
)
|
||||||
katrain.controls.info.text = nodes_here[-1].comment(sgf=True)
|
katrain.controls.info.text = nodes_here[-1].comment(sgf=True)
|
||||||
katrain.controls.active_comment_node = nodes_here[-1]
|
katrain.controls.active_comment_node = nodes_here[-1]
|
||||||
if nodes_here[-1].parent.analysis_exists:
|
if nodes_here[-1].parent.analysis_exists:
|
||||||
|
|||||||
Reference in new issue
Block a user