head hunt only when my snake is bigger and into dual mode

This commit is contained in:
2026-04-03 20:57:33 +02:00
parent 6ab0161b49
commit f124ce6f96
2 changed files with 146 additions and 3 deletions
+6 -3
View File
@@ -348,6 +348,7 @@ class BestBattleSnake(TemplateSnake):
enemy_head = (enemy["head"]["x"], enemy["head"]["y"])
enemy_len = enemy.get("length", len(enemy["body"]))
encase_target_space = max(8, enemy_len * 2)
can_head_hunt = my_len > enemy_len and my_len >= 8
scores:dict[str, float] = {}
move_safety:dict[str, dict[str, Any]] = {}
@@ -421,10 +422,10 @@ class BestBattleSnake(TemplateSnake):
score += max(0, 3 - enemy_options) * 95.0
if reachable_space > enemy_space:
score += 120.0
if direct_head_distance <= 2:
if direct_head_distance <= 2 and can_head_hunt:
score += 40.0
if my_len > enemy_len:
if can_head_hunt:
if direct_head_distance == 1:
score += 220.0 * duel_weights["head_pressure"]
elif direct_head_distance == 2:
@@ -432,6 +433,8 @@ class BestBattleSnake(TemplateSnake):
else:
if direct_head_distance <= 2:
score -= 120.0 * duel_weights["distance_safety"]
if direct_head_distance == 1:
score -= 180.0 * duel_weights["distance_safety"]
hunger_urgency = max(0.0, (65.0 - my_health) / 65.0)
if nearest_food_dist is not None:
@@ -918,7 +921,7 @@ class BestBattleSnake(TemplateSnake):
def _distance_map(self, start:Point, blocked:set[Point], width:int, height:int) -> dict[Point, int]:
"""Build a BFS distance map from the given start cell."""
queue = deque([(start, 0)])
distances = {start:0}
distances = {start: 0}
while queue:
point, distance = queue.popleft()