forked from ucfai/team-game-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_mnk.py
44 lines (39 loc) · 1.03 KB
/
test_mnk.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
import mnk
def test_str():
board = mnk.Board(3, 3, 2)
assert str(board) == '_|_|_\n'*3
def test_move():
board = mnk.Board(3, 3, 2)
board.move(0, 0)
board.move(1, 2)
board.move(2, 1)
assert str(board) == (
'_|O|_\n'
'_|_|X\n'
'X|_|_\n')
def test_undo_move():
board = mnk.Board(3, 3, 2)
board.move(0, 0)
board.undo_move()
assert str(board) == '_|_|_\n'*3
def test_legal_moves():
board = mnk.Board(3, 3, 2)
assert len(board.legal_moves()) == 9
board.move(0, 0)
assert len(board.legal_moves()) == 8
def test_player_has_lost():
board = mnk.Board(3, 3, 2)
board.move(1, 1)
board.move(2, 2)
assert not board.player_has_lost()
board.move(0, 0)
assert board.player_has_lost()
board.undo_move()
board.move(1, 0)
assert board.player_has_lost()
board.undo_move()
board.move(2, 0)
assert board.player_has_lost()
board.undo_move()
board.move(2, 1)
assert board.player_has_lost()