feat: add live replays and PostgreSQL maintenance tools
Build and Push Docker Container / build-and-push (push) Successful in 7m53s
Build and Push Docker Container / build-and-push (push) Successful in 7m53s
- Stream compact live replay updates across local and clustered dashboards. - Render responsive snake bodies as SVG paths with aligned custom icons. - Add cache-busted assets, replay fallback routes, and live-follow playback. - Support PostgreSQL benchmark sampling and idempotent SQLite migration. - Add dry-run cleanup for old low-quality PostgreSQL replay payloads. - Reward safe perimeter lanes and bump Prism to version 1.5.0. - Add backend, migration, dashboard, and perimeter regression coverage.
This commit is contained in:
+19
-16
@@ -8,6 +8,7 @@ from quart_common.web.env import env_int
|
||||
|
||||
from server.dataset.RLBootstrapDataset import RLBootstrapDataset
|
||||
from snakes.core.template import TemplateSnake
|
||||
from snakes.engine.perimeter import perimeter_geometry_score
|
||||
from server.GameBoard import GameBoard
|
||||
|
||||
class ApexBattleSnake(TemplateSnake):
|
||||
@@ -686,19 +687,22 @@ class ApexBattleSnake(TemplateSnake):
|
||||
or (next_opts == 0 and not has_tail_escape)
|
||||
)
|
||||
|
||||
cx, cy = (width - 1) / 2.0, (height - 1) / 2.0
|
||||
center_score = 1.0 - (abs(point[0] - cx) + abs(point[1] - cy)) / max(1.0, cx + cy)
|
||||
|
||||
min_wall_dist = min(point[0], width - 1 - point[0], point[1], height - 1 - point[1])
|
||||
if total_occupancy > 0.25:
|
||||
if min_wall_dist == 0:
|
||||
edge_penalty = 35.0 * total_occupancy
|
||||
elif min_wall_dist == 1:
|
||||
edge_penalty = 15.0 * total_occupancy
|
||||
else:
|
||||
edge_penalty = 0.0
|
||||
else:
|
||||
edge_penalty = 0.0
|
||||
geometry_score = perimeter_geometry_score(
|
||||
point=point,
|
||||
current_head=(my_body[0]["x"], my_body[0]["y"]),
|
||||
width=width,
|
||||
height=height,
|
||||
occupancy=total_occupancy,
|
||||
snake_length=len(future_body),
|
||||
reachable_space=reachable_space,
|
||||
required_space=required_space,
|
||||
liberties=liberties,
|
||||
next_options=next_opts,
|
||||
safe_next_options=en_safe_opts,
|
||||
tail_escape=has_tail_escape,
|
||||
dead_end=dead_end,
|
||||
losing_head_to_head=losing_h2h,
|
||||
)
|
||||
|
||||
hunger = max(0.0, (60.0 - my_health) / 60.0)
|
||||
|
||||
@@ -719,7 +723,7 @@ class ApexBattleSnake(TemplateSnake):
|
||||
score += liberties * 20.0
|
||||
score += next_opts * 10.0
|
||||
score += en_safe_opts * 24.0
|
||||
score += center_score * 14.0
|
||||
score += geometry_score
|
||||
|
||||
if en_safe_opts == 0:
|
||||
score -= 1700.0
|
||||
@@ -727,7 +731,6 @@ class ApexBattleSnake(TemplateSnake):
|
||||
score -= 420.0
|
||||
|
||||
score -= art_penalty
|
||||
score -= edge_penalty
|
||||
score -= h2h_dist2_penalty
|
||||
|
||||
if dead_end:
|
||||
@@ -1421,7 +1424,7 @@ class ApexBattleSnake(TemplateSnake):
|
||||
can_grow = self._enemy_can_grow_this_turn(snake, food_set)
|
||||
if not can_grow:
|
||||
enemy_vacating_tails.add((snake["body"][-1]["x"], snake["body"][-1]["y"]))
|
||||
safe: MoveMap = {}
|
||||
safe: ApexBattleSnake.MoveMap = {}
|
||||
for move, (dx, dy) in self.DIRECTIONS.items():
|
||||
pt = (my_head["x"] + dx, my_head["y"] + dy)
|
||||
if not self._in_bounds(pt, width, height):
|
||||
|
||||
Reference in New Issue
Block a user