timer, simple fix
This commit is contained in:
1 parent
f336bea3d0
commit
9dcbce32e6
6 files changed
+19
-13
No files matched your search
+7
-6
@@ -378,21 +378,22 @@ def generate_ai_move(game: Game, ai_mode: str, ai_settings: Dict) -> Tuple[Move,
|
||||
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:
|
||||
|
||||
def settledness(d):
|
||||
return sum([abs(o) for o in d["ownership"]])
|
||||
def settledness(d, player_fac):
|
||||
return sum([abs(o) for o in d["ownership"] if player_fac * o > 0])
|
||||
|
||||
next_player_sign = cn.player_sign(cn.next_player)
|
||||
moves_with_settledness = sorted(
|
||||
[
|
||||
(Move.from_gtp(d["move"], player=cn.next_player), settledness(d), d)
|
||||
(Move.from_gtp(d["move"], player=cn.next_player), settledness(d,next_player_sign), settledness(d,-next_player_sign), d)
|
||||
for d in candidate_ai_moves
|
||||
if d["pointsLost"] < ai_settings["max_points_lost"] and "ownership" in d
|
||||
],
|
||||
key=lambda t: t[2]["pointsLost"] - ai_settings["settled_weight"] * t[1],
|
||||
key=lambda t: t[3]["pointsLost"] - ai_settings["settled_weight"] * (t[1] + ai_settings["opponent_fac"] * t[2]),
|
||||
)
|
||||
if moves_with_settledness:
|
||||
cands = [
|
||||
f"{move.gtp()} ({d['pointsLost']:.1f} pt lost, {settled:.1f} settledness)"
|
||||
for move, settled, d in moves_with_settledness
|
||||
f"{move.gtp()} ({d['pointsLost']:.1f} pt lost, {d['visits']} visits, {settled:.1f} settledness, {oppsettled:.1f} opponent settledness)"
|
||||
for move, settled, oppsettled, d in moves_with_settledness
|
||||
]
|
||||
ai_thoughts += f"Simple ownership strategy. Candidates {', '.join(cands)} "
|
||||
aimove = moves_with_settledness[0][0]
|
||||
|
||||
@@ -70,7 +70,7 @@ AI_STRENGTH = { # dan ranks, backup if model is missing. TODO: remove some?
|
||||
AI_INFLUENCE: -7,
|
||||
AI_TERRITORY: -7,
|
||||
AI_RANK: float("nan"),
|
||||
AI_SIMPLE_OWNERSHIP: 9,
|
||||
AI_SIMPLE_OWNERSHIP: 3,
|
||||
}
|
||||
|
||||
AI_OPTION_VALUES = {
|
||||
@@ -90,7 +90,8 @@ AI_OPTION_VALUES = {
|
||||
"automatic": "bool",
|
||||
"pda": [(x / 10, f"{'W' if x<0 else 'B'}+{abs(x/10):.1f}") for x in range(-30, 31)],
|
||||
"max_points_lost": [x / 10 for x in range(51)],
|
||||
"settled_weight": [x / 10 for x in range(-100, 101)],
|
||||
"settled_weight": [x / 4 for x in range(1, 17)],
|
||||
"opponent_fac": [x / 10 for x in range(-20, 11)],
|
||||
}
|
||||
AI_KEY_PROPERTIES = {"kyu_rank", "strength", "weaken_fac", "pick_frac", "pick_n", "automatic"}
|
||||
|
||||
|
||||
Reference in new issue
Block a user