ui fiddling
This commit is contained in:
1 parent
3ea068ccd0
commit
d14f077e71
16 files changed
+434
-294
No files matched your search
@@ -7,7 +7,7 @@ from typing import List
|
||||
|
||||
from kivy.clock import Clock
|
||||
|
||||
from constants import OUTPUT_DEBUG
|
||||
from constants import OUTPUT_DEBUG, OUTPUT_INFO
|
||||
from game_node import GameNode
|
||||
from sgf_parser import SGF, Move
|
||||
|
||||
@@ -202,27 +202,29 @@ class Game:
|
||||
time.sleep(0.05)
|
||||
# select move
|
||||
candidate_ai_moves = cn.candidate_moves
|
||||
ai_mode = self.katrain.controls.player_mode(cn.next_player)
|
||||
ai_mode = self.katrain.controls.ai_mode(cn.next_player)
|
||||
|
||||
if "policy" in ai_mode and cn.policy:
|
||||
policy_moves = cn.policy_ranking
|
||||
self.katrain.log(f"Top 5 policy moves are: {policy_moves[:5]}", OUTPUT_DEBUG)
|
||||
aimove = policy_moves[0][0]
|
||||
elif "balance" in ai_mode and candidate_ai_moves[0]['move'] != "pass": # don't play suicidal to balance score - pass when it's best
|
||||
sign = cn.player_sign(cn.next_player) # TODO check
|
||||
sel_moves = [ # top move, or anything not too bad, or anything that makes you still ahead
|
||||
elif "balance" in ai_mode and candidate_ai_moves[0]["move"] != "pass": # don't play suicidal to balance score - pass when it's best
|
||||
sign = cn.player_sign(cn.next_player) # TODO check
|
||||
sel_moves = [ # top move, or anything not too bad, or anything that makes you still ahead
|
||||
move
|
||||
for i, move in enumerate(candidate_ai_moves)
|
||||
if i == 0
|
||||
or move["visits"] >= train_settings["balance_play_min_visits"]
|
||||
or move["visits"] >= train_settings["balance_min_visits"]
|
||||
and (
|
||||
move["pointsLost"] < train_settings["balance_play_randomize_score"]
|
||||
or move["pointsLost"] < train_settings["balance_play_max_lost"]
|
||||
and sign * move["scoreLead"] > train_settings["balance_play_target_score"]
|
||||
move["pointsLost"] < train_settings["balance_randomize_score"]
|
||||
or move["pointsLost"] < train_settings["balance_max_lost"]
|
||||
and sign * move["scoreLead"] > train_settings["balance_target_score"]
|
||||
)
|
||||
]
|
||||
aimove = Move.from_gtp(random.choice(sel_moves)["move"], player=cn.next_player) # TODO: could be weighted towards worse
|
||||
aimove = Move.from_gtp(random.choice(sel_moves)["move"], player=cn.next_player) # TODO: could be weighted towards worse
|
||||
else:
|
||||
if "default" not in ai_mode:
|
||||
self.katrain.log(f"Unknown AI mode {ai_mode}, using default.", OUTPUT_INFO)
|
||||
aimove = Move.from_gtp(candidate_ai_moves[0]["move"], player=cn.next_player)
|
||||
self.play(aimove)
|
||||
|
||||
|
||||
Reference in new issue
Block a user