Build and Push Docker Container / build-and-push (push) Successful in 2m18s
- Register Zenith 1.1 with balanced duel verdicts and forced-outcome overrides. - Prioritize permanent-trail space in Constrictor and health-aware hazard routes. - Deduct executor queue delays and return fallback directions on move timeouts. - Correlate response headers, replay timings, and sampled structured trace logs. - Move shared metrics publication off the response path without losing local counts. - Allow configurable tournament opponents and add a psql helper recipe. - Preserve empty latency values through compact replay encoding and migration. - Update Arena game links and use default assets for missing customizations. - Cover strategy, HTTP lifecycle, tracing, replay codecs, and dashboard behavior. - Validate with 260 passing Python tests, 4 skips, and 2 passing JavaScript tests.
85 lines
3.2 KiB
Python
85 lines
3.2 KiB
Python
import unittest
|
|
from time import perf_counter
|
|
|
|
from snakes import SnakeBuilder, get_snake_version
|
|
from snakes.strategies.prism import PrismBattleSnake_GPT_5_6_Sol
|
|
from snakes.strategies.zenith import ZenithBattleSnake_ClaudeOpus5_5
|
|
|
|
LOSS = -100_000.0
|
|
WIN = 100_000.0
|
|
|
|
class TestZenithRegistration(unittest.TestCase):
|
|
|
|
def test_api_name_and_version_are_exposed(self):
|
|
snake = ZenithBattleSnake_ClaudeOpus5_5()
|
|
|
|
self.assertEqual(snake.name, "ZenithBattleSnake")
|
|
self.assertEqual(snake.version, "1.1.0")
|
|
self.assertEqual(get_snake_version("ZenithBattleSnake_ClaudeOpus5_5"), "1.1.0")
|
|
self.assertIsInstance(snake, PrismBattleSnake_GPT_5_6_Sol)
|
|
self.assertIsInstance(
|
|
SnakeBuilder.build("ZenithBattleSnake_ClaudeOpus5_5"),
|
|
ZenithBattleSnake_ClaudeOpus5_5,
|
|
)
|
|
|
|
class TestZenithVerdicts(unittest.TestCase):
|
|
|
|
def test_proven_loss_is_vetoed_for_best_surviving_heuristic(self):
|
|
scores = {"up": 300.0, "left": 120.0, "right": 90.0}
|
|
verdicts = {"up": (LOSS, 3), "left": (-40.0, 3), "right": (25.0, 3)}
|
|
|
|
self.assertEqual(ZenithBattleSnake_ClaudeOpus5_5._apply_verdicts("up", scores, verdicts), "left")
|
|
|
|
def test_proven_win_overrides_heuristic(self):
|
|
scores = {"up": 300.0, "left": 120.0}
|
|
verdicts = {"up": (15.0, 2), "left": (WIN, 2)}
|
|
|
|
self.assertEqual(ZenithBattleSnake_ClaudeOpus5_5._apply_verdicts("up", scores, verdicts), "left")
|
|
|
|
def test_keeps_choice_when_every_move_loses(self):
|
|
scores = {"up": 300.0, "left": 120.0}
|
|
verdicts = {"up": (LOSS, 2), "left": (LOSS - 1, 2)}
|
|
|
|
self.assertEqual(ZenithBattleSnake_ClaudeOpus5_5._apply_verdicts("up", scores, verdicts), "up")
|
|
|
|
def test_keeps_choice_without_verdict(self):
|
|
scores = {"up": 300.0, "left": 120.0}
|
|
self.assertEqual(ZenithBattleSnake_ClaudeOpus5_5._apply_verdicts("up", scores, {}), "up")
|
|
|
|
def test_verdict_search_resolves_every_candidate(self):
|
|
snake = ZenithBattleSnake_ClaudeOpus5_5()
|
|
# Longer enemy can also reach (2, 5): stepping there loses the head-to-head.
|
|
my_body = [{"x": 1, "y": 5}, {"x": 0, "y": 5}]
|
|
enemy = {"body": [{"x": 3, "y": 5}, {"x": 4, "y": 5}, {"x": 5, "y": 5}], "health": 100}
|
|
safe_moves = {"up": {"x": 1, "y": 6}, "right": {"x": 2, "y": 5}}
|
|
|
|
verdicts = snake._duel_verdicts(
|
|
safe_moves=safe_moves, my_body=my_body, enemy=enemy, my_health=100,
|
|
food_set=set(), hazard_set=set(), hazard_damage=15, hazard_count={},
|
|
previous_hazard_set=set(), width=11, height=11,
|
|
deadline=perf_counter() + 1.0,
|
|
)
|
|
|
|
self.assertEqual(set(verdicts), {"up", "right"})
|
|
self.assertLessEqual(verdicts["right"][0], LOSS / 2)
|
|
self.assertGreater(verdicts["up"][0], LOSS / 2)
|
|
self.assertEqual(
|
|
snake._apply_verdicts("right", {"right": 50.0, "up": 10.0}, verdicts), "up",
|
|
)
|
|
|
|
def test_verdict_search_stops_when_out_of_time(self):
|
|
snake = ZenithBattleSnake_ClaudeOpus5_5()
|
|
|
|
verdicts = snake._duel_verdicts(
|
|
safe_moves={"up": {"x": 0, "y": 2}}, my_body=[{"x": 0, "y": 1}],
|
|
enemy={"body": [{"x": 4, "y": 4}]}, my_health=100,
|
|
food_set=set(), hazard_set=set(), hazard_damage=15, hazard_count={},
|
|
previous_hazard_set=set(), width=5, height=5,
|
|
deadline=perf_counter() - 0.001,
|
|
)
|
|
|
|
self.assertEqual(verdicts, {})
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|