player names
This commit is contained in:
1 parent
f0a239c559
commit
32acd7f067
7 files changed
+42
-11
No files matched your search
+2
-1
@@ -216,6 +216,8 @@ class KaTrainGui(Screen, KaTrainBase):
|
||||
|
||||
def update_player(self, bw, **kwargs):
|
||||
super().update_player(bw, **kwargs)
|
||||
if self.game:
|
||||
self.players_info[bw].name = self.game.root.get_property("P" + bw)
|
||||
if self.controls:
|
||||
self.controls.update_players()
|
||||
self.update_state()
|
||||
@@ -265,7 +267,6 @@ class KaTrainGui(Screen, KaTrainBase):
|
||||
player_info.player_subtype = PLAYING_NORMAL
|
||||
player_info.sgf_rank = move_tree.root.get_property(bw + "R")
|
||||
player_info.calculated_rank = None
|
||||
player_info.name = move_tree.root.get_property("P" + bw)
|
||||
self.update_player(bw)
|
||||
self.controls.graph.initialize_from_game(self.game.root)
|
||||
# self.controls.rank_graph.initialize_from_game(self.game.root)
|
||||
|
||||
@@ -229,4 +229,11 @@ TOP_MOVE_WINRATE = "winrate"
|
||||
TOP_MOVE_VISITS = "visits"
|
||||
TOP_MOVE_NOTHING = "<nothing>"
|
||||
|
||||
TOP_MOVE_OPTIONS = [TOP_MOVE_DELTA_SCORE, TOP_MOVE_SCORE, TOP_MOVE_DELTA_WINRATE, TOP_MOVE_WINRATE, TOP_MOVE_VISITS, TOP_MOVE_NOTHING]
|
||||
TOP_MOVE_OPTIONS = [
|
||||
TOP_MOVE_DELTA_SCORE,
|
||||
TOP_MOVE_SCORE,
|
||||
TOP_MOVE_DELTA_WINRATE,
|
||||
TOP_MOVE_WINRATE,
|
||||
TOP_MOVE_VISITS,
|
||||
TOP_MOVE_NOTHING,
|
||||
]
|
||||
@@ -15,6 +15,7 @@ from katrain.core.constants import (
|
||||
STATUS_ANALYSIS,
|
||||
STATUS_INFO,
|
||||
STATUS_TEACHING,
|
||||
PLAYER_HUMAN,
|
||||
)
|
||||
from katrain.core.engine import KataGoEngine
|
||||
from katrain.core.game_node import GameNode
|
||||
@@ -296,7 +297,10 @@ class Game:
|
||||
eval_thresholds = trainer_config["eval_thresholds"]
|
||||
|
||||
def player_name(player_info):
|
||||
return f"{i18n._(player_info.player_type)} ({i18n._(player_info.player_subtype)})"
|
||||
if player_info.name and player_info.player_type == PLAYER_HUMAN:
|
||||
return player_info.name
|
||||
else:
|
||||
return f"{i18n._(player_info.player_type)} ({i18n._(player_info.player_subtype)})"
|
||||
|
||||
root_properties = self.root.properties
|
||||
x_properties = {}
|
||||
|
||||
@@ -63,4 +63,3 @@ def format_visits(n):
|
||||
if n < 1e6:
|
||||
return f"{n/1000:.0f}k"
|
||||
return f"{n/1e6:.0f}k"
|
||||
|
||||
@@ -504,7 +504,6 @@ class BadukPanWidget(Widget):
|
||||
+ "}[/size]"
|
||||
)
|
||||
|
||||
|
||||
keys[TOP_MOVE_DELTA_SCORE] = (
|
||||
"0.0" if -0.05 < move_dict["pointsLost"] < 0.05 else f"{-move_dict['pointsLost']:+.1f}"
|
||||
)
|
||||
@@ -512,13 +511,14 @@ class BadukPanWidget(Widget):
|
||||
keys[TOP_MOVE_WINRATE] = f"{move_dict['winrate']*100:.1f}"
|
||||
keys[TOP_MOVE_DELTA_WINRATE] = f"{-move_dict['winrateLost']:+.1%}"
|
||||
keys[TOP_MOVE_VISITS] = format_visits(move_dict["visits"])
|
||||
print(fmt,keys)
|
||||
Color(*BLACK)
|
||||
draw_text(
|
||||
pos=(self.gridpos_x[move.coords[0]], self.gridpos_y[move.coords[1]]),
|
||||
text=fmt.format(**keys),
|
||||
font_name="Roboto",
|
||||
markup=True, line_height=0.8, halign='center'
|
||||
markup=True,
|
||||
line_height=0.8,
|
||||
halign="center",
|
||||
)
|
||||
|
||||
if engine_best_move:
|
||||
|
||||
@@ -250,14 +250,20 @@ class NewGamePopup(QuickConfigGui):
|
||||
|
||||
self.rules_spinner.value_refs = [name for abbr, name in katrain.engine.RULESETS_ABBR]
|
||||
|
||||
def update_playerinfo(self):
|
||||
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_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)
|
||||
if self.restart.active:
|
||||
self.katrain.log("Restarting Engine", OUTPUT_DEBUG)
|
||||
self.katrain.engine.restart()
|
||||
for bw, player_setup in self.player_setup.players.items():
|
||||
self.katrain.update_player(bw, **player_setup.player_type_dump)
|
||||
self.update_playerinfo()
|
||||
self.katrain("new-game")
|
||||
|
||||
def update_game(self):
|
||||
@@ -269,6 +275,7 @@ class NewGamePopup(QuickConfigGui):
|
||||
if current != v:
|
||||
changed = True
|
||||
self.katrain.game.root.set_property(k, v)
|
||||
self.update_playerinfo()
|
||||
if changed:
|
||||
self.katrain.engine.on_new_game()
|
||||
self.katrain.game.analyze_all_nodes()
|
||||
|
||||
+15
-2
@@ -383,15 +383,28 @@
|
||||
restart: restart
|
||||
rules_spinner: rules_spinner
|
||||
player_setup: player_setup
|
||||
player_name: {"W": white_player_name, "B": black_player_name}
|
||||
PlayerSetupBlock:
|
||||
size_hint: 1, 2
|
||||
id: player_setup
|
||||
GridLayout:
|
||||
rows: 6
|
||||
rows: 7
|
||||
cols: 3
|
||||
size_hint: 1, 2.5
|
||||
size_hint: 1, 3
|
||||
spacing: CP_SPACING
|
||||
padding: CP_PADDING
|
||||
DescriptionLabel:
|
||||
text: i18n._("names")
|
||||
AnchorLayout:
|
||||
LabelledTextInput:
|
||||
text: ''
|
||||
id: black_player_name
|
||||
size_hint: 0.75, None
|
||||
AnchorLayout:
|
||||
LabelledTextInput:
|
||||
text: ''
|
||||
id: white_player_name
|
||||
size_hint: 0.75, None
|
||||
DescriptionLabel:
|
||||
text: i18n._("board size")
|
||||
AnchorLayout:
|
||||
|
||||
Reference in new issue
Block a user