add better enemy constrictor projection

This commit is contained in:
2026-04-03 21:39:08 +02:00
parent fb579e5fbc
commit dfcdbae85b
2 changed files with 110 additions and 0 deletions
+70
View File
@@ -681,5 +681,75 @@ class TestBestBattleSnake(unittest.TestCase):
move = make_board(game_state).snake_neat_make_a_move()
self.assertEqual(move, "right")
def test_constrictor_prefers_choke_when_safe(self):
game_state = {
"game": {
"id": "test-constrictor-choke",
"ruleset": {"name": "constrictor", "version": "v1.0.0"},
"source": "custom",
"map": "standard",
},
"turn": 25,
"board": {
"height": 7,
"width": 7,
"food": [],
"hazards": [],
"snakes": [
{
"id": "me",
"name": "me",
"health": 100,
"length": 7,
"head": {"x": 2, "y": 3},
"body": [
{"x": 2, "y": 3},
{"x": 2, "y": 2},
{"x": 1, "y": 2},
{"x": 1, "y": 3},
{"x": 1, "y": 4},
{"x": 2, "y": 4},
{"x": 2, "y": 5},
],
},
{
"id": "enemy",
"name": "enemy",
"health": 100,
"length": 7,
"head": {"x": 4, "y": 3},
"body": [
{"x": 4, "y": 3},
{"x": 5, "y": 3},
{"x": 5, "y": 2},
{"x": 4, "y": 2},
{"x": 4, "y": 1},
{"x": 5, "y": 1},
{"x": 6, "y": 1},
],
},
],
},
"you": {
"id": "me",
"name": "me",
"health": 100,
"length": 7,
"head": {"x": 2, "y": 3},
"body": [
{"x": 2, "y": 3},
{"x": 2, "y": 2},
{"x": 1, "y": 2},
{"x": 1, "y": 3},
{"x": 1, "y": 4},
{"x": 2, "y": 4},
{"x": 2, "y": 5},
],
},
}
move = make_board(game_state).snake_neat_make_a_move()
self.assertEqual(move, "right")
if __name__ == "__main__":
unittest.main()