simple ai
This commit is contained in:
1 parent
28b8748e5f
commit
67e827b0ac
6 files changed
+25
-7
No files matched your search
@@ -16,6 +16,8 @@ tmp.pickle
|
||||
my
|
||||
logs
|
||||
callgrind.*
|
||||
cpp/out
|
||||
.vs
|
||||
|
||||
# debug
|
||||
outdated_log.txt
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+11
-4
@@ -357,19 +357,26 @@ def generate_ai_move(game: Game, ai_mode: str, ai_settings: Dict) -> Tuple[Move,
|
||||
aimove = topmove[2]
|
||||
ai_thoughts += f"ScoreLoss strategy found {len(candidate_ai_moves)} candidate moves (best {top_cand.gtp()}) and chose {aimove.gtp()} (weight {topmove[1]:.3f}, point loss {topmove[0]:.1f}) based on score weights."
|
||||
elif ai_mode == AI_SIMPLE_OWNERSHIP:
|
||||
last_player_stones = {s.coords for s in game.stones if s.player == cn.player}
|
||||
stones_with_player = {(*s.coords, s.player) for s in game.stones}
|
||||
next_player_sign = cn.player_sign(cn.next_player)
|
||||
|
||||
def settledness(d, player_sign):
|
||||
return sum([abs(o) for o in d["ownership"] if player_sign * o > 0])
|
||||
|
||||
def is_attachment(d):
|
||||
return any(
|
||||
(d.coords[0] + dx, d.coords[1] + dy) in last_player_stones
|
||||
def is_attachment(move):
|
||||
attach_opponent_stones = sum(
|
||||
(move.coords[0] + dx, move.coords[1] + dy, cn.player) in stones_with_player
|
||||
for dx in [-1, 0, 1]
|
||||
for dy in [-1, 0, 1]
|
||||
if abs(dx) + abs(dy) == 1
|
||||
)
|
||||
nearby_own_stones = sum(
|
||||
(move.coords[0] + dx, move.coords[1] + dy, cn.next_player) in stones_with_player
|
||||
for dx in [-2, 0, 1, 2]
|
||||
for dy in [-2 - 1, 0, 1, 2]
|
||||
if abs(dx) + abs(dy) <= 2 # allows clamps/jumps
|
||||
)
|
||||
return attach_opponent_stones >= 1 and nearby_own_stones == 0
|
||||
|
||||
def is_tenuki(d):
|
||||
return not any(
|
||||
|
||||
@@ -95,7 +95,16 @@ AI_OPTION_VALUES = {
|
||||
"attach_penalty": [x / 10 for x in range(-10, 51)],
|
||||
"tenuki_penalty": [x / 10 for x in range(-10, 51)],
|
||||
}
|
||||
AI_KEY_PROPERTIES = {"kyu_rank", "strength", "weaken_fac", "pick_frac", "pick_n", "automatic","max_points_lost","min_visits"}
|
||||
AI_KEY_PROPERTIES = {
|
||||
"kyu_rank",
|
||||
"strength",
|
||||
"weaken_fac",
|
||||
"pick_frac",
|
||||
"pick_n",
|
||||
"automatic",
|
||||
"max_points_lost",
|
||||
"min_visits",
|
||||
}
|
||||
|
||||
|
||||
CALIBRATED_RANK_ELO = [
|
||||
|
||||
@@ -106,7 +106,7 @@ class BadukPanWidget(Widget):
|
||||
return
|
||||
katrain = self.katrain
|
||||
if self.ghost_stone and ("button" not in touch.profile or touch.button == "left"):
|
||||
game = self.katrain and self.katrain.game
|
||||
game = self.katrain and self.katrain.game
|
||||
current_node = game and self.katrain.game.current_node
|
||||
if (
|
||||
current_node
|
||||
@@ -114,7 +114,7 @@ class BadukPanWidget(Widget):
|
||||
and not self.katrain.next_player_info.ai
|
||||
and not self.katrain.controls.timer.paused
|
||||
and self.katrain.play_analyze_mode == MODE_PLAY
|
||||
and self.katrain.config("timer/main_time",0) * 60 - game.main_time_used <= 0
|
||||
and self.katrain.config("timer/main_time", 0) * 60 - game.main_time_used <= 0
|
||||
and current_node.time_used < self.katrain.config("timer/minimal_use", 0)
|
||||
):
|
||||
self.katrain.controls.set_status(
|
||||
|
||||
Reference in new issue
Block a user