Files
snake-python/tests/snakes/test_PerimeterScoring.py
daniel156161 f14d780f29
Build and Push Docker Container / build-and-push (push) Successful in 7m53s
feat: add live replays and PostgreSQL maintenance tools
- 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.
2026-08-02 00:50:46 +02:00

52 lines
1.4 KiB
Python

import unittest
from snakes.engine.perimeter import perimeter_geometry_score
class TestPerimeterGeometryScore(unittest.TestCase):
def score(self, point, **overrides):
values = {
"point": point,
"current_head": (0, 5),
"width": 11,
"height": 11,
"occupancy": 0.35,
"snake_length": 12,
"reachable_space": 80,
"required_space": 12,
"liberties": 2,
"next_options": 2,
"safe_next_options": 2,
"tail_escape": True,
"dead_end": False,
"losing_head_to_head": False,
}
values.update(overrides)
return perimeter_geometry_score(**values)
def test_safe_wall_lane_can_outscore_adjacent_inner_lane(self):
wall = self.score((0, 6))
inner = self.score((1, 5))
self.assertGreater(wall, inner)
def test_unsafe_wall_does_not_receive_perimeter_reward(self):
safe_wall = self.score((0, 6))
unsafe_wall = self.score((0, 6), safe_next_options=1)
self.assertGreater(safe_wall, unsafe_wall + 30.0)
def test_corner_is_less_attractive_than_straight_edge(self):
corner = self.score((0, 0), current_head=(0, 1))
straight_edge = self.score((0, 6))
self.assertGreater(straight_edge, corner)
def test_losing_head_to_head_never_gets_perimeter_reward(self):
safe_wall = self.score((0, 6))
contested_wall = self.score((0, 6), losing_head_to_head=True)
self.assertGreater(safe_wall, contested_wall + 30.0)
if __name__ == "__main__":
unittest.main()