min visits

This commit is contained in:
Sander Land committed 2020-10-02 14:44:33 +02:00
1 parent 9dcbce32e6
commit 8e0001b771
3 files changed
+16 -6

No files matched your search

+2 -1
View File
@@ -91,7 +91,8 @@
"ai:simple": {
"max_points_lost": 1.75,
"settled_weight": 1.0,
"opponent_fac": 0.5
"opponent_fac": 0.5,
"min_visits": 3
},
"ai:p:weighted": {
"weaken_fac": 1.25,
+13 -5
View File
@@ -384,18 +384,26 @@ def generate_ai_move(game: Game, ai_mode: str, ai_settings: Dict) -> Tuple[Move,
next_player_sign = cn.player_sign(cn.next_player)
moves_with_settledness = sorted(
[
(Move.from_gtp(d["move"], player=cn.next_player), settledness(d,next_player_sign), settledness(d,-next_player_sign), 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
if d["pointsLost"] < ai_settings["max_points_lost"]
and "ownership" in d
and (d["order"] < 5 or d["visits"] >= ai_settings.get("min_visits", 1))
],
key=lambda t: t[3]["pointsLost"] - ai_settings["settled_weight"] * (t[1] + ai_settings["opponent_fac"] * t[2]),
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, {d['visits']} visits, {settled:.1f} settledness, {oppsettled:.1f} opponent settledness)"
for move, settled, oppsettled, d in moves_with_settledness
for move, settled, oppsettled, d in moves_with_settledness[:5]
]
ai_thoughts += f"Simple ownership strategy. Candidates {', '.join(cands)} "
ai_thoughts += f"Simple ownership strategy. Top 5 Candidates {', '.join(cands)} "
aimove = moves_with_settledness[0][0]
else:
game.katrain.log(
+1
View File
@@ -92,6 +92,7 @@ AI_OPTION_VALUES = {
"max_points_lost": [x / 10 for x in range(51)],
"settled_weight": [x / 4 for x in range(1, 17)],
"opponent_fac": [x / 10 for x in range(-20, 11)],
"min_visits": range(1,10)
}
AI_KEY_PROPERTIES = {"kyu_rank", "strength", "weaken_fac", "pick_frac", "pick_n", "automatic"}