feat(snake): modularize engine and add tournament tools
- Split active strategies, reusable engine code, core classes, and legacy snakes. - Replace implicit snake imports with explicit module registrations. - Extract Prism duel, spatial, and survival behavior into focused mixins. - Improve duel scoring with food races, pressure, caches, and depth metrics. - Add deterministic arena scenarios and paired seeded engine tournaments. - Expand benchmark telemetry and bump Prism to version 1.3.0. - Update documentation and tests for the new package layout and tooling.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import unittest
|
||||
|
||||
from scripts.snake_arena_scenarios import SCENARIOS, synthetic_states
|
||||
|
||||
class TestSnakeArenaScenarios(unittest.TestCase):
|
||||
|
||||
def test_default_corpus_rotates_through_every_scenario(self):
|
||||
states = synthetic_states(len(SCENARIOS))
|
||||
|
||||
self.assertEqual(
|
||||
{metadata["scenario"] for _, metadata in states},
|
||||
set(SCENARIOS),
|
||||
)
|
||||
|
||||
def test_scenario_filter_is_deterministic(self):
|
||||
first = synthetic_states(3, ["hazard"])
|
||||
second = synthetic_states(3, ["hazard"])
|
||||
|
||||
self.assertEqual(first, second)
|
||||
self.assertTrue(all(metadata["scenario"] == "hazard" for _, metadata in first))
|
||||
|
||||
def test_generated_you_is_present_on_board(self):
|
||||
for board, metadata in synthetic_states(20):
|
||||
with self.subTest(scenario=metadata["scenario"]):
|
||||
ids = {snake["id"] for snake in board["snakes"]}
|
||||
self.assertIn(metadata["you"]["id"], ids)
|
||||
self.assertGreater(board["width"], 0)
|
||||
self.assertGreater(board["height"], 0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user