head hunt only when my snake is bigger and into dual mode
This commit is contained in:
@@ -218,6 +218,146 @@ class TestBestBattleSnake(unittest.TestCase):
|
||||
move = make_board(game_state).snake_neat_make_a_move()
|
||||
self.assertNotEqual(move, "right")
|
||||
|
||||
def test_duel_small_length_lead_does_not_head_hunt(self):
|
||||
game_state = {
|
||||
"game": {
|
||||
"id": "test-duel-small-no-head-hunt",
|
||||
"ruleset": {"name": "standard", "version": "v1.0.0"},
|
||||
"source": "custom",
|
||||
"map": "standard",
|
||||
},
|
||||
"turn": 20,
|
||||
"board": {
|
||||
"height": 11,
|
||||
"width": 11,
|
||||
"food": [{"x": 1, "y": 1}],
|
||||
"hazards": [],
|
||||
"snakes": [
|
||||
{
|
||||
"id": "me",
|
||||
"name": "me",
|
||||
"health": 90,
|
||||
"length": 7,
|
||||
"head": {"x": 5, "y": 5},
|
||||
"body": [
|
||||
{"x": 5, "y": 5},
|
||||
{"x": 5, "y": 4},
|
||||
{"x": 5, "y": 3},
|
||||
{"x": 4, "y": 3},
|
||||
{"x": 4, "y": 4},
|
||||
{"x": 4, "y": 5},
|
||||
{"x": 4, "y": 6},
|
||||
],
|
||||
},
|
||||
{
|
||||
"id": "enemy",
|
||||
"name": "enemy",
|
||||
"health": 90,
|
||||
"length": 6,
|
||||
"head": {"x": 7, "y": 5},
|
||||
"body": [
|
||||
{"x": 7, "y": 5},
|
||||
{"x": 7, "y": 4},
|
||||
{"x": 7, "y": 3},
|
||||
{"x": 7, "y": 2},
|
||||
{"x": 7, "y": 1},
|
||||
{"x": 6, "y": 1},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
"you": {
|
||||
"id": "me",
|
||||
"name": "me",
|
||||
"health": 90,
|
||||
"length": 7,
|
||||
"head": {"x": 5, "y": 5},
|
||||
"body": [
|
||||
{"x": 5, "y": 5},
|
||||
{"x": 5, "y": 4},
|
||||
{"x": 5, "y": 3},
|
||||
{"x": 4, "y": 3},
|
||||
{"x": 4, "y": 4},
|
||||
{"x": 4, "y": 5},
|
||||
{"x": 4, "y": 6},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
move = make_board(game_state).snake_neat_make_a_move()
|
||||
self.assertNotEqual(move, "right")
|
||||
|
||||
def test_duel_big_length_lead_can_head_hunt(self):
|
||||
game_state = {
|
||||
"game": {
|
||||
"id": "test-duel-big-head-hunt",
|
||||
"ruleset": {"name": "standard", "version": "v1.0.0"},
|
||||
"source": "custom",
|
||||
"map": "standard",
|
||||
},
|
||||
"turn": 20,
|
||||
"board": {
|
||||
"height": 11,
|
||||
"width": 11,
|
||||
"food": [{"x": 1, "y": 1}],
|
||||
"hazards": [],
|
||||
"snakes": [
|
||||
{
|
||||
"id": "me",
|
||||
"name": "me",
|
||||
"health": 90,
|
||||
"length": 8,
|
||||
"head": {"x": 5, "y": 5},
|
||||
"body": [
|
||||
{"x": 5, "y": 5},
|
||||
{"x": 5, "y": 4},
|
||||
{"x": 5, "y": 3},
|
||||
{"x": 4, "y": 3},
|
||||
{"x": 4, "y": 4},
|
||||
{"x": 4, "y": 5},
|
||||
{"x": 4, "y": 6},
|
||||
{"x": 5, "y": 6},
|
||||
],
|
||||
},
|
||||
{
|
||||
"id": "enemy",
|
||||
"name": "enemy",
|
||||
"health": 90,
|
||||
"length": 6,
|
||||
"head": {"x": 7, "y": 5},
|
||||
"body": [
|
||||
{"x": 7, "y": 5},
|
||||
{"x": 7, "y": 4},
|
||||
{"x": 7, "y": 3},
|
||||
{"x": 7, "y": 2},
|
||||
{"x": 7, "y": 1},
|
||||
{"x": 6, "y": 1},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
"you": {
|
||||
"id": "me",
|
||||
"name": "me",
|
||||
"health": 90,
|
||||
"length": 8,
|
||||
"head": {"x": 5, "y": 5},
|
||||
"body": [
|
||||
{"x": 5, "y": 5},
|
||||
{"x": 5, "y": 4},
|
||||
{"x": 5, "y": 3},
|
||||
{"x": 4, "y": 3},
|
||||
{"x": 4, "y": 4},
|
||||
{"x": 4, "y": 5},
|
||||
{"x": 4, "y": 6},
|
||||
{"x": 5, "y": 6},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
move = make_board(game_state).snake_neat_make_a_move()
|
||||
self.assertEqual(move, "right")
|
||||
|
||||
def test_does_not_step_into_stacked_tail(self):
|
||||
game_state = {
|
||||
"game": {
|
||||
|
||||
Reference in New Issue
Block a user