feat(snake): optimize duels and persist customizations
Build and Push Docker Container / build-and-push (push) Successful in 7m29s
Build and Push Docker Container / build-and-push (push) Successful in 7m29s
- Add deadline-aware iterative duel search with bitboards and tuple bodies. - Reuse transposition bounds and move-order hints across search depths. - Persist snake colors, heads, and tails in SQLite and PostgreSQL. - Restore customization metadata when hydrating dashboard replays. - Cover duel deadlines, cache reuse, schema storage, and replay output.
This commit is contained in:
@@ -13,6 +13,11 @@ class TestGameplayDatabase(unittest.IsolatedAsyncioTestCase):
|
||||
"name": "Me",
|
||||
"health": 90,
|
||||
"length": 3,
|
||||
"customizations": {
|
||||
"color": "#00ff00",
|
||||
"head": "ferret",
|
||||
"tail": "swirl",
|
||||
},
|
||||
"head": {"x": me_head[0], "y": me_head[1]},
|
||||
"body": [
|
||||
{"x": me_head[0], "y": me_head[1]},
|
||||
@@ -99,10 +104,13 @@ class TestGameplayDatabase(unittest.IsolatedAsyncioTestCase):
|
||||
""", ("game-abc", 2, "me")).fetchone()[0]
|
||||
self.assertNotEqual(stored_body, "[]")
|
||||
identities = connection.execute("""
|
||||
SELECT snake_id, snake_name, is_you FROM game_snakes
|
||||
SELECT snake_id, snake_name, is_you, customizations_json FROM game_snakes
|
||||
WHERE game_id = ? ORDER BY snake_id
|
||||
""", ("game-abc",)).fetchall()
|
||||
self.assertEqual(identities, [("enemy", "Enemy", 0), ("me", "Me", 1)])
|
||||
self.assertEqual(identities, [
|
||||
("enemy", "Enemy", 0, "{}"),
|
||||
("me", "Me", 1, '{"color":"#00ff00","head":"ferret","tail":"swirl"}'),
|
||||
])
|
||||
repeated_identity = connection.execute("""
|
||||
SELECT snake_name, is_you FROM snake_turns
|
||||
WHERE game_id = ? AND turn = ? AND snake_id = ?
|
||||
@@ -127,7 +135,15 @@ class TestGameplayDatabase(unittest.IsolatedAsyncioTestCase):
|
||||
self.assertEqual(replay["turns"][1]["my_thinking"]["reason"], "food")
|
||||
self.assertEqual(replay["turns"][1]["food"], [{"x": 2, "y": 2}])
|
||||
self.assertEqual(replay["turns"][1]["you"]["id"], "me")
|
||||
self.assertEqual(len(replay["turns"][1]["snakes"][0]["body"]), 3)
|
||||
me = next(snake for snake in replay["turns"][1]["snakes"] if snake["snake_id"] == "me")
|
||||
self.assertEqual(me["customizations"], {
|
||||
"color": "#00ff00",
|
||||
"head": "ferret",
|
||||
"tail": "swirl",
|
||||
})
|
||||
self.assertEqual(len(me["body"]), 3)
|
||||
api_me = next(snake for snake in replay["turns"][1]["board"]["snakes"] if snake["id"] == "me")
|
||||
self.assertEqual(api_me["customizations"], me["customizations"])
|
||||
|
||||
connection.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user