add enemy cut off trap check

This commit is contained in:
2026-04-04 09:55:58 +02:00
parent b0d484dbab
commit 316870ef7a
2 changed files with 186 additions and 1 deletions
+78
View File
@@ -468,6 +468,84 @@ class TestBestBattleSnake(unittest.TestCase):
move = make_board(game_state).snake_neat_make_a_move()
self.assertNotEqual(move, "up")
def test_avoids_enemy_block_in_trap(self):
game_state = {
"game": {
"id": "test-enemy-block-in-trap",
"ruleset": {"name": "standard", "version": "v1.0.0"},
"source": "custom",
"map": "standard",
},
"turn": 24,
"board": {
"height": 7,
"width": 7,
"food": [{"x": 3, "y": 3}],
"hazards": [],
"snakes": [
{
"id": "me",
"name": "me",
"health": 72,
"length": 4,
"head": {"x": 3, "y": 2},
"body": [
{"x": 3, "y": 2},
{"x": 3, "y": 1},
{"x": 2, "y": 1},
{"x": 2, "y": 2},
],
},
{
"id": "enemy-a",
"name": "enemy-a",
"health": 90,
"length": 6,
"head": {"x": 4, "y": 4},
"body": [
{"x": 4, "y": 4},
{"x": 4, "y": 3},
{"x": 4, "y": 2},
{"x": 5, "y": 2},
{"x": 5, "y": 3},
{"x": 5, "y": 4},
],
},
{
"id": "enemy-b",
"name": "enemy-b",
"health": 90,
"length": 6,
"head": {"x": 1, "y": 3},
"body": [
{"x": 1, "y": 3},
{"x": 1, "y": 4},
{"x": 0, "y": 4},
{"x": 0, "y": 3},
{"x": 0, "y": 2},
{"x": 1, "y": 2},
],
},
],
},
"you": {
"id": "me",
"name": "me",
"health": 72,
"length": 4,
"head": {"x": 3, "y": 2},
"body": [
{"x": 3, "y": 2},
{"x": 3, "y": 1},
{"x": 2, "y": 1},
{"x": 2, "y": 2},
],
},
}
move = make_board(game_state).snake_neat_make_a_move()
self.assertEqual(move, "left")
def test_royale_uses_ruleset_hazard_damage_setting(self):
game_state = {
"game": {