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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
|
/**
Copyright (c) Scott Gasch
Module Name:
script.c
Abstract:
Some glue code to support running test scripts and keeping track
of test suite results.
Author:
Scott Gasch ([email protected]) 18 May 2004
Revision History:
$Id: script.c 355 2008-07-01 15:46:43Z scott $
**/
#include "chess.h"
// Declared directly instead of #include <math.h> -- that header #defines
// its own INFINITY_SCORE, which collides with ours (chess.h:198, MAX_SHORT) and
// would silently change what INFINITY_SCORE means for the rest of this file.
extern double pow(double, double);
// ----------------------------------------------------------------------
//
// Global testsuite position counters
//
#define SUITE_MAX_SOLUTIONS (4)
#define SUITE_MAX_AVOIDS (4)
#define SUITE_NUM_HISTOGRAM (8)
//
// A big struct of counters we want to maintain when running test scripts.
//
typedef struct _SUITE_COUNTERS
{
CHAR szId[SMALL_STRING_LEN_CHAR];
ULONG uNumSolutions;
MOVE mvSolution[SUITE_MAX_SOLUTIONS];
ULONG uNumAvoids;
MOVE mvAvoid[SUITE_MAX_AVOIDS];
ULONG uCorrect;
ULONG uIncorrect;
ULONG uTotal;
UINT64 u64TotalNodeCount;
double dCurrentSolutionTime;
ULONG uCurrentSolvedPlies;
ULONG uSigmaDepth;
double dSigmaSolutionTime;
double dAverageNps;
UINT64 u64TotalBetaCutoffs;
UINT64 u64TotalBetaCutoffsOnFirstMove;
UINT64 u64TotalCounterMoveTries;
UINT64 u64TotalCounterMoveHits;
UINT64 u64TotalLeftoverTries;
UINT64 u64TotalLeftoverAlpha;
UINT64 u64TotalLeftoverFH;
UINT64 u64TotalCMEvidenceTries[CM_EVIDENCE_BUCKETS];
UINT64 u64TotalCMEvidenceFH[CM_EVIDENCE_BUCKETS];
// See chess.h's HANG_CP_BUCKETS comment. Same accumulation/print
// pattern as u64TotalCMEvidenceTries above -- only meaningful
// gathered single-threaded (--cpus 1), same as that one (not
// wired into split.c's MP merge).
UINT64 u64TotalHangEstimateTries[HANG_CP_BUCKETS];
UINT64 u64TotalHangEstimateFH[HANG_CP_BUCKETS];
// The real comparison baseline for the buckets above -- same
// fPruneReduceEligible population, not just fIsLeftoverMove.
UINT64 u64TotalEligibleLeftoverTries;
UINT64 u64TotalEligibleLeftoverFH;
// The "down axis" -- (iAlpha - iEval) calibration. Same population
// and comparison baseline as the hang-estimate buckets above.
UINT64 u64TotalGapEstimateTries[GAP_CP_BUCKETS];
UINT64 u64TotalGapEstimateFH[GAP_CP_BUCKETS];
// The "late axis" -- this move's own ordinal position calibration.
// Same population and comparison baseline as the other two axes.
UINT64 u64TotalMoveNumEstimateTries[MOVE_NUM_BUCKETS];
UINT64 u64TotalMoveNumEstimateFH[MOVE_NUM_BUCKETS];
// The "depth axis" -- remaining search depth calibration. Same
// population and comparison baseline as the other three axes.
UINT64 u64TotalDepthEstimateTries[SEARCH_DEPTH_BUCKETS];
UINT64 u64TotalDepthEstimateFH[SEARCH_DEPTH_BUCKETS];
// Joint 4D table, marginal (uncoarsened) resolution -- reassembled
// offline by the bake script via the FOURAXISRAW dump below, never
// printed as a human-readable table here (21,780+ shipped cells,
// 99,825 at this raw resolution -- far too many lines).
UINT64 u64TotalJointTries[SEARCH_DEPTH_BUCKETS][HANG_CP_BUCKETS][GAP_CP_BUCKETS][MOVE_NUM_BUCKETS];
UINT64 u64TotalJointFH[SEARCH_DEPTH_BUCKETS][HANG_CP_BUCKETS][GAP_CP_BUCKETS][MOVE_NUM_BUCKETS];
// Phase 2 -- joint-table-driven graduated LMR calibration (see
// search.c's JOINT_EXTRA_TIER*_THOUSANDTHS comment).
UINT64 u64TotalJointExtraTries[JOINT_EXTRA_TIER_COUNT];
UINT64 u64TotalJointExtraResearch[JOINT_EXTRA_TIER_COUNT];
UINT64 u64TotalLMPPruned;
#ifdef FH_TABLE_COLLECTION
// Full dual-table (5D alpha + 4D beta) collection -- see chess.h's
// SEARCHER_THREAD_CONTEXT.sCounters.tree comment for the full
// design. Dumped as ALPHARAW/BETARAW (5/4-axis raw cells) and
// ESTRAW (1D marginals) below, never printed as a human-readable
// table here -- same reasoning as u64TotalJointTries/FH above,
// just a much bigger shape (the 5D alpha array alone is
// 25*11*11*33*11 = 1,208,625 raw cells).
UINT64 u64TotalAlpha5Tries[SEARCH_DEPTH_BUCKETS][HANG_CP_BUCKETS][GAP_CP_BUCKETS][MOVE_NUM_BUCKETS][IMPROVE_BUCKETS];
UINT64 u64TotalAlpha5FH[SEARCH_DEPTH_BUCKETS][HANG_CP_BUCKETS][GAP_CP_BUCKETS][MOVE_NUM_BUCKETS][IMPROVE_BUCKETS];
UINT64 u64TotalBetaTries[SEARCH_DEPTH_BUCKETS][GAP_BETA_BUCKETS][IMPROVE_BUCKETS][IMPROVE_BUCKETS];
UINT64 u64TotalBetaFH[SEARCH_DEPTH_BUCKETS][GAP_BETA_BUCKETS][IMPROVE_BUCKETS][IMPROVE_BUCKETS];
UINT64 u64TotalImproveEstimateTries[IMPROVE_BUCKETS];
UINT64 u64TotalImproveEstimateFH[IMPROVE_BUCKETS];
UINT64 u64TotalBetaDepthEstimateTries[SEARCH_DEPTH_BUCKETS];
UINT64 u64TotalBetaDepthEstimateFH[SEARCH_DEPTH_BUCKETS];
UINT64 u64TotalBetaGapEstimateTries[GAP_BETA_BUCKETS];
UINT64 u64TotalBetaGapEstimateFH[GAP_BETA_BUCKETS];
UINT64 u64TotalBetaOwnImpEstimateTries[IMPROVE_BUCKETS];
UINT64 u64TotalBetaOwnImpEstimateFH[IMPROVE_BUCKETS];
UINT64 u64TotalBetaEnemyImpEstimateTries[IMPROVE_BUCKETS];
UINT64 u64TotalBetaEnemyImpEstimateFH[IMPROVE_BUCKETS];
#endif // FH_TABLE_COLLECTION
#ifdef JOINT_EXTRA_VERIFY
UINT64 u64TotalJointExtraVerifyTries[JOINT_EXTRA_TIER_COUNT][POST_REDUCE_DEPTH_BUCKETS];
UINT64 u64TotalJointExtraVerifySilentMiss[JOINT_EXTRA_TIER_COUNT][POST_REDUCE_DEPTH_BUCKETS];
UINT64 u64TotalJointExtraVerifyNullBailoutSignature[JOINT_EXTRA_TIER_COUNT];
#endif
#ifdef TEST_NULL
// Null-move precision/recall calibration, summed across every
// position in the suite -- see _NullCalibBucketIndex's comment in
// search.c. Accumulated the same way as u64TotalCMEvidenceTries
// above (per-search counters are copied into g_Options at the end
// of each Think() call, then summed in here by _ProcessSuiteLine),
// and printed once by _PrintSuiteReport at true end-of-suite --
// deliberately *not* dumped after every position, which would
// balloon the logfile (confirmed: 191MB after ~28K of 200K
// positions the first time this was tried that way).
UINT64 u64TotalNCAttempts[NC_TOTAL_BUCKETS];
UINT64 u64TotalNCNullFH[NC_TOTAL_BUCKETS];
UINT64 u64TotalNCRealFH[NC_TOTAL_BUCKETS];
UINT64 u64TotalNCBothFH[NC_TOTAL_BUCKETS];
UINT64 u64TotalNCNullProbeNodeSum[NC_TOTAL_BUCKETS];
UINT64 u64TotalNCFirstMoveNodeSum[NC_TOTAL_BUCKETS];
UINT64 u64TotalNCRealLoopNodeSum[NC_TOTAL_BUCKETS];
#endif
double dSigmaEBF; // sum of per-problem nodes^(1/depth)
ULONG uEBFCount; // number of problems with depth > 0
double dAverageTimeToSolution;
ULONG uHistogram[SUITE_NUM_HISTOGRAM];
}
SUITE_COUNTERS;
static SUITE_COUNTERS g_SuiteCounters;
static void
_ClearSuiteData(void)
/**
Routine description:
Clear data/counters we have for the current test script.
Parameters:
void
Return value:
static void
**/
{
g_SuiteCounters.uNumSolutions = 0;
memset(g_SuiteCounters.mvSolution,
0,
sizeof(g_SuiteCounters.mvSolution));
g_SuiteCounters.uNumAvoids = 0;
memset(g_SuiteCounters.mvAvoid,
0,
sizeof(g_SuiteCounters.mvAvoid));
memset(g_SuiteCounters.szId,
0,
sizeof(g_SuiteCounters.szId));
g_SuiteCounters.uCurrentSolvedPlies = 0;
g_SuiteCounters.dCurrentSolutionTime = 0;
}
COMMAND(IdCommand)
/**
Routine description:
This function implements the 'id' engine command.
Usage:
id [optional string]
With no agruments, id returns the current position's id tag.
With a string argument, id sets the current position's id tag.
id tags are useful[?] for naming positions in test suites...
Parameters:
The COMMAND macro hides four arguments from the input parser:
CHAR *szInput : the full line of input
ULONG argc : number of argument chunks
CHAR *argv[] : array of ptrs to each argument chunk
POSITION *pos : a POSITION pointer to operate on
Return value:
void
**/
{
CHAR *p;
ULONG u;
if (argc < 2)
{
Trace("The current position's id is: \"%s\"\n",
g_SuiteCounters.szId);
}
else
{
p = szInput;
while(*p && !isspace(*p))
{
p++;
}
while(*p && isspace(*p))
{
p++;
}
u = 0;
while(*p)
{
if (!isspace(*p))
{
g_SuiteCounters.szId[u] = *p;
u++;
}
if (u > ARRAY_LENGTH(g_SuiteCounters.szId))
{
break;
}
p++;
}
}
}
COMMAND(SolutionCommand)
/**
Routine description:
This function implements the 'solution' engine command.
Usage:
solution [optional move string]
With no agruments, solution prints out a list of the "correct
solution" move(s) set for the current position.
With a move string argument solution sets another move as the
correct answer to the current position. The move string can
be in ICS or SAN format.
When the engine is allowed to search a position it will
compare its best move from the search against the solution
move(s) for the position and keep track of how many it gets
right/wrong and how long it took to solve.
A position can have up to three solutions. A position cannot
have both solution moves and avoid moves.
Parameters:
The COMMAND macro hides four arguments from the input parser:
CHAR *szInput : the full line of input
ULONG argc : number of argument chunks
CHAR *argv[] : array of ptrs to each argument chunk
POSITION *pos : a POSITION pointer to operate on
Return value:
void
**/
{
ULONG u;
MOVE mv;
if (argc < 2)
{
Trace("There %s %u solution move%s set:\n",
(g_SuiteCounters.uNumSolutions > 1) ? "are" : "is",
g_SuiteCounters.uNumSolutions,
(g_SuiteCounters.uNumSolutions > 1) ? "s" : "");
for(u = 0;
u < g_SuiteCounters.uNumSolutions;
u++)
{
Trace(" %s\n", MoveToSan(g_SuiteCounters.mvSolution[u], pos));
}
}
else
{
mv.uMove = 0;
switch(LooksLikeMove(argv[1]))
{
case MOVE_SAN:
mv = ParseMoveSan(argv[1], pos);
break;
case MOVE_ICS:
mv = ParseMoveIcs(argv[1], pos);
break;
case NOT_MOVE:
break;
}
if (mv.uMove == 0)
{
Trace("Error (bad move): %s\n", argv[1]);
return;
}
if (g_SuiteCounters.uNumSolutions < SUITE_MAX_SOLUTIONS)
{
g_SuiteCounters.mvSolution[g_SuiteCounters.uNumSolutions] = mv;
g_SuiteCounters.uNumSolutions++;
}
}
}
COMMAND(AvoidCommand)
/**
Routine description:
This function implements the 'avoid' engine command.
Usage:
avoid [optional move string]
With no agruments, avoid prints out a list of the "don't play
this" move(s) set for the current position.
With a move string argument, avoid sets another move as the
incorrect answer to the current position. The move string can
be in ICS or SAN format.
When the engine is allowed to search a position it will
compare its best move from the search against the avoid
move(s) for the position and keep track of how many it gets
right/wrong and how long it took to solve.
A position can have up to three avoid moves. A position
cannot have both solution moves and avoid moves.
Parameters:
The COMMAND macro hides four arguments from the input parser:
CHAR *szInput : the full line of input
ULONG argc : number of argument chunks
CHAR *argv[] : array of ptrs to each argument chunk
POSITION *pos : a POSITION pointer to operate on
Return value:
void
**/
{
ULONG u;
MOVE mv;
if (argc < 2)
{
Trace("There %s %u avoid move%s set:\n",
(g_SuiteCounters.uNumAvoids > 1) ? "are" : "is",
g_SuiteCounters.uNumAvoids,
(g_SuiteCounters.uNumAvoids > 1) ? "s" : "");
for(u = 0;
u < g_SuiteCounters.uNumAvoids;
u++)
{
Trace(" %s\n", MoveToSan(g_SuiteCounters.mvAvoid[u], pos));
}
}
else
{
mv.uMove = 0;
switch(LooksLikeMove(argv[1]))
{
case MOVE_SAN:
mv = ParseMoveSan(argv[1], pos);
break;
case MOVE_ICS:
mv = ParseMoveIcs(argv[1], pos);
break;
case NOT_MOVE:
break;
}
if (mv.uMove == 0)
{
Trace("Error (bad move): %s\n", argv[1]);
return;
}
if (g_SuiteCounters.uNumAvoids < SUITE_MAX_AVOIDS)
{
g_SuiteCounters.mvAvoid[g_SuiteCounters.uNumAvoids] = mv;
g_SuiteCounters.uNumAvoids++;
}
}
}
//
// Shared by ScriptCommand and EpdCommand: process one already-read
// line exactly the way a script file's line is processed -- "go"
// triggers a search plus counter accumulation, anything else is
// dispatched through the normal command parser. Factored out so
// EpdCommand can feed it lines synthesized from a raw EPD record
// (setboard/id/solution/avoid/go) instead of lines read verbatim from
// a file, without duplicating this logic or its counter bookkeeping.
//
static void
_ProcessSuiteLine(char *szLine, POSITION *pos)
{
Trace("SCRIPT> %s\n", szLine);
if (!STRNCMPI(szLine, "go", 2))
{
(void)Think(pos);
g_SuiteCounters.u64TotalNodeCount +=
g_Options.u64NodesSearched;
g_SuiteCounters.u64TotalBetaCutoffs +=
g_Options.u64BetaCutoffs;
g_SuiteCounters.u64TotalBetaCutoffsOnFirstMove +=
g_Options.u64BetaCutoffsOnFirstMove;
g_SuiteCounters.u64TotalCounterMoveTries +=
g_Options.u64CounterMoveTries;
g_SuiteCounters.u64TotalCounterMoveHits +=
g_Options.u64CounterMoveHits;
g_SuiteCounters.u64TotalLeftoverTries +=
g_Options.u64LeftoverTries;
g_SuiteCounters.u64TotalLeftoverAlpha +=
g_Options.u64LeftoverAlpha;
g_SuiteCounters.u64TotalLeftoverFH +=
g_Options.u64LeftoverFH;
{
ULONG v;
for (v = 0; v < CM_EVIDENCE_BUCKETS; v++)
{
g_SuiteCounters.u64TotalCMEvidenceTries[v] +=
g_Options.u64CMEvidenceTries[v];
g_SuiteCounters.u64TotalCMEvidenceFH[v] +=
g_Options.u64CMEvidenceFH[v];
}
for (v = 0; v < HANG_CP_BUCKETS; v++)
{
g_SuiteCounters.u64TotalHangEstimateTries[v] +=
g_Options.u64HangEstimateTries[v];
g_SuiteCounters.u64TotalHangEstimateFH[v] +=
g_Options.u64HangEstimateFH[v];
}
g_SuiteCounters.u64TotalEligibleLeftoverTries +=
g_Options.u64EligibleLeftoverTries;
g_SuiteCounters.u64TotalEligibleLeftoverFH +=
g_Options.u64EligibleLeftoverFH;
for (v = 0; v < GAP_CP_BUCKETS; v++)
{
g_SuiteCounters.u64TotalGapEstimateTries[v] +=
g_Options.u64GapEstimateTries[v];
g_SuiteCounters.u64TotalGapEstimateFH[v] +=
g_Options.u64GapEstimateFH[v];
}
for (v = 0; v < MOVE_NUM_BUCKETS; v++)
{
g_SuiteCounters.u64TotalMoveNumEstimateTries[v] +=
g_Options.u64MoveNumEstimateTries[v];
g_SuiteCounters.u64TotalMoveNumEstimateFH[v] +=
g_Options.u64MoveNumEstimateFH[v];
}
for (v = 0; v < SEARCH_DEPTH_BUCKETS; v++)
{
g_SuiteCounters.u64TotalDepthEstimateTries[v] +=
g_Options.u64DepthEstimateTries[v];
g_SuiteCounters.u64TotalDepthEstimateFH[v] +=
g_Options.u64DepthEstimateFH[v];
}
{
ULONG a, b, c;
for (a = 0; a < SEARCH_DEPTH_BUCKETS; a++)
{
for (b = 0; b < HANG_CP_BUCKETS; b++)
{
for (c = 0; c < GAP_CP_BUCKETS; c++)
{
for (v = 0; v < MOVE_NUM_BUCKETS; v++)
{
g_SuiteCounters.u64TotalJointTries[a][b][c][v] +=
g_Options.u64JointTries[a][b][c][v];
g_SuiteCounters.u64TotalJointFH[a][b][c][v] +=
g_Options.u64JointFH[a][b][c][v];
}
}
}
}
}
for (v = 0; v < JOINT_EXTRA_TIER_COUNT; v++)
{
g_SuiteCounters.u64TotalJointExtraTries[v] +=
g_Options.u64JointExtraTries[v];
g_SuiteCounters.u64TotalJointExtraResearch[v] +=
g_Options.u64JointExtraResearch[v];
}
g_SuiteCounters.u64TotalLMPPruned +=
g_Options.u64LMPPruned;
#ifdef FH_TABLE_COLLECTION
{
ULONG a, b, c, d;
for (a = 0; a < SEARCH_DEPTH_BUCKETS; a++)
{
for (b = 0; b < HANG_CP_BUCKETS; b++)
{
for (c = 0; c < GAP_CP_BUCKETS; c++)
{
for (d = 0; d < MOVE_NUM_BUCKETS; d++)
{
for (v = 0; v < IMPROVE_BUCKETS; v++)
{
g_SuiteCounters.u64TotalAlpha5Tries[a][b][c][d][v] +=
g_Options.u64Alpha5Tries[a][b][c][d][v];
g_SuiteCounters.u64TotalAlpha5FH[a][b][c][d][v] +=
g_Options.u64Alpha5FH[a][b][c][d][v];
}
}
}
}
}
for (a = 0; a < SEARCH_DEPTH_BUCKETS; a++)
{
for (b = 0; b < GAP_BETA_BUCKETS; b++)
{
for (c = 0; c < IMPROVE_BUCKETS; c++)
{
for (d = 0; d < IMPROVE_BUCKETS; d++)
{
g_SuiteCounters.u64TotalBetaTries[a][b][c][d] +=
g_Options.u64BetaTries[a][b][c][d];
g_SuiteCounters.u64TotalBetaFH[a][b][c][d] +=
g_Options.u64BetaFH[a][b][c][d];
}
}
}
}
for (v = 0; v < IMPROVE_BUCKETS; v++)
{
g_SuiteCounters.u64TotalImproveEstimateTries[v] +=
g_Options.u64ImproveEstimateTries[v];
g_SuiteCounters.u64TotalImproveEstimateFH[v] +=
g_Options.u64ImproveEstimateFH[v];
g_SuiteCounters.u64TotalBetaOwnImpEstimateTries[v] +=
g_Options.u64BetaOwnImpEstimateTries[v];
g_SuiteCounters.u64TotalBetaOwnImpEstimateFH[v] +=
g_Options.u64BetaOwnImpEstimateFH[v];
g_SuiteCounters.u64TotalBetaEnemyImpEstimateTries[v] +=
g_Options.u64BetaEnemyImpEstimateTries[v];
g_SuiteCounters.u64TotalBetaEnemyImpEstimateFH[v] +=
g_Options.u64BetaEnemyImpEstimateFH[v];
}
for (v = 0; v < SEARCH_DEPTH_BUCKETS; v++)
{
g_SuiteCounters.u64TotalBetaDepthEstimateTries[v] +=
g_Options.u64BetaDepthEstimateTries[v];
g_SuiteCounters.u64TotalBetaDepthEstimateFH[v] +=
g_Options.u64BetaDepthEstimateFH[v];
}
for (v = 0; v < GAP_BETA_BUCKETS; v++)
{
g_SuiteCounters.u64TotalBetaGapEstimateTries[v] +=
g_Options.u64BetaGapEstimateTries[v];
g_SuiteCounters.u64TotalBetaGapEstimateFH[v] +=
g_Options.u64BetaGapEstimateFH[v];
}
}
#endif // FH_TABLE_COLLECTION
#ifdef JOINT_EXTRA_VERIFY
{
ULONG w;
for (v = 0; v < JOINT_EXTRA_TIER_COUNT; v++)
{
for (w = 0; w < POST_REDUCE_DEPTH_BUCKETS; w++)
{
g_SuiteCounters.u64TotalJointExtraVerifyTries[v][w] +=
g_Options.u64JointExtraVerifyTries[v][w];
g_SuiteCounters.u64TotalJointExtraVerifySilentMiss[v][w] +=
g_Options.u64JointExtraVerifySilentMiss[v][w];
}
g_SuiteCounters.u64TotalJointExtraVerifyNullBailoutSignature[v] +=
g_Options.u64JointExtraVerifyNullBailoutSignature[v];
}
}
#endif
}
#ifdef TEST_NULL
{
ULONG v;
for (v = 0; v < NC_TOTAL_BUCKETS; v++)
{
g_SuiteCounters.u64TotalNCAttempts[v] +=
g_Options.u64NCAttempts[v];
g_SuiteCounters.u64TotalNCNullFH[v] +=
g_Options.u64NCNullFH[v];
g_SuiteCounters.u64TotalNCRealFH[v] +=
g_Options.u64NCRealFH[v];
g_SuiteCounters.u64TotalNCBothFH[v] +=
g_Options.u64NCBothFH[v];
g_SuiteCounters.u64TotalNCNullProbeNodeSum[v] +=
g_Options.u64NCNullProbeNodeSum[v];
g_SuiteCounters.u64TotalNCFirstMoveNodeSum[v] +=
g_Options.u64NCFirstMoveNodeSum[v];
g_SuiteCounters.u64TotalNCRealLoopNodeSum[v] +=
g_Options.u64NCRealLoopNodeSum[v];
}
}
#endif
}
else
{
ExecuteCommandLineDirectly(szLine, pos);
}
}
//
// Shared by ScriptCommand and EpdCommand: the end-of-suite banner and
// statistics report. Verbatim extraction of what used to be
// ScriptCommand's own tail -- see that function's history for the
// meaning of each field.
//
static void
_PrintSuiteReport(double dSuiteStart)
{
ULONG u, v, uMax;
double dMult = (double)g_Options.uMyIncrement / (double)SUITE_NUM_HISTOGRAM;
Banner();
Trace("\n"
"TEST SCRIPT execution complete. Final statistics:\n"
"--------------------------------------------------\n"
" correct solutions : %u\n"
" incorrect solutions : %u\n"
" total problems : %u\n"
" total nodecount : %"
COMPILER_LONGLONG_UNSIGNED_FORMAT "\n"
" avg. search speed : %6.1f nps\n"
" avg. solution time : %3.1f sec\n"
" avg. search depth : %4.1f ply\n"
" 1st move beta cut : %5.2f percent\n"
" avg. eff. branching : %5.3f\n"
" counter move hit %% : %5.2f percent (%"
COMPILER_LONGLONG_UNSIGNED_FORMAT " tries)\n"
" leftover : %5.2f%% alpha, %5.2f%% FH (%"
COMPILER_LONGLONG_UNSIGNED_FORMAT " tries)\n"
" script time : %6.1f sec\n\n",
g_SuiteCounters.uCorrect,
g_SuiteCounters.uIncorrect,
g_SuiteCounters.uTotal,
g_SuiteCounters.u64TotalNodeCount,
((double)g_SuiteCounters.u64TotalNodeCount /
(SystemTimeStamp() - dSuiteStart)),
((g_SuiteCounters.uCorrect > 0) ?
(g_SuiteCounters.dSigmaSolutionTime /
(double)g_SuiteCounters.uCorrect) : 0.0),
((double)g_SuiteCounters.uSigmaDepth /
(double)g_SuiteCounters.uTotal),
(100.0 * (double)g_SuiteCounters.u64TotalBetaCutoffsOnFirstMove /
((double)g_SuiteCounters.u64TotalBetaCutoffs + 1.0)),
(g_SuiteCounters.dSigmaEBF /
((double)g_SuiteCounters.uEBFCount + 1.0)),
(100.0 * (double)g_SuiteCounters.u64TotalCounterMoveHits /
((double)g_SuiteCounters.u64TotalCounterMoveTries + 1.0)),
g_SuiteCounters.u64TotalCounterMoveTries,
(100.0 * (double)g_SuiteCounters.u64TotalLeftoverAlpha /
((double)g_SuiteCounters.u64TotalLeftoverTries + 1.0)),
(100.0 * (double)g_SuiteCounters.u64TotalLeftoverFH /
((double)g_SuiteCounters.u64TotalLeftoverTries + 1.0)),
g_SuiteCounters.u64TotalLeftoverTries,
(SystemTimeStamp() - dSuiteStart));
// Countermove evidence calibration -- FH% per evidence bucket,
// an ongoing check that COUNTERMOVE_EVIDENCE_THRESHOLD (chess.h)
// is still well-calibrated as the engine/data evolve.
{
static const ULONG uCMEvidenceFloors[CM_EVIDENCE_BUCKETS] =
{ 0, 1, 100, 1000, 10000, 100000, 1000000 };
Trace("\ncountermove evidence calibration:\n");
for (v = 0; v < CM_EVIDENCE_BUCKETS; v++)
{
Trace(" evidence >= %8lu : %5.2f%% FH (%"
COMPILER_LONGLONG_UNSIGNED_FORMAT " tries)\n",
uCMEvidenceFloors[v],
(100.0 * (double)g_SuiteCounters.u64TotalCMEvidenceFH[v] /
((double)g_SuiteCounters.u64TotalCMEvidenceTries[v] + 1.0)),
g_SuiteCounters.u64TotalCMEvidenceTries[v]);
}
}
// EstimateHangingMaterialCp calibration -- does "how much material
// does this leftover move look like it hangs" actually predict
// FH%? See chess.h's HANG_CP_BUCKETS comment for the bucket shape
// (bucket 0 == not dumb; 1..9 are 100cp-wide bins 1-900cp; 10 is
// the 901cp+ overflow).
{
Trace("\nhanging-material estimate calibration (captures + quiet "
"moves, both gated on fPruneReduceEligible):\n");
Trace(" [baseline] eligible : %5.2f%% FH (%"
COMPILER_LONGLONG_UNSIGNED_FORMAT " tries)\n",
(100.0 * (double)g_SuiteCounters.u64TotalEligibleLeftoverFH /
((double)g_SuiteCounters.u64TotalEligibleLeftoverTries + 1.0)),
g_SuiteCounters.u64TotalEligibleLeftoverTries);
Trace(" not dumb (0cp) : %5.2f%% FH (%"
COMPILER_LONGLONG_UNSIGNED_FORMAT " tries)\n",
(100.0 * (double)g_SuiteCounters.u64TotalHangEstimateFH[0] /
((double)g_SuiteCounters.u64TotalHangEstimateTries[0] + 1.0)),
g_SuiteCounters.u64TotalHangEstimateTries[0]);
for (v = 1; v < HANG_CP_BUCKETS; v++)
{
if (v < HANG_CP_BUCKETS - 1)
{
Trace(" %4u - %4u cp lost : %5.2f%% FH (%"
COMPILER_LONGLONG_UNSIGNED_FORMAT " tries)\n",
1 + (v - 1) * HANG_CP_BUCKET_WIDTH,
v * HANG_CP_BUCKET_WIDTH,
(100.0 * (double)g_SuiteCounters.u64TotalHangEstimateFH[v] /
((double)g_SuiteCounters.u64TotalHangEstimateTries[v] + 1.0)),
g_SuiteCounters.u64TotalHangEstimateTries[v]);
}
else
{
Trace(" %4u+ cp lost : %5.2f%% FH (%"
COMPILER_LONGLONG_UNSIGNED_FORMAT " tries)\n",
1 + (v - 1) * HANG_CP_BUCKET_WIDTH,
(100.0 * (double)g_SuiteCounters.u64TotalHangEstimateFH[v] /
((double)g_SuiteCounters.u64TotalHangEstimateTries[v] + 1.0)),
g_SuiteCounters.u64TotalHangEstimateTries[v]);
}
}
}
// The "down axis" -- (iAlpha - iEval) calibration. See chess.h's
// GAP_CP_BUCKETS comment for the bucket shape (bucket 0 == gap
// <= 0, our own static eval already meets/beats alpha; 1..9 are
// 100cp-wide bins for a positive gap of 1-900cp; 10 is the
// 901cp+ overflow). Same [baseline] eligible line above applies
// here too -- same population, same fPruneReduceEligible gate.
{
Trace("\ngap-to-alpha estimate calibration (captures + quiet "
"moves, both gated on fPruneReduceEligible):\n");
Trace(" gap <= 0 (eval>=alpha): %5.2f%% FH (%"
COMPILER_LONGLONG_UNSIGNED_FORMAT " tries)\n",
(100.0 * (double)g_SuiteCounters.u64TotalGapEstimateFH[0] /
((double)g_SuiteCounters.u64TotalGapEstimateTries[0] + 1.0)),
g_SuiteCounters.u64TotalGapEstimateTries[0]);
for (v = 1; v < GAP_CP_BUCKETS; v++)
{
if (v < GAP_CP_BUCKETS - 1)
{
Trace(" %4u - %4u cp below alpha : %5.2f%% FH (%"
COMPILER_LONGLONG_UNSIGNED_FORMAT " tries)\n",
1 + (v - 1) * GAP_CP_BUCKET_WIDTH,
v * GAP_CP_BUCKET_WIDTH,
(100.0 * (double)g_SuiteCounters.u64TotalGapEstimateFH[v] /
((double)g_SuiteCounters.u64TotalGapEstimateTries[v] + 1.0)),
g_SuiteCounters.u64TotalGapEstimateTries[v]);
}
else
{
Trace(" %4u+ cp below alpha : %5.2f%% FH (%"
COMPILER_LONGLONG_UNSIGNED_FORMAT " tries)\n",
1 + (v - 1) * GAP_CP_BUCKET_WIDTH,
(100.0 * (double)g_SuiteCounters.u64TotalGapEstimateFH[v] /
((double)g_SuiteCounters.u64TotalGapEstimateTries[v] + 1.0)),
g_SuiteCounters.u64TotalGapEstimateTries[v]);
}
}
}
// The "late axis" -- this move's own 1-based ordinal position
// among moves actually tried at this node. See chess.h's
// MOVE_NUM_BUCKETS comment -- direct, unpaired buckets, move
// number (MOVE_NUM_BUCKETS-2)+ collapses into one overflow
// bucket. Same [baseline] eligible line as the other two axes
// applies here too.
{
Trace("\nmove-number estimate calibration (captures + quiet "
"moves, both gated on fPruneReduceEligible):\n");
for (v = 1; v < MOVE_NUM_BUCKETS; v++)
{
if (v < MOVE_NUM_BUCKETS - 1)
{
Trace(" move %4u : %5.2f%% FH (%"
COMPILER_LONGLONG_UNSIGNED_FORMAT " tries)\n",
v,
(100.0 * (double)g_SuiteCounters.u64TotalMoveNumEstimateFH[v] /
((double)g_SuiteCounters.u64TotalMoveNumEstimateTries[v] + 1.0)),
g_SuiteCounters.u64TotalMoveNumEstimateTries[v]);
}
else
{
Trace(" move %4u+ : %5.2f%% FH (%"
COMPILER_LONGLONG_UNSIGNED_FORMAT " tries)\n",
v,
(100.0 * (double)g_SuiteCounters.u64TotalMoveNumEstimateFH[v] /
((double)g_SuiteCounters.u64TotalMoveNumEstimateTries[v] + 1.0)),
g_SuiteCounters.u64TotalMoveNumEstimateTries[v]);
}
}
}
// The "depth axis" -- remaining search depth at this node (uDepth
// / ONE_PLY, whole plies, before this move's own extension/
// reduction). Direct, unpaired buckets, index 0 legitimately used
// (a heavily-reduced move can arrive at remaining depth 0). Same
// [baseline] eligible line as the other axes applies here too.
{
Trace("\ndepth estimate calibration (captures + quiet moves, "
"both gated on fPruneReduceEligible):\n");
for (v = 0; v < SEARCH_DEPTH_BUCKETS; v++)
{
if (v < SEARCH_DEPTH_BUCKETS - 1)
{
Trace(" depth %4u : %5.2f%% FH (%"
COMPILER_LONGLONG_UNSIGNED_FORMAT " tries)\n",
v,
(100.0 * (double)g_SuiteCounters.u64TotalDepthEstimateFH[v] /
((double)g_SuiteCounters.u64TotalDepthEstimateTries[v] + 1.0)),
g_SuiteCounters.u64TotalDepthEstimateTries[v]);
}
else
{
Trace(" depth %4u+ : %5.2f%% FH (%"
COMPILER_LONGLONG_UNSIGNED_FORMAT " tries)\n",
v,
(100.0 * (double)g_SuiteCounters.u64TotalDepthEstimateFH[v] /
((double)g_SuiteCounters.u64TotalDepthEstimateTries[v] + 1.0)),
g_SuiteCounters.u64TotalDepthEstimateTries[v]);
}
}
}
// Phase 2 -- joint-table-driven graduated LMR calibration: for each
// tier (0 == GetLMRReduction's baseline only, 1..3 == that many
// extra plies the joint table added), what fraction of moves
// assigned that tier triggered the existing re-search-on-fail-high
// path? This is the actual scale-calibration mechanism (not the
// offline collection data) -- if low-predicted-FH tiers (2, 3) show
// an EQUAL OR HIGHER research rate than tier 0/1, that's the
// distribution-shift failure this project's history keeps
// producing, and the tier thresholds (or the whole approach) need
// rethinking before any self-play run. A rising research rate with
// tier is the expected, healthy shape.
{
Trace("\njoint-table extra-reduction tier calibration "
"(re-search rate per tier):\n");
for (v = 0; v < JOINT_EXTRA_TIER_COUNT; v++)
{
Trace(" tier %u (+%u extra ply%s) : %5.2f%% research-rate (%"
COMPILER_LONGLONG_UNSIGNED_FORMAT " tries)\n",
v, v, (1 == v) ? "" : "s",
(100.0 * (double)g_SuiteCounters.u64TotalJointExtraResearch[v] /
((double)g_SuiteCounters.u64TotalJointExtraTries[v] + 1.0)),
g_SuiteCounters.u64TotalJointExtraTries[v]);
}
Trace("\nlate-move pruning (overt skip, not reduction): %"
COMPILER_LONGLONG_UNSIGNED_FORMAT " moves pruned\n",
g_SuiteCounters.u64TotalLMPPruned);
}
#ifdef JOINT_EXTRA_VERIFY
// "Silent miss" shadow-verification calibration: of the extra-
// reduced moves whose real score never triggered a re-search (the
// population the report block above CAN'T see into), how many
// would have failed high anyway if just the extra plies were
// removed? This is the direct answer to "how much unverified
// playing-strength loss is this mechanism causing" -- a real-
// search-cost-doubling measurement, JOINT_EXTRA_VERIFY builds only.
{
UINT64 u64TierTries, u64TierMiss;
ULONG w;
Trace("\njoint-table extra-reduction SILENT MISS calibration "
"(shadow re-search, extra-plies-removed):\n");
for (v = 1; v < JOINT_EXTRA_TIER_COUNT; v++)
{
u64TierTries = 0;
u64TierMiss = 0;
for (w = 0; w < POST_REDUCE_DEPTH_BUCKETS; w++)
{
u64TierTries += g_SuiteCounters.u64TotalJointExtraVerifyTries[v][w];
u64TierMiss += g_SuiteCounters.u64TotalJointExtraVerifySilentMiss[v][w];
}
Trace(" tier %u (+%u extra ply%s) : %5.2f%% silent-miss (%"
COMPILER_LONGLONG_UNSIGNED_FORMAT " tries), of which %5.2f%% "
"(%" COMPILER_LONGLONG_UNSIGNED_FORMAT ") match the null-move "
"bailout signature (iShadowScore == beta+1 exactly)\n",
v, v, (1 == v) ? "" : "s",
(100.0 * (double)u64TierMiss / ((double)u64TierTries + 1.0)),
u64TierTries,
(100.0 * (double)g_SuiteCounters.u64TotalJointExtraVerifyNullBailoutSignature[v] /
((double)u64TierMiss + 1.0)),
g_SuiteCounters.u64TotalJointExtraVerifyNullBailoutSignature[v]);
}
// Breakdown by EFP's own two-tier margin-schedule boundaries
// (search.c's _PostReduceDepthBucketEfpAligned) rather than
// plain whole-ply buckets -- tests whether silent misses
// concentrate specifically inside EFP's tier windows (a
// different pruning mechanism behaving differently there) or
// are spread uniformly by remaining depth alone.
{
static const char *rgszBucketLabel[POST_REDUCE_DEPTH_BUCKETS] = {
"< 1 ply (should not happen)",
"EFP tier1 (selective futility)",
"EFP tier2 (extended futility)",
"no EFP, nearby",
"no EFP, comfortably deep"
};
Trace("\n ...broken down by EFP-tier-aligned remaining "
"depth window (is this an EFP-tier-window effect?):\n");
for (v = 1; v < JOINT_EXTRA_TIER_COUNT; v++)
{
for (w = 0; w < POST_REDUCE_DEPTH_BUCKETS; w++)
{
Trace(" tier %u, %-32s : %5.2f%% silent-miss (%"
COMPILER_LONGLONG_UNSIGNED_FORMAT " tries)\n",
v, rgszBucketLabel[w],
(100.0 * (double)g_SuiteCounters.u64TotalJointExtraVerifySilentMiss[v][w] /
((double)g_SuiteCounters.u64TotalJointExtraVerifyTries[v][w] + 1.0)),
g_SuiteCounters.u64TotalJointExtraVerifyTries[v][w]);
}
}
}
}
#endif
// Joint 4D raw dump for offline reassembly/baking -- one line per
// populated cell, marginal (uncoarsened) indices, this checkpoint's
// cumulative totals (never summed across checkpoints by the bake
// script -- last checkpoint per shard is authoritative, matching
// every prior FHGAPRAW/FHJOINTRAW collection run in this project).
{
ULONG a, b, c;
for (a = 0; a < SEARCH_DEPTH_BUCKETS; a++)
{
for (b = 0; b < HANG_CP_BUCKETS; b++)
{
for (c = 0; c < GAP_CP_BUCKETS; c++)
{
for (v = 0; v < MOVE_NUM_BUCKETS; v++)
{
if (g_SuiteCounters.u64TotalJointTries[a][b][c][v] > 0)
{
Trace("FOURAXISRAW %lu %lu %lu %lu %"
COMPILER_LONGLONG_UNSIGNED_FORMAT " %"
COMPILER_LONGLONG_UNSIGNED_FORMAT "\n",
a, b, c, v,
g_SuiteCounters.u64TotalJointFH[a][b][c][v],
g_SuiteCounters.u64TotalJointTries[a][b][c][v]);
}
}
}
}
}
}
#ifdef FH_TABLE_COLLECTION
// Full dual-table raw dump for offline reassembly/baking (dual_table_run*/
// aggregate.py et al): ALPHARAW is the 5D alpha joint (depth, dumb,
// gap, late, improve -- late==0 is the "whole node" sample, see
// chess.h), BETARAW is the 4D beta joint (depth, gap, own-improve,
// enemy-improve), ESTRAW is every independent 1D marginal (used
// only by marginal_crosscheck.py, never for baking itself). Same
// "last checkpoint per shard is authoritative" convention as the
// FOURAXISRAW dump above.
{
ULONG a, b, c, d;
for (a = 0; a < SEARCH_DEPTH_BUCKETS; a++)
{
for (b = 0; b < HANG_CP_BUCKETS; b++)
{
for (c = 0; c < GAP_CP_BUCKETS; c++)
{
for (d = 0; d < MOVE_NUM_BUCKETS; d++)
{
for (v = 0; v < IMPROVE_BUCKETS; v++)
{
if (g_SuiteCounters.u64TotalAlpha5Tries[a][b][c][d][v] > 0)
{
Trace("ALPHARAW %lu %lu %lu %lu %lu %"
COMPILER_LONGLONG_UNSIGNED_FORMAT " %"
COMPILER_LONGLONG_UNSIGNED_FORMAT "\n",
a, b, c, d, v,
g_SuiteCounters.u64TotalAlpha5FH[a][b][c][d][v],
g_SuiteCounters.u64TotalAlpha5Tries[a][b][c][d][v]);
}
}
}
}
}
}
for (a = 0; a < SEARCH_DEPTH_BUCKETS; a++)
{
for (b = 0; b < GAP_BETA_BUCKETS; b++)
{
for (c = 0; c < IMPROVE_BUCKETS; c++)
{
for (d = 0; d < IMPROVE_BUCKETS; d++)
{
if (g_SuiteCounters.u64TotalBetaTries[a][b][c][d] > 0)
{
Trace("BETARAW %lu %lu %lu %lu %"
COMPILER_LONGLONG_UNSIGNED_FORMAT " %"
COMPILER_LONGLONG_UNSIGNED_FORMAT "\n",
a, b, c, d,
g_SuiteCounters.u64TotalBetaFH[a][b][c][d],
g_SuiteCounters.u64TotalBetaTries[a][b][c][d]);
}
}
}
}
}
for (v = 0; v < SEARCH_DEPTH_BUCKETS; v++)
{
if (g_SuiteCounters.u64TotalDepthEstimateTries[v] > 0)
{
Trace("ESTRAW depth %lu %" COMPILER_LONGLONG_UNSIGNED_FORMAT
" %" COMPILER_LONGLONG_UNSIGNED_FORMAT "\n", v,
g_SuiteCounters.u64TotalDepthEstimateFH[v],
g_SuiteCounters.u64TotalDepthEstimateTries[v]);
}
}
for (v = 0; v < HANG_CP_BUCKETS; v++)
{
if (g_SuiteCounters.u64TotalHangEstimateTries[v] > 0)
{
Trace("ESTRAW dumb %lu %" COMPILER_LONGLONG_UNSIGNED_FORMAT
" %" COMPILER_LONGLONG_UNSIGNED_FORMAT "\n", v,
g_SuiteCounters.u64TotalHangEstimateFH[v],
g_SuiteCounters.u64TotalHangEstimateTries[v]);
}
}
for (v = 0; v < GAP_CP_BUCKETS; v++)
{
if (g_SuiteCounters.u64TotalGapEstimateTries[v] > 0)
{
Trace("ESTRAW gap %lu %" COMPILER_LONGLONG_UNSIGNED_FORMAT
" %" COMPILER_LONGLONG_UNSIGNED_FORMAT "\n", v,
g_SuiteCounters.u64TotalGapEstimateFH[v],
g_SuiteCounters.u64TotalGapEstimateTries[v]);
}
}
for (v = 0; v < MOVE_NUM_BUCKETS; v++)
{
if (g_SuiteCounters.u64TotalMoveNumEstimateTries[v] > 0)
{
Trace("ESTRAW late %lu %" COMPILER_LONGLONG_UNSIGNED_FORMAT
" %" COMPILER_LONGLONG_UNSIGNED_FORMAT "\n", v,
g_SuiteCounters.u64TotalMoveNumEstimateFH[v],
g_SuiteCounters.u64TotalMoveNumEstimateTries[v]);
}
}
for (v = 0; v < IMPROVE_BUCKETS; v++)
{
if (g_SuiteCounters.u64TotalImproveEstimateTries[v] > 0)
{
Trace("ESTRAW improve %lu %" COMPILER_LONGLONG_UNSIGNED_FORMAT
" %" COMPILER_LONGLONG_UNSIGNED_FORMAT "\n", v,
g_SuiteCounters.u64TotalImproveEstimateFH[v],
g_SuiteCounters.u64TotalImproveEstimateTries[v]);
}
}
for (v = 0; v < SEARCH_DEPTH_BUCKETS; v++)
{
if (g_SuiteCounters.u64TotalBetaDepthEstimateTries[v] > 0)
{
Trace("ESTRAW betadepth %lu %" COMPILER_LONGLONG_UNSIGNED_FORMAT
" %" COMPILER_LONGLONG_UNSIGNED_FORMAT "\n", v,
g_SuiteCounters.u64TotalBetaDepthEstimateFH[v],
g_SuiteCounters.u64TotalBetaDepthEstimateTries[v]);
}
}
for (v = 0; v < GAP_BETA_BUCKETS; v++)
{
if (g_SuiteCounters.u64TotalBetaGapEstimateTries[v] > 0)
{
Trace("ESTRAW betagap %lu %" COMPILER_LONGLONG_UNSIGNED_FORMAT
" %" COMPILER_LONGLONG_UNSIGNED_FORMAT "\n", v,
g_SuiteCounters.u64TotalBetaGapEstimateFH[v],
g_SuiteCounters.u64TotalBetaGapEstimateTries[v]);
}
}
for (v = 0; v < IMPROVE_BUCKETS; v++)
{
if (g_SuiteCounters.u64TotalBetaOwnImpEstimateTries[v] > 0)
{
Trace("ESTRAW betaown %lu %" COMPILER_LONGLONG_UNSIGNED_FORMAT
" %" COMPILER_LONGLONG_UNSIGNED_FORMAT "\n", v,
g_SuiteCounters.u64TotalBetaOwnImpEstimateFH[v],
g_SuiteCounters.u64TotalBetaOwnImpEstimateTries[v]);
}
}
for (v = 0; v < IMPROVE_BUCKETS; v++)
{
if (g_SuiteCounters.u64TotalBetaEnemyImpEstimateTries[v] > 0)
{
Trace("ESTRAW betaopp %lu %" COMPILER_LONGLONG_UNSIGNED_FORMAT
" %" COMPILER_LONGLONG_UNSIGNED_FORMAT "\n", v,
g_SuiteCounters.u64TotalBetaEnemyImpEstimateFH[v],
g_SuiteCounters.u64TotalBetaEnemyImpEstimateTries[v]);
}
}
}
#endif // FH_TABLE_COLLECTION
#ifdef TEST_NULL
// Null-move precision/recall calibration, summed across the whole
// suite (see _NullCalibBucketIndex's comment in search.c for the
// encoding and what each dimension means). Decode each bucket
// index back into its component bands for a readable line; skip
// empty cells so this stays legible even though the full table has
// NC_TOTAL_BUCKETS cells.
{
static const char *rgszDepthBand[NC_DEPTH_BUCKETS] =
{ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
"11", "12", "13", "14", "15", "16+" };
static const char *rgszDeficitBand[NC_DEFICIT_BUCKETS] =
{ "<-300", "-300..-100", "-100..0", "0..100", "100..300", "300+" };
static const char *rgszMaterialBand[NC_MATERIAL_BUCKETS] =
{ "0-1", "2", "3-5", "6+" };
ULONG uIdx, uDecode, uNullDepthB, uOuterDepthB, uDeficitB;
ULONG uMaxMaterialB, uMoverMaterialB;
UINT64 u64Attempts, u64NullFH, u64RealFH, u64BothFH;
UINT64 u64NullProbeNodeSum, u64FirstMoveNodeSum, u64RealLoopNodeSum;
double dAvgNullProbeNodes, dAvgFirstMoveNodes, dAvgRealLoopNodes;
double dNullSuccessRate, dEVFirstMoveOnly, dEV;
Trace("\nNull-move calibration (attempts / nullFH / realFH / both / "
"precision / recall / nullSuccessRate / avgNullProbeNodes / "
"avgFirstMoveNodes / avgRealLoopNodes / EVFirstMoveOnly / "
"EV-per-attempt-in-nodes):\n");
for (uIdx = 0; uIdx < NC_TOTAL_BUCKETS; uIdx++)
{
u64Attempts = g_SuiteCounters.u64TotalNCAttempts[uIdx];
if (0 == u64Attempts) continue;
u64NullFH = g_SuiteCounters.u64TotalNCNullFH[uIdx];
u64RealFH = g_SuiteCounters.u64TotalNCRealFH[uIdx];
u64BothFH = g_SuiteCounters.u64TotalNCBothFH[uIdx];
u64NullProbeNodeSum = g_SuiteCounters.u64TotalNCNullProbeNodeSum[uIdx];
u64FirstMoveNodeSum = g_SuiteCounters.u64TotalNCFirstMoveNodeSum[uIdx];
u64RealLoopNodeSum = g_SuiteCounters.u64TotalNCRealLoopNodeSum[uIdx];
// Decode uIdx (innermost/fastest-varying dimension first),
// matching _NullCalibBucketIndex's encoding in search.c.
// Use a scratch copy -- uIdx itself is still the array
// index for the lookups above/below.
uDecode = uIdx;
uMoverMaterialB = uDecode % NC_MATERIAL_BUCKETS;
uDecode /= NC_MATERIAL_BUCKETS;
uMaxMaterialB = uDecode % NC_MATERIAL_BUCKETS;
uDecode /= NC_MATERIAL_BUCKETS;
uDeficitB = uDecode % NC_DEFICIT_BUCKETS;
uDecode /= NC_DEFICIT_BUCKETS;
uOuterDepthB = uDecode % NC_DEPTH_BUCKETS;
uDecode /= NC_DEPTH_BUCKETS;
uNullDepthB = uDecode % NC_DEPTH_BUCKETS;
dAvgNullProbeNodes = (double)u64NullProbeNodeSum / (double)u64Attempts;
dAvgFirstMoveNodes = (double)u64FirstMoveNodeSum / (double)u64Attempts;
dAvgRealLoopNodes = (double)u64RealLoopNodeSum / (double)u64Attempts;
dNullSuccessRate = (double)u64NullFH / (double)u64Attempts;
// EV of TRYING null vs. going straight to the real move loop,
// in nodes saved per attempt (positive = trying pays off):
// on the dNullSuccessRate fraction of attempts we pay the
// (cheap) null probe instead of the (expensive) real-loop
// cost; on the rest we pay the null probe *in addition* to
// still needing the real loop. dEV uses avgRealLoopNodes --
// the true total cost of however the real search actually
// resolved the node (one move, several, or production's own
// separate null success) -- while dEVFirstMoveOnly keeps the
// cheaper move-1-only proxy alongside it for comparison.
// Both assume (per the user's simplifying assumption,
// matched by this dataset's ~99.96% overall precision) that
// a null-move fail-high is correct.
dEVFirstMoveOnly =
dNullSuccessRate * (dAvgFirstMoveNodes - dAvgNullProbeNodes)
- (1.0 - dNullSuccessRate) * dAvgNullProbeNodes;
dEV = dNullSuccessRate * (dAvgRealLoopNodes - dAvgNullProbeNodes)
- (1.0 - dNullSuccessRate) * dAvgNullProbeNodes;
Trace(" nullDepth=%s outerDepth=%s deficit=%s "
"maxMaterial=%s moverMaterial=%s : "
"%"COMPILER_LONGLONG_UNSIGNED_FORMAT" / "
"%"COMPILER_LONGLONG_UNSIGNED_FORMAT" / "
"%"COMPILER_LONGLONG_UNSIGNED_FORMAT" / "
"%"COMPILER_LONGLONG_UNSIGNED_FORMAT" / "
"%5.3f / %5.3f / %5.3f / %10.1f / %10.1f / %10.1f / %10.1f / %10.1f\n",
rgszDepthBand[uNullDepthB],
rgszDepthBand[uOuterDepthB],
rgszDeficitBand[uDeficitB],
rgszMaterialBand[uMaxMaterialB],
rgszMaterialBand[uMoverMaterialB],
u64Attempts, u64NullFH, u64RealFH, u64BothFH,
(u64NullFH != 0) ? (100.0 * (double)u64BothFH / (double)u64NullFH) : 0.0,
(u64RealFH != 0) ? (100.0 * (double)u64BothFH / (double)u64RealFH) : 0.0,
100.0 * dNullSuccessRate,
dAvgNullProbeNodes, dAvgFirstMoveNodes, dAvgRealLoopNodes,
dEVFirstMoveOnly, dEV);
}
}
#endif
// Histogram stuff
if (g_SuiteCounters.uTotal > 0) {
uMax = g_SuiteCounters.uHistogram[0];
for (u = 1; u < SUITE_NUM_HISTOGRAM; u++)
{
if (g_SuiteCounters.uHistogram[u] > uMax)
{
uMax = g_SuiteCounters.uHistogram[u];
}
}
for (u = 0; u < SUITE_NUM_HISTOGRAM; u++)
{
Trace("%4.1f .. %4.1f: ",
(double)u * dMult, (double)(u + 1) * dMult);
for (v = 0;
(uMax > 0) && (v < 50 * g_SuiteCounters.uHistogram[u] / uMax);
v++)
{
Trace("*");
}
Trace("\n");
}
}
}
COMMAND(ScriptCommand)
/**
Routine description:
This function implements the 'script' engine command.
Usage:
script <required filename>
The script command opens the reads the required filename and
reads it line by line. Each line of the script file is
treated as a command and executed in sequence. Each command
is executed fully before the next script line is read and
executed. When all lines in the script file have been read
and executed the engine will print out a post-script report of
test suite statistics and then begin to pay attention to
commands from the keyboard again.
Scripts are meant to facilitate execution of test suites.
Parameters:
The COMMAND macro hides four arguments from the input parser:
CHAR *szInput : the full line of input
ULONG argc : number of argument chunks
CHAR *argv[] : array of ptrs to each argument chunk
POSITION *pos : a POSITION pointer to operate on
Return value:
void
**/
{
FILE *p;
static CHAR szLine[SMALL_STRING_LEN_CHAR];
double dSuiteStart;
ULONG uGoCount = 0;
// 2026-09-28: a wall-clock `timeout`-killed shard (e.g. a 90-minute
// sharded joint-table collection run) never reaches true end-of-
// script, so _PrintSuiteReport's single end-of-suite call would
// never fire and a killed shard would contribute zero data. Print
// the same (cumulative, non-resetting) report every
// CHECKPOINT_GO_INTERVAL positions too -- the FOURAXISRAW dump (and
// every other line in the report) always reflects the full running
// total since suite start, so the *last* checkpoint printed before
// a kill is a complete, valid snapshot on its own; a bake script
// just needs to find and use the last one, never sum across them.
#define CHECKPOINT_GO_INTERVAL (5)
if (argc < 2)
{
Trace("Error (Usage: script <filename>): %s\n", argv[0]);
return;
}
if (FALSE == SystemDoesFileExist(argv[1]))
{
Trace("Error (file doesn't exist): %s\n", argv[1]);
return;
}
p = fopen(argv[1], "rb");
if (NULL != p)
{
dSuiteStart = SystemTimeStamp();
memset(&(g_SuiteCounters), 0, sizeof(g_SuiteCounters));
while(fgets(szLine, ARRAY_LENGTH(szLine), p))
{
_ProcessSuiteLine(szLine, pos);
if (!STRNCMPI(szLine, "go", 2))
{
uGoCount++;
if (0 == (uGoCount % CHECKPOINT_GO_INTERVAL))
{
Trace("\nCHECKPOINT after %lu positions:\n", uGoCount);
_PrintSuiteReport(dSuiteStart);
}
}
if (TRUE == g_fExitProgram) break;
}
fclose(p);
_PrintSuiteReport(dSuiteStart);
}
#undef CHECKPOINT_GO_INTERVAL
}
COMMAND(EpdCommand)
/**
Routine description:
Runs a raw EPD test suite file directly -- no perl preprocessing
into a setboard/solution/go script first. Historically the only
way to run a suite from real-world EPD (the "board stm castle ep
[halfmove fullmove] bm <move>; id \"...\"; ..." format most public
tactical suites ship in) was tests/convert_epd.pl, which had a
real, silent-corruption bug: its single "everything between the
board and bm is [^b]+" regex breaks on any Black-to-move record
(the side-to-move field is literally the character "b"), and
because $fen/$id/$solution were unscoped globals rather than
per-line locals, a failed match silently carried the *previous*
record's board and solution forward instead of erroring --
confirmed live by feeding it a real 5-position batch, where the
one Black-to-move line came out as a byte-for-byte duplicate of
the line before it. This command replaces that whole external
preprocessing step with real per-record EPD parsing (see
ParseEpdRecord, fen.c) feeding the exact same
_ProcessSuiteLine/_PrintSuiteReport machinery ScriptCommand uses,
so a raw EPD file can just be handed to the engine directly.
Usage:
epd <required filename>
Parameters:
The COMMAND macro hides four arguments from the input parser:
CHAR *szInput : the full line of input
ULONG argc : number of argument chunks
CHAR *argv[] : array of ptrs to each argument chunk
POSITION *pos : a POSITION pointer to operate on
Return value:
void
**/
{
FILE *p;
static CHAR szLine[SMALL_STRING_LEN_CHAR];
static CHAR szSynth[SMALL_STRING_LEN_CHAR];
CHAR szFen[SMALL_STRING_LEN_CHAR];
CHAR szId[SMALL_STRING_LEN_CHAR];
CHAR szMoves[SUITE_MAX_SOLUTIONS + SUITE_MAX_AVOIDS][SMALL_STRING_LEN_CHAR];
ULONG uNumMoves;
FLAG fIsAvoid;
double dSuiteStart;
ULONG u;
ULONG uLineNum = 0;
if (argc < 2)
{
Trace("Error (Usage: epd <filename>): %s\n", argv[0]);
return;
}
if (FALSE == SystemDoesFileExist(argv[1]))
{
Trace("Error (file doesn't exist): %s\n", argv[1]);
return;
}
p = fopen(argv[1], "rb");
if (NULL != p)
{
dSuiteStart = SystemTimeStamp();
memset(&(g_SuiteCounters), 0, sizeof(g_SuiteCounters));
while(fgets(szLine, ARRAY_LENGTH(szLine), p))
{
uLineNum++;
if (FALSE == ParseEpdRecord(szLine, szFen, ARRAY_LENGTH(szFen),
szId, ARRAY_LENGTH(szId),
szMoves, ARRAY_LENGTH(szMoves),
&uNumMoves, &fIsAvoid))
{
if (szLine[0] && (szLine[0] != '\n') && (szLine[0] != '#'))
{
Trace("epd: skipping unparseable line %lu: %s",
uLineNum, szLine);
}
continue;
}
snprintf(szSynth, ARRAY_LENGTH(szSynth), "setboard %s\n", szFen);
_ProcessSuiteLine(szSynth, pos);
if (TRUE == g_fExitProgram) break;
if (szId[0])
{
snprintf(szSynth, ARRAY_LENGTH(szSynth), "id %s\n", szId);
_ProcessSuiteLine(szSynth, pos);
}
for (u = 0; u < uNumMoves; u++)
{
snprintf(szSynth, ARRAY_LENGTH(szSynth), "%s %s\n",
fIsAvoid ? "avoid" : "solution", szMoves[u]);
_ProcessSuiteLine(szSynth, pos);
}
_ProcessSuiteLine("go\n", pos);
if (TRUE == g_fExitProgram) break;
}
fclose(p);
_PrintSuiteReport(dSuiteStart);
}
}
FLAG
WeAreRunningASuite(void)
/**
Routine description:
A function that returns TRUE if the engine is running a test suite
and FALSE otherwise.
Parameters:
void
Return value:
FLAG
**/
{
if (g_SuiteCounters.uNumSolutions +
g_SuiteCounters.uNumAvoids)
{
return(TRUE);
}
return(FALSE);
}
FLAG
CheckTestSuiteMove(MOVE mv, SCORE iScore, ULONG uDepth)
/**
Routine description:
This function is called by RootSearch when it has finished a
search. The MOVE parameter is the best move that the search
found. This code checks that move against the solution or avoid
moves for the current position, determines if we "got it right"
and updates the test suite counters accordingly.
Parameters:
MOVE mv
Return value:
FLAG
**/
{
FLAG fSolved = FALSE;
ULONG u;
if (!WeAreRunningASuite()) return FALSE;
//
// There is(are) solution move(s).
//
if (g_SuiteCounters.uNumSolutions)
{
ASSERT(g_SuiteCounters.uNumAvoids == 0);
fSolved = FALSE;
for (u = 0; u < g_SuiteCounters.uNumSolutions; u++)
{
if ((mv.cFrom == g_SuiteCounters.mvSolution[u].cFrom) &&
(mv.cTo == g_SuiteCounters.mvSolution[u].cTo))
{
fSolved = TRUE;
break;
}
}
if (!fSolved) {
g_SuiteCounters.uCurrentSolvedPlies = 0;
g_SuiteCounters.dCurrentSolutionTime = 0.0;
} else {
if (g_SuiteCounters.uCurrentSolvedPlies == 0) {
g_SuiteCounters.dCurrentSolutionTime =
(SystemTimeStamp() - g_MoveTimer.dStartTime);
}
g_SuiteCounters.uCurrentSolvedPlies++;
}
}
else if (g_SuiteCounters.uNumAvoids)
{
//
// Handle avoid-move problems.
//
fSolved = TRUE;
for (u = 0; u < g_SuiteCounters.uNumAvoids; u++)
{
if ((mv.cFrom == g_SuiteCounters.mvAvoid[u].cFrom) &&
(mv.cTo == g_SuiteCounters.mvAvoid[u].cTo))
{
fSolved = FALSE;
}
}
if (!fSolved)
{
g_SuiteCounters.uCurrentSolvedPlies = 0;
g_SuiteCounters.dCurrentSolutionTime = 0.0;
} else {
if (g_SuiteCounters.uCurrentSolvedPlies == 0) {
g_SuiteCounters.dCurrentSolutionTime =
(SystemTimeStamp() - g_MoveTimer.dStartTime);
}
g_SuiteCounters.uCurrentSolvedPlies++;
}
}
else
{
UtilPanic(SHOULD_NOT_GET_HERE,
NULL, NULL, NULL, NULL,
__FILE__, __LINE__);
}
//
// Handle "FastScript" variable for solution moves.
//
if ((g_Options.fFastScript) &&
(g_SuiteCounters.uCurrentSolvedPlies > 4) &&
(iScore >= 0))
{
if (((g_Options.uMyIncrement != 0) &&
(SystemTimeStamp() - g_MoveTimer.dStartTime >=
(double)g_Options.uMyIncrement / 3)) ||
((g_Options.uMaxDepth != 0) &&
(uDepth >= g_Options.uMaxDepth / 3)))
{
Trace("FAST SCRIPT --> stop searching now\n");
g_MoveTimer.bvFlags |= TIMER_STOPPING;
}
}
return(fSolved);
}
void
PostMoveTestSuiteReport(SEARCHER_THREAD_CONTEXT *ctx)
/**
Routine description:
If we're running a suite, print a little blurb after each move to
act as a running total of how we're doing.
Parameters:
SEARCHER_THREAD_CONTEXT *ctx
Return value:
void
**/
{
MOVE mv = ctx->mvRootMove;
ULONG uDepth = ctx->uRootDepth / ONE_PLY, y;
double dMult;
//
// This is the real move the searched picked when all was said and
// done (i.e. it ran out of time or reached a fixed depth). See
// if it's right.
//
if (WeAreRunningASuite())
{
g_SuiteCounters.uTotal++;
g_SuiteCounters.uSigmaDepth += uDepth;
if (uDepth > 0)
{
g_SuiteCounters.dSigmaEBF +=
pow((double)ctx->sCounters.tree.u64TotalNodeCount,
1.0 / (double)uDepth);
g_SuiteCounters.uEBFCount++;
}
if (CheckTestSuiteMove(mv, -1, uDepth))
{
Trace("Problem %s solved in %3.1f sec.\n",
g_SuiteCounters.szId,
g_SuiteCounters.dCurrentSolutionTime);
g_SuiteCounters.uCorrect++;
g_SuiteCounters.dSigmaSolutionTime +=
g_SuiteCounters.dCurrentSolutionTime;
dMult = (double)g_Options.uMyIncrement /
(double)SUITE_NUM_HISTOGRAM;
ASSERT(SUITE_NUM_HISTOGRAM > 0);
for (y = 1; y <= SUITE_NUM_HISTOGRAM; y++)
{
if (g_SuiteCounters.dCurrentSolutionTime < ((double)y * dMult))
{
g_SuiteCounters.uHistogram[y-1]++;
break;
}
if (y == SUITE_NUM_HISTOGRAM)
{
//
// This one is actually > time-to-think. This
// really happens... like we had 20 sec to think
// and solved it in 20.1 or something before the
// stop-searching timer was checked.
//
g_SuiteCounters.uHistogram[y-1]++;
}
}
}
else
{
Trace(">>>>> Problem %s was not solved. <<<<<\n\n",
g_SuiteCounters.szId);
g_SuiteCounters.uIncorrect++;
}
Trace("Current suite score: %u correct of %u problems.\n",
g_SuiteCounters.uCorrect,
g_SuiteCounters.uTotal);
_ClearSuiteData();
}
}
|