diff options
| author | Scott Gasch <[email protected]> | 2026-10-15 11:12:37 -0700 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2026-10-15 11:12:37 -0700 |
| commit | ef2c2f667c4fc2c0303f56ea487183916f82fb67 (patch) | |
| tree | d781a71ea958ca421521b21c93eb9c2ce59df65c /src/testsup.c | |
| parent | d9419c104e9fe193649931cee167b819044c6ca3 (diff) | |
Fix several latent search/move-generation bugs found via NNUE annotation tooling
- probe.c: EGTB win/loss scores now render as +-MATE100 (literal +-NMATE)
instead of a misleading float, matching how a real forced mate prints.
- hash.c: fix a sign error in StoreExactScore's loss-side hash bound
(iValue +NMATE paired with HASH_FLAG_UPPER, should be -NMATE) -- dormant
until the probe.c fix made it reachable every EGTB loss.
- san.c: a checking castle move (O-O+/O-O-O+) printed as +-O/+-O-O --
the check-suffix pointer was captured before strcpy filled the
buffer, so '+' overwrote the leading 'O' instead of appending.
- search.c/searchsup.c: MATEMOVE/DRAWMOVE/RECOGNMOVE/EGTBMOVE now record
into the PV unconditionally instead of only when the ambient alpha-beta
window happens to strictly contain the score -- these are exact,
game-theoretic results, not heuristic bounds, so a PVS scout-window
tie (common once a line's value is already known) shouldn't suppress
them. This is why <#>/<=>/<REC>/<EGTB> almost never showed up in a
printed PV.
- util.c: WalkPV now reconstructs a still-missing final move/sentinel
directly from the board when the recorded PV runs out one ply short
of (or exactly at) a forced mate/stalemate/draw, instead of leaving
the printed PV silently truncated.
- gamelist.c/board.c/testsup.c: SetRootPosition now parses into a local
staging POSITION and validates IsBoardLegal + VerifyPositionConsistency
(both moved/enabled for all build profiles, not just TEST/EVAL_DUMP)
before committing to g_RootPosition. Previously a rejected setboard
(e.g. a hand-built FEN leaving the side not on move in check) still
left the partially-parsed, illegal position in g_RootPosition for the
next `go` to search -- GetRootPosition() hands out a stable pointer
straight to it with no defensive copy -- causing a crash instead of
the clean "Error (malformed FEN)" rejection already printed.
All verified via precommit_check.sh (TEST=1 self-test suite + DEBUG
smoke test) in addition to targeted manual repros for each bug.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Diffstat (limited to 'src/testsup.c')
| -rw-r--r-- | src/testsup.c | 47 |
1 files changed, 7 insertions, 40 deletions
diff --git a/src/testsup.c b/src/testsup.c index c5c62c2..379cbab 100644 --- a/src/testsup.c +++ b/src/testsup.c @@ -22,46 +22,13 @@ Revision History: #include "chess.h" -FLAG -IsBoardLegal(POSITION *pos) -{ - COOR c; - - for (c = A1; c <= H1; c++) - { - if (!IS_EMPTY(pos->rgSquare[c].pPiece)) - { - if (IS_PAWN(pos->rgSquare[c].pPiece)) - { - return(FALSE); - } - } - } - - for (c = A8; c <= H8; c++) - { - if (!IS_EMPTY(pos->rgSquare[c].pPiece)) - { - if (IS_PAWN(pos->rgSquare[c].pPiece)) - { - return(FALSE); - } - } - } - - if (InCheck(pos, WHITE) && - InCheck(pos, BLACK)) - { - return(FALSE); - } - - if (InCheck(pos, FLIP(pos->uToMove))) - { - return(FALSE); - } - return(TRUE); -} - +// IsBoardLegal moved to board.c (2026-10-15) -- it's not test-only: +// gamelist.c's SetRootPosition needs it on every build profile to +// reject an illegal FEN (e.g. the side not on move left in check) +// before it ever reaches search, not just under TEST/EVAL_DUMP, which +// is all that linked this file in before. Declaration unchanged +// (chess.h), callers unchanged (including TestLegalMoveGenerator, +// below). void GenerateRandomLegalPosition(POSITION *pos) |
