endgame option to influence and territory
This commit is contained in:
1 parent
abc21943b5
commit
f4e3624758
2 files changed
+15
-8
No files matched your search
+5
-3
@@ -101,7 +101,7 @@
|
||||
"stddev": 7.5,
|
||||
"pick_n": 5,
|
||||
"pick_frac": 0.5,
|
||||
"endgame": 0.5,
|
||||
"endgame": 0.45,
|
||||
"_help_left": "Samples `pick_n + pick_frac * <number of legal moves>` away from the last move and plays the best one.",
|
||||
"_help_right": "Increase `stddev` makes it prefer moves further away. Stops tenukiing after the 'endgame' fraction of the board is filled."
|
||||
},
|
||||
@@ -111,8 +111,9 @@
|
||||
"pick_frac": 0.4,
|
||||
"threshold": 3.5,
|
||||
"line_weight": 10,
|
||||
"endgame": 0.4,
|
||||
"_help_left": "Samples `pick_n + pick_frac * <number of legal moves>` and plays the best one, biased to above the `threshold` line.",
|
||||
"_help_right": "Increase `line_weight` to penalize moves near the edge more."
|
||||
"_help_right": "Increase `line_weight` to penalize moves near the edge more. Stops strategy after the 'endgame' fraction of the board is filled."
|
||||
},
|
||||
"P:Territory": {
|
||||
"pick_override": 0.95,
|
||||
@@ -120,8 +121,9 @@
|
||||
"pick_frac": 0.4,
|
||||
"threshold": 3.5,
|
||||
"line_weight": 2,
|
||||
"endgame": 0.4,
|
||||
"_help_left": "Samples `pick_n + pick_frac * <number of legal moves>` and plays the best one, biased to below the `threshold` line.",
|
||||
"_help_right": "Increase `line_weight` to penalize moves closer to the center more."
|
||||
"_help_right": "Increase `line_weight` to penalize moves closer to the center more. Stops strategy after the 'endgame' fraction of the board is filled."
|
||||
}
|
||||
},
|
||||
"board_ui": {
|
||||
|
||||
+10
-5
@@ -95,13 +95,18 @@ def ai_move(game: Game, ai_mode: str, ai_settings: Dict) -> Tuple[Move, GameNode
|
||||
legal_policy_moves = [(pol, mv) for pol, mv in policy_moves if not mv.is_pass if pol > 0]
|
||||
n_moves = int(ai_settings["pick_frac"] * len(legal_policy_moves) + ai_settings["pick_n"])
|
||||
if "influence" in ai_mode or "territory" in ai_mode:
|
||||
|
||||
thr_line = ai_settings["threshold"] - 1 # zero-based
|
||||
if "influence" in ai_mode:
|
||||
weight = lambda x, y: (1 / ai_settings["line_weight"]) ** (max(0, thr_line - min(size[0] - 1 - x, x)) + max(0, thr_line - min(size[1] - 1 - y, y)))
|
||||
if cn.depth >= ai_settings["endgame"] * size[0] * size[1]:
|
||||
weighted_coords = [(policy_grid[y][x], 1, x, y) for x in range(size[0]) for y in range(size[1]) if policy_grid[y][x] > 0]
|
||||
ai_thoughts += f"Generated equal weights as move number >= {ai_settings['endgame'] * size[0] * size[1]}. "
|
||||
else:
|
||||
weight = lambda x, y: (1 / ai_settings["line_weight"]) ** (max(0, min(size[0] - 1 - x, x, size[1] - 1 - y, y) - thr_line))
|
||||
weighted_coords = [(policy_grid[y][x] * weight(x, y), weight(x, y), x, y) for x in range(size[0]) for y in range(size[1]) if policy_grid[y][x] > 0]
|
||||
ai_thoughts += f"Generated weights for {ai_mode} according to weight factor {ai_settings['line_weight']} and distance from {thr_line+1}th line. "
|
||||
if "influence" in ai_mode:
|
||||
weight = lambda x, y: (1 / ai_settings["line_weight"]) ** (max(0, thr_line - min(size[0] - 1 - x, x)) + max(0, thr_line - min(size[1] - 1 - y, y)))
|
||||
else:
|
||||
weight = lambda x, y: (1 / ai_settings["line_weight"]) ** (max(0, min(size[0] - 1 - x, x, size[1] - 1 - y, y) - thr_line))
|
||||
weighted_coords = [(policy_grid[y][x] * weight(x, y), weight(x, y), x, y) for x in range(size[0]) for y in range(size[1]) if policy_grid[y][x] > 0]
|
||||
ai_thoughts += f"Generated weights for {ai_mode} according to weight factor {ai_settings['line_weight']} and distance from {thr_line+1}th line. "
|
||||
elif "local" in ai_mode or "tenuki" in ai_mode:
|
||||
var = ai_settings["stddev"] ** 2
|
||||
if not cn.move or cn.move.coords is None:
|
||||
|
||||
Reference in new issue
Block a user