-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
executable file
·77 lines (68 loc) · 2.12 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from typing import Dict, Tuple
from chess import Chess
from colorama import Fore, Style
def test_move_gen(data: Dict[bytes, Tuple[int, int]]) -> None:
for fen, test_cases in data.items():
print(f"\n{Fore.CYAN}Testing FEN: {fen}{Style.RESET_ALL}")
print(f"{'-'*40}")
c.load_fen(fen)
for i, (depth, expected_result) in enumerate(test_cases, start=1):
result = c.perft_test(depth)
if result == expected_result:
print(f"{Fore.GREEN}[✓] Test {i}: Depth {depth} passed {Style.RESET_ALL}")
print(f" {Fore.YELLOW}Expected: {expected_result}, Got: {result}{Style.RESET_ALL}")
else:
print(f"{Fore.RED}[✗] Test {i}: Depth {depth} failed")
print(f" {Fore.YELLOW}Expected: {expected_result}, Got: {result}{Style.RESET_ALL}")
print(f"{'-'*40}\n")
return None
if __name__ == '__main__':
tests = {
b'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1':
[
(0, 1),
(1, 20),
(2, 400),
(3, 8902),
(4, 197281),
(5, 4865609),
(6, 119060324)
],
b'r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - ' :
[
(1, 48),
(2, 2039),
(3, 97862),
(4, 4085603),
(5, 193690690),
(6, 8031647685)
],
b'r3k2r/Pppp1ppp/1b3nbN/nP6/BBP1P3/q4N2/Pp1P2PP/R2Q1RK1 w kq - 0 1' :
[
(1, 6),
(2, 264),
(3, 9467),
(4, 422333),
(5, 15833292),
(6, 706045033)
],
b'8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - - ' :
[
(1, 14),
(2, 191),
(3, 2812),
(4, 43238),
(5, 674624),
(6, 11030083),
(7, 178633661)
],
b'rnbq1k1r/pp1Pbppp/2p5/8/2B5/8/PPP1NnPP/RNBQK2R w KQ - 1 8':
[
(1, 44),
(2, 1486),
(3, 63379),
(4, 2103487)
]
}
c = Chess()
test_move_gen(tests)