-
Notifications
You must be signed in to change notification settings - Fork 1
/
move_test.py
44 lines (35 loc) · 1.38 KB
/
move_test.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 unittest
import board
import move_generator
class Tests(unittest.TestCase):
def total_moves(self, depth: int, gs: board.GameState) -> int:
board_array = gs.board
active_player = gs.active_player()
total = 0
for rank in board_array:
for piece in rank:
if piece.get_color() == active_player:
lgl_moves = gs.legal_moves(move_generator.legal_moves(piece, gs.board))
for _ in lgl_moves:
if depth == 1:
total += 1
else:
gs.make_move(_, False)
total += self.total_moves(depth - 1, gs)
gs.undo_move(False)
return total
def test_first(self) -> None:
gs = board.GameState()
self.assertEqual(self.total_moves(1, gs), 20)
def test_second(self) -> None:
gs = board.GameState()
self.assertEqual(self.total_moves(2, gs), 400)
def test_third(self) -> None:
gs = board.GameState()
self.assertEqual(self.total_moves(3, gs), 8902)
def test_fourth(self) -> None:
gs = board.GameState()
self.assertEqual(self.total_moves(4, gs), 197281)
def test_fifth(self) -> None:
gs = board.GameState()
self.assertEqual(self.total_moves(5, gs), 4865609)