komi display, fix fox

This commit is contained in:
Sander Land committed 2020-08-28 22:29:43 +02:00
1 parent fd67ea8491
commit 341d016348
7 files changed
+35 -11

No files matched your search

+1
View File
@@ -159,6 +159,7 @@ class KaTrainGui(Screen, KaTrainBase):
self.board_controls.mid_circles_container.add_widget(top)
self.board_controls.branch.disabled = not cn.parent or len(cn.parent.children) <= 1
self.controls.players["W"].captures = prisoners["W"]
self.controls.players["W"].komi = self.game.komi
self.controls.players["B"].captures = prisoners["B"]
# update engine status dot
+2 -2
View File
@@ -61,8 +61,8 @@ class KaTrainBase:
if self.debug_level >= OUTPUT_DEBUG:
Config.set("kivy", "log_enable", 1)
Config.set("kivy", "log_level", "debug")
if self.debug_level >= OUTPUT_EXTRA_DEBUG:
Config.set("kivy", "log_level", "trace")
# if self.debug_level >= OUTPUT_EXTRA_DEBUG:
# Config.set("kivy", "log_level", "trace")
self.players_info = {"B": Player("B"), "W": Player("W")}
self.reset_players()
+3 -2
View File
@@ -226,8 +226,9 @@ class KataGoEngine:
next_move: Optional[GameNode] = None,
extra_settings: Optional[Dict] = None,
):
moves = [m for node in analysis_node.nodes_from_root for m in node.moves]
initial_stones = analysis_node.root.placements
nodes = analysis_node.nodes_from_root
moves = [m for node in nodes for m in node.moves]
initial_stones = [m for node in nodes for m in node.placements]
if next_move:
moves.append(next_move)
if ownership is None:
+8 -2
View File
@@ -55,7 +55,11 @@ class Game:
self.root = move_tree
self.komi = self.root.komi
handicap = int(self.root.get_property("HA", 0))
if handicap >= 2 and not self.root.placements:
if (
handicap >= 2
and not self.root.placements
and not (not self.root.move_with_placements and self.root.children and self.root.children[0].placements)
): # not really according to sgf, and not sure if still needed, last clause for fox
self.root.place_handicap_stones(handicap)
else:
board_size = katrain.config("game/size")
@@ -310,7 +314,9 @@ class Game:
if mode == "extra":
if kwargs.get("continuous", False):
visits = max(engine.config["max_visits"], math.ceil(cn.analysis_visits_requested * 1.25))
visits = min(
1_000_000_000, max(engine.config["max_visits"], math.ceil(cn.analysis_visits_requested * 1.25))
)
else:
visits = cn.analysis_visits_requested + engine.config["max_visits"]
self.katrain.controls.set_status(i18n._("extra analysis").format(visits=visits), STATUS_ANALYSIS)
+8 -2
View File
@@ -333,9 +333,15 @@ class SGF:
match = re.search(cls.SGF_PAT, input_str)
clipped_str = match.group() if match else input_str
root = cls(clipped_str).root
# Fix weird FoxGo server KM values
if "foxwq" in root.get_list_property("AP"):
fixed_komi = 0.5 if root.get_property("HA") == 1 else 7.5
root.set_property("KM", fixed_komi)
if int(root.get_property("HA", 0)) >= 1:
corrected_komi = 0.5
elif root.get_property("RU").lower() in ["chinese", "cn"]:
corrected_komi = 7.5
else:
corrected_komi = 6.5
root.set_property("KM", corrected_komi)
return root
@classmethod
+12 -3
View File
@@ -277,16 +277,25 @@
<PlayerInfo>:
captures: 0
player: 'B'
komi: 0
player_type: 'player:human'
player_subtype: 'game:normal'
background_color: BOX_BACKGROUND_COLOR if self.active else BACKGROUND_COLOR
outline_color: BOX_BACKGROUND_COLOR
outline_width: 2
padding: [2*CP_PADDING,CP_PADDING,CP_PADDING,CP_PADDING]
CircleWithText:
player: root.player
text: str(root.captures)
BoxLayout:
size_hint: 0.32, 1
orientation: 'vertical'
CircleWithText:
player: root.player
text: str(root.captures)
Label:
size_hint: 1,0.25
halign: 'center'
valign: 'middle'
font_size: self.height
text: "%s: %.1f" % (i18n._('komi'), root.komi) if root.player=='W' else ''
BoxLayout:
size_hint: 0.75, 1
pos_hint: {'x':0,'y':0}
+1
View File
@@ -338,6 +338,7 @@ class PlayerInfo(MDBoxLayout, BackgroundMixin):
captures = NumericProperty(0)
player = OptionProperty("B", options=["B", "W"])
player_type = StringProperty("Player")
komi = NumericProperty(0)
player_subtype = StringProperty("")
name = StringProperty("", allownone=True)
rank = StringProperty("", allownone=True)