forked from ASPP/pelita_template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_demo03_smartrandom.py
52 lines (48 loc) · 1.25 KB
/
test_demo03_smartrandom.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from demo03_smartrandom import move
from pelita.utils import setup_test_game
def test_legalmoves():
# check that the only two valid moves are always returned
# we try ten times, to test 10 different random streams
layout="""
########
#0######
#1. .EE#
########
"""
for i in range(10):
bot = setup_test_game(layout=layout, is_blue=True)
next_move,_ = move(bot, None)
assert next_move in ((0,1), (0,0))
def test_eat_enemy():
# check that we indeed eat an enemy when possible
layout="""
########
#E###.##
#0. 1E#
########
"""
bot = setup_test_game(layout=layout, is_blue=True)
next_move, _ = move(bot, None)
assert next_move == (0,-1)
def test_eat_food():
# check that we indeed collect food when possible
layout="""
########
#E # .##
#1.E 0 #
########
"""
bot = setup_test_game(layout=layout, is_blue=True)
next_move, _ = move(bot, None)
assert next_move == (0,-1)
def test_no_kamikaze_stop():
# Check that we stop if escaping would kill us
layout="""
########
# ###.#
#1. E0E#
########
"""
bot = setup_test_game(layout=layout, is_blue=True)
next_move, _ = move(bot, None)
assert next_move == (0, 0)