@@ -6,6 +6,67 @@ import 'perft_parser.dart';
6
6
const nodeLimit = 10000000 ;
7
7
8
8
void main () async {
9
+ group ('Standard chess' , () {
10
+ test ('initial position' , () {
11
+ const pos = Chess .initial;
12
+ expect (perft (pos, 0 ), 1 );
13
+ expect (perft (pos, 1 ), 20 );
14
+ expect (perft (pos, 2 ), 400 );
15
+ expect (perft (pos, 3 ), 8902 );
16
+ expect (perft (pos, 4 ), 197281 );
17
+ });
18
+
19
+ group ('tricky' , () {
20
+ final tests = Parser ()
21
+ .parse (File ('test/resources/tricky.perft' ).readAsStringSync ());
22
+ for (final perftTest in tests) {
23
+ for (final testCase in perftTest.cases
24
+ .takeWhile ((testCase) => testCase.nodes < nodeLimit)) {
25
+ test ('${perftTest .id } ${perftTest .fen } ${testCase .depth }' , () {
26
+ final position = Chess .fromSetup (Setup .parseFen (perftTest.fen));
27
+ expect (perft (position, testCase.depth), testCase.nodes,
28
+ reason:
29
+ 'id: ${perftTest .id }\n fen: ${perftTest .fen } \n depth: ${testCase .depth } \n nodes: ${testCase .nodes }' );
30
+ });
31
+ }
32
+ }
33
+ });
34
+
35
+ group ('impossible checker' , () {
36
+ final tests = Parser ().parse (
37
+ File ('test/resources/impossible-checker.perft' ).readAsStringSync ());
38
+ for (final perftTest in tests) {
39
+ for (final testCase in perftTest.cases
40
+ .takeWhile ((testCase) => testCase.nodes < nodeLimit)) {
41
+ test ('${perftTest .id } ${perftTest .fen } ${testCase .depth }' , () {
42
+ final position = Chess .fromSetup (Setup .parseFen (perftTest.fen),
43
+ ignoreImpossibleCheck: true );
44
+ expect (perft (position, testCase.depth), testCase.nodes,
45
+ reason:
46
+ 'id: ${perftTest .id }\n fen: ${perftTest .fen } \n depth: ${testCase .depth } \n nodes: ${testCase .nodes }' );
47
+ });
48
+ }
49
+ }
50
+ });
51
+
52
+ group ('random' , () {
53
+ final tests = Parser ()
54
+ .parse (File ('test/resources/random.perft' ).readAsStringSync ());
55
+ // only test 10 position in random. Test file has around 6000 positions
56
+ for (final perftTest in tests.take (50 )) {
57
+ final position = Chess .fromSetup (Setup .parseFen (perftTest.fen));
58
+ for (final testCase in perftTest.cases
59
+ .takeWhile ((testCase) => testCase.nodes < nodeLimit)) {
60
+ test ('${perftTest .id } ${perftTest .fen } ${testCase .depth }' , () {
61
+ expect (perft (position, testCase.depth), testCase.nodes,
62
+ reason:
63
+ 'id: ${perftTest .id }\n fen: ${perftTest .fen } \n depth: ${testCase .depth } \n nodes: ${testCase .nodes }' );
64
+ });
65
+ }
66
+ }
67
+ });
68
+ });
69
+
9
70
group ('Three Check' , () {
10
71
final tests =
11
72
Parser ().parse (File ('test/resources/3check.perft' ).readAsStringSync ());
@@ -103,52 +164,6 @@ void main() async {
103
164
}
104
165
});
105
166
106
- // group('Chess Tricky', () {
107
- // final tests =
108
- // Parser().parse(File('test/resources/tricky.perft').readAsStringSync());
109
- // for (final perftTest in tests) {
110
- // for (final testCase in perftTest.cases
111
- // .takeWhile((testCase) => testCase.nodes < nodeLimit)) {
112
- // test('${perftTest.id} ${perftTest.fen} ${testCase.depth}', () {
113
- // final position = Chess.fromSetup(Setup.parseFen(perftTest.fen),
114
- // ignoreImpossibleCheck:
115
- // true); // true: otherwise there is an Impossible Check Error
116
- // expect(perft(position, testCase.depth), testCase.nodes,
117
- // reason:
118
- // 'id: ${perftTest.id}\nfen: ${perftTest.fen} \ndepth: ${testCase.depth} \nnodes: ${testCase.nodes}');
119
- // });
120
- // }
121
- // }
122
- // });
123
-
124
- group ('Random' , () {
125
- final tests =
126
- Parser ().parse (File ('test/resources/random.perft' ).readAsStringSync ());
127
- // only test 10 position in random. Test file has around 6000 positions
128
- for (final perftTest in tests.take (50 )) {
129
- final position = Chess .fromSetup (Setup .parseFen (perftTest.fen));
130
- for (final testCase in perftTest.cases
131
- .takeWhile ((testCase) => testCase.nodes < nodeLimit)) {
132
- test ('${perftTest .id } ${perftTest .fen } ${testCase .depth }' , () {
133
- expect (perft (position, testCase.depth), testCase.nodes,
134
- reason:
135
- 'id: ${perftTest .id }\n fen: ${perftTest .fen } \n depth: ${testCase .depth } \n nodes: ${testCase .nodes }' );
136
- });
137
- }
138
- }
139
- });
140
-
141
- group ('Standard' , () {
142
- test ('initial position' , () {
143
- const pos = Chess .initial;
144
- expect (perft (pos, 0 ), 1 );
145
- expect (perft (pos, 1 ), 20 );
146
- expect (perft (pos, 2 ), 400 );
147
- expect (perft (pos, 3 ), 8902 );
148
- expect (perft (pos, 4 ), 197281 );
149
- });
150
- });
151
-
152
167
group ('Chess 960' , () {
153
168
final tests = Parser ()
154
169
.parse (File ('test/resources/chess960.perft' ).readAsStringSync ());
0 commit comments