komi in info
This commit is contained in:
1 parent
ef24fd3bf2
commit
be5a588d68
7 files changed
+41
-28
No files matched your search
+13
-5
@@ -207,8 +207,11 @@ class Game:
|
||||
return sum(self.chains, [])
|
||||
|
||||
@property
|
||||
def ended(self):
|
||||
return self.current_node.parent and self.current_node.is_pass and self.current_node.parent.is_pass
|
||||
def end_result(self):
|
||||
if self.current_node.end_state:
|
||||
return self.current_node.end_state
|
||||
if self.current_node.parent and self.current_node.is_pass and self.current_node.parent.is_pass:
|
||||
return self.manual_score or i18n._("board-game-end")
|
||||
|
||||
@property
|
||||
def prisoner_count(
|
||||
@@ -283,13 +286,17 @@ class Game:
|
||||
def player_name(player_info):
|
||||
return f"{i18n._(player_info.player_type)} ({i18n._(player_info.player_subtype)})"
|
||||
|
||||
root_properties = self.root.properties
|
||||
x_properties = {}
|
||||
if "KaTrain" in self.root.get_property("AP", ""):
|
||||
for bw in "BW":
|
||||
self.root.set_property("P" + bw, player_name(self.katrain.players_info[bw]))
|
||||
x_properties["P" + bw] = player_name(self.katrain.players_info[bw])
|
||||
player_info = self.katrain.players_info[bw]
|
||||
if player_info.player_type == PLAYER_AI:
|
||||
self.root.set_property(bw + "R", rank_label(player_info.calculated_rank))
|
||||
|
||||
x_properties[bw + "R"] = rank_label(player_info.calculated_rank)
|
||||
if "+" in str(self.end_result):
|
||||
x_properties["RE"] = self.end_result
|
||||
self.root.properties = {**root_properties, **{k: [v] for k, v in x_properties.items()}}
|
||||
player_names = {bw: re.sub(r"['<>:\"/\\|?*]", "", self.root.get_property("P" + bw, bw)) for bw in "BW"}
|
||||
game_name = f"katrain_{player_names['B']} vs {player_names['W']} {self.game_id}"
|
||||
file_name = os.path.abspath(os.path.join(path, f"{game_name}.sgf"))
|
||||
@@ -303,6 +310,7 @@ class Game:
|
||||
)
|
||||
with open(file_name, "w", encoding="utf-8") as f:
|
||||
f.write(sgf)
|
||||
self.root.properties = root_properties
|
||||
return i18n._("sgf written").format(file_name=file_name)
|
||||
|
||||
def analyze_extra(self, mode, **kwargs):
|
||||
|
||||
@@ -23,6 +23,7 @@ class GameNode(SGFNode):
|
||||
self.time_used = 0
|
||||
self.analysis_visits_requested = 0
|
||||
self.undo_threshold = random.random() # for fractional undos
|
||||
self.end_state = None
|
||||
|
||||
def sgf_properties(self, save_comments_player=None, save_comments_class=None, eval_thresholds=None):
|
||||
properties = copy.copy(super().sgf_properties())
|
||||
@@ -151,6 +152,8 @@ class GameNode(SGFNode):
|
||||
def comment(self, sgf=False, teach=False, details=False, interactive=True):
|
||||
single_move = self.move
|
||||
if not self.parent or not single_move: # root
|
||||
if self.root:
|
||||
return f"{i18n._('komi')}: {self.komi:.1f}\n{i18n._('ruleset')}: {i18n._(self.get_property('RU','Japanese').lower())}\n"
|
||||
return ""
|
||||
|
||||
text = i18n._("move").format(number=self.depth) + f": {single_move.player} {single_move.gtp()}\n"
|
||||
@@ -193,8 +196,10 @@ class GameNode(SGFNode):
|
||||
text += "\n" + i18n._("Info:AI thoughts").format(thoughts=self.ai_thoughts)
|
||||
else:
|
||||
text = i18n._("No analysis available") if sgf else i18n._("Analyzing move...")
|
||||
|
||||
if "C" in self.properties:
|
||||
text += "\n[u]SGF Comments:[/u]\n" + "\n".join(self.properties["C"])
|
||||
|
||||
return text
|
||||
|
||||
@property
|
||||
@@ -258,3 +263,6 @@ class GameNode(SGFNode):
|
||||
moves = [(policy_grid[y][x], Move((x, y), player=self.next_player)) for x in range(szx) for y in range(szy)]
|
||||
moves.append((self.policy[-1], Move(None, player=self.next_player)))
|
||||
return sorted(moves, key=lambda mp: -mp[0])
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user