forked from ASPP/pelita_template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_demo01_stopping.py
35 lines (32 loc) · 1.34 KB
/
test_demo01_stopping.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from demo01_stopping import move
from pelita.utils import setup_test_game
def test_stays_there_simple_layout():
# Given a simple layout, verify that the bot does not move, independent
# of its initial position.
# Note that for this test, we only mention the walls (#), food (.) and bots
# b, x and y, but leave out bot a. Bot a will be specified in `setup_test_game`.
layout="""
########
# .#
#.b xy#
########
"""
# generate all possible locations within the maze
all_locations = ((x, y) for x in range(1,7) for y in range(1,3))
for loc in all_locations:
bot = setup_test_game(layout=layout, is_blue=True, bots={'a':loc})
next_pos = move(bot, {})
# check that we did not move
assert next_pos == bot.position
def test_stays_there_builtin_fixed_layout():
# Using a fixed builtin layout, verify that the bot stays on its initial position
bot = setup_test_game(layout='normal_050', is_blue=True)
next_pos = move(bot, {})
# check that we did not move
assert next_pos == bot.position
def test_stays_there_builtin_random_layout():
# Using a random builtin layout, verify that the bot stays on its initial position
bot = setup_test_game(layout=None, is_blue=True)
next_pos = move(bot, {})
# check that we did not move
assert next_pos == bot.position